UVM monitor是一个passive component,通过virtual interface来捕获DUT的信号,并将他们转化为sequence item格式。sequence item或者transactions被广播给其他component组件,如UVM scoreboard,coverage collector等。monitor使用TLM analysis port来广播transactions事务。
uvm_monitor 类声明:
virtual class uvm_monitor extends uvm_component
用户定义的monitor必须从 uvm_monitor 扩展,而 uvm_monitor 派生自 uvm_component。
class <monitor_name> extends uvm_monitor;
class monitor extends uvm_monitor;
// declaration for the virtual interface, analysis port, and monitor sequence item.
virtual add_if vif;
uvm_analysis_port #(seq_item) item_collect_port;
seq_item mon_item;
`uvm_component_utils(monitor)
// constructor
function new(string name = "monitor", uvm_component parent = null);
super.new(name, parent);
item_collect_port = new("item_collect_port", this);
mon_item = new();
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(virtual add_if) :: get(this, "", "vif", vif))
`uvm_fatal(get_type_name(), "Not set at top level");
endfunction
task run_phase (uvm_phase phase);
forever begin
// Sample DUT information and translate into transaction
item_collect_port.write(mon_item);
end
endtask
endclass