Bird
Raised Fist0
VHDLprogramming~10 mins

Stimulus process with wait statements in VHDL - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Stimulus process with wait statements
Start process
↓
Apply stimulus
↓
Wait for time or event
↓
Apply next stimulus
↓
Wait again
↓
Repeat or end
The process applies signals, then waits for a specified time or event before continuing to the next step.
Execution Sample
VHDL
stim_proc: process
begin
  signal_a <= '0';
  wait for 10 ns;
  signal_a <= '1';
  wait for 20 ns;
  wait;
end process stim_proc;
This process sets signal_a to '0', waits 10 ns, sets it to '1', waits 20 ns, then stops.
Execution Table
StepTime (ns)Actionsignal_a ValueWait Statement
10Set signal_a to '0''0'wait for 10 ns
210Wait ends, set signal_a to '1''1'wait for 20 ns
330Wait ends, process waits indefinitely'1'wait (infinite)
4-Process stops here, no further action'1'no further wait
💡 Process stops at infinite wait statement, no further stimulus applied
Variable Tracker
VariableStart (0 ns)After 1 (10 ns)After 2 (30 ns)Final
signal_a'0''1''1''1'
Key Moments - 2 Insights
Why does the process stop after the last wait statement?
Because the last wait statement is 'wait;' with no condition or time, it causes the process to pause indefinitely, as shown in execution_table step 3.
Does the signal change immediately after the wait statement?
No, the signal changes happen right after the wait period ends, as seen between steps 1 and 2 in the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of signal_a at 15 ns?
AUndefined
B'0'
C'1'
DProcess stopped
💡 Hint
15 ns is between step 2 (10 ns, '1') and step 3 (30 ns, '1') in the execution_table.
At which step does the process enter an infinite wait?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at the Wait Statement column in the execution_table for the infinite wait.
If the first wait was changed to 'wait for 5 ns;', how would signal_a change at 7 ns?
Asignal_a would be '1'
Bsignal_a would still be '0'
Csignal_a would be undefined
DProcess would stop
💡 Hint
Refer to variable_tracker and execution_table timing for signal changes after wait periods.
Concept Snapshot
Stimulus process uses wait statements to control timing.
Signals change, then process waits for time or event.
'wait for time;' pauses process for that duration.
'wait;' pauses process indefinitely.
Useful for testbenches to apply signals step-by-step.
Full Transcript
This VHDL stimulus process example shows how signals are assigned values and then the process waits for specified times before continuing. Initially, signal_a is set to '0' at time 0 ns. The process then waits for 10 ns. After 10 ns, signal_a changes to '1'. The process waits another 20 ns. At 30 ns, the process reaches an infinite wait statement and stops executing further. The variable tracker shows signal_a starting undefined, then becoming '0' at 0 ns, and '1' at 10 ns, remaining '1' thereafter. Key points include understanding that signals change right after wait periods end, and that a plain 'wait;' causes the process to pause forever. The quizzes test understanding of signal values at specific times and the effect of wait statements on process flow.

Practice

(1/5)
1. What is the main purpose of using wait for statements inside a stimulus process in VHDL?
easy
A. To declare variables inside the process
B. To pause the process and apply inputs step-by-step over time
C. To define the clock period for the design
D. To reset all signals to zero immediately

Solution

  1. Step 1: Understand the role of stimulus processes

    Stimulus processes apply test inputs to signals during simulation.
  2. Step 2: Identify the function of wait for

    The wait for statement pauses the process for a specified time, allowing signals to hold values before changing again.
  3. Final Answer:

    To pause the process and apply inputs step-by-step over time -> Option B
  4. Quick Check:

    Stimulus process uses wait for to pause and apply inputs [OK]
Hint: Wait statements pause input changes to simulate time steps [OK]
Common Mistakes:
  • Thinking wait for resets signals
  • Confusing wait for with variable declaration
  • Assuming wait for defines clock period
2. Which of the following is the correct way to end a stimulus process in VHDL to stop it from running indefinitely?
easy
A. wait;
B. stop;
C. end process;
D. wait for 10 ns;

Solution

  1. Step 1: Review how stimulus processes terminate

    Stimulus processes often run indefinitely unless explicitly stopped.
  2. Step 2: Identify the correct wait statement to stop the process

    The statement wait; causes the process to suspend forever, effectively stopping it.
  3. Final Answer:

    wait; -> Option A
  4. Quick Check:

    Use wait; to stop stimulus process [OK]
Hint: Use plain wait; to stop stimulus process execution [OK]
Common Mistakes:
  • Using wait for with a time instead of wait;
  • Trying to use end process; as a stop command
  • Using stop; which is not valid VHDL
3. Consider the following VHDL stimulus process snippet:
process
  begin
    signal_a <= '0';
    wait for 10 ns;
    signal_a <= '1';
    wait for 20 ns;
    wait;
end process;
What is the value of signal_a at 25 ns after simulation start?
medium
A. '0'
B. Undefined
C. '1'
D. Signal does not change

Solution

  1. Step 1: Trace signal assignments over time

    At 0 ns, signal_a is set to '0'. After 10 ns, it changes to '1'.
  2. Step 2: Determine signal value at 25 ns

    At 25 ns, which is after the 10 ns and before the 30 ns (10+20), signal_a remains '1'.
  3. Final Answer:

    '1' -> Option C
  4. Quick Check:

    Signal changes at 10 ns to '1', stays until 30 ns [OK]
Hint: Add wait times cumulatively to find signal value at given time [OK]
Common Mistakes:
  • Assuming signal_a is still '0' at 25 ns
  • Ignoring the second wait for 20 ns
  • Confusing wait; with wait for
4. Identify the error in the following stimulus process code:
process
begin
  signal_b <= '1';
  wait for 5 ns
  signal_b <= '0';
  wait for 5 ns;
  wait;
end process;
medium
A. Missing semicolon after first wait for statement
B. Signal assignment syntax is incorrect
C. wait; statement is misplaced
D. Process missing sensitivity list

Solution

  1. Step 1: Check syntax of wait statements

    The first wait for 5 ns is missing a semicolon at the end.
  2. Step 2: Confirm other syntax elements

    Signal assignments and the final wait; are correct. Sensitivity list is not required in a process with wait statements.
  3. Final Answer:

    Missing semicolon after first wait for statement -> Option A
  4. Quick Check:

    Every wait for must end with semicolon [OK]
Hint: Check semicolons after wait for statements carefully [OK]
Common Mistakes:
  • Thinking sensitivity list is required with wait
  • Misreading signal assignment syntax
  • Assuming wait; must be last line only
5. You want to create a stimulus process that toggles clk every 15 ns and stops after 90 ns. Which code snippet correctly implements this behavior?
hard
A. process begin clk <= '0'; wait for 15 ns; clk <= '1'; wait for 15 ns; wait; end process;
B. process begin clk <= '0'; wait for 90 ns; clk <= '1'; wait; end process;
C. process begin for i in 0 to 5 loop clk <= '0'; wait for 15 ns; clk <= '1'; wait for 15 ns; end loop; wait; end process;
D. process variable count : integer := 0; begin while count < 6 loop clk <= not clk; wait for 15 ns; count := count + 1; end loop; wait; end process;

Solution

  1. Step 1: Understand toggling every 15 ns for 90 ns

    Toggling means changing clk from 0 to 1 or 1 to 0 every 15 ns. For 90 ns total, toggling happens 6 times (90/15).
  2. Step 2: Analyze each option's logic

    process variable count : integer := 0; begin while count < 6 loop clk <= not clk; wait for 15 ns; count := count + 1; end loop; wait; end process; uses a loop with a counter to toggle clk 6 times, waiting 15 ns each time, then stops with wait;. Others either toggle once or use incorrect timing.
  3. Final Answer:

    variable count : integer := 0; while count < 6 loop clk <= not clk; wait for 15 ns; count := count + 1; end loop; wait; -> Option D
  4. Quick Check:

    Loop with wait for 15 ns toggles clk 6 times [OK]
Hint: Use loop with counter and wait for to toggle signals repeatedly [OK]
Common Mistakes:
  • Using single wait for without loop for repeated toggling
  • Incorrect loop ranges causing wrong toggle count
  • Not stopping process after toggling
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard