| |
Config/VirtInterfaceConfigDb
Setting Virtual Interface Properties in the Testbench with the Configuration Database using the config_db API
这是将实际接口引用分配给测试平台内的虚拟接口句柄的推荐方法。这种方法通常有三个步骤。
1.使用config_db API将指向特定接口实例的虚拟接口放入配置数据库。
2.test class从配置数据库中提取虚拟接口,并将其放置在一个配置对象中,该配置对象可用于通过该特定接口与DUT通信的特定组件(agent,driver,monitor等)。
3.通过虚拟接口实际访问DUT的组件将从提供的配置对象中的虚拟接口设置其虚拟接口属性。
这里有一个讨论,为什么人们会采用test class的方法来获取信息并将信息分发给agent和事务传输器(如driver,monitor等),而不是让事务传输器或agent直接获取数据。
此方法支持可伸缩性(即可变化性,即使接口变化了我改test class就行,不用改从test class往下传的多个组件的接口)和可重用性:
【此处需一幅图】
Placing a Virtual Interface into the Configuration Database using the config_db API
与OVM(其中代码仅限于存储从ovm_object派生的整数值,字符串或对象)不同,就将所有类型的信息存储在资源/配置数据库中而言,UVM允许更大的灵活性。这包括虚拟接口句柄,用户自定义类型等。使用config_db API时,将使用要存储的信息类型设置参数。这允许进行简单的set()和get()调用,而无需将信息包装在容器对象(如ovm_container)中。
// Top level module for a wishbone system with bus connection
// multiple masters and slaves
module top_mac;
...
// WISHBONE interface instance
// Supports up to 8 masters and up to 8 slaves
wishbone_bus_syscon_if wb_bus_if();
...
initial begin
//set interfaces in config space
uvm_config_db #(virtual wishbone_bus_syscon_if)::set(null, "uvm_test_top",
"WB_BUS_IF", wb_bus_if);
run_test("test_mac_simple_duplex"); // create and start running test
end
endmodule
注意:
Making the Virtual Interface Available in the Testbench
test class创建一个具有虚拟接口属性的配置对象。然后,它通过调用config_db :: get()函数来对此属性进行分配,该函数从配置数据库传递虚拟接口。此method(此处指函数 config_db::get() )的第二个参数必须与用于将虚拟接口放置在配置数据库中的字符串相同。
然后,test将配置对象放入配置数据库,以便为通过该特定接口与DUT通信的特定组件(agents, drivers, monitors等)提供访问。
class test_mac_simple_duplex extends uvm_test;
...
wb_config wb_config_0; // config object for WISHBONE BUS
...
function void set_wishbone_config_params();
//set configuration info
wb_config_0 = new();
if (!uvm_config_db #(virtual wishbone_bus_syscon_if)::get(this, "",
"WB_BUS_IF",
wb_config_0.v_wb_bus_if)) // virtual interface
`uvm_fatal("TEST_MAC_SIMPLE_DUPLEX", "Can't read WB_BUS_IF");
... // other WISHBONE bus configuration settings
uvm_config_db#(wb_config)::set(this, "*", "wb_config", wb_config_0); // put in config
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
set_wishbone_config_params();
...
endfunction : build_phase
...
endclass
Assigning Virtual Interface Property in Transactor
通过虚拟接口实际访问DUT的组件将从提供的配置对象中的虚拟接口设置其虚拟接口属性。
// WISHBONE master driver
class wb_m_bus_driver extends uvm_driver #(wb_txn, wb_txn);
...
virtual wishbone_bus_syscon_if m_v_wb_bus_if; // Virtual Interface
wb_config m_config;
...
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if (!uvm_config_db #(wb_config)::get(this, "", "wb_config", m_config)) // get config object
`uvm_fatal("Config Fatal", "Can't get the wb_config")
...
endfunction : build_phase
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
m_v_wb_bus_if = m_config.v_wb_bus_if; // set local virtual if property
endfunction : connect_phase
...
endclass
(在http://verificationacademy.com/uvm-ovm上在线下载源代码示例)。