APB UVM Agent  0.0.1
apb_agent.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 the UVC Agent component for Amba Peripheral Bus (APB).
22 *
23 * The implementation comes from the Verification Cookbook at the Verification
24 * Academy site (https://verificationacademy.com/). It follows the conventional
25 * UVC agent structure.
26 *
27 * The agent consists of the following parts: Driver, monitor, sequencer and
28 * a coverage collection class. The agent is configured through a specific
29 * configuration object. The agent exports its monitor's analysis port.
30 */
31 class apb_agent extends uvm_component;
32 
33 // UVM Factory Registration Macro
34 //
35 `uvm_component_utils(apb_agent)
36 
37 //------------------------------------------
38 // Data Members
39 //------------------------------------------
40 //! Agent configuration. It will be obtained from the UVM Configuration DB during
41 //! the build phase, under the keyword `apb_agent_config`.
42 apb_agent_config m_cfg;
43 //------------------------------------------
44 // Component Members
45 //------------------------------------------
46 //! Analysis port exported from the agent's monitor component.
47 uvm_analysis_port #(apb_seq_item) ap;
48 //! An instance of the APB monitor. This component is always present (i.e. even
49 //! in the passive mode).
51 //! An instance of the APB sequencer. It is present only in the active mode.
53 //! An instance of the APB driver. It is present only in the active mode.
55 //! An instance collecting functional coverage. It is present only if the agent
56 //! was configured with enabled coverage collection.
58 //------------------------------------------
59 // Methods
60 //------------------------------------------
61 
62 // Standard UVM Methods:
63 
64 /**
65 * Implements the default UVM component constructor.
66 */
67 extern function new(
68  //! Name of the agent component. This name will be associated with the agent
69  //! instance and may be used for looking up the instance in the UVM Config DB.
70  string name = "apb_agent",
71  //! Reference to a parent component, which the agent instance will be a part of.
72  uvm_component parent = null
73 );
74 
75 /**
76 * Builds individual components based on configured agent's settings.
77 */
78 extern function void build_phase(
79  //! Reference to the build phase instance.
80  uvm_phase phase
81 );
82 
83 /**
84 * Connects all the components that have been created suring the build phase.
85 */
86 extern function void connect_phase(
87  //! Reference to the connect phase instance.
88  uvm_phase phase
89 );
90 
91 endclass: apb_agent
92 
93 
94 function apb_agent::new(string name = "apb_agent", uvm_component parent = null);
95  super.new(name, parent);
96 endfunction
97 
98 function void apb_agent::build_phase(uvm_phase phase);
99  if(!uvm_config_db #(apb_agent_config)::get(this, "", "apb_agent_config", m_cfg)) begin
100  `uvm_error("build_phase", "APB agent config not found")
101  end
102  // Monitor is always present
103  m_monitor = apb_monitor::type_id::create("m_monitor", this);
104  // Only build the driver and sequencer if active
105  if(m_cfg.active == UVM_ACTIVE) begin
106  m_driver = apb_driver::type_id::create("m_driver", this);
107  m_sequencer = apb_sequencer::type_id::create("m_sequencer", this);
108  end
109  if(m_cfg.has_functional_coverage) begin
110  m_fcov_monitor = apb_coverage_monitor::type_id::create("m_fcov_monitor", this);
111  end
112 endfunction: build_phase
113 
114 function void apb_agent::connect_phase(uvm_phase phase);
115  m_monitor.APB = m_cfg.APB;
116  m_monitor.apb_index = m_cfg.apb_index;
117  ap = m_monitor.ap;
118  // Only connect the driver and the sequencer if active
119  if(m_cfg.active == UVM_ACTIVE) begin
120  m_driver.seq_item_port.connect(m_sequencer.seq_item_export);
121  m_driver.APB = m_cfg.APB;
122  end
123  if(m_cfg.has_functional_coverage) begin
124  m_monitor.ap.connect(m_fcov_monitor.analysis_export);
125  end
126 
127 endfunction: connect_phase
Implements an APB bus transaction monitor.
Definition: apb_monitor.svh:32
Encapsulates APB agent configuration settings.
apb_driver m_driver
An instance of the APB driver. It is present only in the active mode.
Definition: apb_agent.svh:54
new(string name="apb_agent", uvm_component parent=null)
Implements the default UVM component constructor.
Definition: apb_agent.svh:94
Sequencer specialization for use with apb_driver.
apb_coverage_monitor m_fcov_monitor
An instance collecting functional coverage.
Definition: apb_agent.svh:57
uvm_component_utils(apb_agent) apb_agent_config m_cfg
Agent configuration.
void build_phase(uvm_phase phase)
Builds individual components based on configured agent's settings.
Definition: apb_agent.svh:98
Implements the UVC Agent component for Amba Peripheral Bus (APB).
Definition: apb_agent.svh:31
uvm_analysis_port< apb_seq_item > ap
Analysis port exported from the agent&#39;s monitor component.
Definition: apb_agent.svh:47
void connect_phase(uvm_phase phase)
Connects all the components that have been created suring the build phase.
Definition: apb_agent.svh:114
Collects basic functional coverage information observed by an APB agent.
apb_monitor m_monitor
An instance of the APB monitor.
Definition: apb_agent.svh:50
apb_sequencer m_sequencer
An instance of the APB sequencer. It is present only in the active mode.
Definition: apb_agent.svh:52
Implements an APB bus master acting as the driver of an APB agent.
Definition: apb_driver.svh:37