-
Notifications
You must be signed in to change notification settings - Fork 2
/
driver_rb.sv
61 lines (51 loc) · 1.8 KB
/
driver_rb.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
60
61
typedef virtual interface_rb.mst rb_vif;
class driver_rb extends uvm_driver #(transaction_rb);
`uvm_component_utils(driver_rb)
rb_vif vif;
event begin_record, end_record;
transaction_rb tr;
bit item_done;
function new(string name = "driver_rb", uvm_component parent = null);
super.new(name, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(rb_vif)::get(this, "", "vif", vif)) begin
`uvm_fatal("NOVIF", "failed to get virtual interface")
end
endfunction
task run_phase (uvm_phase phase);
forever begin
@(posedge vif.clk) begin
item_done = 1'b0;
vif.valid_i = 1'b0;
if(vif.rst) begin
repeat(10) @(posedge vif.clk);
end
if(!vif.rst) begin
vif.data_i <= '0;
vif.addr <= '0;
vif.valid_i <= '0;
item_done = 0;
end
else begin
if(tr)begin
$display("data_i = ",tr.data_i);
$display("addr = ",tr.addr);
vif.data_i <= tr.data_i;
vif.addr <= tr.addr;
vif.valid_i <= 1'b1;
item_done = 1;
end
end
if (item_done) begin
`uvm_info("ITEM_DONE", $sformatf("Item done."), UVM_HIGH);
seq_item_port.item_done();
end
if ((item_done || !tr) && vif.rst) begin
seq_item_port.try_next_item(tr);
end
end
end
endtask
endclass