firmwareMIT

Half adder in Verilog

breadboardhub/half-adder-in-verilog
verilogtestbenchhalfadder
ShareXLinkedInFacebookRedditWhatsApp
B
Mike M
v1.0.0 · UpdatedNov 24, 2026 ·0 downloads ·0 forks
Verilog, with a testOpen in the chip playground
// A half adder: adds two bits.
// sum is 1 when exactly one input is 1; carry is 1 when both are.
module half_adder (
  input  wire a,
  input  wire b,
  output wire sum,
  output wire carry
);
  assign sum   = a ^ b;
  assign carry = a & b;
endmodule
Description

Two gates that add two bits. It comes with a test that builds with Yosys and runs in the browser. Flip a and b with the switches and watch sum and carry change, here and in the diagram.

Cite this design
@design{breadboardhub/half-adder-in-verilog,
  title = {Half adder in Verilog},
  author = {breadboardhub},
  url = {https://www.breadboardhub.com/breadboardhub/half-adder-in-verilog},
  version = {1.0.0}
}