2013-08-27 78 views

回答

2

你不

// Interface 
interface my_if(
    input IntReg 
); 
endinterface: my_if 

// Interface bind 
bind intModule my_if my_if0(
    .IntReg(IntReg) 
); 

然后像这样访问寄存器不需要使用bind

module DUT; 
bit clk; 
initial begin 
    repeat (5) begin 
     #5 clk = 0; 
     #5 clk = 1; 
    end 
end 

always @(posedge clk) begin 
    $display ("[Time %0t ps] IntReg value = %x", $time, DUT.IntModule.IntReg); 
end 

IntModule IntModule(); 
endmodule 

module IntModule; 
    reg IntReg = 1; 
endmodule 

/* 
[Time 10 ps] IntReg value = 1 
[Time 20 ps] IntReg value = 1 
[Time 30 ps] IntReg value = 1 
[Time 40 ps] IntReg value = 1 
[Time 50 ps] IntReg value = 1 
*/ 
2

是的,你可以使用interfacebind:与EDA游乐场SIM结果

virtual my_if _if = top.DUT.IntModule.my_if0; 
$display ("[Time %0t ps] IntReg value = %x", 
    $time, _if.IntReg); 

完整的示例:http://www.edaplayground.com/s/4/115