In reply to cooltoad:
Below is a link that I once used in a training class. I’ll emphasize certain points below.
I see this approach as a good way to drive interface signals.
http://systemverilog.us/vf/test_if_class.sv
interface dut_if(input logic clk); // DO NOT USE!!!!!
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);
ap_rdwr: assert property(@ (driver_cb)
not(rd && wr));
ap_addr_not0: assume property(@(driver_cb) $time> 20ns |-> address != 'h0);
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
Notice the 3 ns delays in the outputs.
http://systemverilog.us/vf/noforce.png
// ***** On the force, I tried
task automatic drive();
if(!randomize(tx)) $error("randomization failure");
@ (v_if.driver_cb) begin
if(!randomize(tx)) $error("randomization failure");
...
if(tx.wr)
//v_if.driver_cb.data <= tx.data_dr;
force v_if.driver_cb.data = tx.data_dr;
else v_if.driver_cb.data <= 'hZ;
end
endtask : drive
// **** ERROR MESSAGE
Variables accessed through virtual interface cannot be used in continuous assignments.
Thus, go over my example and see if that works for you. I feel it is a better and cleaner approach, and more a la UVM.
Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr
- SVA Handbook 4th Edition, 2016 ISBN 978-1518681448
- A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
- Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
- Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 978-1539769712
- Component Design by Example ", 2001 ISBN 0-9705394-0-1
- VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
- VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115