【发布时间】:2020-02-29 14:33:40
【问题描述】:
我知道 SystemVerilog 允许您通过将 SystemVerilog 类中的接口声明为“虚拟”来保存对接口的引用。总线,是否也可以将模块声明为“虚拟”以保存对 SystemVerilog 类中模块的引用?示例:
`timescale 1 ns / 10 ps
// Verilog-95 style BFM (with verilog 2001 style ports)
module BFM1(
input wire clk,
output reg [15:0] data
);
task write(input [15:0] data1);
data = data1;
@(posedge clk);
#1;
endtask;
endmodule
class MyClass
//"Virtual module" (instead of a "virtual interface")
virtual BFM1 vBFM1;
function new(virtual BFM1 vvBFM1);
// save virtual module reference
vBFM1 = vvBFM1;
endfunction
function write(input [15:0] data);
vBFM.write(data);
endfunction
endclass
// Testbench top-level
module top;
reg clk;
reg [15:0] data;
initial begin
clk = 0;
forever #5 !clk = clk;
end
BFM1 BFM1(
.clk (clk),
.data (data)
);
DUT DUT(
.clk (clk),
.data (data)
);
initial begin
//Verilog-95 Style BFM call
BFM1.write(16'h12340);
// SystemVerilog Class style
MyClass MyClass1 = new(BFM1);
MyClass.write(16'hDEAD);
MyClass.write(16'hBEEF);
$finish;
end
endmodule
// Design under Test
module DUT(
input wire clk,
input wire [15:0] data
);
//insert design under test logic
endmodule
我只是好奇,我是否可以省去使用 SystemVerilog 接口的形式,而只使用 SystemVerilog 类中的旧 verilog-95 样式 BFM?
我只是认为,如果您的 DUT 使用 VHDL,旧式 BFM 在 SystemVerilog 测试平台中会更好地工作,因为 VHDL 没有 SystemVerilog 接口。创建不必要的接口和包只是为了将 SystemVerilog 测试台插入不使用它们的 VHDL DUT 是一种冗余。
【问题讨论】:
标签: system-verilog uvm