jus*_*eep 0 interface system-verilog uvm
我有一个系统verilog接口
interface add_sub_if(
input bit clk,
input [7:0] a,
input [7:0] b,
input doAdd,
input [8:0] result
);
clocking dut_cb @(posedge clk);
output a;
output b;
output doAdd;
input result;
endclocking // cb
modport dut(clocking dut_cb);
endinterface: add_sub_if
Run Code Online (Sandbox Code Playgroud)
我有一个使用这个接口的 SV 模块
module dummy(add_sub_if.dut _if);
....
endmodule: dummy
Run Code Online (Sandbox Code Playgroud)
将其连接到我的 TB 中的理想方式是什么?
如果我实例化接口,我需要创建电线。
如果我使用绑定,那么我还需要对各个信号进行端口映射,这比使用接口的便利性要好。
另一个附加问题是,如何将一个这样的接口分配给另一个接口?
提前致谢,
拉吉迪普
您可以在IEEE Std 1800-2012第 3.5 节(接口)中找到接口定义和用法的简单示例。它展示了如何定义界面并将其与设计挂钩(按照您已经完成的方式)。它还显示了如何在顶级模块/包装器内实例化(和连接)接口(为了方便起见,我直接从规范复制了下面的代码):
interface simple_bus(input logic clk); // Define the interface
logic req, gnt;
logic [7:0] addr, data;
logic [1:0] mode;
logic start, rdy;
endinterface: simple_bus
module memMod(simple_bus a); // simple_bus interface port
logic avail;
// When memMod is instantiated in module top, a.req is the req
// signal in the sb_intf instance of the 'simple_bus' interface
always @(posedge clk) a.gnt <= a.req & avail;
endmodule
module cpuMod(simple_bus b); // simple_bus interface port
...
endmodule
module top;
logic clk = 0;
simple_bus sb_intf(.clk(clk)); // Instantiate the interface
memMod mem(.a(sb_intf)); // Connect interface to module instance
cpuMod cpu(.b(sb_intf)); // Connect interface to module instance
endmodule
Run Code Online (Sandbox Code Playgroud)
连接好接口后,您就可以驱动/采样来自测试用例程序的所有信号(只需记住您必须将接口传递给它)。在这种情况下,它会是这样的:
program testcase(simple_bus tb_if);
initial begin
tb_if.mode <= 0;
repeat(3) #20 tb_if.req <= 1'b1;
[...]
$finish;
end
endprogram
Run Code Online (Sandbox Code Playgroud)
对于实际示例,您可以查看我的 GitHub 页面上提供的UVM 测试平台的源代码。接口连接在xge_test_top.sv文件中完成。