-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapb_monitor.sv
More file actions
56 lines (45 loc) · 1.7 KB
/
Copy pathapb_monitor.sv
File metadata and controls
56 lines (45 loc) · 1.7 KB
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
class apb_monitor extends uvm_monitor;
`uvm_component_utils(apb_monitor)
function new(string name = "apb_monitor" , uvm_component parent = null);
super.new(name , parent);
endfunction
virtual apb_interface vif;// virtual interface handle
uvm_analysis_port #(apb_item) apb_mon_analysis_port;// analysis port for broadcasting packets
apb_item pkt;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
pkt = apb_item::type_id::create("pkt");
apb_mon_analysis_port = new("apb_mon_analysis_port" , this);
if(!uvm_config_db#(virtual apb_interface)::get(this , "" , "apb_vif" , vif)) begin
`uvm_error(get_type_name(), "Failed to get virtual interface");
end
else begin
`uvm_info(get_type_name(), "Virtual interface recieved successfully", UVM_HIGH);
end
endfunction
virtual task main_phase(uvm_phase phase);
`uvm_info(get_type_name() , "Starting Main phase" , UVM_MEDIUM)
forever begin
sample_apb();
end
`uvm_info(get_type_name() , "Ending Main phase" , UVM_MEDIUM)
endtask
// sampling logic for APB
task sample_apb();
@(posedge vif.clk iff vif.resetn);
if(vif.PSELx && vif.PENABLE && vif.PREADY) begin
pkt.PADDR = vif.PADDR;
pkt.PSELx = vif.PSELx;
pkt.PENABLE = vif.PENABLE;
pkt.PWRITE = vif.PWRITE;
pkt.PWDATA = vif.PWDATA;
pkt.PSTRB = vif.PSTRB;
pkt.PREADY = vif.PREADY;
pkt.PRDATA = vif.PRDATA;
pkt.PSLVERR = vif.PSLVERR;
pkt.print_apb_mst("APB_MONITOR" , UVM_MEDIUM);
pkt.print_apb_slv("APB_MONITOR" , UVM_MEDIUM);
apb_mon_analysis_port.write(pkt);
end
endtask
endclass