|
发表于 2015-11-18 15:45:48
|
显示全部楼层
在你的书中有这样一个例子,代码如下:
class sequence0 extends uvm_sequence #(my_transaction);
my_transaction m_trans;
function new(string name= "sequence0");
super.new(name);
endfunction
virtual task body();
if(starting_phase != null)
starting_phase.raise_objection(this);
repeat (5) begin
`uvm_do(m_trans)
`uvm_info("sequence0", "send one transaction", UVM_MEDIUM)
end
#100;
if(starting_phase != null)
starting_phase.drop_objection(this);
endtask
`uvm_object_utils(sequence0)
endclass
class sequence1 extends uvm_sequence #(my_transaction);
my_transaction m_trans;
function new(string name= "sequence1");
super.new(name);
endfunction
virtual task body();
if(starting_phase != null)
starting_phase.raise_objection(this);
repeat (3) begin
`uvm_do_with(m_trans, {m_trans.pload.size < 500;})
`uvm_info("sequence1", "send one transaction", UVM_MEDIUM)
end
grab();
`uvm_info("sequence1", "grab the sequencer ", UVM_MEDIUM)
repeat (4) begin
`uvm_do_with(m_trans, {m_trans.pload.size < 500;})
`uvm_info("sequence1", "send one transaction", UVM_MEDIUM)
end
`uvm_info("sequence1", "ungrab the sequencer ", UVM_MEDIUM)
ungrab();
repeat (3) begin
`uvm_do_with(m_trans, {m_trans.pload.size < 500;})
`uvm_info("sequence1", "send one transaction", UVM_MEDIUM)
end
#100;
if(starting_phase != null)
starting_phase.drop_objection(this);
endtask
`uvm_object_utils(sequence1)
endclass
class my_case0 extends base_test;
function new(string name = "my_case0", uvm_component parent = null);
super.new(name,parent);
endfunction
`uvm_component_utils(my_case0)
extern virtual task main_phase(uvm_phase phase);
endclass
task my_case0::main_phase(uvm_phase phase);
sequence0 seq0;
sequence1 seq1;
seq0 = new("seq0");
seq0.starting_phase = phase;
seq1 = new("seq1");
seq1.starting_phase = phase;
fork
seq0.start(env.i_agt.sqr);
seq1.start(env.i_agt.sqr);
join
endtask
这里使用了sequencer的grab操作。
如果将sequence1的grab();以及ungrab();换成lock();和unlock();运行情况如下:
在lock语句之前,sequence0和sequence1交替产生transaction;在lock语句后,一直发送sequence1的transaction,知道unlock语句被调用后,sequence0和sequence1又开始交替产生transaction。
但是,如果是grab运行情况又是什么呢?
书中对grab操作的描述是这样的:与lock操作一样。grab操作也用于暂时拥有sequencer的所有权,只是grab操作比lock操作优先级更高,lock请求被插入sequencer仲裁队列的最后面,等到它时,它前面的仲裁请求都已结束。grab请求则被放入sequencer仲裁队列的最前面,它几乎是一出发就拥有了sequencer的所有权。
按照这个逻辑,sequence1也要等到grab前面的语句执行完毕之后才能获得sequencer的所有权,运行的情况不合lock的时候是一样吗? |
|