BitFlow

Verilog interview questions and answers (RTL design)

The Verilog and digital-design questions that come up most in RTL, FPGA and VLSI interviews, with short, correct answers and code, from blocking assignments to CDC and FIFOs.

By BitFlow · · 12 min read

How to use this list

These are the questions interviewers for RTL design, FPGA and VLSI front-end roles ask again and again. Each answer is the short version you would say out loud, followed by the detail that shows you understand it. Where there is a BitFlow problem for it, write the code there: interviewers increasingly ask you to write and debug Verilog live.

Language basics

Worked example: 1. What is the difference between blocking (=) and nonblocking (<=) assignments?

The classic opener, and the source of many simulation-versus-hardware bugs.

  1. A blocking assignment updates the variable immediately, so the next statement sees the new value.
  2. A nonblocking assignment schedules the update for the end of the time step; every right-hand side in the step is read first.
  3. Use <= in clocked blocks (it models flip-flops sampling together) and = in combinational always @(*) blocks.

Answer:Nonblocking for sequential logic, blocking for combinational logic, never mixed in one block.

Worked example: 2. What is the difference between wire and reg?

Often followed by: does reg mean a register?

  1. A wire is a net driven continuously by an assign or a module output; it holds no value of its own.
  2. A reg is a variable assigned inside an always or initial block.
  3. reg does not mean flip-flop: a reg assigned in always @(*) synthesises to plain combinational logic. (SystemVerilog's logic type replaces both in most code.)

Answer:The difference is how a signal is assigned, not what hardware it becomes.

Worked example: 3. What is the difference between == and ===?

Tests whether you know Verilog's four-state values (0, 1, X, Z).

  1. == is logical equality: if either side has an X or Z bit, the result is X.
  2. === is case equality: it compares X and Z literally and always returns 0 or 1.
  3. === is for testbenches; it is not synthesisable as a comparison against X or Z.

Answer:== can return X; === never does.

Worked example: 4. What is the difference between parameter and localparam?

Comes up when you write a reusable, configurable module.

  1. A parameter can be overridden when the module is instantiated (#(.WIDTH(16))).
  2. A localparam cannot be overridden; use it for constants derived inside the module, such as state encodings.

Answer:parameter is an input to the module; localparam is internal.

Worked example: 5. What do $display, $strobe and $monitor do differently?

A testbench question about when values are printed.

  1. $display prints immediately, when the statement runs, so it can show values before nonblocking updates land.
  2. $strobe prints at the end of the time step, after nonblocking updates.
  3. $monitor prints whenever any of its arguments changes.

Answer:Use $strobe to see the values registers actually settled to.

Synthesis and hardware

Worked example: 6. What causes an unintended latch, and how do you avoid it?

Probably the most common debugging question.

  1. A combinational always block that does not assign a signal on every path: an if without an else, or a case without a default.
  2. The tool must remember the old value, so it builds a latch.
  3. Fix: assign every output a default at the top of the block, then override it.

Answer:Incomplete assignment in combinational logic infers a latch.

Worked example: 7. Which Verilog constructs are not synthesisable?

Checks that you know the difference between describing hardware and describing a simulation.

  1. Delays (#10), initial blocks in most ASIC flows (FPGAs can use them for power-up values), $display and other system tasks, force/release, and loops whose bounds are not constant.
  2. Real-valued arithmetic and === against X or Z.

Answer:Anything that describes simulation behaviour rather than hardware structure.

Worked example: 8. What is the difference between case, casez and casex?

Asked alongside priority encoders and instruction decoders.

  1. case matches exactly, including X and Z.
  2. casez treats Z (and ?) in the item as don't-care.
  3. casex treats both X and Z as don't-care, which can hide X bugs in simulation; prefer casez or SystemVerilog's case inside.

Answer:Use casez for wildcard matching; avoid casex.

Worked example: 9. Synchronous or asynchronous reset: which and why?

There is no single right answer; the trade-offs are what is being tested.

  1. Synchronous reset is sampled at the clock edge: simpler timing and immune to glitches, but it needs the clock running.
  2. Asynchronous reset acts immediately and works without a clock, but its release must be synchronised to avoid metastability (assert asynchronously, de-assert synchronously).

Answer:Either is fine if used consistently; the common ASIC answer is async assert, sync de-assert.

Timing and clock domains

Worked example: 10. What are setup and hold time?

Usually followed by a maximum-frequency calculation.

  1. Setup: how long data must be stable before the clock edge. Hold: how long after.
  2. Setup limits the maximum frequency: T ≥ t_cq + t_logic + t_su.
  3. Hold does not depend on the clock period, so a hold violation cannot be fixed by slowing the clock.

Answer:See the full article on setup and hold time for worked numbers.

Worked example: 11. What is metastability and how do you handle it?

The core of every clock-domain-crossing question.

  1. When a flip-flop samples an input that changes inside its setup-hold window, its output can hover between 0 and 1 for an unbounded time.
  2. For a single-bit signal crossing clock domains, use a two-flip-flop synchroniser: the second flop gives the first a full cycle to resolve.

Answer:It cannot be prevented, only made improbable enough by synchronising.

Worked example: 12. How do you pass a multi-bit value between clock domains?

The follow-up to metastability.

  1. Not by synchronising each bit: the bits can be caught at different times.
  2. Use an asynchronous FIFO (Gray-coded pointers), a handshake (req/ack) with the data held stable, or Gray code for counters that change by one.

Answer:Asynchronous FIFO for streams, handshake for occasional values.

Write-the-code questions

Worked example: 13. Write a rising-edge detector.

Output a one-cycle pulse when a synchronous input goes from 0 to 1.

  1. Register the input once to remember its previous value.
  2. The pulse is the current value AND NOT the previous one.

Answer:One flip-flop and one AND gate, shown below.

module rise_detect (input clk, input x, output rise);
  reg x_d;
  always @(posedge clk) x_d <= x;
  assign rise = x & ~x_d;
endmodule
Try it: edge detector →Write and simulate it against BitFlow's tests.
Worked example: 14. Design a sequence detector for 1011.

Expect follow-ups: overlapping or not, Moore or Mealy.

  1. Draw states for each matched prefix: S0, S1, S10, S101, and S1011 for Moore.
  2. Work out where each state goes on 0 and on 1, keeping the longest suffix that is still a prefix (that handles overlap).
  3. Write a state register plus combinational next-state and output logic.

Answer:Five states for Moore, four for Mealy. The FSM article has both in full.

Worked example: 15. Why use a FIFO, and how deep should it be?

A system-level question that tests whether you think about rates, not just logic.

  1. A FIFO absorbs rate differences between a producer and a consumer, often across clock domains.
  2. Depth ≈ burst length × (1 − read rate / write rate), rounded up to a power of two with margin for synchroniser latency.

Answer:Size it from the worst-case burst, not the average rate.

Questions

What Verilog questions are asked in RTL design interviews?

The most common are blocking vs nonblocking assignments, wire vs reg, latch inference, setup and hold time, metastability and clock-domain crossing, FSM design such as a sequence detector, and FIFO design and sizing.

What is the difference between blocking and nonblocking assignments in Verilog?

Blocking (=) updates immediately so later statements see the new value; nonblocking (<=) updates at the end of the time step after all right-hand sides are read. Use nonblocking in clocked blocks and blocking in combinational blocks.

How do you avoid latches in Verilog?

In every combinational always block, assign each output on every path: give each signal a default value at the top of the block, include else branches, and add a default to every case statement.

How do you safely cross clock domains in Verilog?

Use a two-flip-flop synchroniser for single-bit signals, and an asynchronous FIFO with Gray-coded pointers or a request/acknowledge handshake for multi-bit data.

Was this article helpful?

Keep going