目录如下:
第2章 一个简单的UVM验证平台
2.1 验证平台的组成
2.2 只有driver的验证平台
2.2.1 最简单的验证平台
2.2.2 加入factory机制
2.2.3 加入objection机制
2.2.4 加入virtual interface
2.3 为验证平台加入各个组件
2.3.1 加入transaction
2.3.2 加入env
2.3.3 加入monitor
2.3.4 封装成agent
未完待续
正文在下面
2.3.3 加入monitor
代码多了一个my_monitor.sv。
验证平台必须检测DUT的输入输出信号。
实现检测DUT行为的组件是monitor。driver负责把transaction级别的数据转变为DUT的端口级别,并驱动DUT,monitor的行为与其相对,用于收集DUT端口数据,并将其转换成transaction交给后续的组件如reference model、scoreboard等处理。
一、my_monitor
monitor的定义如下:
`ifndef MY_MONITOR__SV
`define MY_MONITOR__SV
class my_monitor extends uvm_monitor;
virtual my_if vif;
`uvm_component_utils(my_monitor)
function new(string name = "my_monitor", uvm_component parent = null);
super.new(name, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(virtual my_if)::get(this, "", "vif", vif))
`uvm_fatal("my_monitor", "virtual interface must be set for vif!!!")
endfunction
extern task main_phase(uvm_phase phase);
extern task collect_one_pkt(my_transaction tr);
endclass
task my_monitor::main_phase(uvm_phase phase);
my_transaction tr;
while(1) begin
tr = new("tr");
collect_one_pkt(tr)