RTL Design #62 · 2026-11-24 · Carry-lookahead · Medium · about 20 min

Carry-lookahead adder with group signals

Write a carry-lookahead adder in adder.sv, in two modules. Both are purely combinational (no clock, no reset).

cla8 adds two 8-bit numbers and a carry in:

  • sum is the low 8 bits of a + b + cin, and cout is bit 8 of that sum.
  • gp (group propagate) is 1 when every bit position propagates, that is, a ^ b is all ones.
  • gg (group generate) is 1 when the block produces a carry out on its own: the carry out of a + b with cin taken as 0.
  • So cout = gg | (gp & cin).

cla16 adds two 16-bit numbers and a carry in, with sum (16 bits) and cout. Build it from two cla8 blocks, low byte and high byte. The carry into the high block is c8 = gg_lo | (gp_lo & cin), worked out from the low block's group signals. cout is the high block's carry out.

Example for cla8: a = 8'hff, b = 8'h00, cin = 1 gives sum = 8'h00, cout = 1, gp = 1, gg = 0. With a = 8'h01, b = 8'hff, cin = 0 you get sum = 8'h00, cout = 1, gp = 0, gg = 1.

Write and run your answer in the browser. The hidden tests check it, and it’s free.