RTL Design / Module 12: Career & Interview
Lesson 12.2 · Patterns

Top RTL interview patterns — with worked solutions

Whiteboard RTL questions test whether you think in hardware, not whether you've memorized syntax. This lesson gives you eight high-frequency patterns with code, diagrams, and how to talk through each one aloud — the narration matters as much as the answer.

Interview narration formula

Rule → Code → Why → Trap. Say the rule first ("blocking in sequential logic causes races"), write the fix, explain synthesis behavior, name the common mistake. Thirty seconds of reasoning beats three minutes of silent typing.

1

Pattern map — what shows up where

PatternFrequencyCourse lessonI2C tie-in
Blocking vs non-blockingVery highblocking-vs-nonblockingBit engine counter uses <=
Latch inferenceVery highlatch-combo-multidriveCSR read in always @(*)
FIFO full/emptyHighsync-fifoTX queue extension for I2C
CDC 2-FFHighcdc-sync-structuressda_i synchronizer gap
FSM safe defaultHighsafe-fsm-designByte FSM ABORT → IDLE
Counter / moduloMediumcountersCLKDIV bit timing
Priority mux / arbiterMediumarbitersMulti-master bus (extension)
Setup / holdMediumclocks-setup-holdACK sample on SDA
▶ Practice patterns in the simulator
2

Blocking vs non-blocking

Pattern 1

Question: "What's wrong with this counter? Fix it."

BUGGY — blocking in sequential
always @(posedge clk or negedge rst_n) begin
  if (!rst_n)
    count = 0;          // blocking
  else
    count = count + 1;  // blocking — sim race, wrong synthesis intent
end
FIXED — non-blocking in sequential
always @(posedge clk or negedge rst_n) begin
  if (!rst_n)
    count <= 8'd0;
  else
    count <= count + 8'd1;
end
How to talk through

"In sequential always blocks I use non-blocking assignment. Blocking evaluates immediately in source order — two registers updating each other in one clock can race in simulation. Non-blocking schedules all RHS reads before any LHS writes — that's the hardware model: all flops sample, then all update."

Trap

Using <= in combinational always @(*) is also wrong — use blocking = there. Rule: blocking in combo, non-blocking in seq.

3

Latch inference

Pattern 2

Question: "Will this infer a latch? Fix it."

BUGGY — incomplete if in combo
always @(*) begin
  if (enable)
    out = in;
  // else missing — out holds previous value → LATCH
end
FIXED — default assignment
always @(*) begin
  out = 8'd0;           // default — no latch
  if (enable)
    out = in;
end
Latch vs flop
How to talk through

"A latch is transparent when enable is high — synthesis infers it when a combinational output isn't assigned in every branch. I default all outputs at the top of always @(*), or use if/else if/else covering all cases. In sequential logic, every reg gets assigned every clock — that's a flop, not a latch."

4

FIFO full / empty

Pattern 3

Question: "Design a synchronous FIFO with full and empty flags."

Sync FIFO pointer diagram
sync_fifo_flags.v — core logic
// Pointer + count approach (DEPTH must be power of 2 for ptr wrap)
localparam PTR_W = $clog2(DEPTH);

reg [PTR_W:0] wr_ptr, rd_ptr;  // extra bit for full/empty discrimination
wire [PTR_W:0] count = wr_ptr - rd_ptr;

assign empty = (count == 0);
assign full  = (count == DEPTH);
assign wr_en_ok = wr_en && !full;
assign rd_en_ok = rd_en && !empty;

always @(posedge clk or negedge rst_n) begin
  if (!rst_n) begin
    wr_ptr <= 0;
    rd_ptr <= 0;
  end else begin
    if (wr_en_ok) wr_ptr <= wr_ptr + 1;
    if (rd_en_ok) rd_ptr <= rd_ptr + 1;
  end
end
How to talk through

"Same clock domain — I use write and read pointers plus a count or MSB trick. Empty when pointers equal, full when write has lapped read. I gate wr_en when full and rd_en when empty to prevent corruption. For async FIFO I'd need gray pointers — different question, see our CDC lesson."

Trap

Using only lower bits of pointers without the extra MSB — you can't distinguish full from empty when both pointers are equal. See sync FIFO lesson.

5

CDC — 2-flop synchronizer (why not bus)

Pattern 4

Question: "Cross a single-bit control from clk_a to clk_b. Why not synchronize a 32-bit bus this way?"

2FF synchronizer
sync_2ff.v
module sync_2ff (
  input  wire clk_dst,
  input  wire rst_n,
  input  wire async_in,   // from other clock domain
  output wire sync_out
);
  (* ASYNC_REG = "TRUE" *) reg meta, sync;
  always @(posedge clk_dst or negedge rst_n) begin
    if (!rst_n) begin meta <= 1'b0; sync <= 1'b0; end
    else begin meta <= async_in; sync <= meta; end
  end
  assign sync_out = sync;
endmodule
How to talk through

"For a single control bit I use two flops on the destination clock — first may go metastable, second samples a settled value. Never synchronize a multi-bit bus with independent 2-FF chains — bits can skew across cycles and you'll read garbage. Use gray-code pointers in async FIFO, or a handshake with req/ack. That's exactly the gap I'd fix on sda_i in my I2C capstone."

Deep dive: CDC don'ts — bus vs gray and multi-clock mindset.

6

FSM safe default

Pattern 5

Question: "Write a Moore FSM with safe recovery from illegal states."

safe_fsm.v — default to IDLE
typedef enum logic [1:0] { IDLE, LOAD, RUN, DONE } state_t;
state_t state, next;

always @(posedge clk or negedge rst_n) begin
  if (!rst_n) state <= IDLE;
  else        state <= next;
end

always @(*) begin
  next = IDLE;  // safe default — any unhandled state recovers
  case (state)
    IDLE: next = start ? LOAD : IDLE;
    LOAD: next = RUN;
    RUN:  next = done_flag ? DONE : RUN;
    DONE: next = ack ? IDLE : DONE;
    default: next = IDLE;  // synthesis + sim safety net
  endcase
end
How to talk through

"I default next_state to IDLE at the top — if state is corrupted or I add a new state and forget a branch, the FSM recovers instead of latching in an illegal encoding. My I2C byte FSM does the same: ABORT from any state forces IDLE. Two always blocks: one seq for state reg, one combo for next — classic Moore style from our FSM lessons."

See safe FSM design and your I2C byte FSM.

7

Counter / modulo

Pattern 6

Question: "Build a counter that counts 0 to N-1 then wraps."

modulo_counter.v
module modulo_counter #(
  parameter int MAX = 8  // counts 0 .. MAX-1
) (
  input  wire       clk,
  input  wire       rst_n,
  input  wire       en,
  output reg [$clog2(MAX)-1:0] count
);
  localparam int LAST = MAX - 1;

  always @(posedge clk or negedge rst_n) begin
    if (!rst_n)
      count <= 0;
    else if (en) begin
      if (count == LAST)
        count <= 0;
      else
        count <= count + 1;
    end
  end
endmodule
How to talk through

"Compare to LAST, wrap to zero — that's the I2C CLKDIV pattern. Width is $clog2(MAX) bits. If MAX isn't power of two, this compare-wrap is cleaner than modulo operator which some synthesis tools handle poorly. I'd mention the I2C bit engine counts down from CLKDIV to zero — same idea, different direction."

Trap

Off-by-one: counting 0..N instead of 0..N-1. Always state inclusive range aloud in the interview.

8

Priority mux / light arbiter

Pattern 7

Question: "Four requesters, one grant — fixed priority."

priority_arb.v
module priority_arb (
  input  wire [3:0] req,
  output reg  [3:0] gnt
);
  always @(*) begin
    gnt = 4'b0000;
    if (req[0])      gnt = 4'b0001;  // highest priority
    else if (req[1]) gnt = 4'b0010;
    else if (req[2]) gnt = 4'b0100;
    else if (req[3]) gnt = 4'b1000;
  end
endmodule
How to talk through

"Fixed priority is a priority encoder — lowest index wins. One-hot grant, at most one bit set. For fairness I'd use round-robin from our arbiter lesson. Multi-master I2C would need bus arbitration — check SDA high before START — that's the protocol version of this pattern."

Extension: arbiters lesson.

9

Setup / hold intuition

Pattern 8

Question: "Explain setup and hold. What happens if you violate them?"

Setup hold diagram

Talk track: "Setup: data must be stable before the clock edge by tsu. Hold: data must stay stable after the edge by th. Violate either and the flop may go metastable — output hovers between 0 and 1, then resolves randomly. That's why we don't sample async pads blindly — my I2C ACK sample happens when SCL is stable high, giving implicit setup."

Course links: clocks setup hold, critical path intuition.

10

Practice checklist — before your next interview

  • Write blocking vs non-blocking fix from memory in <60s
  • Draw 2-FF sync and explain why not for 32-bit bus
  • Code FIFO empty/full with pointer MSB trick
  • Add default case to any FSM on whiteboard
  • Explain setup/hold with one hand-wave diagram
  • Connect each pattern to I2C capstone or course lab
  • Practice Rule → Code → Why → Trap narration for each
Whiteboard trap

Don't start typing code immediately. Pause, restate the question, say "I'll use a two-always-block Moore FSM with safe default" — then write. Interviewers score process.

11

Bonus pattern — reset synchronizer

Bonus

Question: "Why sync reset deassert? Show the circuit."

reset_sync.v — async assert, sync deassert
// Async assert (immediate) + sync deassert (avoid reset removal metastability)
module reset_sync (
  input  wire clk,
  input  wire rst_n_async,  // from pad — may be async
  output wire rst_n_sync
);
  (* ASYNC_REG = "TRUE" *) reg r1, r2;
  always @(posedge clk or negedge rst_n_async) begin
    if (!rst_n_async) begin r1 <= 1'b0; r2 <= 1'b0; end  // async assert
    else begin r1 <= 1'b1; r2 <= r1; end                    // sync deassert
  end
  assign rst_n_sync = r2;
endmodule
How to talk through

"Assert async so reset works even if clock is dead. Deassert synchronously — releasing reset near a clock edge can cause metastability in downstream flops. Two-flop chain on deassert is standard ASIC practice." Tie to reset synchronizers lesson.

12

Pattern difficulty ladder

LevelPatternsWhen asked
JuniorBlocking/NB, latch fix, counter, FSM defaultPhone screen, new grad onsite
Junior+FIFO flags, 2-FF sync, priority arb, setup/holdTechnical round 1–2
MidGray async FIFO, pipeline hazard, multi-clock handshakeAfter 2+ yr experience

After this course you're solid on the Junior column. Junior+ is reachable with deliberate practice — that's your 30-day goal from 12.4.

🎯 What to remember

  • Eight patterns cover ~80% of junior RTL whiteboard questions.
  • Narrate: Rule → Code → Why → Trap — don't go silent.
  • Tie answers to course labs and your I2C capstone where possible.
  • Async FIFO / gray code is the follow-up when they say "cross clocks."
  • Lesson 12.3 maps these skills to job descriptions.
Advertisement