-
Notifications
You must be signed in to change notification settings - Fork 1
/
monitor.sv
57 lines (50 loc) · 1.79 KB
/
monitor.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
class monitor extends uvm_monitor;
interface_vif vif;
event begin_record, end_record;
transaction_in tr_in;
transaction_out tr_out;
uvm_analysis_port #(transaction_in) req_port;
uvm_analysis_port #(transaction_out) resp_port;
`uvm_component_utils(monitor)
function new(string name, uvm_component parent);
super.new(name, parent);
req_port = new ("req_port", this);
resp_port = new ("resp_port", this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(interface_vif)::get(this, "", "vif", vif)) begin
`uvm_fatal("NOVIF", "failed to get virtual interface")
end
tr_in = transaction_in::type_id::create("tr_in", this);
tr_out = transaction_out::type_id::create("tr_out", this);
endfunction
virtual task run_phase(uvm_phase phase);
super.run_phase(phase);
fork
collect_transactions(phase);
join
endtask
virtual task collect_transactions(uvm_phase phase);
forever begin
@(posedge vif.clk) begin
if(!vif.busy_o) begin
@(posedge vif.busy_o);
begin_tr(tr_in, "req");
tr_in.data = vif.dt_i;
req_port.write(tr_in);
@(negedge vif.clk);
end_tr(tr_in);
end
else if(vif.busy_o)begin
@(negedge vif.busy_o);
begin_tr(tr_out, "resp");
tr_out.result = vif.dt_o;
resp_port.write(tr_out);
@(negedge vif.clk);
end_tr(tr_out);
end
end
end
endtask
endclass