TDEB Top Bar

Trending
Semiconductor Industry News — The Digital Electronics Blog
Follow Us

TDEB Masthead

The Semiconductor Hub

Semiconductors.  Chips and Systems.  Innovation.

Indexed by leading Search Engines, AI and referenced by Engineers worldwide 500+ Articles 10M+ Pageviews 30+ Reports 50+ Citations

VLSI, ASIC and VHDL Interview Questions with Answers

mg
by
3
Share Facebook X LinkedIn WhatsApp Email

Ten classic VLSI, ASIC and VHDL interview questions on RTL coding guidelines: sensitivity lists, latch-free combinational logic, one driver per signal, splitting processes, safe state machines, state encoding and resets. Each one is a rule of thumb that interviewers like because the honest answer includes an exception.

The ten guidelines at a glance

Every question below is about writing VHDL that simulates the same way as the hardware it produces. In plain words:

  1. Sensitivity list: a combinational process must wake up whenever any input it reads changes, or simulation and hardware disagree.
  2. Assign in every branch: if an output is not given a value on some path, the hardware has to remember the old value, which means an unwanted latch.
  3. One process per signal: two processes driving one signal is two drivers fighting over one wire.
  4. Separate unrelated logic: small, focused processes are easier to read, test and change.
  5. Recover from bad states: a state machine that lands in an unused state must find its way back to a known one.
  6. State encoding: one-hot uses one flip-flop per state and very simple logic; binary uses fewer flip-flops and more logic.
  7. Reset: the design needs a known starting point after power-up.
  8. Implicit state machines: if a process waits in several places, each place must respond to reset.
  9. Reset only what matters: control state needs a reset; pure data registers often do not.
  10. Synchronous or asynchronous reset: both work; the important part is that reset is released cleanly, in step with the clock.

Why interviewers ask these

These rules separate someone who has written VHDL that only has to simulate from someone who has taken a design through synthesis and onto silicon or an FPGA. The best answers give the reason, the exception and what goes wrong if you ignore the rule. Several of the textbook answers that circulate online are wrong in detail; the corrections are marked below.

Deep dive: the numbers and details

This part holds the full answers, code examples and the corrections. Skip it if the overview is all you need.

1. For a combinational process in VHDL, the sensitivity list should contain all of the signals that are read in the process. Please give a detailed reason and an exception to this statement.

Reason: The sensitivity list in a combinational process specifies the signals that, when changed, should trigger the execution of the process. In VHDL, a combinational process should be sensitive to all the signals that are read within the process to ensure that the process is re-executed whenever any of these signals change. This helps maintain the integrity of the design and ensures that the outputs are updated correctly based on the latest input values. Synthesis tools build full combinational logic regardless of the list, so a missing signal gives a simulation that does not match the gates.

Exception (corrected): a clocked (sequential) process. It reads many signals, but it only needs the clock, plus the asynchronous reset if there is one, because outputs change only on those events:

process (clk, rst)            -- not d, en, ...
begin
  if rst = '1' then
    q <= '0';
  elsif rising_edge(clk) then
    if en = '1' then
      q <= d;
    end if;
  end if;
end process;

In VHDL-2008, process (all) builds the complete list for a combinational process automatically, which removes this class of bug. The original answer gave as the exception a process that uses variables internally and does not read signals; that is not a real exception, because any signal the process reads still has to be in the list.

2. For a combinational process, every signal that is assigned to must be assigned to in every branch of If-Then-Else statement and Case statement. Why?

Assigning a signal in every branch of an If-Then-Else or Case statement ensures that the signal gets a value for every possible combination of input conditions. If a signal is not assigned in one branch, there may be situations where the signal retains its previous value, leading to unintended behavior. This practice helps avoid latches and ensures that the output is well-defined for all possible input conditions.

The simplest way to guarantee it is a default assignment at the top of the process:

process (all)
begin
  y <= '0';                    -- default: no latch possible
  case sel is
    when "00"   => y <= a;
    when "01"   => y <= b;
    when others => null;       -- y keeps the default
  end case;
end process;

3. Each signal should be assigned to in only one process. Please give a detailed reason and an exception to this statement.

Reason: Assigning a signal in multiple processes can lead to contention and race conditions. Each process creates its own driver, so a signal assigned in two processes has two drivers. For an unresolved type such as std_ulogic or unsigned this is a compile error; for a resolved type such as std_logic it compiles, and the resolution function produces 'X' whenever the two drivers disagree. Synthesis either rejects it or builds two outputs shorted together. Keeping a signal assignment within a single process helps maintain a clear and predictable flow of data.

Exception (corrected): a deliberately shared, resolved signal, the classic case being a tri-state bus where each process drives 'Z' when it is not the active driver. On-chip tri-states are rare in modern ASIC flows and FPGA fabrics, so this mostly appears at chip pins and in testbenches. The original answer gave signals declared in a package and shared between processes; declaring a signal in a package does not remove the multiple-driver problem.

4. Separate unrelated signals into different processes. Give at least two reasons!

  • Simulation efficiency: a process re-runs whenever anything in its sensitivity list changes. If unrelated signals share one process, every change in one recomputes all of them. Separate processes only run when their own inputs change.
  • Readability and maintainability: keeping unrelated signals in separate processes enhances code readability and maintainability. It makes it easier to understand and modify specific functionalities without affecting unrelated parts of the design.
  • Fewer accidental latches and missing sensitivities: a small process has fewer branches and fewer inputs to get wrong.

5. In a state-machine, illegal and unreachable states should transition to the reset state. Explain.

Transitioning illegal and unreachable states to the reset state ensures that the state machine remains in a known and well-defined state when unexpected conditions occur. A state register can be pushed into an unused code by a single-event upset, a glitch or a timing violation on an asynchronous input. Without a recovery path, the machine can lock up there for good.

One catch: synthesis tools often treat when others as unreachable and optimize the recovery logic away, because no legal transition leads to those codes. If recovery really matters, ask the tool for it explicitly. The AMD Vivado synthesis guide documents the FSM_SAFE_STATE attribute, which inserts logic that detects an illegal state and moves the machine to a known good state on the next clock; it notes the trade is extra area and some loss of speed.

6. If your state-machine has less than 16 states, use a one-hot encoding. Explain.

One-hot encoding uses a flip-flop for each state, with only one flip-flop being set (hot) at a time. In "Finite State Machine (FSM) Design & Synthesis using SystemVerilog, Part I" (SNUG 2019, sections 4.2 and 5), Cliff Cummings and Heath Chambers explain the trade: binary encodings use fewer flip-flops, while one-hot needs only very simple logic to move from one state to the next, and FPGA synthesis tools build small state machines as one-hot by default for that reason.

Correction: the original answer said one-hot is more area-efficient below 16 states. It is the other way round for flip-flops: a 12-state machine needs 12 flip-flops one-hot and 4 in binary. One-hot wins on speed and on next-state logic, which is why it suits FPGAs, where flip-flops are plentiful and each extra level of lookup tables costs delay. In an ASIC, where the paper's rule of thumb is that flip-flops cost area, binary or Gray encoding is often the better choice. The "16 states" figure is a rule of thumb, not a hard limit. Vivado lets you choose with the FSM_ENCODING attribute.

StatesBinary flip-flopsOne-hot flip-flopsNext-state logic
424Similar
12412One-hot much simpler
32532One-hot simpler, but flip-flop cost dominates in an ASIC

7. Include a reset signal in all clocked circuits. Explain.

Including a reset signal in clocked circuits allows for a controlled and predictable initialization of the system. It ensures that the system starts in a known state and behaves reliably during power-up or other exceptional conditions. In simulation it also clears the 'U' and 'X' values that would otherwise spread through the design.

Correction: the original answer said reset signals help prevent metastability. A reset does not prevent metastability; releasing a reset close to a clock edge can cause it. Cummings and Mills, in "Synchronous Resets? Asynchronous Resets? I am so confused!" (SNUG San Jose 2002, sections 4.4 and 5), call de-assertion the real problem: a reset released at or near the active clock edge can leave flip-flops metastable, and different flip-flops can leave reset in different clock cycles.

8. For implicit state-machines, check for reset after every wait statement.

Implicit state machines use several wait until rising_edge(clk) statements in one process, and each wait is effectively a state. Checking for reset after every wait statement ensures that the machine leaves whatever state it is in when reset arrives. Without it, reset only takes effect when the process loops back to the top. Note that many synthesis tools support implicit state machines only partly; an explicit state register is the more portable style.

9. Connect reset to the important control signals in the design, such as the state signal. Do not reset every flip-flop. Explain.

Control registers (state machines, counters, valid flags, enables) must start in a known state. Many datapath registers, such as pipeline stages or shift registers whose contents are always overwritten before they are used, do not. Leaving reset off them saves a gate or a larger flip-flop per bit and, more importantly, shrinks the reset distribution tree that has to meet timing across the chip. In an FPGA, flip-flops without reset are also easier to pack into shift-register and DSP resources.

It is a trade, not a law. The same Cummings and Mills paper states the authors' opinion that, in general, every flip-flop in an ASIC should be resettable, and it shows that mixing reset and non-reset flip-flops in one clocked block can add unwanted logic. Keep reset and non-reset registers in separate processes.

10. Use synchronous, not asynchronous reset. Explain.

The original answer argued that synchronous reset is predictable and that asynchronous reset causes metastability. The fuller picture, from section 3 and section 4 of the Cummings and Mills paper:

Synchronous resetAsynchronous reset
AdvantagesFully synchronous design; clock filters small reset glitches; good for resets generated by internal logicResets with no clock running; keeps reset logic out of the data path; guaranteed reset at power-up (for example to avoid internal tri-state contention)
DisadvantagesNeeds a running clock; may need a pulse stretcher; reset can be masked by X in simulation; adds logic to the data pathRelease near a clock edge can cause metastability; sensitive to glitches on the reset line; needs care for test (DFT)

The paper's own recommendation is asynchronous assertion with synchronous de-assertion: a reset synchronizer that resets the design immediately but releases it in step with the clock. In VHDL:

process (clk, rst_n_in)
begin
  if rst_n_in = '0' then           -- assert immediately
    rst_meta <= '0';
    rst_n    <= '0';
  elsif rising_edge(clk) then      -- release on a clock edge
    rst_meta <= '1';
    rst_n    <= rst_meta;
  end if;
end process;

Use one synchronizer per clock domain. Many teams do standardize on synchronous reset, especially in FPGAs, so the right interview answer is to state the trade and say which your team uses and why.

Share Facebook X LinkedIn WhatsApp Email

Post a Comment

3 Comments

Your comments will be moderated before it appears here.

  1. 1> If this is not done, then even if the output is assigned the value of the input signal which has not transitioned, i.e. unintentional assignment of input to output

    2>>
    3> This will lead to multiple driver problems. ex If a signal is being driven in two always blocks being clocked by same/different clocks.

    4>

    7> If not reset, then signals will be undefined from the period reset is low to the period clock starts

    8>

    10> If reset is synchronous, then the output signal is undefined until clock is present, undefined from reset =0 to clock pulse.

    ReplyDelete
  2. Can you answer the rest of the questions?

    ReplyDelete
Post a Comment

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!