|
发表于 2019-10-29 14:21:41
|
显示全部楼层
不能用force, 试试下面的例子
interface dut_if(input logic clk);
parameter hold_time =3; // 3ns
parameter setup_time = 5;
wire[31:0] data;
logic[31:0] address;
logic rd, wr;
clocking driver_cb @(posedge clk);
default input #setup_time output #hold_time;
output address;
output rd, wr;
inout data;
endclocking
modport dut_mp(inout data, input clk, rd, wr, address);
modport driver_mp(clocking driver_cb);
endinterface : dut_if
class driver;
virtual interface dut_if.driver_mp v_if;
transaction tx =new();
// driver
task automatic drive();
if(!randomize(tx)) $error("randomization failure");
@ (v_if.driver_cb) begin
if(!randomize(tx)) $error("randomization failure");
v_if.driver_cb.rd <= tx.rd;
v_if.driver_cb.wr <= tx.wr;
v_if.driver_cb.address <= tx.address;
if(tx.wr) v_if.driver_cb.data <= tx.data_dr;
else v_if.driver_cb.data <= 'hZ;
end
endtask : drive
endclass : driver |
|