Process sensitivity list in VHDL - Time & Space Complexity
When using a process sensitivity list in VHDL, it's important to understand how often the process runs as inputs change.
We want to know how the number of executions grows when input signals change more often or increase in number.
Analyze the time complexity of the following VHDL process with a sensitivity list.
process(clk, reset)
begin
if reset = '1' then
output <= '0';
elsif rising_edge(clk) then
output <= input_signal;
end if;
end process;
This process updates output when either clk or reset changes, reacting to clock edges and reset signals.
The process runs every time a signal in the sensitivity list changes.
- Primary operation: The process body executes on each change of
clkorreset. - How many times: Once per signal event on any sensitivity list signal.
As the number of signals in the sensitivity list grows, the process may run more often because it reacts to more events.
| Number of Signals (n) | Approx. Process Runs |
|---|---|
| 2 | Runs on changes to 2 signals |
| 5 | Runs on changes to 5 signals |
| 10 | Runs on changes to 10 signals |
Pattern observation: More signals mean more possible triggers, so the process runs more often, roughly proportional to the number of signals.
Time Complexity: O(n)
This means the process execution grows linearly with the number of signals in the sensitivity list.
[X] Wrong: "The process runs only once regardless of how many signals are in the sensitivity list."
[OK] Correct: The process actually runs every time any signal in the list changes, so more signals mean more runs.
Understanding how sensitivity lists affect process execution helps you write efficient VHDL and shows you grasp event-driven design concepts.
"What if we replaced the sensitivity list with a wait statement inside the process? How would the time complexity change?"
Practice
Solution
Step 1: Understand the role of sensitivity list
The sensitivity list tells VHDL which signals to watch for changes.Step 2: Identify what triggers the process
The process runs only when a signal in the sensitivity list changes value.Final Answer:
Which signals trigger the process to run when they change -> Option AQuick Check:
Sensitivity list = triggers process run [OK]
- Thinking sensitivity list sets signal data types
- Confusing sensitivity list with signal assignment order
- Assuming sensitivity list controls clock frequency
Solution
Step 1: Recall VHDL process syntax
The sensitivity list is enclosed in parentheses after the keyword process.Step 2: Match correct syntax
Only the syntax with parentheses and comma-separated signals is correct: process(clk, reset)Final Answer:
process(clk, reset) -> Option DQuick Check:
Parentheses and commas = correct syntax [OK]
- Omitting parentheses around sensitivity list
- Using square or curly brackets instead of parentheses
- Separating signals with spaces instead of commas
process(a, b) begin c <= a and b; end process;
What happens if signal
b changes value?Solution
Step 1: Check sensitivity list signals
The process sensitivity list includes signalsaandb.Step 2: Understand process triggering
Whenbchanges, the process runs and updatescwitha and b.Final Answer:
The process runs and updatesc-> Option BQuick Check:
Signal in sensitivity list changed = process runs [OK]
- Thinking only first signal triggers process
- Assuming process runs but output doesn't update
- Confusing syntax error with normal behavior
process(clk)
begin
if reset = '1' then
q <= '0';
elsif rising_edge(clk) then
q <= d;
end if;
end process;Assuming
reset is a signal, what is the problem?Solution
Step 1: Check signals used inside process
The process usesresetandclksignals.Step 2: Verify sensitivity list completeness
Onlyclkis in the sensitivity list;resetis missing, which can cause simulation mismatches.Final Answer:
Reset signal is missing from the sensitivity list -> Option AQuick Check:
All input signals must be in sensitivity list [OK]
- Ignoring signals that affect outputs in sensitivity list
- Thinking clock should be removed from sensitivity list
- Confusing edge detection with sensitivity list content
a and b. Inside, you compute c <= a or b;. Later, you add a new signal enable that gates the output: if enable = '1' then c <= a or b; else c <= '0'; end if;What must you do to the sensitivity list to ensure correct simulation?
Solution
Step 1: Identify all signals affecting outputs
Nowenablecontrols outputcalong withaandb.Step 2: Update sensitivity list accordingly
To simulate correctly,enablemust be added to the sensitivity list withaandb.Final Answer:
Addenableto the sensitivity list -> Option CQuick Check:
All input signals in sensitivity list = correct simulation [OK]
- Forgetting to add new control signals to sensitivity list
- Removing original signals from sensitivity list incorrectly
- Assuming sensitivity list auto-updates with code changes
Ready to prove it?
Pass the test and this pattern moves unknown
