0
0
VHDLprogramming~5 mins

Stimulus process with wait statements in VHDL

Choose your learning style9 modes available
Introduction

A stimulus process with wait statements helps you test your digital design by applying inputs at specific times.

When you want to test how a circuit reacts to different input signals over time.
When you need to create a simple testbench to check your design without a clock.
When you want to apply inputs step-by-step and observe outputs after each change.
Syntax
VHDL
process
begin
  -- apply input signals
  wait for time_duration;
  -- apply next inputs
  wait for time_duration;
  -- repeat as needed
  wait;
end process;

The wait for statement pauses the process for a set time.

The final wait; stops the process forever, ending the test.

Examples
This process sets signal_a to '0', waits 10 nanoseconds, then sets it to '1', waits another 10 nanoseconds, and stops.
VHDL
process
begin
  signal_a <= '0';
  wait for 10 ns;
  signal_a <= '1';
  wait for 10 ns;
  wait;
end process;
This process toggles signal_b with waits in between to simulate input changes over time.
VHDL
process
begin
  signal_b <= '1';
  wait for 5 ns;
  signal_b <= '0';
  wait for 5 ns;
  signal_b <= '1';
  wait;
end process;
Sample Program

This testbench process sets the reset signal high, waits 20 ns, sets it low, waits 30 ns, sets it high again, then stops. This simulates reset pulses for testing.

VHDL
library ieee;
use ieee.std_logic_1164.all;

entity testbench is
end testbench;

architecture behavior of testbench is
  signal clk : std_logic := '0';
  signal reset : std_logic := '0';
begin
  stimulus_process: process
  begin
    reset <= '1';
    wait for 20 ns;
    reset <= '0';
    wait for 30 ns;
    reset <= '1';
    wait;
  end process;
end behavior;
OutputSuccess
Important Notes

Use wait for to control timing precisely in your testbench.

Always end stimulus processes with wait; to avoid infinite loops.

Stimulus processes without clocks are useful for simple input testing.

Summary

Stimulus processes apply inputs step-by-step with timed waits.

wait for pauses the process for a set time.

Use wait; to stop the process after testing.