Three structural sins that lint catches on every chip: inferred latches from incomplete branches, combinational loops that oscillate or confuse synthesis, and multi-driven nets that fight in silicon.
A pattern in RTL that violates how gates and flops are built — independent of whether your testbench ever stimulates the failing path.
When combinational logic does not assign every output for every input combination, synthesis inserts a transparent latch to hold the previous value. Latches are hard to time, rarely intended in datapath RTL, and a top lint failure.
Missing else/default means the tool must preserve state — that is a latch, not "free storage."
// BAD — latch inferred on y when en=0
always @(*) begin
if (en) y = data_in;
end
// BAD — incomplete case
always @(*) begin
case (op)
2'b00: result = a + b;
2'b01: result = a - b;
// 2'b10, 2'b11: no assignment
endcase
end
// GOOD — default-at-top pattern
always @(*) begin
y = 8'h00;
if (en) y = data_in;
end
// GOOD — full case with default
always @(*) begin
result = 8'h00;
case (op)
2'b00: result = a + b;
2'b01: result = a - b;
2'b10: result = a & b;
default: result = a | b;
endcase
end
// synthesis full_case silences the warning but does not add hardware. If a case branch is missing, you still get a latch or X behavior — you just won't hear about it until silicon.
A combinational loop is a cycle of purely combinational logic with no register to break it. Simulators may oscillate, settle to X, or appear to work depending on delta cycles. Synthesis may optimize the loop away unpredictably or fail timing entirely.
// BAD — ready depends on valid which depends on ready wire full = valid && !ready; // downstream full assign ready = !full; // loop: ready = !(valid && !ready) // BAD — transparent latch behavior via combo feedback assign grant = req & ~|grant; // grant fights itself
// GOOD — break loop with registered state reg occupied; assign ready = !occupied; always @(posedge clk) if (!rst_n) occupied <= 1'b0; else if (valid && ready) occupied <= 1'b1; else if (downstream_taken) occupied <= 1'b0; // GOOD — arbiter uses priority encoder, not self-referential grant wire [3:0] grant_onehot = req & (~req + 1); // thermo/priority
| Loop type | Common cause | Fix |
|---|---|---|
| Ready/valid | ready combo-derived from valid | Register occupancy; skid buffer |
| Arbiter | Grant feeds back into request mask | Registered grant; priority tree |
| Combo FSM | Next state computed from current without flop | Separate combo next + seq state reg |
A net driven by more than one source creates contention — two drivers fighting to set the value. Verilog permits it with tri-state or explicit resolution; synthesizable RTL almost never should.
// BAD — assign AND always both drive bus wire [7:0] bus; assign bus = sel ? a : 8'hzz; // driver 1 (conceptual) always @(*) begin if (load) bus = mem_rdata; // driver 2 — illegal for synth end // BAD — two always blocks on same reg always @(posedge clk) count <= count + 1; always @(posedge clk) if (clr) count <= 0; // merge into one block
// GOOD — single driver via mux wire [7:0] bus = load ? mem_rdata : (sel ? a : 8'h00); // GOOD — one always block owns count always @(posedge clk) begin if (!rst_n) count <= 8'h00; else if (clr) count <= 8'h00; else count <= count + 1; end
See also Lesson 4.4 — Incomplete Case & Latches for deeper latch-prevention patterns. This lesson connects those coding rules to lint signoff.
Structural bugs are especially nasty because simulation and synthesis can disagree. A latch inferred in synthesis may behave differently in sim depending on initialization and X-propagation settings.
// May pass sim, fail lint, fail timing in silicon reg [3:0] nibble; always @(*) begin if (load) nibble = data_in[3:0]; // latch when !load end // Sim: nibble keeps old value when load=0 — "works" in directed test // Lint: INFERRED_LATCH — ERROR // Fix: nibble = 4'h0; at top, then override when load
| Lint message | Root cause | Fix pattern |
|---|---|---|
INFERRED_LATCH | Missing else/default | Default-at-top |
COMBO_LOOP | Feedback without register | Insert flop or restructure mux |
MULTIPLE_DRIVER | assign + always on same signal | Single driver + mux |
INCOMPLETE_CASE | case without default | Add default branch |
always @(*) block assigns all outputs on all pathsPractice: Take any module from Module 4–8 labs and run through this mental checklist: default assignments? single drivers? no combo loops on ready/valid? These habits prevent 80% of first-pass lint failures.
# Catches latch + combo loop + multidrive in one pass verilator --lint-only -Wall rtl/my_fsm.v 2>&1 | grep -E "LATCH|LOOP|MULTIDRIV" # Common Verilator messages mapping to this lesson: # COMBDLY → combo loop / blocking ordering # WIDTH → not structural, but fix anyway # UNDRIVEN → missing driver (related to multi-drive inverse)