Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 37 ยท Concurrent and Sequential Code

Processes and Sensitivity Lists

Master the VHDL process: how it wakes up, sensitivity lists and process(all), combinational and clocked processes, rising_edge, resets, wait statements and latch traps.

A process is a block of sequential statements that sits inside the concurrent world of an architecture. From outside, a process is just one concurrent statement; inside, the statements run top to bottom like ordinary code. Processes are where you write if, case and loops, and where registers (flip-flops) are described.

How a process runs

A process is an infinite loop that runs when it is activated and then suspends:

  1. At the start of simulation every process runs once, up to its first suspension.
  2. A process with a sensitivity list suspends at the end and wakes whenever a signal on that list has an event (changes value).
  3. A process with wait statements suspends at each wait until the condition is met.
VHDL
process (a, b, sel)          -- sensitivity list
begin
  if sel = '1' then
    y <= a;
  else
    y <= b;
  end if;
end process;

You cannot have both a sensitivity list and a wait in the same process (a sensitivity list is a shorthand for a wait on ... at the end).

Combinational processes

A process describes combinational logic when its output depends only on current inputs. The rules:

  • every signal that is read must be in the sensitivity list;
  • every output must be assigned on every path (no latches).

If you forget a signal in the list, the simulation behaves differently from the synthesized hardware: the simulator waits for the listed signals only, but the synthesizer builds real gates sensitive to everything. VHDL-2008 fixes the whole problem:

VHDL
process (all)                -- sensitive to everything read in the process
begin
  ...
end process;

process (all) is the recommended style for combinational code with --std=08.

Clocked processes

A sequential (clocked) process updates registers on a clock edge:

VHDL
process (clk)
begin
  if rising_edge(clk) then
    q <= d;
  end if;
end process;

rising_edge(clk) is true when clk changed from '0' to '1'. It is defined in std_logic_1164, and is safer than the old clk'event and clk = '1' because it ignores transitions from 'U' or 'X'. A flip-flop needs only the clock in its sensitivity list, since nothing else matters between edges.

With a synchronous reset, the reset is checked inside the clock edge:

VHDL
process (clk)
begin
  if rising_edge(clk) then
    if reset = '1' then
      q <= '0';
    else
      q <= d;
    end if;
  end if;
end process;

With an asynchronous reset the reset acts immediately, so it joins the sensitivity list and is checked first:

VHDL
process (clk, reset)
begin
  if reset = '1' then
    q <= '0';
  elsif rising_edge(clk) then
    q <= d;
  end if;
end process;

Most FPGA designs prefer synchronous resets (they map well onto the fabric), but asynchronous reset is common for global resets and for ASICs. Whichever you choose, use it consistently.

Two kinds of process

Combinational process (all), no clock
Clocked process (clk), rising_edge
Latch trap Assign on every path

The clocked process is how flip-flops are written.

1 / 2

wait statements

Processes without sensitivity lists use wait to suspend. This is the normal style in testbenches (next chapters):

VHDL
clk_gen : process
begin
  clk <= '0'; wait for 5 ns;
  clk <= '1'; wait for 5 ns;
end process;

Variants are wait for 10 ns;, wait until clk = '1';, wait on a, b; and a bare wait; that suspends forever. Synthesis tools support only a limited form (wait until rising_edge(clk); as the first statement of a clocked process); everything with times is for simulation.

Simulating the clocked process

The C stand-in drives a clock for five cycles through a D flip-flop with synchronous reset. The "process" runs only when the clock rises, and the register changes after the process finishes, which you can see in the printout: q shows the value d had before the edge.

C Stand-in (C): D flip-flop with synchronous reset

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

The latch trap

A combinational process that does not assign its output on every path creates a latch. Both snippets look similar; only the second is safe:

VHDL
-- latch: y keeps its old value when en = '0'
process (all) begin
  if en = '1' then y <= a; end if;
end process;

-- fix: assign a default first
process (all) begin
  y <= '0';
  if en = '1' then y <= a; end if;
end process;

The default-first pattern is the easiest cure. The stand-in below contrasts "latch-like" and "combinational" behavior: with the latch, y remembers; with the default, it is a pure function of the inputs.

C Stand-in (C): latch vs default assignment

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Never put an after delay or a wait for in code you intend to synthesize. The tool ignores or rejects them, and the hardware will not match your simulation.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which sensitivity list is enough for a rising-edge D flip-flop with synchronous reset?

    Only the clock matters between edges; reset and d are sampled at the clock edge.
  2. 2. What does process (all) do (VHDL-2008)?

    It automatically includes all signals read in the process, preventing missing-sensitivity bugs.
  3. 3. How is an asynchronous reset written?

    An async reset is in the sensitivity list and its test comes first, outside the clock-edge condition.
  4. 4. What creates an unintended latch?

    If an output keeps its old value on some path, memory is implied, which synthesizes to a latch.

Summary

  • A process is a sequential block that runs when a signal on its sensitivity list changes (or at wait).
  • Combinational: process (all), assign every output on every path.
  • Clocked: process (clk) with rising_edge(clk); synchronous or asynchronous reset.
  • wait statements are mostly for testbenches; default assignments prevent latches.

Next: if, case and Loops