0
0
VHDLprogramming~5 mins

Stimulus process with wait statements in VHDL - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Stimulus process with wait statements
O(n)
Understanding Time Complexity

When we use wait statements in a VHDL stimulus process, we want to understand how the time the process takes grows as we add more wait steps.

We ask: How does adding more wait statements affect the total execution time?

Scenario Under Consideration

Analyze the time complexity of the following code snippet.

process
  begin
    signal_a <= '1';
    wait for 10 ns;
    signal_a <= '0';
    wait for 10 ns;
    signal_a <= '1';
    wait for 10 ns;
    wait; -- end process
end process;

This process changes a signal and waits for fixed time intervals between changes.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Each wait for 10 ns statement pauses the process.
  • How many times: The process has three wait statements executed sequentially.
How Execution Grows With Input

Imagine we add more wait statements like these to the process.

Input Size (number of wait steps)Approx. Operations (waits)
33 waits
1010 waits
100100 waits

Pattern observation: The total wait time grows directly with the number of wait statements added.

Final Time Complexity

Time Complexity: O(n)

This means the total execution time grows in a straight line as you add more wait steps.

Common Mistake

[X] Wrong: "Adding more wait statements does not affect total execution time because the process just waits."

[OK] Correct: Each wait adds a fixed delay, so more waits add more total time, making the process take longer.

Interview Connect

Understanding how wait statements affect timing helps you design testbenches and simulations that run efficiently and predictably.

Self-Check

"What if we replaced fixed wait times with conditional waits? How would that change the time complexity?"