开头老是想打Hi,就像写信一样,
class xx_transaction extends uvm_sequence_item;
rand int id ;
rand bit [xx:0] signal_A ;
constraint con_init {
soft (signal_A== xx'b0);
}
把id和我们期望看到的信号放到下面这个里面,然后我们调用tr.print函数就可以打印出来,如果只在上面定义,不放这的话,是打印不出来的
并且UVM_ALL_ON要加上,这个UVM_ALL_ON就是把变量的comp/pack/print等功能打开
`uvm_object_utils_begin(spd_det_transaction)
`uvm_field_int (id , UVM_ALL_ON)
`uvm_field_int (signal_A , UVM_ALL_ON)
`uvm_object_utils_end
function new(string name = "xx_transaction");
super.new(name);
endfunction
function bit compare_data(bit [xx:0] cur, exp);//比较函数,比较成功返回1,失败返回0
compare_data = (cur==exp);
endfunction
function bit [15:0] compare_tr(spd_det_transaction mdl_tr);
bit result=1'b1;
if (mdl_tr==null) `uvm_fatal(get_type_name(), "mdl_tr is null")
if (mdl_tr.id==id) 这个是确认数据包ID一致
`uvm_info (get_type_name(), $sformatf("compare mon_tr_%0d with mdl_tr_%0d", id, mdl_tr.id), UVM_HIGH)
else
`uvm_fatal(get_type_name(), $sformatf("compare mon_tr_%0d with mdl_tr_%0d, id not match", id, mdl_tr.id))
if(!compare_data(xx, mdl_tr.xx))begin 这个是比较数据包,一个来自model一个来自monitor
result=0
打印相关信息
end
endfunction
endclass