← ProblemsVerilog Language / Modules: Hierarchy
Adder 2
15%hierarchyarithmeticNow go one level deeper in the hierarchy. The same 32-bit adder is built from two add16 modules — but this time add16 is a structural adder that instantiates sixteen 1-bit full adders named add1:
module add1 ( input a, input b, input cin, output sum, output cout );
You must write two things:
top_module— instantiate two of the providedadd16modules to form a 32-bit adder, exactly as in the previous exercise (lower half gets cin = 0; its cout feeds the upper half's cin; final cout is dropped).- The full adder
add1itself. A full adder adds three 1-bit values and produces a 2-bit result:
sum = a XOR b XOR cin
cout = majority(a, b, cin) — at least two of the three inputs are 1
The provided add16 (below your code) chains your add1 sixteen times via a ripple-carry — don't modify it. If add1 is wrong, the whole adder is wrong.