Configuring Your Resources The UVM Way!
Configuring Your Resources The UVM Way!
Configuring Your Resources The UVM Way!
uvm_resource_db#(type)::read_by_name(scope,
key, type_var, accessor);
uvm_resource_db#(type)::read_by_type(scope,
type_field, accessor);
uvm_resource_db#(int)::set(top.env*,A,",12
34,this);
Using uvm_config_db:
The above code ensures that the setting of the value Here, we look at the common verification challenges and see
happens in the monitor instance path only. The how the UVM configuration mechanism help us address
uvm_config_db #(bit)::get() call can be avoided if the field some of them.
automation macros are used in the UVM component instance
as shown below: 3.1 Propagating Virtual Interfaces
`uvm_field_int(check_en, UVM_PRINT| The Resource Database works with all SystemVerilog data
UVM_COPY); types. One ubiquitous requirement across all verification
environments is to have a mechanism which enables passing
The uvm_component, which in this case is the Monitor class the virtual interfaces easily across different verification
should be instantiated in the component hierarchy and that components. It is important to avoid using cross-module
super.build_phase() or apply_config_settings() should be references (XMRs) in environments as it makes it impossible
called in the component's build_phase(). In this case, the to put them in packages and thus compile them separately. It
get call is implicitly invoked. However, the also makes the environment inherently non-reusable.
recommendation is not to rely on the field automation
macros, and invoke an explicit uvm_config_db::get(). This Thus, a better approach is to "push" the virtual interface into
enables better type checking and traceability through the the Configuration Database from the top-level module. That
issuing of a warning/error message on an unsuccessful get). top-level module is specific to the environment used to verify
the DUT. It is thus perfectly acceptable to specify
2.2.2 Propagating the Configuration Object Across environment-specific hierarchical names in that module.
the Testbench Hierarchy Since the module is not an uvm_component, "null" is
specified as the context argument and the absolute
To set the configuration object across the hierarchy, see Figure 5. hierarchical name is specified for the agent where the virtual
interface is assigned. As the environment is usually
instantiated by the test, the absolute hierarchical name will
start with "uvm_test_top.".
Here, irrespective of whether the field automation macros are Figure 7: Propagating Virtual Interfaces using UVM Resources
used or not, an explicit get() for the class object in the driver
Agents should extract their virtual interfaces from the that a right set of sequences are executed in different phases.
Configuration Database entry named "vif" during Also, this allows the UVM components themselves to be
the build phase. A fatal error should be issued if no virtual generic in nature which makes them reusable easily across a
interface is retrieved. The agents are then responsible for wider range of requirements.
propagating that virtual interface to the drivers and monitors To execute a sequence in a specific phase in UVM, one
it encapsulates. needs to override the default_sequence string for a specific
. sequencer for that phase. The easiest mechanism is to use the
Resource Database to override the default_sequence string
from the test case or in the environment.
uvm_config_db
#(uvm_object_wrapper)::set(this,
<path_to_sequencer>.main_phase,
default_sequence,
sequence_name>::type_id::get());
The m_sequencer handle is no longer required if global Configuration Parameters: The Command Line Processor
configuration is desired. This can then be achieved through class provides a general interface to the command line
uvm_resource_db. arguments that are provided for the given simulation. The
uvm_cmdline_processor class also provides support for
uvm_resource_db#(int)::read_by_name("SEQ_CNTR setting various UVM variables from the command line, such
L", "item_count", item_count); as components verbosities and configuration settings for
integral types and strings. As far as overriding configurations
The item_count value for the resource then can be set in the settings are concerned, the command line option can only be
testcase as: used for setting the integer/string only in a class derived from
uvm_component. The control of the testbench configuration
uvm_resource_db#(int)::set("SEQ_CNTRL", of the scalar types through command line can be done as
"item_count", 10);
follows:
This essentially allows the sequences to reconfigure +uvm_set_config_int=<comp>,<field>,<value>
themselves based on the scenarios at any point in time. For +uvm_set_config_string=<comp>,<field>,<value>
example, a sequence can retrieve the memory allocation
patterns from the Register Model, and target the next set of An example of the same would be :
accesses in the un-allocated regions. The sequences +uvm_set_config_int=uvm_test_top.*.drv,delay,
themselves become more reusable from a vertical reuse 10
perspective as they reconfigure themselves based on newer
constraints applied in the configuration space. It has to be ensured that the user must register the field which
would be overridden using the field automation macros.
With the new run time phases in the UVM domain, There should not be any white spaces between the strings
sequences can be made to run in different phases. This gives passed to the command line argument. This can be very
a lot of granularity in terms of stimulus control and ensuring easily extended to the sequence or sequence library specific
parameters which can thus end up saving a lot of simulation uvm_config_db#::get(). If the return value denotes a
cycles. In this case, the user has to explicitly do a get in the successful retrieval, the rand_mode() of that specific
respective sequences as shown below. parameter can be turned to 0, so that the variable no longer
participates in the randomization.
if(uvm_resource_db#int)::read_by_name("*",
A,value,this))
A.rand_mode(0);
Subsequently, the following command line will change the Coverage Convergence:
total number of sequences executed for a specific sequence The SystemVerilog language provides capabilities to query
library to be 25 instead of the default 10. the functional coverage results on the fly. An intelligent
reactive testbench can thus use this information obtained
+uvm_set_config_int=uvm_test_top.tb.sequencer through constructs like get_coverage() to change its
,default_sequence.max_random_count,25 stimulus. Thus, without quitting simulation, the testbench in
an automated way identifies holes that it needs to target and
Thus, for specific values which are used as knobs and other changes the constrained random stimulus accordingly. One
discrete configuration parameters, additional tests do not of the pre-requisites to achieve this is to create your
have to be written. Different permutations can be tried out constraints in a way that it can also be modified during
from the command line without requiring any recompiles. simulation. This is made possible if variables are used to
Debug modes can also be enabled through the same model the testbench constraints. Thus by dynamically
mechanism. changing the value of the variables during simulation, the
overall stimulus sample space can be expanded or shrunk.
Factory Overrides from the command line: The changes that Thus, an intelligent reactive testbench can help raise the
can be propagated from the command line extends to factory productivity, by helping the user to cut down on the number
overrides as well. The testbench objects which are registered of tests to reach his or her coverage goals.
with the UVM factory can be overridden globally or in a
given hierarchy specified by an instance path in the The coverage model itself can be set in the Configuration
command line. Database. It can be retrieved easily in the sequences through
the Resource Mechanism, queried and based on the coverage
+uvm_set_inst_override=<req_type>,<override_t query results, the generation of the subsequent sequence
ype>,<inst_path> items can be biased by modifying specific constraint
+uvm_set_type_override=<req_type>,<override_t
ype>
variables as well as testbench parameters across the
environment [4].This can be done by biasing the weights on
An example of the above overrides would be : a randsequence branch, or by changing the distributions
modeled through variables.
+uvm_set_inst_override=driver,NewDriver,*.drv
0 Covergroup manipulation:
+uvm_set_type_override=packet,newPacket The enabling or disabling a covergroup can be controlled
through the UVM Resource mechanism. The coverage
attributes like weight, at_least, coverpoint ranges can be
3.3.2 Randomization Control and Performance changed as well.
The RTL Configuration class itself can be registered to the Figure 17: Loading the Randomized RTL Configuration
Configuration Database. It can be retrieved in the Testbench
Configuration class which can then subsequently set In projects where highly configurable IP has to be verified, it
testbench parameters. The additional methods to load or store is convenient to control and observe the progress of
the RTL configuration from an external file can be provided. verification across, not only the modes of operation, but also
This configuration object is then instantiated in the UVM those modes relating to specific RTL configurations. The
environment as shown in Figure 15. added benefit of using this method is that constrained
randomization and functional coverage collection can be now
be used for RTL configurations.
3.4.2 Leveraging Dynamic Reconfiguration The following APIs helps to ensure that different
components can reconfigure themselves at any time when
As designs grow in size, memory size and simulation speed there is a relevant change in any of the attributes registered in
are becoming critical issues for many customers. It is the Configuration Database.
becoming increasingly difficult to accommodate large
designs in 32-bit memory. Although the entire design may wait_modified: Waits for a configuration setting to be
need a 64-bit for simulation, only a portion of the design may set for a testbench attribute in a specific context and for
be necessary to run many tests. The simulation speed can be a specific instance name.
improved by removing or replacing part of the design exists: Checks if a value for a specific testbench
hierarchy with alternate models. The removing portions of attribute is available in an instance with a specific
the hierarchy by replacing modules with empty modules, context as a starting point.
simpler modules or higher-level models allows the design
size to be reduced, resulting in decreased memory
As described earlier, the UVM sequences would look up the
requirements. This has the additional benefit of faster
Resource Database to generate appropriate stimulus based on
simulation due to the pruned design size.
the current configuration. They can be reactive when the
The Dynamic Reconfiguration provides a flexible
need arises. The coverage model would sample the
mechanism to replace portions of the design hierarchy at
appropriate cover bins, the scoreboard and protocol checkers
runtime. This enables many design configurations to be used
would verify and validate the traffic based on the dynamic
without the need to re-compile the design.
parameters. With all the components feeding in relevant
statistics back to the resource manager, different
performance metrics at the system level can be assessed and
improved upon. Thus, a significantly smaller yet
configurable verification setup can target a bigger chunk of
DUT functionality and avoid wasteful debug cycles to rule
out false negatives.
Figure 18: Reconfiguring Design Hierarchy 4. DEBUG Infrastructure for UVM Resources
This requires passing in a configuration file at compile time There is a lot of functionality and convenience that the UVM
specifying all the instances that can be substituted or black Resources provides. Along with the functionality, it is
boxed with empty shells. At run time, one or more important that appropriate debug hooks are provided so that
configuration file gets passed to the executable which the user can easily decipher any unexpected behavior is seen
specifies the actual instance hierarchies for that simulation. in the Testbench.
As in the case of modeling RTL configurations, a similar file
dumped out from the first parse can generate the appropriate UVM Configuration debug APIs enables the recording of all
configuration file which can be used for stubbing out reads and writes done to the Database. It stores information
specific hierarchies at runtime. This ensures that the about the accesses. It records the number of times a resource
testbench is aware of the changed hierarchy. Additionally, all is read or written at what times from which hierarchical
different permutations and combinations of the actual RTL component. A mechanism to turn off recording is provided
instances can be tracked in the testbench. as simulation performance can be affected because of the
same. Based on the information analyzed from the resource
3.5 Effective Resource Management (Bringing it All dump, one can improvise on the usage of UVM
Together) configuration APIs and use them more optimally
For System Level verification, the complexities and the Figure 19 shows the hierarchy of functions that are used in
permutations of functionalities that have to be verified debugging UVM Resources. The user is not expected to
increases manifold. Some of these include: invoke all of these and the pictorial representation basically
Exercising modes of the peripherals with all the illustrates the internal debug process. Invoking the dump()
possible modes of system configuration function of the uvm_resource_db triggers the entire process
provided the user has set the auditing parameter as arguments
Bandwidth issues in the system when multiple
when invoking the Resource APIs.
peripheral devices contest for system resources
IRQ Handling
Power Modes and how that affects different
components
Memory Allocation Management
10. REFERENCES
[1] UVM User Guide
[2] UVM Reference Manual
[3] Accellera Verification IP Technical Subcommittee
Documents
http://www.accellera.org/apps/org/workgroup/vip
[3] UVM World Website http://www.uvmworld.org/
[4] A Practical Look @ SystemVerilog Coverage
Tips, Tricks, and Gotchas, Doug Smith, John Ansley
[5] Synopsys UVM CES Training
[6] http://www.vmmcentral.org/vmartialarts
[7] Advanced Testbench Conguration with Resources,
Mark Glasser, Mohamed Elmalaki