鏈接:https://zhuanlan.zhihu.com/p/446791549
來源:知乎
uvm從1.1d到1.2再到IEEE1800.2姐军,有了很多變化褥傍。尤其是從1.1d到1.2矿辽,在objection的使用上有了一些關(guān)鍵性變化。
在uvm進(jìn)入到1.2后,starting_phase不在推薦使用坎穿。更為重要的是河绽,不僅僅是不再推薦,而且如果以default sequence的方式啟動以后敢朱,default sequence被啟動以后剪菱,starting_phase依然會是null,如果沿用以前的代碼拴签,整個平臺就起不來了
task body()
if(starting_phase != null)
starting_phase.raise_objection(this)
//do something
if(starting_phase != null)
starting_phase.drop_objection(this)
endtask
盡管starting_phase不推薦使用孝常,但是這個類并沒有被uvm刪除,如果想要繼續(xù)使用蚓哩,那么需要在使用之前進(jìn)行如下賦值构灸。
starting_phase=get_starting_phase()
get_starting_phase的原型如下
image.png
如果不想這么麻煩,也可以使用1.2的新方法岸梨,
`uvm_sequence_base::set_automatic_phase_objection`
image.png
下面是一個例子
function my_sequence::new(string name="unnamed");
super.new(name);
set_automatic_phase_objection(1);
endfunction : new
在時間上喜颁,他的整個運(yùn)行過程如下
start() is executed
--! Objection is raised !--
pre_start() is executed
pre_body() is optionally executed
body() is executed
post_body() is optionally executed
post_start() is executed
--! Objection is dropped !--
start() unblocks
當(dāng)然稠氮,也不一定要在new函數(shù)中set,也可以在new以后半开,再額外set
my_legacy_seq_type seq = new("seq");
seq.set_automatic_phase_objection(1);
seq.start(my_sequencer);
但是個人不推薦使用隔披,因為如果環(huán)境在1.1d和1.2之間切換,會產(chǎn)生意想不到的問題寂拆,在1.1d中并沒有這種方法奢米。
所以按照個人理解,最穩(wěn)妥的方法就是直接使用start啟動sequence纠永,并且在start前后控制objection鬓长,像下面這樣
task main_phase(uvm_phase phase)
my_seq_type seq = new("seq");
phase.raise_objection(this)
seq.start(my_sequencer);
phase.drop_objection(this)
endtask
這樣在uvm1.1d和1.2中都能夠安全的啟動并且控制objection