完善monitor与scoreboard
- monitor。负责监测interface上的数据,并将其送入scoreboard进行数据比对。目前的数据发送都是SINGLE,所以只需要将写的数据送回即可,但是当存在NSEQ、SEQ时,数据需要堆积起来,放入数组中。这也是之前在dirver中将数据放入的是数组,而不是一个变量。虽然目前还未用到SEQ传输,但是需要数据来存放。所以在lvc_ahb_transaction中需要加入一个函数:
function void increase_data(int n = 1);//如果新加入data,将data宽度+1,再把之前的data放入
data = new[data.size + 1] (data);
all_beat_response = new[all_beat_response.size + 1] (all_beat_response);
endfunction
完善lvc_ahb_monitor:
- 在monitor_transaction中执行收集任务,并item_observed_port.write(t)。这句write是内建函数。使用这种方式将monitor采集到的seq写入,在被广播的对象处拿到。
- 先在SEQ处,采集AHB的驱动信号,根据采集到的xact来判断需要收集读还是写数据。forever的目的是一直采集数据知道本次burst结束
`ifndef LVC_AHB_MONITOR_SV
`define LVC_AHB_MONITOR_SV
class lvc_ahb_monitor extends uvm_monitor;
lvc_ahb_agent_configuration cfg;//添加配置、virtual接口
virtual lvc_ahb_if vif;
uvm_analysis_port #(lvc_ahb_transaction) item_observed_port;//广播到cov、scb
`uvm_component_utils(lvc_ahb_monitor)
function new(string name = "lvc_ahb_monitor", uvm_component parent = null);
super.new(name, parent);
item_observed_port = new("item_observed_port", this);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
endfunction
task run_phase(uvm_phase phase);
super.run_phase(phase);
fork
monitor_transactions();
join_none
endtask
task monitor_transactions();
lvc_ahb_transaction t;
forever begin
collect_transfer(t);
item_observed_port.write(t);//collect采样到transfer后通过analysis_port广播出去
end
endtask
task collect_transfer(output lvc_ahb_transaction t);
// collect transfer from interface收集interface来的trans
t = lvc_ahb_transaction::type_id::create("t");//创建一个trans
@(vif.cb_mon iff vif.cb_mon.htrans == NSEQ);//等到NSEQ开始(trans是向量和左边枚举类型有隐式转化)
t.trans_type = trans_type_enum'(vif.cb_mon.htrans);//把状态记录下来
t.xact_type = xact_type_enum'(vif.cb_mon.hwrite);//记录是write or read
t.burst_type = burst_type_enum'(vif.cb_mon.hburst);
t.burst_size = burst_size_enum'(vif.cb_mon.hsize);
t.addr = vif.cb_mon.haddr;
forever begin
monitor_valid_data(t);
if(t.trans_type == IDLE)
break;
end
t.response_type = t.all_beat_response[t.current_data_beat_n