Skip to content

Latest commit

 

History

History

Day-31

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

In this code:

  • The ripple_carry_adder module takes two 32-bit inputs A and B and produces a 32-bit sum output sum along with the carry-out carry_out.

  • We use a generate loop to instantiate 32 instances of the full_adder module, connecting them in a ripple carry fashion. Each instance of the full_adder module computes the sum and carry-out for one bit position.

  • The full_adder module takes three inputs A, B, and Ci (carry-in) and produces two outputs S (sum) and Co (carry-out).

This code models a 32-bit ripple carry adder using full adders, which is a simple but slow method of adding two numbers. For more efficient addition of large numbers, you might consider using other adder structures like a carry-lookahead adder or carry-skip adder.

In this simplified testbench, we have two test cases:

  1. Case 1 tests the addition of 0xABCDEF01 and 0x12345678.
  2. Case 2 tests the addition of 0xFFFFFFFF and 0x00000001.

You can add more test cases by following a similar structure. Each case sets the input values A and B, waits for some simulation time to allow the computation to finish, and then displays the results.

Make sure to extend the testbench with more test cases and adjust the initial values of A and B as needed to cover the desired scenarios.