module top;
bit clk;
always #5 clk = ~clk;
arb_if arbif(clk); //例化一个接口,将时钟传入
arb a1 (arbif); //例化一个设计模块,接口作为参数传入
test t1 (arbif); //例化一个测试模块,接口作为参数传入
endmodule : top
//接口的定义
interface arb_if(input bit clk);
logic [1:0] grant,request;
logic rst;
endinterface
//设计模块
module arb(arb_if arbif); //module中的interface不需要声明方向
...
always @(posedge arbif.clk or pasedge arbif.rst) begin
if (arbif.rst) //索引interface信号
arbif.grant <= 2'b00;
else
arbif.grant <= next_grant;
....
end
endmodule
//测试模块
module test(arb_if arbif);
...
initial begin
//复位
Systemverilog(绿皮书)第四章——连接设计(一)接口
最新推荐文章于 2022-10-20 21:23:04 发布