Layered Sequences
Build reusable stimulus by composing high-level scenarios from lower-level protocol sequences without duplicating driver-level transaction logic.
Learning objectives
- Explain why layered sequences improve stimulus reuse and maintainability.
- Distinguish a parent sequence from the child sequences it composes.
- Start child sequences correctly from a parent sequence.
- Understand the difference between sequence layering and multi-agent orchestration.
- Use sequence layering to separate scenario intent from protocol-level stimulus.
- Debug a layered sequence by tracing control from the parent sequence to the driver.
Step 1: Understand the concept
A layered sequence is a sequence architecture in which a higher-level sequence builds a meaningful scenario by composing lower-level sequences.
The important idea is separation of intent from implementation. A high-level sequence should describe what scenario should happen, while lower-level sequences encapsulate how the required protocol transactions are generated.
For example, imagine a bus agent that supports read and write transactions. Instead of writing every bus transaction directly inside every test, we can build reusable layers:
Test scenario
|
v
+-----------------------+
| high-level sequence |
| "write configuration" |
+-----------------------+
|
v
+-----------------------+
| write sequence |
| creates bus writes |
+-----------------------+
|
v
+-----------------------+
| bus sequence item |
| address/data/control |
+-----------------------+
|
v
+-----------------------+
| sequencer -> driver |
+-----------------------+
The higher layer should not need to duplicate the details required to construct every individual bus transaction. If the protocol changes, the lower-level sequence can often be updated without rewriting every scenario.
Step 2: Know what a layer owns
Before creating a sequence hierarchy, decide what each layer is responsible for. A useful division is:
| Layer | Typical responsibility |
|---|---|
| Scenario sequence | Expresses the verification intent and business-level operation. |
| Protocol sequence | Translates that operation into legal protocol transactions. |
| Sequence item | Represents one transaction consumed by the sequencer/driver. |
| Driver | Converts sequence items into pin-level interface activity. |
Consider a memory-mapped bus. A scenario might say:
write register 0x20 with value 0x55
The scenario sequence should not need to know every handshake detail of the bus. A reusable write sequence can translate the operation into the appropriate transaction.
This gives us a clean dependency direction:
Scenario intent
|
v
Reusable protocol sequence
|
v
Sequence item
|
v
Driver implementation Step 3: Build a reusable child sequence
Start with a small protocol-level sequence. Assume the environment has a
bus_sequencer that accepts bus_item transactions.
class bus_write_seq extends uvm_sequence #(bus_item);
`uvm_object_utils(bus_write_seq)
rand bit [31:0] addr;
rand bit [31:0] data;
function new(string name = "bus_write_seq");
super.new(name);
endfunction
task body();
bus_item req;
req = bus_item::type_id::create("req");
start_item(req);
req.write = 1'b1;
req.addr = addr;
req.data = data;
finish_item(req);
endtask
endclass
This sequence owns the mechanics of creating a bus write transaction. A
higher-level scenario does not need to repeat the start_item(),
field assignment, and finish_item() pattern.
Step 4: Compose the child sequence from a parent sequence
Now create a higher-level sequence that represents a meaningful verification operation.
Suppose the scenario is:
1. Write 0x55 to address 0x20.
2. Write 0xAA to address 0x24.
3. Continue with the rest of the test scenario.
The parent sequence can create and start two instances of the reusable write sequence.
class configure_block_seq extends uvm_sequence #(bus_item);
`uvm_object_utils(configure_block_seq)
function new(string name = "configure_block_seq");
super.new(name);
endfunction
task body();
bus_write_seq write_seq;
write_seq = bus_write_seq::type_id::create("write_seq_1");
write_seq.addr = 'h20;
write_seq.data = 'h55;
write_seq.start(m_sequencer);
write_seq = bus_write_seq::type_id::create("write_seq_2");
write_seq.addr = 'h24;
write_seq.data = 'hAA;
write_seq.start(m_sequencer);
endtask
endclass
The parent sequence expresses the scenario, while
bus_write_seq owns the details of generating a bus write.
The important control flow is:
configure_block_seq
|
+----> bus_write_seq(addr=0x20, data=0x55)
|
+----> bus_write_seq(addr=0x24, data=0xAA)
|
v
bus_item
|
v
driver
Step 5: Understand sequence execution
When a parent sequence calls:
write_seq.start(m_sequencer);
the child sequence executes on the selected sequencer. Its
body() generates sequence items, and those items participate in
the normal sequencer-driver handshake.
The parent sequence normally waits for the child sequence to complete before continuing. Therefore:
write_seq.start(m_sequencer);
next_operation();
means that next_operation() is reached after the child sequence
finishes.
Step 6: Sequence layering is not the same as a virtual sequence
These concepts are related, but they solve different problems.
Layered sequences are useful when one sequence can build a higher-level operation from lower-level sequences on the same stimulus path.
A virtual sequence is typically used when higher-level stimulus must coordinate activity across multiple sequencers or agents.
| Problem | Typical solution |
|---|---|
| Build a register-write operation from reusable bus transactions | Layered sequences |
| Build a packet operation from reusable lower-level packet sequences | Layered sequences |
| Coordinate traffic on APB and an interrupt interface | Virtual sequence |
| Coordinate stimulus across several protocol agents | Virtual sequence / virtual sequencer architecture |
Do not introduce a virtual sequencer simply because a parent sequence exists. First identify whether the scenario actually needs to coordinate multiple sequencers.
Step 7: Avoid hard-coded protocol knowledge at the wrong layer
A common design mistake is allowing every high-level sequence to manipulate protocol fields directly.
For example, this can become difficult to maintain:
req.valid = 1;
req.write = 1;
req.addr = 'h20;
req.data = 'h55;
req.wait_states = 3;
// repeated in many scenario sequences
If protocol rules change, many sequences must then be modified.
A better architecture centralizes protocol-specific construction in reusable sequences:
configure_block_seq
|
v
bus_write_seq
|
v
bus_item
|
v
driver
The higher-level sequence can remain focused on intent while the lower-level sequence handles protocol construction.
Step 8: Improve the design with parameters and randomization
Once the deterministic version works, make the child sequence reusable across more scenarios.
class bus_write_seq extends uvm_sequence #(bus_item);
`uvm_object_utils(bus_write_seq)
rand bit [31:0] addr;
rand bit [31:0] data;
constraint aligned_addr_c {
addr[1:0] == 2'b00;
}
function new(string name = "bus_write_seq");
super.new(name);
endfunction
task body();
bus_item req;
req = bus_item::type_id::create("req");
start_item(req);
req.write = 1'b1;
req.addr = addr;
req.data = data;
finish_item(req);
endtask
endclass
The parent sequence can now control the scenario while the child sequence retains reusable protocol constraints.
A useful development order is:
- Make one deterministic child sequence work.
- Compose it from a parent sequence.
- Verify that the expected transactions reach the driver.
- Add constraints and controlled randomization.
- Only then generalize the sequence for broader reuse.
Step 9: Debug a layered sequence systematically
When layered stimulus fails, do not immediately modify every sequence involved. Trace the hierarchy one level at a time.
-
Did the parent sequence start?
Add a clearuvm_infomessage at the beginning of itsbody(). -
Did the child sequence start?
Report its name, address, data, or other important parameters. -
Did the child generate a sequence item?
Check the transaction immediately before and afterfinish_item(). -
Did the driver receive the item?
Confirm the driver'sget_next_item()or equivalent handshake. -
Did the monitor observe the expected protocol activity?
Use the monitor transaction as independent evidence.
This produces a useful verification chain:
Parent started
|
v
Child started
|
v
Sequence item generated
|
v
Driver received item
|
v
DUT activity occurred
|
v
Monitor observed transaction
Each step gives you evidence about where the problem actually exists.
Step 10: Recognize common layering mistakes
Try it yourself
Create a small layered stimulus architecture for a memory-mapped peripheral.
- Create a reusable
bus_write_seq. - Create a reusable
bus_read_seq. - Create a higher-level
configure_block_seq. - Make
configure_block_seqperform two writes followed by one read. - Run the sequence on a single bus sequencer.
- Use the monitor output to confirm that the expected three transactions occurred in order.
Challenge:
Modify the child sequences so that the addresses and data are configurable
without changing the structure of configure_block_seq.
Verification checkpoint
You should be able to answer these questions before moving on:
- Why is a layered sequence more reusable than putting all transaction generation in a test?
- What responsibility belongs in the high-level sequence?
- What responsibility belongs in the protocol-level sequence?
- What happens when a parent sequence calls
child_seq.start(m_sequencer)? - When would a virtual sequence be more appropriate than simple sequence layering?
Key takeaways
- Layered sequences separate high-level scenario intent from lower-level protocol stimulus.
- A parent sequence can compose reusable child sequences instead of duplicating transaction-generation code.
- Child sequences should execute on compatible sequencers and participate in the normal sequencer-driver handshake.
- Deterministic layered stimulus should be validated before adding extensive randomization.
- Sequence layering and virtual sequences are related but solve different architectural problems.
- Good layering reduces duplication while preserving a clear abstraction boundary between scenario intent and protocol implementation.
- Debug layered stimulus by tracing evidence from parent sequence to child sequence, sequence item, driver, and monitor.