| |
The Agent Build Phase
Notes:
1.可以从monitor的analysis port为agent的analysis port句柄分配指针。这节省了必须在agent中构建单独的analysis port对象。
2.在agent中为driver和monitor分配虚拟接口,这就不需要这些子组件具有配置表查找的代价了。
apb agent的以下代码说明了配置对象如何确定在build phase和connect phase期间发生的情况:
//
// Class Description:
//
//
class apb_agent extends uvm_component;
// UVM Factory Registration Macro
//
`uvm_component_utils(apb_agent)
//------------------------------------------
// Data Members
//------------------------------------------
apb_agent_config m_cfg;
//------------------------------------------
// Component Members
//------------------------------------------
uvm_analysis_port #(apb_seq_item) ap;
apb_monitor m_monitor;
apb_sequencer m_sequencer;
apb_driver m_driver;
apb_coverage_monitor m_fcov_monitor;
//------------------------------------------
// Methods
//------------------------------------------
// Standard UVM Methods:
extern function new(string name = "apb_agent", uvm_component parent = null);
extern function void build_phase( uvm_phase phase );
extern function void connect_phase( uvm_phase phase );
endclass: apb_agent
function apb_agent::new(string name = "apb_agent", uvm_component parent = null);
super.new(name, parent);
endfunction
function void apb_agent::build_phase( uvm_phase phase );
if( !uvm_config_db #( apb_agent_config )::get(this,"apb_agent_config",m_cfg) ) `uvm_error(...)
// Monitor is always present
m_monitor = apb_monitor::type_id::create("m_monitor", this);
// Only build the driver and sequencer if active
if(m_cfg.active == UVM_ACTIVE) begin
m_driver = apb_driver::type_id::create("m_driver", this);
m_sequencer = apb_sequencer::type_id::create("m_sequencer", this);
end
if(m_cfg.has_functional_coverage) begin
m_fcov_monitor = apb_coverage_monitor::type_id::create("m_fcov_monitor", this);
end
endfunction: build_phase
function void apb_agent::connect_phase( uvm_phase phsae );
m_monitor.APB = m_cfg.APB;
ap = m_monitor.ap;
// Only connect the driver and the sequencer if active
if(m_cfg.active == UVM_ACTIVE) begin
m_driver.seq_item_port.connect(m_sequencer.seq_item_export);
m_driver.APB = m_cfg.APB;
end
if(m_cfg.has_functional_coverage) begin
m_monitor.ap.connect(m_fcov_monitor.analysis_export);
end
endfunction: connect_phase
在块级测试平台示例中agent的构建过程可以遵循此处APB agent的构建过程: