CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Combinational Logic

Forcing a Carry Lookahead Structure

HardVerilog / SystemVerilogBuild

High speed adders bypass the linear delay of ripple carry architectures by computing carries in parallel. The Carry Lookahead Generator is the heart of this optimization, flattening the boolean logic into a two level sum of products structure. By evaluating generate and propagate signals simultaneously, the logic depth remains constant regardless of the bit width of the block, allowing the adder to hit aggressive timing targets.

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 out c[1] is 0. • Bit 2: generate is 0, propagate is 1, carry in c[1] is 0. Carry out c[2] is 0. • Bit 3: generate is 1, propagate is 0. Carry out c[3] is 1. • Output c becomes 4'b1000. • Block propagate p_block is 0 because bit 3 does not propagate. • Block generate g_block is 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 on g[0], p[0], and c_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_block output must evaluate to true if the block generates a carry out independently of c_in.

Topics

ArithmeticOptimizationCombinational LogicSynthesis

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real testbench — you get the waveform back, not a stored answer.

This problem is part of Codiode Pro. The statement above is free to read.

Sign in to solveSee what Pro unlocks

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.

Related problems

  • Single Continuous AssignmentEasy
  • Basic Vector ConcatenationEasy
  • Ternary Operator MuxEasy
  • Underscores for ReadabilityEasy
  • Left Hand Side ConcatenationEasy
  • Inout Port MechanicsEasy
  • Explicit Binary LiteralsEasy
  • Vector Port EndiannessEasy

Browse all problems · Learning tracks