← ProblemsVerilog Language / Modules: Hierarchy
Carry-select adder
15%hierarchyarithmeticmuxA ripple-carry adder is slow because the upper half must wait for the lower half's carry. A carry-select adder computes both possibilities for the upper half in parallel, then picks the right one once the carry is known.
Using three instances of the provided add16 ({cout, sum} = a + b + cin), build a 32-bit carry-select adder:
- One add16 adds the lower 16 bits with
cin = 0; its sum drivessum[15:0]. - Two more add16s both add the upper 16 bits — one assuming
cin = 0, the other assumingcin = 1. - A 16-bit 2-to-1 multiplexer (which you write yourself) selects between the two upper sums: when the lower adder's carry-out is 0 pick the cin=0 result, when it's 1 pick the cin=1 result. The mux output drives
sum[31:16].
The final carry-out is discarded.