| |
DualTop
通常,DUT-TB验证框架具有单个SystemVerilog模块作为顶层。该顶层模块包含DUT及其相关接口、协议模块、连接关系和所支持的逻辑。它还包含用于创建测试平台的代码。该顶层模块所包含的这些繁杂的“东西”都会变得混乱而难以管理。管理所有这些东西的另一种方法是将与DUT直接相关的所有内容封装在包装器模块中。Verilog允许在simulation中使用多个顶层模块。这两个模块都没有实例化,而是都被视为顶层模块。这种安排称为双顶层。
双顶层是emulation的必需品。DUT包装器模块(双顶层中的其中一个顶层)是emulator中的东西。包含测试平台的另一个顶层模块(双顶层中的另一个顶层模块)在simulator中保持运行。如果测试平台仅用于simulation,则双顶层不是必需的,但是仍然可以为模块化、重用性等目的提供有用的封装级别。
使用uvm_config_db完成DUT包装器模块和测试平台之间的虚拟接口连接通信。
【此处需一幅图】
DUT Wrapper module
在此示例中,MAC DUT及其相关接口和协议模块以及WISHBONE slave memory以及WISHBONE总线逻辑包含在DUT包装器模块top_mac中。
module top_mac;
import uvm_pkg::*;
import test_params_pkg::*;
// WISHBONE interface instance
// Supports up to 8 masters and up to 8 slaves
wishbone_bus_syscon_if wb_bus_if();
//-----------------------------------
// WISHBONE 0, slave 0: 000000 - 0fffff
// this is 1 Mbytes of memory
wb_slave_mem #(mem_slave_size) wb_s_0 (
...
);
// wires for MAC MII connection
wire [3:0] MTxD;
wire [3:0] MRxD;
//-----------------------------------
// MAC 0
// It is WISHBONE slave 1: address range 100000 - 100fff
// It is WISHBONE Master 0
eth_top mac_0 (
...
);
// protocol module for MAC MII interface
mac_mii_protocol_module #(.INTERFACE_NAME("MIIM_IF")) mii_pm(
...
);
initial
//set WISHBONE virtual interface in config space
uvm_config_db #(virtual wishbone_bus_syscon_if)::set(null, "uvm_test_top", "WB_BUS_IF", wb_bus_if);
endmodule
Testbench top module
在创建测试平台的顶层模块中是一个调用run_test()的initial块。请注意导入uvm_pkg :: run_test和tests_pkg :: test_mac_simple_duplex。这些是编译run_test()代码行所必需的。
// This the top for the tesbench in a dual top setup
// The dut is in the top_mac dut wrapper module
module top;
import uvm_pkg::run_test;
import tests_pkg::test_mac_simple_duplex;
initial
run_test("test_mac_simple_duplex"); // create and start running test
endmodule
Questasim with more than one top level module
对vsim的调用包括多个顶层模块。
#Makefile
...
normal: clean cmp
vsim +nowarnTSCALE -c top top_mac -suppress 3829 -do "run -all"
...
(在http://verificationacademy.com/uvm-ovm上在线下载源代码示例)。