Search the wiki

Loading guides…↑ ↓ to navigate · Esc to close

IT THINKS Build Your Own GPU 4 Bit Adder Solution

Build ADD4 as a ripple-carry chain: split both four-bit inputs, add the lowest pair of bits, and pass the resulting carry into the next stage. Repeat through bit 3, join the four sum bits, and wire the final carry to the carry output. Use a half adder for bit 0 if there is no external carry; otherwise use a full adder and connect the incoming carry.

Split the input buses

Use SPLIT on each four-bit bus and pair the bits by index. Catchy’s SPLIT and JOIN help places bit 0 at the top. Start the carry chain at bit 0, even if your bench layout makes another stage look like the starting point. Keep the sum lines in that same bit order at JOIN.

Build each full-adder stage

For each bit, compute p as a XOR b. XOR p with carry_in to get the sum bit. Form carry_out by OR-ing a AND b with p AND carry_in. Connect that result to the next stage’s carry input.

Choose the first-stage carry

At bit 0, a half adder produces a sum and a carry from the two inputs. A full adder with carry-in held low produces the same outputs. If the contract supplies a carry input, connect it to the bit-0 full adder. The bit-3 carry leaves the circuit separately from the four-bit sum.

Test normal sums and overflow

With 0000 and 0000, expect sum 0000 and carry 0. With 0111 and 0001, expect 1000 and carry 0, which means the carry reached the high bit. With 1111 and 0001, expect 0000 and carry 1. Another useful check is 1111 plus 1111, which produces 1110 and carry 1.

Trace the first wrong stage

Start at the lowest bit and compare each stage’s carry output with the next stage’s carry input. If the individual sums and carries are right but the final number is wrong, recheck JOIN’s bit order. The arithmetic here matches published ADD4 behavior for the unsigned input pairs without external carry. Use your contract brief for the actual palette, pin labels, and timing budget.

Sources