Ripple Carry Adder Module in VHDL and Verilog
4 stars based on
40 reviews
The goal of this tutorial is make you familiar with designing different types of circuits that perform addition, starting from the base design of a half-adder, then extending it to a full adder, and afterwards we move to a full 4-bit adder all adders include the carry output.
All designs will be verified by writing a test-bench for them. Designing and Simulating a Half-Adder One of the fundamental circuits that are used in adders is half-adder. A half-adder consists of two one-bit inputs as shown in Figure 1 A and B.
It does not include any carry as input. The output of the circuit consists of two one-bit ports, C and S. The former represents the carry that might be generated while calculating the addition, and the latter is the sum of the two inputs. In total "C S" in total show the addition result of A and B. The truth table of a half-adder is shown in Table 1. Half-adder Tasks Download the SystemC code for the half-adder: Make sure the design of the half-adder is correct and corresponds to the truth table in Table 1.
Compile your code with the following comamnd you might need to change the path to your library: If everything works ok, you should be able to see a waveform such as Figure 2.
For this purpose, you can use GTKWave. Waveforms for simulation of a half-adder in GTKWave Now try to modify the test-bench so that in addition to generating waveforms on the output VCD file, it also shows the results on the console output terminal in text format. The circuit of a Full adder is shown in Figure 2, along with its truth table in Table 2. If everything works ok, you should be able to see a waveform such as Figure 3.
Waveforms for simulation of a full-adder in GTKWave Try to use the knowledge of creating hierarchical designs in SystemC and create a full-adder by using two half-adders structural design. In order to make it easier, the base code is given here: However, you write the verilog code for 4 bit ripple carry full adder using half adder make sure the modules are connected properly using signals.
Try to make full-adder design correspond to Figure 3. Write the test-bench for the design which should be similar to the previous full adder design. Compile the design again similar to before and verify its correctness by visualizing the outputs using waveform in GTKWave. Structural design of a full-adder using two half-adders Designing and Simulating a 4-bit Adder In this part of the tutorial, you should already know how to make a hierarchical structural design in SystemC.
A 4-bit RCA based on full-adders looks like what is shown in Figure 4. This is an adder which adds two 4-bit numbers as inputs,A and B, and also accepts an input carry Cin. On the output it generates a 4-bit Sum value along with an output carry ,if the addition results in an output carry Cout.
Try to understand the code. Now based on the knowledge from the previous tasks, redesign the 4-bit adder, according to Figure 3 structural design. You can use the design of the full-adder you verified in the previous task for creating the 4-bit Ripple Carry Adder RCA. If everything works ok, you should be able to see a waveform such write the verilog code for 4 bit ripple carry full adder using half adder Figure 5.
Do you know any alternative s? Can you read the values this port bit by bit to binary signals? If your answer is no, how would you solve this?