sequence的启动
seq的start通过传递sqr句柄实现启动;
但是这种方式将接口暴露在外,不被提倡。
启动以后,seq会调用uvm_do之类的宏向其传递的句柄开始发送事件给sqr;
而driver将通过TLM取得sqr接收的数据,并驱动到端口上。
UVM1.1中sequence的启动
对于UVM1.1来说,启动sequence可以通过default_sequence完成;
在顶层模块设置
uvm_config_db#(uvm_object_wrapper)::set(this,"i_agt.sqr.main_phase","default_sequence",my_sequence::type_id::get());
之后,在uvm_sequence这个基类中,有一个变量名为starting_phase,
它的类型是uvm_phase,sequencer在启动default_sequence时,会:
task my_sequencer::main_phase(uvm_phase phase);seq.starting_phase = phase;seq.start(this); endtask
之后即可通过判断starting_phase的状态决定
starting_phase.raise_objection(this);和starting_phase.drop_objection(this);
class my_sequence extends uvm_sequence #(my_transaction); my_transaction m_trans; virtual task body();if(starting_phase != null)starting_phase.raise_objection(this);repeat (10) begin`uvm_do(m_trans)end#1000;if(starting_phase != null)starting_phase.drop_objection(this);endtask`uvm_object_utils(my_sequence) endclass
uvm从1.1d到1.2再到IEEE1800.2,有了很多变化。尤其是从1.1d到1.2,在objection的使用上有了一些关键性变化。
在uvm进入到1.2后,starting_phase不在推荐使用。
更为重要的是,不仅仅是不再推荐,而且如果以default sequence的方式启动以后,
default sequence被启动以后,starting_phase依然会是null,如果沿用以前的代码,整个平台就起不来了
解决方法一:
添加:
starting_phase = get_starting_phase();
class my_sequence extends uvm_sequence#(my_transaction);`uvm_object_utils(my_sequence)virtual task body();// ── 1. 取到真正的 phase 句柄starting_phase = get_starting_phase();// ── 2. 用它来管理 objectionif (starting_phase != null)starting_phase.raise_objection(this);// ── 3. 你的事务逻辑repeat (10) begin`uvm_do(m_trans)end#1000;// ── 4. 最后 drop objectionif (starting_phase != null)starting_phase.drop_objection(this);endtask endclass
uvm_sequence_base::set_automatic_phase_objection
function my_sequence::new(string name="unnamed");super.new(name);set_automatic_phase_objection(1); endfunction : new
执行顺序
start() is executed--! Objection is raised !--pre_start() is executedpre_body() is optionally executedbody() is executedpost_body() is optionally executedpost_start() is executed--! Objection is dropped !-- start() unblocks
使用方法:
顶层 testbench 中设置 default_sequence(必须):
uvm_config_db#(uvm_object_wrapper)::set(this,"env.agent.sequencer.main_phase","default_sequence",my_sequence::type_id::get());
告诉 sequencer 在某个 phase 自动启动哪个 sequence(否则需要自行在某个phase里写入,比如下面这种):
task my_sequencer::main_phase(uvm_phase phase);my_sequence seq;phase.raise_objection(this);seq = my_sequence::type_id::create("seq");seq.start(this); phase.drop_objection(this); endtask