Half Adder Verilog code Using Vivado @ Xilinx Basys3 FPGA

Hello tech enthusiasts! Today, we’re diving into the basics of digital electronics with a crucial component: the Half Adder, implemented in Verilog. Whether you’re just starting out or looking to brush up on your knowledge, this post will guide you through understanding how a Half Adder operates and how to code it in Verilog.

What is a Half Adder?

A half adder is a simple digital circuit that adds two single-bit binary numbers, A and B. It produces two outputs: the Sum (S) and the Carry (C). Here’s how it works:

circuit diagram of Half Adder
1-bit Half Adder symbol

The Components: XOR and AND Gates

The half adder uses two types of logic gates:

  • XOR Gate: This gate outputs 1 when the inputs are different. It calculates the Sum (S) of A and B.
  • AND Gate: This gate outputs 1 only when both inputs are 1. It calculates the Carry (C) from the addition of A and B.

The Truth Table

To understand the half adder’s operation, look at its truth table:

ABSum (S)Carry (C)
0000
0110
1010
1101

How It Works

  1. Inputs A and B: These are the two binary numbers you want to add.
  2. Sum (S): Calculated by the XOR gate. If A and B are different, S is 1; if they are the same, S is 0.
  3. Carry (C): Calculated by the AND gate. It’s 1 only if both A and B are 1.

Verilog Code: Half Adder

Verilog testbench code : HalfAdder

Constraints file : Basys3 board

Modify this file when you are preparing for synthesis, implementation, and bitstream generation. Be sure to activate the necessary properties when using it. You can ignore this file for simulation purposes.

Schematic : Half Adder

halfaddr schm - 1
Halfadder - 2

Simulation: Half Adder

half addr verilog Simulation

Conclusion

The half adder is a crucial component in digital electronics, forming the basis for more complex circuits like the full adder. Understanding it is essential for anyone interested in digital design.

It can also be use to developed using full Adder (FA) module.

Thanks for reading! Stay tuned for more insights into digital electronics.

<—Prev

……

Next —->

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top