uvm_virtual_sequence

virtual sequence实际上是一个容器, 其中包含多个sequence, 这些sequence可以给不同env的sequencer发送激励。 比如Soc系统中有PCIe, wishbone, apb总线,一个比较好的方式就是使用virtual sequence进行控制:

如下图所示:

virtual sequence的使用示例如下代码所示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class my_virtual_seq extends uvm_sequence;
`uvm_object_utils (my_virtual_seq)
`uvm_declare_p_sequencer (my_virtual_sequencer)

function new (string name = "my_virtual_seq");
super.new (name);
endfunction

apb_rd_wr_seq m_apb_rd_wr_seq;
wb_reset_seq m_wb_reset_seq;
pcie_gen_seq m_pcie_gen_seq;

task pre_body();
m_apb_rd_wr_seq = apb_rd_wr_seq::type_id::create ("m_apb_rd_wr_seq");
m_wb_reset_seq = wb_reset_seq::type_id::create ("m_wb_reset_seq");
m_pcie_gen_seq = pcie_gen_seq::type_id::create ("m_pcie_gen_seq");
endtask

task body();
...
m_apb_rd_wr_seq.start (p_sequencer.m_apb_seqr);
fork
m_wb_reset_seq.start (p_sequencer.m_wb_seqr);
m_pcie_gen_seq.start (p_sequencer.m_pcie_seqr);
join
...
endtask
endclass

档virtual sequence定义后, 可以在test case中这样去定义:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class my_test extends uvm_test;
`uvm_component_utils (my_test)

my_env m_env;

...

task run_phase (uvm_phase phase);
my_virtual_seq m_vseq = my_virtual_seq::type_id::create ("m_vseq");
phase.raise_objection (this);
m_vseq.start (m_env.m_virtual_seqr);
phase.drop_objection (this);
endtask
endclass