我能用嵌套接口代替modport吗?
这样做的目的是在利用接口简化连接的同时实现许多不同模块的大规模互连。我不喜欢使用泛型接口--它们在源代码中很难理解。
如果我有一个被许多模块使用的通用模块(例如,reset_synchronizer),那么我可以在每个接口中定义一个modport来定义该模块的信号,例如:
interface xyz(input clk, input arst);
logic srst;
modport reset_synchronizer_mp (input clk, input arst, output srst);
endinterface
我可以在需要同步重置的每个接口中定义它。但是,当我需要更改reset_synchronizer模块时,可能需要传递一个enable,我需要更新接口端口(添加enable信号),并更新为reset_synchronizer创建modport的所有接口中的每个modport。
interface xyz(input clk, input enable, input arst);
logic srst;
modport reset_synchronizer_mp (input clk, input enable, input arst, output srst);
endinterface
如果我不使用modport,而是使用嵌套接口(reset_synchronizer_intf),那么我不能只在主接口中执行此操作:
interface xyz(input clk, input arst);
logic srst;
reset_synchronizer_intf reset_synchronizer_mp (clk, arst, srst);
endinterface
为了简化这一过程(假设信号名称匹配):
interface xyz(input clk, input arst);
logic srst
reset_synchronizer_intf reset_synchronizer_mp (.*);
endinterface
为了添加enable,我只需要更新主reset_synchronizer.sv (定义模块和接口的地方),并更新所有接口,但只在端口列表或信号声明中更新:
interface xyz(input clk, input enable, input arst);
reset_synchronizer_intf reset_synchronizer_mp (.*);
endinterface
当我正在寻找的信号存在于主界面中时,这就变得更有吸引力了,但我现在想将它们引入到一些通用模块中。例如,一个通常只有srst的电源选通模块,但现在我也想通过rst。我可以在电源门控模块的接口级进行更改,而不是在每个接口内部进行更改。
发布于 2018-04-12 01:30:45
这也意味着在连接到接口xyz时需要知道嵌套。
module top;
xyx xyz_if(.*)
mymodule inst(xyx_if);
endmodule
module mymodule (xyz xyz_p);
...
xyz.reset_synchronizer_mp.enable = 1;
endmodule
这很可能是不可合成的。
https://stackoverflow.com/questions/49780722
复制相似问题