APB UVM Agent  0.0.1
apb_monitor.svh
Go to the documentation of this file.
1 //------------------------------------------------------------
2 // Copyright 2010 Mentor Graphics Corporation
3 // All Rights Reserved Worldwide
4 //
5 // Licensed under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in
7 // compliance with the License. You may obtain a copy of
8 // the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in
13 // writing, software distributed under the License is
14 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15 // CONDITIONS OF ANY KIND, either express or implied. See
16 // the License for the specific language governing
17 // permissions and limitations under the License.
18 //------------------------------------------------------------
19 
20 /**
21 * Implements an APB bus transaction monitor.
22 *
23 * The monitor can snoop transactions for a single slave (i.e. single PSEL) at
24 * a time. Observed transactions are passed to subscribers through an analysis
25 * port.
26 *
27 * The monitor transacrion type, apb_seq_item, is shared with the apb_driver
28 * implementation.
29 *
30 * Normally the APB monitor is a part of an APB agent.
31 */
32 class apb_monitor extends uvm_component;
33 
34 // UVM Factory Registration Macro
35 //
36 `uvm_component_utils(apb_monitor);
37 
38 //! Reference to the APB bus interface
39 virtual apb_if APB;
40 
41 //------------------------------------------
42 // Data Members
43 //------------------------------------------
44 //! Identifies which PSEL line is this monitor connected to.
45 int apb_index = 0;
46 //------------------------------------------
47 // Component Members
48 //------------------------------------------
49 //! Analysis port through which to broadcast observed APB transactions.
50 uvm_analysis_port #(apb_seq_item) ap;
51 
52 //------------------------------------------
53 // Methods
54 //------------------------------------------
55 
56 // Standard UVM Methods:
57 
58 /**
59 * Conventional UVM component constructor.
60 */
61 extern function new(string name = "apb_monitor", uvm_component parent = null);
62 /**
63 * Instantiates the analysis port.
64 */
65 extern function void build_phase(uvm_phase phase);
66 /**
67 * Forks off a forever loop that monitors APB transactions for slave selected
68 * by ::apb_index.
69 */
70 extern task run_phase(uvm_phase phase);
71 /**
72 * Presently a stub function.
73 */
74 extern function void report_phase(uvm_phase phase);
75 
76 endclass: apb_monitor
77 
78 function apb_monitor::new(string name = "apb_monitor", uvm_component parent = null);
79  super.new(name, parent);
80 endfunction
81 
82 function void apb_monitor::build_phase(uvm_phase phase);
83  ap = new("ap", this);
84 endfunction: build_phase
85 
86 task apb_monitor::run_phase(uvm_phase phase);
87  apb_seq_item item;
88  apb_seq_item cloned_item;
89 
90  item = apb_seq_item::type_id::create("item");
91 
92  forever begin
93  // Detect the protocol event on the TBAI virtual interface
94  @(posedge APB.PCLK);
95  if(APB.PREADY && APB.PSEL[apb_index])
96  // Assign the relevant values to the analysis item fields
97  begin
98  item.addr = APB.PADDR;
99  item.we = APB.PWRITE;
100  if(APB.PWRITE)
101  begin
102  item.data = APB.PWDATA;
103  end
104  else
105  begin
106  item.data = APB.PRDATA;
107  end
108  // Clone and publish the cloned item to the subscribers
109  $cast(cloned_item, item.clone());
110  ap.write(cloned_item);
111  end
112  end
113 endtask: run_phase
114 
115 function void apb_monitor::report_phase(uvm_phase phase);
116 // Might be a good place to do some reporting on no of analysis transactions sent etc
117 
118 endfunction: report_phase
Implements an APB bus transaction monitor.
Definition: apb_monitor.svh:32
task run_phase(uvm_phase phase)
Forks off a forever loop that monitors APB transactions for slave selected by ::apb_index.
Definition: apb_monitor.svh:86
Base APB transaction.
void report_phase(uvm_phase phase)
Presently a stub function.
void build_phase(uvm_phase phase)
Instantiates the analysis port.
Definition: apb_monitor.svh:82
new(string name="apb_monitor", uvm_component parent=null)
Conventional UVM component constructor.
Definition: apb_monitor.svh:78
int apb_index
Identifies which PSEL line is this monitor connected to.
Definition: apb_monitor.svh:45
interface apb_if(input PCLK, input PRESETn)
APB bus interface with very simple property checking.
Definition: apb_if.sv:4
virtual apb_if APB
Reference to the APB bus interface.
Definition: apb_monitor.svh:39
uvm_analysis_port< apb_seq_item > ap
Analysis port through which to broadcast observed APB transactions.
Definition: apb_monitor.svh:50
uvm_component_utils(apb_monitor)