Directed Stimulus
Learn how to create deterministic UVM sequences that target specific behaviors, reproduce failures, verify corner cases, and provide a clear path from stimulus to expected results.
Learning objectives
- Explain what directed stimulus is and when it is useful.
- Create deterministic UVM sequences using specific transaction values.
- Separate test intent from driver protocol implementation.
- Use directed sequences to verify reset, boundary, and corner-case behavior.
- Understand the relationship between stimulus and expected results.
- Reproduce a known failure using deterministic stimulus.
- Recognize when directed stimulus should be replaced or complemented by constrained-random stimulus.
Step 1: Understand directed stimulus
Directed stimulus means deliberately choosing the exact transactions, values, and order of operations that a test should perform.
Instead of asking the randomization engine to choose an address and data value, the sequence explicitly specifies them.
Write address 0x10 data 0xAA
Write address 0x14 data 0x55
Read address 0x10
Read address 0x14
The behavior is deterministic: given the same DUT state and environment, the test attempts the same scenario every time.
Step 2: Why directed stimulus matters
Constrained-random testing is powerful, but random stimulus is not always the best starting point.
Directed stimulus is especially useful for:
- basic smoke tests,
- reset and startup verification,
- specific protocol requirements,
- boundary conditions,
- known corner cases,
- regression tests for previously discovered bugs,
- debugging a failing scenario,
- demonstrating a feature to another engineer.
A directed test can also be easier to debug because there are fewer variables changing between runs.
Step 3: Directed stimulus versus random stimulus
| Directed stimulus | Constrained-random stimulus |
|---|---|
| Explicit values | Values selected by randomization |
| Highly deterministic | Different legal scenarios can be explored |
| Excellent for known scenarios | Excellent for broad exploration |
| Usually easier to reproduce | Can discover unexpected combinations |
| Can become repetitive at scale | Requires careful constraints and debug strategy |
Good verification environments use both approaches. Directed tests provide precise control, while constrained-random tests explore a much larger legal input space.
Step 4: Start with a transaction
Assume we already have the transaction from earlier lessons:
class bus_transaction extends uvm_sequence_item;
rand bit write;
rand bit [7:0] addr;
rand bit [7:0] data;
`uvm_object_utils(bus_transaction)
function new(string name = "bus_transaction");
super.new(name);
endfunction
endclass
A directed sequence does not have to call randomize().
It can explicitly assign the values it wants to test.
Step 5: Write your first directed sequence
Here is a simple sequence that performs one specific write.
class directed_write_sequence
extends uvm_sequence #(bus_transaction);
`uvm_object_utils(directed_write_sequence)
function new(string name = "directed_write_sequence");
super.new(name);
endfunction
task body();
bus_transaction req;
req = bus_transaction::type_id::create("req");
start_item(req);
req.write = 1'b1;
req.addr = 8'h10;
req.data = 8'hAA;
finish_item(req);
endtask
endclass
This sequence always requests the same transaction:
WRITE
address = 0x10
data = 0xAA
The sequence controls the transaction's intent. The driver still decides how that transaction becomes legal pin-level activity.
Step 6: Send multiple directed transactions
A directed scenario often contains several transactions.
task body();
bus_transaction req;
// First write
req = bus_transaction::type_id::create("write_1");
start_item(req);
req.write = 1'b1;
req.addr = 8'h10;
req.data = 8'hAA;
finish_item(req);
// Second write
req = bus_transaction::type_id::create("write_2");
start_item(req);
req.write = 1'b1;
req.addr = 8'h14;
req.data = 8'h55;
finish_item(req);
endtask
The ordering is intentional. The second transaction is not allowed to replace the first transaction in the scenario.
Step 7: Use directed stimulus for a specific requirement
The strongest directed tests begin with a verification requirement.
For example:
Requirement:
A write followed by a read to the same address
must return the written data.
The directed sequence can directly express that requirement:
WRITE address=0x20 data=0x5A
READ address=0x20
The expected result is also clear:
Expected read data = 0x5A
This gives the test a simple verification story:
Requirement
|
v
Directed stimulus
|
v
DUT behavior
|
v
Observed transaction
|
v
Expected result
|
v
Pass / Fail Step 8: Directed stimulus is not the same as checking
A common beginner mistake is to think that generating a transaction proves that the DUT behaved correctly.
Stimulus and checking are separate responsibilities.
| Activity | Typical owner |
|---|---|
| Choose what operation to perform | Sequence / test |
| Drive protocol signals | Driver |
| Observe DUT activity | Monitor |
| Determine whether behavior is correct | Scoreboard / assertions / checks |
A directed test is therefore only half of the verification problem: create the right stimulus and independently determine whether the DUT responded correctly.
Step 9: Directed stimulus for boundary conditions
Directed sequences are particularly useful when testing exact boundary values.
For an 8-bit address, you might deliberately test:
8'h00
8'h01
8'h7F
8'h80
8'hFE
8'hFF
These values are much more meaningful than simply hoping randomization eventually selects them.
The same idea applies to data values:
8'h00
8'hFF
8'hAA
8'h55
8'h80
8'h01
Directed boundary tests are often an excellent complement to later constrained-random testing.
Step 10: Directed stimulus for reset scenarios
The reset sequence from Lesson 37 is another form of directed stimulus.
For example, a test might intentionally perform:
1. Assert reset
2. Hold reset for 5 clocks
3. Release reset
4. Write 0xAA to address 0x20
5. Read address 0x20
6. Assert reset again
7. Read address 0x20
8. Verify the post-reset value
Every step has a specific purpose. This is exactly where directed stimulus is strongest.
Step 11: Directed stimulus for bug reproduction
One of the most valuable uses of directed sequences is reproducing a failure discovered during debugging.
Suppose a random test discovers that a particular sequence of operations causes a failure:
WRITE 0x10 = 0xAA
WRITE 0x14 = 0x55
READ 0x10
RESET
READ 0x14
Once the scenario is understood, create a small directed regression test that performs exactly those operations.
Now the failure can be reproduced without depending on a particular random seed.
Step 12: Keep protocol details out of the sequence
A directed sequence should still operate at the transaction level.
Avoid code such as:
vif.valid <= 1'b1;
vif.addr <= 8'h20;
@(posedge vif.clk);
vif.ready...
vif.valid <= 1'b0;
That is driver-level protocol behavior.
The directed sequence should instead say:
req.write = 1'b1;
req.addr = 8'h20;
req.data = 8'h5A;
The driver remains responsible for converting those fields into legal interface activity.
Step 13: Make directed sequences readable
A directed test should tell a human what scenario it is testing.
Compare:
req.addr = 8'h20;
req.data = 8'h5A;
with a sequence structure that makes the intent explicit:
// Write known value to the target address.
send_write(8'h20, 8'h5A);
// Read it back and verify the stored value.
send_read(8'h20);
As the environment becomes larger, helper sequence tasks can make directed scenarios easier to understand without moving protocol implementation into the sequence.
Step 14: Avoid overusing directed stimulus
Directed tests have a limitation: they only exercise the scenarios you explicitly write.
Imagine a bus with:
- 256 possible addresses,
- 256 possible data values,
- multiple operation types,
- different transaction ordering possibilities.
Writing a separate directed test for every legal combination would be impractical.
This is where constrained-random stimulus becomes valuable.
Directed:
"Test exactly this scenario."
Constrained-random:
"Explore many legal scenarios."
The next lesson will build on this idea by introducing constrained-random stimulus.
Step 15: A complete directed sequence
Here is a small sequence that intentionally writes two values and reads them back.
class basic_directed_sequence
extends uvm_sequence #(bus_transaction);
`uvm_object_utils(basic_directed_sequence)
function new(string name = "basic_directed_sequence");
super.new(name);
endfunction
task send_write(
bit [7:0] addr,
bit [7:0] data
);
bus_transaction req;
req = bus_transaction::type_id::create("write_req");
start_item(req);
req.write = 1'b1;
req.addr = addr;
req.data = data;
finish_item(req);
endtask
task send_read(bit [7:0] addr);
bus_transaction req;
req = bus_transaction::type_id::create("read_req");
start_item(req);
req.write = 1'b0;
req.addr = addr;
req.data = '0;
finish_item(req);
endtask
task body();
// Directed scenario:
// write two values, then read them back.
send_write(8'h10, 8'hAA);
send_write(8'h14, 8'h55);
send_read(8'h10);
send_read(8'h14);
endtask
endclass
The scenario is easy to read:
WRITE 0x10 = 0xAA
WRITE 0x14 = 0x55
READ 0x10
READ 0x14
The driver still owns the actual bus protocol.
Step 16: Debug directed stimulus
Directed tests are especially useful for debugging because the expected transaction stream is known in advance.
When something fails, ask:
- Did the sequence generate the intended transaction?
- Did the sequencer send it to the driver?
- Did the driver translate it correctly?
- Did the DUT receive the intended protocol activity?
- Did the monitor observe what actually happened?
- Did the scoreboard compare against the correct expectation?
If the directed sequence says:
WRITE 0x20 = 0x5A
but the monitor reports:
WRITE 0x24 = 0x5A
you immediately know that something changed between stimulus generation and observation.
Step 17: Directed stimulus mental model
Verification requirement
|
v
Exact scenario
|
v
Directed sequence
|
v
Sequence item
|
v
Sequencer
|
v
Driver
|
v
DUT
|
v
Monitor
|
v
Scoreboard / Checks
|
v
Pass / Fail
The power of directed stimulus comes from making the intended scenario explicit and repeatable.
Try it yourself
Create a directed sequence for a simple memory-like bus.
- Write
8'hAAto address8'h10. - Write
8'h55to address8'h20. - Read address
8'h10. - Read address
8'h20. - Keep all protocol timing inside the driver.
- Print each intended operation with
uvm_info. - Use the monitor and scoreboard to determine whether the DUT returned the expected results.
Challenge: Create a regression sequence that reproduces a hypothetical bug: write two different addresses, assert reset, release reset, and then read one of the addresses. Decide what the expected post-reset result should be based on your DUT specification.
Key takeaways
- Directed stimulus deliberately specifies the exact transactions and scenario to execute.
- It is especially useful for smoke tests, requirements, boundaries, corner cases, reset scenarios, and bug reproduction.
- A directed sequence controls transaction intent, not DUT pin-level protocol timing.
- The driver remains responsible for converting transactions into legal interface activity.
- Stimulus generation does not prove correctness; monitors, scoreboards, assertions, and other checks provide the evidence.
- Deterministic sequences make failures easier to reproduce and debug.
- Important discovered bugs should become repeatable regression tests.
- Directed stimulus and constrained-random stimulus complement each other rather than replacing each other.
- Use directed testing when you know exactly what behavior you want to exercise; use constrained-random testing when you need broader exploration.