-
Notifications
You must be signed in to change notification settings - Fork 16
/
monitor.sv
54 lines (46 loc) · 1.43 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
class monitor extends uvm_monitor;
input_vif vif;
event begin_record, end_record;
packet_in tr;
uvm_analysis_port #(packet_in) item_collected_port;
`uvm_component_utils(monitor)
function new(string name, uvm_component parent);
super.new(name, parent);
item_collected_port = new ("item_collected_port", this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
assert(uvm_config_db#(input_vif)::get(this, "", "vif", vif));
tr = packet_in::type_id::create("tr", this);
endfunction
virtual task run_phase(uvm_phase phase);
super.run_phase(phase);
fork
collect_transactions(phase);
record_tr();
join
endtask
virtual task collect_transactions(uvm_phase phase);
wait(vif.rst === 1);
@(negedge vif.rst);
forever begin
do begin
@(posedge vif.clk);
end while (vif.valid === 0 || vif.ready === 0);
-> begin_record;
tr.A = vif.A;
tr.B = vif.B;
item_collected_port.write(tr);
@(posedge vif.clk);
-> end_record;
end
endtask
virtual task record_tr();
forever begin
@(begin_record);
begin_tr(tr, "monitor");
@(end_record);
end_tr(tr);
end
endtask
endclass