4-bit Carry Lookahead Unit
A ripple adder waits for each carry in turn. A carry lookahead unit computes all the carries at once from the generate and propagate signals, so its depth doesn't grow with the width.
This module computes the outgoing carries for four bits simultaneously, along with the block propagate and block generate signals required for hierarchical cascading. It takes bitwise propagate (p) and generate (g) signals from a 4-bit block, alongside the initial carry in (c_in). From these inputs, it calculates the carry out for each of the four bits, output as a 4-bit vector c. It also computes a single p_block signal which is true if the entire 4-bit block propagates a carry, and a g_block signal which is true if the 4-bit block generates a carry internally.
Timing and Reset Rules:
- This module is purely combinational.
- There is no clock and no reset.
- Outputs must reflect changes in inputs immediately based on boolean logic.
Worked Trace:
- Input:
p= 4'b0111,g= 4'b1000,c_in= 0 - Bit 0: generate is 0, propagate is 1, carry in is 0. Carry out
c[0]is 0. - Bit 1: generate is 0, propagate is 1, carry in
c[0]is 0. Carry outc[1]is 0. - Bit 2: generate is 0, propagate is 1, carry in
c[1]is 0. Carry outc[2]is 0. - Bit 3: generate is 1, propagate is 0. Carry out
c[3]is 1. - Output
cbecomes 4'b1000. - Block propagate
p_blockis 0 because bit 3 does not propagate. - Block generate
g_blockis 1 because bit 3 generates a carry.
| Signal | Direction | Width | Description |
|---|---|---|---|
| p | input | 4 | Bitwise propagate signals; p[0] corresponds to bit 0 |
| g | input | 4 | Bitwise generate signals; g[0] corresponds to bit 0 |
| c_in | input | 1 | Initial carry input to the 4-bit block |
| c | output | 4 | Computed carries; c[0] is the carry out of bit 0, c[3] is the carry out of bit 3 |
| p_block | output | 1 | Block propagate signal; true if all 4 bits propagate a carry |
| g_block | output | 1 | Block generate signal; true if the block internally generates a carry |
Constraints
- The design must be purely combinational.
- Do not use the addition operator (
+); you must express the exact boolean equations to force the lookahead structure. - Output
c[0]represents the carry out of the first bit, which depends only ong[0],p[0], andc_in. - Output
c[3]represents the carry out of the fourth bit, which is the carry out of the entire 4-bit block. - The
g_blockoutput must evaluate to true if the block generates a carry out independently ofc_in.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Synthesis Intuition
Problem 24 of 25 in the Synthesis Intuition track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks