SystemVerilog 中测试台环境的接口 Modport 连接
Interface Modport Connection to Testbench Environment in SystemVerilog
我有一个简单的仲裁器设计,它授予两个请求之一优先于第一个请求。我想将它连接到用 SystemVerilog 设计的测试台。我想通过两个位置的接口将我的环境连接到我的 DUT:1) 到监控总线的监视器 2)。给一个驱动,驱动相关的测试用例。
对于这两个连接,我定义了两个modports
。我在顶层模块中实例化了我的 DUT 和接口,并尝试使用虚拟接口将引用传递给这两个 modports
。但是,我收到如下编译时错误:
** Error: Environment.sv(8): Illegal assignment to type 'virtual interface arbi_if' from type 'virtual interface arb_if': Virtual interface type 'arbi_if' cannot be assigned type 'arb_if'.
不同代码如下:
arb_if.sv
interface arb_if(
input clk
);
logic [1:0] request;
logic [1:0] grant;
logic rst;
clocking cb @(posedge clk);
input grant;
output request;
endclocking
modport TEST(clocking cb, output rst);
modport ARBI(input clk, grant, output rst, request);
modport MONT(input clk, grant, rst, request);
endinterface
Environment.sv
class Environment;
virtual arbi_if af;
virtual arbi_if.TEST aft;
virtual arbi_if.TEST afm;
function new(virtual arb_if af);
this.af = af;
this.aft = af.TEST;
this.afm = af.MONT;
endfunction
endclass
test.sv
`include "Environment.sv"
class test;
Environment env;
virtual arb_if af;
function new(virtual arb_if afi);
this.af = afi; // Compiler complains for this line.
endfunction
...
endclass
tb_top.sv
module tb_top;
reg clk;
initial
begin
clk = 0;
forever #5 clk = ~clk;
end
arb_if arbif(clk);
arb a(arbif);
test ta(arbif);
endmodule
总而言之,我想知道如何将对 modports 的引用从顶级模块传递到不同的 类?
上面的代码已经过删减,以作为一个最小的工作示例。
在声明接口端口或虚拟接口变量,或对它们进行赋值时,Modports 只是受限的访问权限。这在 IEEE 1800-2017 LRM 的 25.9 虚拟接口 和 25.10 访问接口对象 部分进行了解释。
本质上,您始终可以从 无限制 接口实例到 modport
限制 端口或变量进行接口类型分配,但是您永远不能在相反的方向(限制到不受限制)或从一种 modport 类型到另一种 modport 类型进行分配。
我有一个简单的仲裁器设计,它授予两个请求之一优先于第一个请求。我想将它连接到用 SystemVerilog 设计的测试台。我想通过两个位置的接口将我的环境连接到我的 DUT:1) 到监控总线的监视器 2)。给一个驱动,驱动相关的测试用例。
对于这两个连接,我定义了两个modports
。我在顶层模块中实例化了我的 DUT 和接口,并尝试使用虚拟接口将引用传递给这两个 modports
。但是,我收到如下编译时错误:
** Error: Environment.sv(8): Illegal assignment to type 'virtual interface arbi_if' from type 'virtual interface arb_if': Virtual interface type 'arbi_if' cannot be assigned type 'arb_if'.
不同代码如下:
arb_if.sv
interface arb_if(
input clk
);
logic [1:0] request;
logic [1:0] grant;
logic rst;
clocking cb @(posedge clk);
input grant;
output request;
endclocking
modport TEST(clocking cb, output rst);
modport ARBI(input clk, grant, output rst, request);
modport MONT(input clk, grant, rst, request);
endinterface
Environment.sv
class Environment;
virtual arbi_if af;
virtual arbi_if.TEST aft;
virtual arbi_if.TEST afm;
function new(virtual arb_if af);
this.af = af;
this.aft = af.TEST;
this.afm = af.MONT;
endfunction
endclass
test.sv
`include "Environment.sv"
class test;
Environment env;
virtual arb_if af;
function new(virtual arb_if afi);
this.af = afi; // Compiler complains for this line.
endfunction
...
endclass
tb_top.sv
module tb_top;
reg clk;
initial
begin
clk = 0;
forever #5 clk = ~clk;
end
arb_if arbif(clk);
arb a(arbif);
test ta(arbif);
endmodule
总而言之,我想知道如何将对 modports 的引用从顶级模块传递到不同的 类? 上面的代码已经过删减,以作为一个最小的工作示例。
在声明接口端口或虚拟接口变量,或对它们进行赋值时,Modports 只是受限的访问权限。这在 IEEE 1800-2017 LRM 的 25.9 虚拟接口 和 25.10 访问接口对象 部分进行了解释。
本质上,您始终可以从 无限制 接口实例到 modport
限制 端口或变量进行接口类型分配,但是您永远不能在相反的方向(限制到不受限制)或从一种 modport 类型到另一种 modport 类型进行分配。