RTL Design / Module 9: Lint · CDC · Timing · Area · QoR
Lesson 9.2

Latch inference, combo loops & multi-driven nets

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.

Structural bug

A pattern in RTL that violates how gates and flops are built — independent of whether your testbench ever stimulates the failing path.

1

Latch inference — incomplete if/case

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.

Latch inference mechanism

Missing else/default means the tool must preserve state — that is a latch, not "free storage."

latch_bad.v
// 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
latch_good.v
// 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
Trap

// 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.

2

Combinational loops

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.

Combinational loop
combo_loop_bad.v
// 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
combo_loop_good.v
// 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 typeCommon causeFix
Ready/validready combo-derived from validRegister occupancy; skid buffer
ArbiterGrant feeds back into request maskRegistered grant; priority tree
Combo FSMNext state computed from current without flopSeparate combo next + seq state reg
3

Multi-driven nets

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.

multidrive_bad.v
// 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
multidrive_good.v
// 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.

4

Simulation vs synthesis mismatch

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.

sim_synth_diverge.v
// 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
5

Lint rule cross-reference

Lint messageRoot causeFix pattern
INFERRED_LATCHMissing else/defaultDefault-at-top
COMBO_LOOPFeedback without registerInsert flop or restructure mux
MULTIPLE_DRIVERassign + always on same signalSingle driver + mux
INCOMPLETE_CASEcase without defaultAdd default branch
  • Every always @(*) block assigns all outputs on all paths
  • Ready/valid never combo-loops through the same beat's valid
  • One driver per net — mux if multiple sources
  • One always block per clocked register
  • Run lint before review; zero ERROR on structural rules
▶ Fix structural bugs in simulator

Practice: 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.

verilator_structural_check.sh
# 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)

🎯 What to remember

  • Latches = incomplete assignment in combo logic. Default-at-top is the cure.
  • Combo loops = feedback without a flop. Break with registered state.
  • Multi-driven nets = two sources on one wire. Mux into a single driver.
  • These three account for a large fraction of first-pass lint failures.
  • Next: clock and reset rules — where lint catches timing disasters early.
Advertisement