-
Notifications
You must be signed in to change notification settings - Fork 5
/
driver.sv
59 lines (50 loc) · 1.87 KB
/
driver.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import uvm_pkg::*;
`include "uvm_macros.svh"
// ----DRIVER----
class fifo_driver extends uvm_driver #(data_item)
`uvm_component_utils(fifo_driver)
virtual fifo_if fifo_driver_vif;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction: new
function void build_phase(uvm_phase phase);
super.build(phase);
if (!uvm_config_db#(virtual fifo_if)::get(this, "", "fifo_if", fifo_driver_vif))
`uvm_fatal("NO_VIF", {"Must set virtual interface for: ", get_full_name(), ".fifo_driver_vif"})
`uvm_info(get_full_name(), "Build stage done ", UVM_LOW)
endfunction
virtual task run_phase(uvm_phase phase);
fork
check_reset();
driver_to_dut();
join
endtask: run_phase
virtual task check_reset();
forever begin
@(negedge fifo_driver_vif.rst_n);
`uvm_info(get_type_name(), "Resetting signals ", UVM_LOW)
fifo_driver_vif.read_en <= 1'b0;
fifo_driver_vif.write_en <= 1'b0;
fifo_driver_vif.data_in <= 32'b0;
fifo_driver_vif.data_out <= 32'b0;
end
endtask: check_reset
virtual task driver_to_dut(data_item pkt);
forever begin
while (!fifo_driver_vif.rst) begin
seq_item_port.get_next_item(req);
fifo_driver_vif.write_en <= 1'b0;
fifo_driver_vif.read_en <= 1'b0;
repeat(pkt.delay) @(posedge fifo_driver_vif.clk)
fifo_driver_vif.read_en <= pkt.read_en;
fifo_driver_vif.write_en <= pkt.write_en;
fifo_driver_vif.data_in <= pkt.data_in;
fifo_driver_vif.data_out <= pkt.data_out;
@(posedge fifo_driver_vif.clk)
fifo_driver_vif.write_en <= 1'b0;
fifo_driver_vif.read_en <= 1'b0;
seq_item_port.item_done();
end
end
endtask: driver_to_dut
endclass: fifo_driver