Synthesis turns your always @(*) blocks into gates. Some RTL shapes become deep combinational clouds; others naturally break into pipeline-friendly pieces. Learn to recognize timing killers before the first synthesis report.
Structure that maps to shallow combo logic per cycle, balanced trees where possible, and explicit registers at natural boundaries — so critical paths are predictable and fixable.
| Structure | Timing impact | Better alternative |
|---|---|---|
Deep if-else-if chain (16+ branches) | Serial priority mux — O(n) levels | Register + one-hot select; tree encoder |
| Wide priority arbiter in one cycle | Long carry through grant logic | Round-robin with registered mask |
| 32×32 multiply + add + compare | Single mega cloud | 2–3 stage pipeline (Module 8) |
| FSM next-state + output in one combo block | State decode feeds output mux same cycle | Moore outputs registered; Mealy only when shallow |
| Balanced binary tree mux | log₂(n) levels — predictable | Prefer over linear priority when fair |
| Registered intermediate results | Cuts path — adds latency | Default fix for timing closure |
Pipelining trades latency for shorter per-cycle paths. Unbalanced priority chains don't pipeline cleanly without restructuring.
// 8-request priority arbiter — all combo, one cycle always @(*) begin grant = 8'b0; if (req[0]) grant = 8'b0000_0001; else if (req[1]) grant = 8'b0000_0010; else if (req[2]) grant = 8'b0000_0100; // ... 5 more elsif — synthesizes to 7-level priority mux else if (req[7]) grant = 8'b1000_0000; end
// Registered mask — timing-friendly, fair over time
reg [7:0] mask_q;
wire [7:0] req_masked = req & mask_q;
wire [2:0] idx = priority_encode(req_masked); // can be registered too
wire any = |req_masked;
always @(posedge clk) begin
if (!any)
mask_q <= 8'hFF; // wrap: all eligible again
else
mask_q <= mask_q & ~(8'b1 << idx); // clear served bit
end
assign grant = any ? (8'b1 << idx) : 8'b0;
A case with 64 branches inside one always @(*) is not "cleaner" than nested if — synthesis builds a priority or binary tree either way. Size and encoding matter, not keyword choice alone.
// One-hot select — balanced mux tree, not linear priority
always @(*) begin
out = 32'h0;
case (1'b1) // synthesis maps to parallel mux
sel[0]: out = src0;
sel[1]: out = src1;
sel[2]: out = src2;
sel[3]: out = src3;
default: out = 32'h0;
endcase
end
// Requires sel one-hot — add assertion in TB (Module 10.3)
A 32×32 multiply is rarely one-cycle at high frequency. Treat multipliers like Module 8 pipelines — register partial products.
// 2-stage multiply — each stage meets ~400 ps budget @ aggressive node reg [31:0] a_q, b_q; reg [31:0] partial_q; always @(posedge clk) begin a_q <= a_in; b_q <= b_in; partial_q <= a_q * b_q[15:0]; // stage 1: lower half multiply end always @(posedge clk) product <= partial_q + (a_q * b_q[31:16] << 16); // stage 2 // Interface: valid/ready or fixed 2-cycle latency — document in spec
Retiming: Synthesis can sometimes move registers automatically ("retiming"). Don't rely on it — place pipeline registers explicitly in RTL so latency is predictable and documented.
Mixing wide datapath math with FSM decode in one combinational block creates paths from state bits through arithmetic to next state — a timing nightmare.
// Split: registered datapath, combo FSM stays shallow
reg [31:0] acc_q;
wire [31:0] acc_next = (state == ST_ACCUM) ? acc_q + data_in : acc_q;
always @(posedge clk) acc_q <= acc_next; // arithmetic registered
always @(posedge clk) begin // FSM only sees flags, not full adder
case (state)
ST_IDLE: if (start) state <= ST_ACCUM;
ST_ACCUM: if (acc_q > THRESH) state <= ST_DONE; // compare on reg output
ST_DONE: state <= ST_IDLE;
endcase
end
Rule of thumb: If an operation is wider than 16 bits or takes more than one arithmetic op, register it. FSM logic should consume status (done, overflow, compare result), not raw wide buses in the same combo cone.
// Moore outputs registered — shorter paths from state to output reg [2:0] state_q; reg done_q; // Moore: output registered with state always @(posedge clk) begin state_q <= next_state; done_q <= (next_state == ST_DONE); // compare on next_state, reg output end // Mealy combo output in same cycle as state decode — timing risk: // assign done = (state == ST_DONE) && last_beat; // avoid if path is hot
When you add pipeline registers, downstream logic must tolerate extra cycles. A skid buffer or valid/ready interface (Module 6 handshakes) makes added latency explicit instead of breaking a fixed-cycle protocol.
| Interface style | Pipeline friendly? | Note |
|---|---|---|
| Fixed 1-cycle request/response | No | Must restructure or add bypass |
| Valid-ready | Yes | Latency-insensitive — add pipe stages freely |
| Credit-based | Yes | Count credits include pipeline depth |
# RTL timing closure workflow (per synthesis iteration) 1. Open worst negative slack path in report 2. Map startpoint/endpoint to Verilog signals 3. Count combo ops on that path (mux/add/cmp/mul) 4. Choose fix: pipeline OR simplify OR retime FSM 5. Update interface spec if latency changed 6. Re-synthesize — confirm slack improved on THAT path 7. Check next worst path — repeat until WNS ≥ 0
Lesson 9.8 connection: When you read "U5678 (ADD32)" in a timing report, you are looking at the same combo cloud this lesson teaches you to avoid writing in the first place. Prevention beats iteration.
Module 8 taught pipelining for throughput. This lesson teaches the same registers for timing closure — often the same fix serves both goals.
case vs if is not magic; depth and width of logic matter.