| |
Assigning Virtual Interfaces From The Configuration Space
在调用UVM run_test()方法之前,应该通过将它们连接到SystemVerilog接口来连接到DUT的顶层I / O边界上的信号,然后应该将每个接口的句柄分配给通过uvm_config_db :: set传入test的虚拟 接口句柄。有关此主题的更多信息,请参阅有关虚拟接口的文章。
在test的build方法中,需要将这些虚拟接口引用分配给相关组件配置对象内的虚拟接口句柄。然后,各个组件访问其配置对象内的虚拟接口句柄,以便驱动或监视DUT信号。为了使组件保持模块化和可重用,driver和monitor不应直接从配置空间获取其虚拟接口指针,只能从其配置对象获取。test类是确保通过其配置对象将虚拟接口分配给正确的验证组件的正确位置。
以下代码显示了SPI测试平台示例如何使用uvm_config_db :: get方法为apb_agents配置对象中的虚拟接口句柄进行虚拟接口分配:
// The build method from before, adding the apb agent virtual interface assignment
// Build the env, create the env configuration
// including any sub configurations and assigning virtual interfaces
function void spi_test_base::build_phase( uvm_phase phase );
// Create env configuration object
m_env_cfg = spi_env_config::type_id::create("m_env_cfg");
// Call function to configure the env
configure_env(m_env_cfg);
// Create apb agent configuration object
m_apb_cfg = apb_agent_config::type_id::create("m_apb_cfg");
// Call function to configure the apb_agent
configure_apb_agent(m_apb_cfg);
// Adding the apb virtual interface:
if( !uvm_config_db #( virtual apb3_if )::get(this, "" , "APB_vif",m_apb_cfg.APB) ) `uvm_error(...)
// More to follow
endfunction: build_phase