这是我的代码 -> eda Playground
当下面的代码激活时,当“monitor”将值发送为 anlaysis_port 时,uvm_scoreboard 中的“trasn packet queue”类会发生更改。我只是给出了一个将数据写入数据包队列的“push_back”方法。但队列中的所有数据都已更改。
`uvm_analysis_imp_decl(_expdata)
`uvm_analysis_imp_decl(_actdata)
class exp_obj extends uvm_object;
`uvm_object_utils(exp_obj)
apb_transaction exp_queue[$];
function new(string name = "exp_obj");
super.new(name);
endfunction
endclass
class apb_scoreboard extends uvm_scoreboard;
`uvm_component_utils(apb_scoreboard)
uvm_analysis_imp_expdata#(apb_transaction, apb_scoreboard) mon_export;
uvm_analysis_imp_actdata#(apb_transaction, apb_scoreboard) sb_export;
exp_obj obj;
function new(string name, uvm_component parent);
super.new(name, parent);
mon_export = new("mon_export", this);
sb_export = new("sb_export", this);
obj = new("obj");
obj.rand_mode(0);
//obj = exp_obj::type_id::create("exp_queue", this);
//exp_queue = new();
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
//exp_queue = apb_transaction::type_id::create("exp_queue", this);
endfunction
function write_actdata(input apb_transaction tr);
apb_transaction expdata;
if (tr.pwrite == 0 && tr.penable == 0) begin
if(obj.exp_queue.size()) begin
`uvm_info(get_type_name(), $psprintf("queue[0]: \n%s", obj.exp_queue[0].sprint()), UVM_LOW)
//expdata = apb_transaction::type_id::create($psprintf("exp_queue%d", exp_queue.size()), this);
expdata = obj.exp_queue.pop_front();
tr.compare(expdata);
if(tr.prdata == expdata.pwdata)begin
`uvm_info("",$sformatf("MATCHED, %8h", expdata.pwdata),UVM_LOW)
end
else begin
`uvm_info("",$sformatf("MISMATCHED, tr: %8h, expdata: %8h", tr.prdata, expdata.pwdata),UVM_LOW)
end
end
end
endfunction
function write_expdata(input apb_transaction tr);
if (tr.pwrite == 1 && tr.penable == 1) begin
obj.exp_queue.push_back(tr);
`uvm_info(get_type_name(), "get_write_data", UVM_LOW)
tr.print();
`uvm_info(get_type_name(), $psprintf("queue[0]: \n%s", obj.exp_queue[0].sprint()), UVM_LOW)
end
foreach(obj.exp_queue[i]) `uvm_info(get_type_name(), $psprintf("pwdata[%d]: %8h", i, obj.exp_queue[i].pwdata), UVM_LOW)
endfunction
endclass
目标是将写入数据存储在队列中,无论如何,都会用随机数据替换。
如何才能获得所需的行为?
你的问题(至少其中之一)是你只构造了一个交易对象。您需要做的是为进入队列的每个事务构造一个新对象。将其放入监视器的永久循环中,以写入记分板。