Testbench entity (no ports) in VHDL - Time & Space Complexity
We want to understand how the time needed to run a VHDL testbench changes as we add more test cases or signals.
How does the testbench's execution time grow when we increase its workload?
Analyze the time complexity of the following VHDL testbench entity without ports.
entity tb_example is
end tb_example;
architecture behavior of tb_example is
begin
process
begin
-- test stimulus here
wait;
end process;
end behavior;
This code defines a testbench entity with no input or output ports, running a process that applies test signals.
Look for loops or repeated actions inside the testbench process.
- Primary operation: The process runs test stimulus, which may include loops or waits.
- How many times: Depends on how many test cases or signal changes are coded inside the process.
As you add more test cases or signal changes, the process runs more steps.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 steps of test stimulus |
| 100 | 100 steps of test stimulus |
| 1000 | 1000 steps of test stimulus |
Pattern observation: The execution time grows roughly in direct proportion to the number of test steps.
Time Complexity: O(n)
This means the time to run the testbench grows linearly as you add more test steps.
[X] Wrong: "The testbench runs instantly no matter how many tests it has."
[OK] Correct: Each added test step takes time to simulate, so more tests mean longer run time.
Understanding how testbench runtime grows helps you write efficient tests and manage simulation time well.
"What if the testbench process included nested loops for tests? How would the time complexity change?"