Interrupt Verification
Verify interrupt generation, masking, clearing, timing, and correlation with the events that caused them.
Learning objectives
- Explain how interrupt verification fits into a multi-interface UVM environment.
- Distinguish an interrupt event from the register state that enables, masks, or clears it.
- Build an interrupt monitor that publishes observable interrupt events.
- Correlate an interrupt with the DUT operation or event that should have caused it.
- Verify missing, spurious, duplicate, masked, uncleared, and incorrectly timed interrupts.
- Make interrupt checking reset-aware and suitable for reusable environments.
Step 1: Understand what an interrupt really represents
An interrupt is usually not an isolated signal. It is the DUT's externally visible indication that some internal event requires software or another system component to respond.
A realistic interrupt flow often looks like this:
Bus transaction
|
v
DUT operation
|
v
Internal event
|
+---- status/event bit updated
|
+---- interrupt request generated
|
v
Interrupt interface
|
v
Interrupt monitor
|
+----> scoreboard / checker
|
+----> coverage
This means an interrupt test often has two related observation paths:
- Register path: enable, mask, status, clear, and acknowledge behavior.
- Interrupt path: when and how the interrupt becomes observable.
Lesson 56 introduced register access through the UVM Register Model. Lesson 57 introduced reset as a state transition. This lesson combines those ideas: an interrupt may depend on register configuration, and reset may change both the configuration and the pending interrupt state.
Step 2: Define the interrupt behavior before writing the checker
Before implementing UVM components, write down the expected relationship between the triggering event and the interrupt.
For example, suppose a DUT contains a receive engine with:
- a
RX_DONEstatus bit; - a
RX_DONE_ENinterrupt-enable bit; - a
RX_DONE_CLRmechanism; and - an
irqoutput.
The expected behavior might be:
RX operation completes
|
v
RX_DONE becomes pending
|
+---- RX_DONE_EN = 0 ----> no IRQ
|
+---- RX_DONE_EN = 1 ----> IRQ asserted
|
v
software clears event
|
v
IRQ deasserts
Notice that there are several separate requirements:
- The operation must create the correct status event.
- The event must be recorded correctly.
- The interrupt must be generated when enabled.
- The interrupt must remain suppressed when masked or disabled.
- The interrupt must clear according to the specified mechanism.
- The interrupt must not appear without a qualifying event.
These should not automatically become one giant scoreboard comparison. Keep the individual responsibilities observable and diagnosable.
Step 3: Model interrupt events explicitly
An interrupt monitor should publish a transaction describing what it observed. This is more useful than forcing every consumer to interpret raw signal edges independently.
class interrupt_item extends uvm_sequence_item;
`uvm_object_utils(interrupt_item)
int unsigned source_id;
bit asserted;
time timestamp;
function new(string name = "interrupt_item");
super.new(name);
endfunction
endclass
class interrupt_monitor extends uvm_monitor;
`uvm_component_utils(interrupt_monitor)
virtual interrupt_if vif;
uvm_analysis_port #(interrupt_item) analysis_port;
function new(string name, uvm_component parent);
super.new(name, parent);
analysis_port = new("analysis_port", this);
endfunction
task run_phase(uvm_phase phase);
interrupt_item item;
forever begin
@(posedge vif.clk);
if (vif.irq) begin
item = interrupt_item::type_id::create("item");
item.source_id = 0;
item.asserted = 1'b1;
item.timestamp = $time;
analysis_port.write(item);
end
end
endtask
endclass
The exact transaction fields depend on the interrupt interface. For multiple interrupt sources, the transaction may contain a source ID, vector, cause, edge/level information, or other protocol-specific information.
Step 4: Connect the interrupt monitor to checking
The environment should own the connections between the interrupt agent and the checker.
class subsystem_env extends uvm_env;
`uvm_component_utils(subsystem_env)
bus_agent bus;
interrupt_agent irq;
interrupt_checker checker;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
bus = bus_agent::type_id::create("bus", this);
irq = interrupt_agent::type_id::create("irq", this);
checker = interrupt_checker::type_id::create("checker", this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
bus.monitor.analysis_port.connect(checker.bus_imp);
irq.monitor.analysis_port.connect(checker.irq_imp);
endfunction
endclass
Because the bus and interrupt streams have different transaction types, use separate analysis implementation declarations rather than trying to overload write() with different argument types.
`uvm_analysis_imp_decl(_bus)
`uvm_analysis_imp_decl(_irq)
class interrupt_checker extends uvm_component;
`uvm_component_utils(interrupt_checker)
uvm_analysis_imp_bus #(bus_item, interrupt_checker) bus_imp;
uvm_analysis_imp_irq #(interrupt_item, interrupt_checker) irq_imp;
function new(string name, uvm_component parent);
super.new(name, parent);
bus_imp = new("bus_imp", this);
irq_imp = new("irq_imp", this);
endfunction
function void write_bus(bus_item item);
// Record qualifying DUT operations or register accesses.
endfunction
function void write_irq(interrupt_item item);
// Match the observed interrupt against expected behavior.
endfunction
endclass
The important architectural point is that the checker receives observations. It does not reach into the driver or interrupt agent's internal state to discover what happened.
Step 5: Correlate the triggering event with the interrupt
The central interrupt-checking problem is correlation:
Stimulus
|
v
Operation accepted
|
v
Expected interrupt created
|
| DUT processing
|---------------------------->
|
v
Observed interrupt
|
v
Match expected event
For a simple single-source design, an expected interrupt may be represented by a small state object:
class expected_irq extends uvm_object;
`uvm_object_utils(expected_irq)
int unsigned source_id;
time start_time;
time deadline;
function new(string name = "expected_irq");
super.new(name);
endfunction
endclass
The checker can maintain outstanding expectations indexed by a correlation key:
typedef int unsigned irq_key_t;
expected_irq expected_by_key[irq_key_t];
function void expect_interrupt(
irq_key_t key,
int unsigned source_id,
time start_time,
time deadline
);
expected_irq exp;
if (expected_by_key.exists(key)) begin
`uvm_error("IRQ_DUP_EXPECT",
$sformatf("Interrupt expectation already exists for key %0d", key))
return;
end
exp = expected_irq::type_id::create("exp");
exp.source_id = source_id;
exp.start_time = start_time;
exp.deadline = deadline;
expected_by_key[key] = exp;
endfunction
For a protocol where one operation always causes one interrupt, the key might be a transaction ID. For a design where multiple events aggregate into one interrupt, the model needs different semantics.
Step 6: Verify enable, mask, and clear behavior
Interrupt verification becomes much more useful when it exercises the configuration that controls interrupt generation.
Enabled interrupt
1. Configure RX_DONE_EN = 1.
2. Cause a receive completion.
3. Observe RX_DONE status.
4. Expect an interrupt.
5. Verify the interrupt timing and source.
6. Clear the interrupt according to the specification.
7. Verify that the interrupt clears.
Masked interrupt
1. Configure RX_DONE_EN = 0.
2. Cause a receive completion.
3. Verify RX_DONE reflects the event if specified.
4. Verify no interrupt is generated.
This distinction is important: masking an interrupt does not necessarily mean that the underlying event disappears. A status bit may still become pending while the external interrupt remains suppressed.
Clear behavior
Clear semantics must come from the register specification. Common possibilities include:
- write-one-to-clear;
- read-to-clear;
- explicit acknowledge;
- automatic clear after servicing; or
- clear only after another state transition.
The test should verify both the register state and the external interrupt behavior when the specification defines a relationship between them.
Step 7: Add timing and latency checks
An interrupt can be logically correct but still violate its timing requirement.
Suppose the specification states that an interrupt must be observable within 4 clock cycles after a qualifying event. The checker should track the event timestamp and evaluate a deadline.
event accepted
|
+---- cycle 0
|
+---- cycle 1
|
+---- cycle 2
|
+---- cycle 3
|
+---- cycle 4 <-- deadline
|
+---- no IRQ --> failure
Do not simply report a timeout because an interrupt has not appeared yet. Define:
- the exact event that starts the timer;
- the exact interrupt observation that completes it;
- the allowed latency;
- what reset does to an outstanding expectation; and
- what happens if an interrupt arrives after the deadline.
This follows directly from the latency-aware checking principles introduced earlier in the course.
Step 8: Detect the important interrupt failure classes
A production-quality interrupt checker should distinguish several failure modes.
| Failure | Meaning | Useful diagnostic |
|---|---|---|
| Missing | An expected interrupt never arrived. | Source, triggering event, deadline, outstanding key. |
| Spurious | An interrupt arrived without a valid expected cause. | Interrupt source, timestamp, recent qualifying events. |
| Duplicate | More interrupts arrived than the specification allows. | Source, count, related event/key. |
| Late | The interrupt arrived after its permitted latency. | Start time, observed time, measured latency. |
| Masked incorrectly | An interrupt appears despite being disabled or masked. | Enable/mask state and triggering event. |
| Not cleared | The interrupt remains active after the specified clear operation. | Clear transaction and interrupt state transition. |
Step 9: Make interrupt verification reset-aware
Reset can invalidate both interrupt state and outstanding expectations.
Before reset:
event A ----> expected IRQ A
event B ----> expected IRQ B
RESET
|
v
expected IRQ A ?
expected IRQ B ?
After reset:
new events belong to the new reset epoch.
The correct behavior depends on the DUT specification. If reset discards pending operations and clears interrupt state, the checker should discard the corresponding expectations. If an operation survives reset, the expectation may need to survive as well.
A simple reset-aware checker might expose an explicit method:
function void handle_reset();
expected_by_key.delete();
`uvm_info("IRQ_RESET",
"Cleared outstanding interrupt expectations",
UVM_MEDIUM)
endfunction
Do not assume that clearing expectations is always correct. It is correct only when reset invalidates those expected interrupt events.
Also consider:
- interrupt state during reset;
- interrupt state immediately after reset release;
- pending status bits after reset;
- default interrupt-enable state;
- an interrupt generated immediately after reset; and
- partial operations interrupted by reset.
Step 10: Use assertions for local interrupt rules
Some interrupt requirements are naturally expressed as temporal properties. These are good candidates for SVA rather than a transaction-level scoreboard.
For example, if the specification says that irq must remain low while reset is asserted:
ap_irq_low_during_reset:
assert property (
@(posedge clk)
!reset_n |-> !irq
)
else
`uvm_error("IRQ_RESET",
"Interrupt asserted while reset is active");
This property is only correct if the specification actually requires irq to remain low during reset. The reset polarity, synchronization, and timing relationship must match the DUT.
Use assertions for precise local temporal rules and UVM transaction-level checking for relationships such as:
bus operation
|
v
qualifying event
|
v
expected interrupt
|
v
observed interrupt Step 11: Build a practical interrupt test sequence
A useful first test should be deterministic rather than heavily randomized.
task body();
uvm_status_e status;
uvm_reg_data_t data;
// 1. Configure interrupt enable.
reg_model.RX_DONE_EN.write(
status,
'h1,
UVM_FRONTDOOR
);
// 2. Perform the operation that should generate the event.
start_receive();
// 3. Wait for and check the interrupt.
wait_for_expected_interrupt();
// 4. Read status if required by the specification.
reg_model.STATUS.read(
status,
data,
UVM_FRONTDOOR
);
// 5. Clear the interrupt/event.
reg_model.RX_DONE_CLR.write(
status,
'h1,
UVM_FRONTDOOR
);
// 6. Verify the interrupt returns to its expected state.
wait_for_interrupt_clear();
endtask
This sequence deliberately uses the register model for register operations rather than embedding bus-specific transactions in the interrupt test.
The low-level bus agent remains responsible for transporting the register access. The interrupt agent remains responsible for observing the interrupt interface.
Step 12: Add negative scenarios
Interrupt verification is incomplete if it only tests the happy path.
Scenario A: Disabled interrupt
Generate the underlying event while the interrupt is disabled. Verify the specified status behavior and confirm that no external interrupt is produced.
Scenario B: Clear before interrupt
Exercise the legal or illegal ordering of event, status read, and clear operation according to the specification.
Scenario C: Repeated events
Generate multiple events quickly. Determine whether the DUT should produce one interrupt per event, aggregate events, or retain a pending indication.
Scenario D: Reset while pending
Generate an interrupt-causing event, then assert reset before servicing it. Verify the specified reset behavior and ensure the checker does not report stale expectations as new failures.
Scenario E: Spurious interrupt
Verify that the checker reports an interrupt when there is no qualifying cause. This is especially useful for validating the checker itself and for detecting incorrect DUT interrupt generation.
Step 13: Debug an interrupt failure systematically
When an interrupt check fails, do not start by changing the interrupt checker. Trace the complete causal path.
Test stimulus
|
v
Bus transaction
|
v
DUT accepted operation?
|
v
Expected event created?
|
v
Status/event state correct?
|
v
Enable/mask state correct?
|
v
IRQ generated?
|
v
Interrupt monitor observed it?
|
v
Checker correlated it correctly?
A useful diagnostic record should include:
- interrupt source;
- correlation key, when applicable;
- triggering transaction or event;
- register enable/mask state;
- expected time or cycle;
- observed time or cycle;
- reset epoch;
- number of outstanding expectations; and
- relevant status and clear operations.
Common mistakes
- Checking only the IRQ pin: ignores the relationship between event, status, enable, and clear behavior.
- Assuming every IRQ is a pulse: some interrupts are level-sensitive or latched.
- Assuming one event always means one IRQ: aggregated interrupt designs may have different semantics.
- Ignoring masking: a masked event may still update status without asserting the external interrupt.
- Using callback order as timing evidence: analysis callbacks describe observed transactions, not necessarily the exact causal ordering of independent interfaces.
- Ignoring reset: outstanding interrupt expectations can become stale across reset.
- Hard-coding register addresses into the interrupt checker: keep register access in the register model and use observed transactions or explicit configuration at the appropriate boundary.
- Putting interrupt checking inside the driver: the driver generates stimulus; independent checking should normally consume monitor observations.
- Using a single giant checker: separate local temporal assertions, register checking, interrupt observation, and cross-interface correlation where that improves diagnosis.
Try it yourself
Design an interrupt verification scenario for a DUT with:
- one bus interface;
- two interrupt sources;
- an interrupt-enable register;
- a status register; and
- a write-to-clear register.
Write down:
- What bus transaction creates each expected event?
- What does the interrupt monitor publish?
- How will the checker correlate an event with an interrupt?
- What happens when the interrupt is disabled?
- What happens when two events occur before the first interrupt is cleared?
- What happens if reset occurs while an interrupt is pending?
Challenge: Build an interrupt scoreboard
Extend the checker so that it can detect:
- a missing interrupt;
- a spurious interrupt;
- a duplicate interrupt;
- an interrupt arriving after its latency deadline;
- an interrupt generated while its source is disabled; and
- an uncleared interrupt after the required clear operation.
Then add reset handling. Decide explicitly whether outstanding expectations survive or are discarded when reset occurs.
Extra challenge: modify the design so that two events can be represented by one aggregated interrupt. Explain how your expected-event model changes.
Knowledge check
-
Why is checking only the IRQ signal insufficient?
Because interrupt correctness often depends on the triggering event, status state, enable/mask configuration, timing, and clear behavior.
-
Why should an interrupt monitor publish transactions?
It converts protocol-level observations into reusable analysis data that scoreboards, coverage collectors, and other components can consume.
-
What is the difference between a masked event and a nonexistent event?
A masked event may still occur and update status while its external interrupt is suppressed. The exact behavior depends on the specification.
-
What should happen to an outstanding interrupt expectation during reset?
It should be discarded or preserved according to the DUT's reset semantics; the checker must not make the decision implicitly.
-
When is an assertion a better fit than a transaction-level scoreboard?
For precise local temporal rules, such as an interrupt being forbidden during reset or a signal relationship holding on a clocking event.
-
Why is interrupt aggregation important?
Because one interrupt may represent multiple pending causes, so a simple one-event-to-one-IRQ matching algorithm may report valid DUT behavior as an error.
Key takeaways
- Interrupt verification connects register configuration, DUT events, and an externally observable interrupt interface.
- Define whether the interrupt is edge-based, level-based, latched, aggregated, or otherwise specified before implementing the checker.
- Use an interrupt monitor to publish observable interrupt transactions through an analysis port.
- Correlate expected interrupt events with observed interrupts using an appropriate key or event model.
- Verify enabled, masked, cleared, repeated, missing, spurious, duplicate, and late interrupt behavior.
- Make interrupt checking explicitly aware of reset and in-flight operations.
- Use assertions for local temporal rules and UVM components for transaction-level and cross-interface relationships.
- Debug the complete causal path from stimulus to event to status to interrupt to checker before modifying the checker.
What comes next?
In Lesson 59, Error Injection, you will deliberately create protocol and functional error conditions and verify that the environment recognizes them correctly. The interrupt work from this lesson provides a useful foundation: injected errors may themselves generate status events or interrupts, and the checker must distinguish an intentionally injected fault from an unexpected verification-environment failure.