1.sequencer和sequence
start()和`uvm_do()挂载的区别
通过uvm_sequence::start()
来挂载root sequence,而在内部的child sequence可以通过宏uvm_do()
来实现。
class bus_trans extends uvm_sequence_item;
rand int data;
`uvm_object_utils_begin(bus_trans)
`uvm_field_int(data, UVM_ALL_ON)
`uvm_object_utils_end
...
endclass
class child_seq extends uvm_sequence;
`uvm_object_utils(child_seq)
...
task body(); //类似于组件里的run
uvm_sequence_item tmp;
bus_trans req;
tmp = create_item(bus_trans::get_type(), m_sequencer, "req");//创建了一个item,而且挂载到了m_sequencer上面
void' ($cast(req, tmp));//转化成子类,不转化没有办法constraint
start_item(req);//开启等待
req.randomsize with {data == 10;};
finish_item(req);//等待仲裁
get_response(tmp);//函数原型就是获得父类句柄
void' ($cast(rsp, tmp));
`uvm_info("SEQ", $sformatf("gotttot a item \n %s", rsp.sprint()), UVM_LOW)
endtask
endclass
class sequencer extends uvm_sequencer;
`uvm_component_utils(sequencer)
...
endclass
class driver extends uvm_driver;
`uvm_component_utils(driver)
...
task run_phase(uvm_phase phase);
REQ tmp;
forever begin
seq_item_port.get_next_item(tmp);
void' ($cast(req, tmp));
`uvm_info("DRV", $sformatf("got a item \n %s", req.sprint()),UVM_LOW)
seq_item_port.item_done();
end
endtask
endclass
class env extends uvm_env;
sequencer sqr;
driver drv;
`uvm_component_utils(env)
...
function void build_phase(uvm_phase phase);
sqr = sequencer::type_id::create("sqr", this);
drb = driver::type_id::create("drv", this);
endfunction
function void connect_phase(uvm_phase phase);
drv.seq_item_port.connect(sqr.seq_item_export);
endfunction
endclass
class test1 extend uvm_test;
env e;
`uvm_component_utils(test1)
...
function void build_phase(uvm_phase phase);
e = env::type_id::create("e", this);
endfunction
task run_phase(uvm_phase phase);
flat_seq seq;
phase.raise_objection(phase);
seq = new();
seq.start(e.sqr);
phase.drop_objection(phase);
endtask
endclass
class top_seq extends uvm_sequence;
`uvm_object