Inserting a Pipeline Stage into Existing Logic
When static timing analysis reports setup violations in combinational blocks, engineers must insert pipeline registers to shorten critical paths. This modification must maintain functional equivalence while increasing clock latency by one or more cycles.
Identifying Legal Cut Boundaries
Not all intermediate nodes in an expression represent valid pipeline boundaries. Select cut points where sub-expressions form stable, self-contained values.
Consider a multi-operator combinational expression:
// Original combinational assignment: fails timing constraints
assign stage_result = (a + b) * (c - d) + e;
This expression offers two primary cut locations:
- Immediately after evaluating the sub-expressions
(a + b)and(c - d). - Immediately after evaluating the intermediate product.
Attempting to register partial products within the multiplier without saving carry-save states causes functional errors. Always place pipeline cuts at locations where intermediate values are fully evaluated.
Inserting Registers and Splitting Expressions
Split the original expression into two synchronous stages:
// Stage 1: compute intermediate sub-expressions and register results
reg [WIDTH-1:0] sum_ab, diff_cd;
reg [WIDTH-1:0] e_reg; // Passthrough signal registration
always @(posedge clk) begin
sum_ab <= a + b;
diff_cd <= c - d;
e_reg <= e;
end
// Stage 2: compute final result using registered terms
always @(posedge clk) begin
stage_result <= sum_ab * diff_cd + e_reg;
end
The mathematical operation remains identical, but computation now requires two clock cycles. Downstream circuits must expect output data one clock cycle later.
Preserving Passthrough Signal Alignment
Notice the registration of signal e into e_reg.
Although stage 1 does not manipulate signal e, the signal must traverse a pipeline register to maintain temporal alignment:
If an engineer omits e_reg, stage 2 adds current cycle data e(t) to intermediate products derived from past cycle data (a(t-1) + b(t-1)).
This omission silently corrupts datapath calculations.
Every signal traversing a pipeline boundary requires matching register stages.
Engineering Checklist for Pipeline Insertion
- Identify an intermediate node producing a complete mathematical value.
- Insert a flip-flop register bank to capture that intermediate value.
- Audit all parallel signals entering downstream stages and insert matching passthrough registers.
- Add a valid-flag register pipeline to track data validity across stages.
- Update testbenches to verify that outputs arrive on the specified clock cycle.
Avoid using loose testbench checks that accept outputs on arbitrary clock cycles. Cycle-accurate verification is necessary to detect temporal alignment bugs.
Verification Exercise
The following combinational statement forms a critical path. Insert a pipeline register after the multiplier. Ensure all passthrough signals maintain temporal alignment across the new boundary.
assign result = clamp_enable ? clamp(a * b, min_val, max_val) : (a * b);
View Solution
reg [2*WIDTH-1:0] product_reg;
reg clamp_enable_reg;
reg [WIDTH-1:0] min_val_reg, max_val_reg;
always @(posedge clk) begin
product_reg <= a * b; // Registered intermediate product
clamp_enable_reg <= clamp_enable; // Passthrough control signal
min_val_reg <= min_val; // Passthrough limit boundary
max_val_reg <= max_val; // Passthrough limit boundary
end
always @(posedge clk) begin
result <= clamp_enable_reg ? clamp(product_reg, min_val_reg, max_val_reg) : product_reg;
end
Three signals require matching passthrough registers: clamp_enable, min_val, and max_val.
Registering a * b in stage 1 also eliminates redundant multiplier hardware.
Pipeline retrofitting requires registering intermediate computation results and all accompanying passthrough signals. The next article addresses pipeline flow control, including stalls, bubbles, and backpressure.