Pipelining a Large Adder
A 64-bit carry chain may not fit in one clock period. Splitting it into four 16-bit stages, with each stage's carry registered for the next, does.
The pipeline_adder module computes the 64-bit addition of a and b by splitting the operation into four 16-bit pipelined stages. The pipeline accepts new inputs on every clock cycle and produces the sum and carry-out with a latency of exactly 4 clock cycles. To maintain data alignment, the partial sums and carry bits must be passed through registers at each stage so that the final 64-bit sum correctly represents the addition of a and b from the exact same input cycle.
| Signal | Direction | Width | Description |
|---|---|---|---|
clk |
input | 1 | Positive-edge triggered clock |
rst_n |
input | 1 | Asynchronous active-low reset; clears all outputs and internal registers |
a |
input | 64 | First operand |
b |
input | 64 | Second operand |
sum |
output | 64 | Pipelined 64-bit sum result |
cout |
output | 1 | Pipelined carry-out bit |
Timing and Reset Rules
- Clock edge:
posedge clk - Reset type: asynchronous, active-low (
negedge rst_n) - Output values on reset:
sumandcoutmust be exactly0. All internal pipeline registers must also be cleared to0.
Worked Trace
Cycle 1: rst_n=0 → sum=0, cout=0
Cycle 2: rst_n=1, a=1, b=2 (Operation A) → sum=0, cout=0
Cycle 3: a=5, b=5 (Operation B) → sum=0, cout=0
Cycle 4: a=0, b=0 → sum=0, cout=0
Cycle 5: a=0, b=0 → sum=0, cout=0
Cycle 6: a=0, b=0 → sum=3, cout=0 (Result of Operation A)
Cycle 7: a=0, b=0 → sum=10, cout=0 (Result of Operation B)
Pipeline Timing
Constraints
- Trigger on the positive edge of
clkand negative edge ofrst_n. - All outputs and internal registers must be completely cleared to
0on reset. - The pipeline must have exactly a 4-cycle latency from input to output.
- The module must accept new inputs on every clock cycle (throughput of 1 operation per cycle).
- Do not use a single 64-bit addition (e.g.,
sum = a + b). The addition must be broken into four distinct 16-bit additions.
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 Pipelining
Problem 18 of 20 in the Pipelining track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks