Vcs
Vcs
Version E-2011.03
March 2011
Comments?
E-mail your comments about this manual to:
[email protected].
Disclaimer
SYNOPSYS, INC., AND ITS LICENSORS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH
REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Registered Trademarks ()
Synopsys, AEON, AMPS, Astro, Behavior Extracting Synthesis Technology, Cadabra, CATS, Certify, CHIPit, CoMET,
Confirma, CODE V, Design Compiler, DesignWare, EMBED-IT!, Formality, Galaxy Custom Designer, Global Synthesis,
HAPS, HapsTrak, HDL Analyst, HSIM, HSPICE, Identify, Leda, LightTools, MAST, METeor, ModelTools, NanoSim,
NOVeA, OpenVera, ORA, PathMill, Physical Compiler, PrimeTime, SCOPE, Simply Better Results, SiVL, SNUG,
SolvNet, Sonic Focus, STAR Memory System, Syndicated, Synplicity, the Synplicity logo, Synplify, Synplify Pro,
Synthesis Constraints Optimization Environment, TetraMAX, UMRBus, VCS, Vera, and YIELDirector are registered
trademarks of Synopsys, Inc.
Trademarks ()
AFGen, Apollo, ARC, ASAP, Astro-Rail, Astro-Xtalk, Aurora, AvanWaves, BEST, Columbia, Columbia-CE, Cosmos,
CosmosLE, CosmosScope, CRITIC, CustomExplorer, CustomSim, DC Expert, DC Professional, DC Ultra, Design
Analyzer, Design Vision, DesignerHDL, DesignPower, DFTMAX, Direct Silicon Access, Discovery, Eclypse, Encore,
EPIC, Galaxy, HANEX, HDL Compiler, Hercules, Hierarchical Optimization Technology, High-performance ASIC
Prototyping System, HSIMplus, i-Virtual Stepper, IICE, in-Sync, iN-Tandem, Intelli, Jupiter, Jupiter-DP, JupiterXT,
JupiterXT-ASIC, Liberty, Libra-Passport, Library Compiler, Macro-PLUS, Magellan, Mars, Mars-Rail, Mars-Xtalk,
Milkyway, ModelSource, Module Compiler, MultiPoint, ORAengineering, Physical Analyst, Planet, Planet-PL, Polaris,
Power Compiler, Raphael, RippledMixer, Saturn, Scirocco, Scirocco-i, SiWare, Star-RCXT, Star-SimXT, StarRC,
System Compiler, System Designer, Taurus, TotalRecall, TSUPREM-4, VCSi, VHDL Compiler, VMC, and Worksheet
Buffer are trademarks of Synopsys, Inc.
ii
Contents
1
Introduction
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
VMM Benefits: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Ease of Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Reuse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Effectiveness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
How to Use This User Guide? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Basic Concepts of VMM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Building Blocks - Class Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
Verification Environments and Execution Control Phases. . . . . . . . . . . 1-12
Enhanced Verification Performance and Flexibility . . . . . . . . . . . . . . . . 1-14
Debug and Analysis: Message Service Class and Transaction Debug . 1-15
What's New in VMM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
UML Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Testbench Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Signal Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
Command Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15
VMM User Guide
iii
Functional Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scenario Layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Test Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sub-environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constructing and Controlling Environments . . . . . . . . . . . . . . . . . . . . . . . . . .
Quick Transaction Modeling Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Understanding Implicit and Explicit Phasing . . . . . . . . . . . . . . . . . . . . .
Composing Explicitly Phased Environments . . . . . . . . . . . . . . . . . . . . .
Composing Explicitly Phased Sub-Environments . . . . . . . . . . . . . . . . .
Composing Implicitly Phased Environments/Sub-Environments . . . . . .
Reaching Consensus for Terminating Simulation . . . . . . . . . . . . . . . . .
Architecting Verification IP (VIP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
VIP and Testbench Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transactors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Environments and Sub-Environments . . . . . . . . . . . . . . . . . . . . . . . . . .
Testing VIPs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Advanced Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mixed Phasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2-17
2-20
2-22
2-23
2-28
2-30
2-31
2-33
2-41
2-48
2-56
2-63
2-63
2-63
2-65
2-71
2-73
2-73
2-75
2-75
Modeling Transactions
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Class Properties/Data Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Quick Transaction Modeling Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Message Service in Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Randomizing Transaction Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Context References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Inheritance and OOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Handling Transaction Payloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Factory Service for Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Shorthand Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
User-Defined Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Unsupported Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
rand_mode() copy in Shorthand Macros . . . . . . . . . . . . . . . . . . . . . . . .
3-20
3-23
3-25
3-31
3-34
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Transactor Phasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
Explicit Transactor Phasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Implicit Phasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
Threads and Processes Versus Phases . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
Physical-Level Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
Transactor Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-26
Advanced Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-31
User-defined vmm_xactor Member Default Implementation . . . . . . . . . 4-31
User-Defined Implicit Phases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-32
Skipping an Implicit Phase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
Disabling an Implicit Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
Synchronizing on Implicit Phase Execution . . . . . . . . . . . . . . . . . . . . . . 4-36
Breakpoints on Implicit Phasing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
Concatenation of Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
Explicitly Phasing Timelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-42
Communication
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Channel Declaration (vmm_channel_typed) . . . . . . . . . . . . . . . . . . . . . .
Channel Declaration (vmm_channel). . . . . . . . . . . . . . . . . . . . . . . . . . . .
Connection of Channels Between Transactors . . . . . . . . . . . . . . . . . . . .
Channel Completion and Response Models . . . . . . . . . . . . . . . . . . . . . .
5-2
5-3
5-4
5-5
5-5
5-8
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
VMM User Guide
vi
Message Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simulation Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Shorthand Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Issuing Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Filtering Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Redirecting Message to File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Promotion and Demotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Message Catcher. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Message Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Stop Simulation Depending Upon Error Number . . . . . . . . . . . . . . . . . .
Class Factory Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Modeling a Transaction to be Factory Enabled . . . . . . . . . . . . . . . . . . .
Creating Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Replacing Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Factory for Parameterized Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Factory for Atomic Generators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Factory for Scenario Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Modifying a Testbench Structure Using a Factory . . . . . . . . . . . . . . . . .
Options & Configurations Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Hierarchical Options (vmm_opts). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Specifying Placeholders for Hierarchical Options . . . . . . . . . . . . . . . . .
Setting Hierarchical Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Setting Hierarchical Options on Command Line . . . . . . . . . . . . . . . . . .
Structural Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Specifying Structural Configuration Parameters in Transactors . . . . . .
Setting Structural Configuration Parameters . . . . . . . . . . . . . . . . . . . . .
Setting Options on Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . .
RTL Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Defining RTL Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . .
Using RTL Configuration in vmm_unit Extension . . . . . . . . . . . . . . . . .
7-14
7-14
7-15
7-16
7-17
7-19
7-20
7-20
7-23
7-24
7-26
7-26
7-28
7-31
7-32
7-34
7-36
7-38
7-41
7-43
7-43
7-43
7-44
7-45
7-46
7-48
7-50
7-51
7-52
7-52
7-54
7-55
7-56
7-57
7-58
7-58
7-59
Methodology Guide
Recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
Message Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Transactors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
Tests and Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5
Channels and TLM Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
Message Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
Transactors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10
Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10
Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14
Tests and Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15
10
Primers
vmm_tlm_nb_transport_fw_port#(I,D,P) . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-341
vmm_tlm_nb_transport_port#(I,D,P) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-344
vmm_tlm_port_base#(D,P) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-347
vmm_tlm_initiator_socket#(I,D,P) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-356
vmm_tlm_target_socket#(T,D,P) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-359
vmm_tlm_transport_interconnect#(DATA) . . . . . . . . . . . . . . . . . . . . . . . . . . B-363
vmm_tlm_transport_interconnect_base#(DATA,PHASE) . . . . . . . . . . . . . . B-365
vmm_tlm_reactive_if #(DATA, q_size) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-370
vmm_unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-377
vmm_version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-406
vmm_voter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-413
vmm_xactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-417
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-417
vmm_xactor_callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-477
vmm_xactor_iter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-478
Using the vmm_xactor_iter Class . . . . . . . . . . . . . . . . . . . . . . . . . . . B-479
Using the Shorthand Macro `foreach_vmm_xactor() . . . . . . . . . . . . . B-480
Release Notes
1
Introduction
Overview
UML Diagram
Resources
Overview
Winning in competitive electronic systems and computer industries
requires continuous delivery of high quality and feature-rich products
efficiently. To this end, companies constantly seek innovative ways
to improve their product development cycles.
Electronic designs have become so complex that design
development often relies on ready-made foundations of design and
verification blocks. This translates into the requirement of even more
complex verification components and environments. With an evershrinking time-to-market window, verification task has become
crucial within the complex system and chip design flow.
Companies strive to raise productivity and quality of design
verification, streamline and reduce the time it takes to functionally
validate a design before fabrication.
We see that today's chip designs require work at many levels of
abstractions - high-level abstract models, transaction-level models
and gate level netlist.
Design components in many levels of abstractions are frequently
reused and expanded. Complications in their integration - be it
internal design blocks or third party IPs, together with their
verification environments, can unexpectedly delay the development.
VMM User Guide
1-2
VMM Benefits:
By using VMM, you can take advantage of the following benefits:
- Avoid common implementation mistakes
- Set clear expectations for verification components and features
- Reduce development time, integration time, and engineers
ramp up time as a result of the known expectations
VMM guidelines help you to develop a well defined and thoughtthrough verification environment that is,
- Easy to use (modular, flexible, customizable)
- Reusable (from block level to top level; from one project to
another project)
VMM User Guide
1-4
Ease of Use
Reuse
Vertical: You can reuse the environment components from blocklevel to subsystem-level and system-level verification. This is
made possible by the sub-environment architecture, which
enables easy vertical reuse. Transactor phases can be
automatically run or called in the environment. This can be
implicitly or explicitly controlled respectively. Both explicitly and
implicitly phased sub-environments provide this vertical reuse
functionality. Implicitly phased environments simplify
incorporation of user-defined phases, addition, deletion and
reordering of phases in transactors. Multiple timelines, reuse of
verification environments and components achieve fine-grained
controllability over phasing in a sub-system.
Effectiveness
vmm_object
The vmm_object virtual base class is used as the common base
class for all VMM classes. Classes derived from vmm_object and
any VMM base class can form a searchable and named object
hierarchy.
For details, see Chapter 7, "Common Infrastructure and Services".
vmm_data
[Transactions/Data model]
`vmm_callback
Callbacks are used to incorporate new mechanisms and routines
once a verification environment and its components have been
developed. Callback routines are registered in the main routines and
executed (or called back) at certain user-defined simulation points.
The `vmm_callback macro defines a callback class that contains
methods to be executed when registered callbacks are called.
For details on callbacks, see Chapter 4, "Modeling Transactors and
Timelines".
vmm_group
The vmm_group class is extended to create sub-environment and
environments with implicit phasing. All transactors instantiated in this
environment have their phases automatically called at the
appropriate time.
For details, see Chapter 4, "Modeling Transactors and Timelines".
vmm_consensus
The vmm_consensus object offers a well-defined service for
collaboration on deciding test completion and ending simulation.
For details, see Chapter 7, "Common Infrastructure and Services".
vmm_subenv
The vmm_subenv virtual base class is extended to create explicitlyphased sub-environments. All transactors and sub-environments
instantiated in this environment must have their phase methods
explicitly called at the appropriate time.
For details on vmm_subenv, see Chapter 2, "Architecting Verification
Environments".
vmm_env
The vmm_env virtual base class is extended to create explicitlyphased environments. This class includes a set of predefined
methods that correspond to specific simulation phases. All
transactors and sub-environments instantiated in this environment
must have their phases methods explicitly called at the appropriate
time.
VMM User Guide
1-13
vmm_test
The vmm_test class is extended to implement testcases. It is where
tests add scenarios, override factories and modify connections. The
vmm_test class can be used for standalone tests or for
concatenating multiple implicitly-phased tests within a simulation run
to improve overall simulation efficiency.
For details, see Chapter 6, "Implementing Tests & Scenarios".
vmm_opts
The vmm_opts object allows to define and set configuration options.
Options can be set from the simulator command line, file or within the
code itself. These options can be set on a per-instance basis or
globally by using regular expressions.
For details, see Chapter 7, "Common Infrastructure and Services".
TLM-2.0 is now supported, it is complemented with channelbased connectivity and communication mechanisms.
UML Diagram
The following diagram shows the relationship between the various
VMM classes.
Resources
The following resources are available for VMM users:
VMM Central (www.vmmcentral.org) is an online community for
VMM users to:
- Share information
- Exchange ideas
- Obtain VMM related news and updates
- Receive support on VMM related inquiries
- Learn new tricks and techniques from VMM users and experts
Note: VMM users are strongly encouraged to register as a member.
Usage scenarios and recommendations of various VMM features
are discussed in the following primers:
- Composing Environments
- Writing Command Layer Master Transactors
- Writing Command Layer Slave Transactors
- Writing Command Layer Monitor Transactors
- Using Command Layer Transactors
- Using the Register Abstraction Layer
- Using the Memory Allocation Manager
- Using the Data Stream Scoreboard
2
Architecting Verification Environments
Overview
Testbench Architecture
Advanced Usage
Overview
The challenge in transitioning from a procedural language such as
Verilog or VHDL, to a language like SystemVerilog is in making
effective use of the object-oriented programming model. When
properly used, these features can greatly enhance the reusability of
testbench components.
This section covers the following topics:
Testbench Architecture
This section describes recommended testbench architecture. You
implement testcases on top of a verification environment as shown
in Figure 2-1. The verification environment implements the
Verification Environment
DUT
Verification environments are not monolithic. As shown in Figure 22, environments are composed of layers. As in Figure 2-3, they
mirror the abstraction layers in the data processed by the design.
You design them to meet the various requirements of testcases
written for it. Each layer provides a set of services to the upper layers
or testcases, while abstracting it from the lower-level details.
Figure 2-2
Testcase A
Scenario
Generator
High-Level Transactions
Driver
Self-Check
Monitor
Functional
Atomic Transactions
Checker
Driver
Command
Properties
Checker
Functional Coverage
Monitor
1s & 0s
Signal
Figure 2-3
DUT
Data Generator
Firmware
Scoreboard
AMBA AHB
Interface
Checker
AMBA AHB
Interface
Master
Properties
USB Transfers
USB
Checker
Functional Coverage
Testcase A
USB
Transactions
DUT
Though Figure 2-2 shows testcases interacting only with the upper
layers of the verification environment, they can by-pass various
layers to interact with various components of the environment or the
DUT to accomplish their goals.
Signal Layer
This layer provides signal-level connectivity to the DUT. Then the
signal layer provides pin name abstraction enabling verification
components that are used and unmodified with different DUTs or
different implementation models of the same DUT. For example,
consider an RTL description of the DUT using interface
constructs and a gate-level description of the same DUT using
individual bit I/O signals. This layer might abstract synchronization
and timing of synchronous signals with respect to a reference signal.
The signal abstraction this layer provides is accessible. All layers
and testcases above it might use it where signal-level access is
required.
interface mii_if(...);
...
endinterface: mii_if;
...
class mii_phy_layer ...;
virtual mii_if.phy_layer sigs;
...
endclass: phy_layer
...
interface mii_if();
inout
tx_clk;
inout [3:0] txd;
inout
tx_en;
inout
tx_err;
inout
rx_clk;
inout [3:0] rxd;
inout
rx_dv;
inout
rx_err;
inout
crs;
inout
col;
...
endinterface: mii_if
interface mii_if;
...
parameter setup_time = 5ns;
parameter hold_time = 3ns;
This implementation style allows changing the set-up and hold time
on a per instance basis to meet the needs of the DUT without
modifying the interface declaration itself. Modifying the interface
declaration has global effects. However, you can specify parameters
for each interface instance.
Example 2-4
mii_if #(.setup_time(1),
.hold_time (0)) mii();
interface mii_if;
...
modport mac_layer(clocking
clocking
input
input
...
modport phy_layer(clocking
clocking
output
mtx,
mrx,
crs,
col, ...);
ptx,
prx,
crs,
output
col, ...);
...
modport passive(clocking ptx,
clocking mrx,
input crs,
input col, ...);
...
endinterface: mii_if
You might have written verification components and the design using
different interface declarations for the same physical signals. To
connect the verification components to the design, it is necessary to
map two separate interface instances to the same physical
signals. This can be accomplished with continuous assignments for
unidirectional signals and aliasing for bidirectional signals. Example
2-8 shows how to model a top-level module that contains multiple
interfaces.
Example 2-7
interface eth_tx_if;
// RTL Design Interface
bit
clk;
wire [3:0] d;
logic
en;
logic
err;
logic
crs;
logic
col;
endinterface: eth_tx_if
module tb_top;
bit
eth_tx_if
mii_if
tx_clk;
mii_dut(); // Design Interface Instance
mii_xct(); // Transactor Interface Instance
assign mii_dut.clk
= tx_clk; // Unidirectional
assign mii_xct.tx_clk = tx_clk;
alias mii_xct.txd
= mii_dut.d; // Inout
...
endmodule: tb_top
Example 2-8
module tb_top;
bit tx_clk;
...
initial
begin
...
#20; // No clock edge at T=0
tx_clk = 0;
...
forever begin
#(T/2) tx_clk = 1;
#(T/2) tx_clk = 0;
end
end
endmodule: tb_top
Using a two-state data type ensures that you initialize the clock
signals to a known, valid value.
If a four-state logic type such as logic, is used to implement the
clock signals, the initialization of those signals to 1b0 might be
considered as an active negative edge by some design components.
The alternative of leaving the clock signals at 1'bx while you delay
the clock edges -- as in the previous rule might cause functional
problems if you propagate these unknown values.
Clock signals can be synchronized with an asynchronous
relationship inherently. This is required to simulate with a fixed initial
phase and a common timing reference such as the internal
simulation time. You should randomize the relationship of such
clocks to ensure that problems related to asynchronous clock
domains can surface during simulation.
Example 2-9
integer tx_rx_offset;
integer T = 100;
initial
// 0-99% T lag
begin
...
tx_rx_offset = {$random} % 100;
#20; // No clock edge at T=0
tx_clk = 0;
rx_clk = 0;
...
fork
begin
#(T * (tx_rx_offset % 100) / 100.0);
forever begin
#(T/2) rx_clk = 1;
#(T/2) rx_clk = 0;
end
end
join_none
forever begin
#(T/2) tx_clk = 1;
#(T/2) tx_clk = 0;
end
end
Command Layer
The command layer typically contains bus-functional models,
physical-level drivers, monitors and checkers associated with the
various interfaces and physical-level protocols present in the DUT.
Regardless of how you model the DUT, the command layer provides
a consistent, low-level transaction interface to it. At this level, you
define a transaction as an atomic data transfer or command
operation on an interface such as a register write, transmission of an
Ethernet frame or fetching of an instruction.
You typically define atomic operations using individual timing
diagrams in interface specifications. Reading and writing registers is
an example of an atomic operation. The command layer provides
methods to access registers in the DUT. This layer has a mechanism
that bypasses the physical interface to peek and poke the register
values directly into the DUT model.
Note: The implementation of direct-access, register read/write driver
is dependent upon the implementation of the DUT.
A driver actively supplies stimulus data to the DUT. A proactive driver
is in control of the initiation and type of the transaction.
Whenever the higher layers of the verification environment supply a
new transaction to a proactive driver, the transaction on the physical
interface gets immediately executed. For example, a master busfunctional model for an AMBA AHB interface is a proactive driver.
Functional Layer
The functional layer provides the necessary abstraction layers to
process application-level transactions and verify the correctness of
the DUT.
Functional Sub-Layers
TCP over IP
Driver
Self-Check
Monitor
IP Fragment
& Re-assembly
Driver
Self-Check
Monitor
IP Fragments
over Ethernet
Driver
Self-Check
Monitor
Ethernet MAC
Driver
Self-Check
Monitor
...
mii_phy_layer phy;
...
virtual function void build();
...
this.phy = new(...);
...
endfunction: build
...
virtual task start();
...
this.phy.start_xactor();
...
endtask: start
endclass: tb_env
program test;
tb_env env = new;
...
endprogram
Scenario Layer
This layer provides controllable and synchronizable data and
transaction generators. By default, they initiate broad-spectrum
stimulus to the DUT. You can use different generators or managers
to supply data and transactions at the various sub-layers of the
functional layer. This layer also contains a DUT configuration
generator.
Test Layer
Testcases involve a combination of modifying constraints on
generators, definition of new random scenarios, synchronization of
different transactors and creation of random or directed stimulus.
This layer might provide additional testcase-specific self-checking
that is not provided by the functional layer at the transaction level.
For example, it checks where correctness will depend on timing with
respect to a particular synchronization event introduced by the
testcase.
The environment instantiates all necessary transactors and
manages their execution. Therefore, the environment that
encapsulates them should preferably be instantiated in a program
block.
Sub-environments
VMM promotes the design of transactors and self-checking
structures so that you can reuse them in different environments. For
example, you can construct system-level verification environments
of the same basic components used to construct block-level
environments.
When you construct a system-level environment using the same
basic components used to construct block-level environments, VMM
arranges, combines and connects these same basic components
the same way. For example, a block-level self-checking structure
complete with stimulus and response monitors, and scoreboard
Scenario
Testcase A
Generator
Driver
Generator
Self-Check
Monitor
Functional Reusable
Sub-Env.
Command
Signal
Driver
Monitor
Reusable
Sub-Env.
Monitor
Driver
DUT
a different physical bus. They can also be fed from a driver transactor
as shown in Figure 2-7, thereby eliminating or delaying the need to
develop a command-layer monitor if none is readily available.
Figure 2-6
Scenario
Testcase A
Generator
Driver
Generator
Self-Check
Functional
Command
Signal
Monitor
Reusable
Sub-Env.
Driver
Monitor
Monitor
DUT
Driver
Figure 2-7
Scenario
Testcase A
Generator
Driver
Functional
Command
Signal
Generator
Self-Check
Monitor
Reusable
Sub-Env.
Driver
Monitor
Driver
DUT
Figure 2-8
Self-Check
Monitor
Reusable
Structure
Driver
Block
Monitor
Monitor
Block
Block
There are different ways in which you can specify the configuration
of a sub-environment. The following section describes the various
techniques.
vmm_data_member_scalar(da, DO_ALL)
vmm_data_member_scalar(sa, DO_ALL)
vmm_data_member_scalar(len_typ, DO_ALL)
vmm_data_member_scalar_array(data, DO_ALL)
vmm_data_member_scalar(fcs,
DO_ALL-DO_PACK-DO_UNPACK)
vmm_data_member_end(eth_frame)
constraint valid_frame {
fcs == 0;
}
endclass
If you do not want calling each transactor phases at the right time,
another modeling style is to use implicit phasing. You need to
create an environment that extends vmm_group. All transactors
that you instantiate in this environment automatically call their
phases at the right time. Note that yet it is possible to explicitly
call transactor phases herein. For details, see Composing
Implicitly Phased Environments/Sub-Environments on page 248.
Reuse
- Implicitly phased sub-environments allow easy vertical reuse
from block to system. You can easily remove/add/customize
phases.
- Explicitly phased sub-environments allow easy reuse but you
invoke their phases at the right place when you instantiate in
environment that extends vmm_env.
Ease of Use
- Implicitly phased sub-environments are easy to use and you
require limited knowledge upon the transactors.
- Explicitly phased sub-environments phases are well-defined
but you should know when and where to add the transactor
controls.
Note: It is possible for the environment to deal with implicit and explicit
phase i.e. the mixed phases. For details, see Mixed Phasing on
page 2-75.
Figure 2-9
Base Class
DUT-Specific Extension
virtual gen_cfg()
virtual gen_cfg()
virtual build()
virtual build()
virtual reset_dut()
virtual reset_dut()
virtual cfg_dut()
virtual cfg_dut()
virtual start()
virtual start()
virtual wait_for_end()
virtual wait_for_end()
virtual stop()
virtual stop()
virtual cleanup()
virtual cleanup()
virtual report()
virtual report()
Example 2-14
You can use additional analysis port binding to sample data into a
functional coverage model or modify the data for error injection. You
should ensure that the self-checking structure is aware of all known
exceptions or errors injected in the stimulus or observed on the
response. This correctly predicts the expected response or assesses
the correctness of the observed response.
Some components need access to the transaction to modify or to
delay it, before you process it by the transactor. For example, error
injection can corrupt a parity byte. You achieve this by registering
callback extensions for these particular components.
You should call the callback before you call the analysis port. This
ensures that the scoreboard views the actual transaction that is
executed.
Starting Transactors
Configuring the DUT often requires that the configuration and host
interface transactors be started in the extension of the
vmm_env::cfg_dut() method.
A testcase should be able to control the duration of a simulation. It
might be in terms of number of transactions you execute or absolute
time or all transactors consenting to stop the simulation.
An instance of vmm_consensus must be present in the
environment to terminate test.
You should use vmm_consensus blocking task,
vmm_consensus::wait_for_consensus() in the
vmm_env::wait_for_end() method to control the duration of a
simulation.
All contributing components to this consensus should be registered
using the vmm_consensus::register_*() functions. For
details, see Reaching Consensus for Terminating Simulation on
page 2-56.
Example 2-19
Sub-Environment Declaration
By redefining the value of the macro from the command line, you can
thus derive a sub-environment from an organization-specific base
class, even if it comes from outside the organization.
Example 2-21
Example 2-22
function new(
...
endfunction: new
class mii_eth_frame_sb_cfg;
rand ahb_cfg ahb;
rand mii_cfg mii;
endclass: mii_eth_frame_sb_cfg
class mii_eth_frame_sb extends vmm_subenv;
function new(mii_eth_frame_sb_cfg cfg, ...);
...
endfunction: new
endclass: mii_eth_frame_sb
endclass: mii_eth_frame_sb
Using a task named configure() to configure the subenvironment and the portion of the DUT associated with the
sub-environment.
You must configure the sub-environment and the portion of the DUT
that corresponds to the functionality it verifies, when the functionality
of the sub-environment is configurable.
If the sub-environment and associated DUT functionality are not
configurable, this method must still exist to document that fact.
Example 2-26
Even if you don't need to extend a method for a particular subenvironment, you should extend it anyway and leave it empty to
explicitly document that fact.
You must then call these methods in their corresponding simulation
step method in the extension of the vmm_env base class where you
use a sub-environment.
Extensions of the, vmm_subenv::stop() and
vmm_subenv::cleanup() virtual methods shall call their base
implementation first.
The stop() method shall stop all registered transactors.
The implementation of these methods in the base class manages the
sequence in which you must invoke these methods. They will report
an error if you do not use a sub-environment properly.
Example 2-28
Top-test
Post-test
Phase
Method
RTL Config
vmm_rtl_config::*
gen_config
vmm_group::gen_config_ph()
build
vmm_unit::build_ph()
configure
vmm_unit::configure_ph()
connect
vmm_unit::connect_ph()
configure_test
vmm_unit::configure_test_ph()
start of sim
vmm_unit::start_of_sim_ph()
reset
vmm_unit::reset_ph()
training
vmm_unit::training_ph()
config_dut
vmm_unit::config_dut_ph()
start
vmm_unit::start_ph()
start of test
vmm_unit::start_of_test_ph()
run
vmm_unit::run_ph()
shutdown
vmm_unit::shutdown_ph()
cleanup
vmm_unit::cleanup_ph()
report
vmm_unit::report_ph()
final
vmm_unit::final_ph()
Pre-test timeline
This timeline builds, configures and connects the verification
environment that will be used by all tests. It is only called once,
by the firstly executed test.
- RTL configuration: Create and populate RTL configuration
descriptors that reflect the compile-time RTL configuration
parameters. You can then use these RTL configuration
parameters to affect the structure of the verification
environment. For examples, see RTL Configuration on page
7-52.
- gen_config: Perform dynamic configuration of vmm_group
objects. Registered vmm_group::gen_config_ph are
called for root objects.
- Build: Instantiate and allocate environment components. You
might make VMM channel connections between components
optionally here. Registered vmm_unit::build_ph() phases
are called top down.
Top-test timeline
This timeline is the main timeline for the execution of a single test.
This is repeated if multiple tests are concatenated in the same
simulation run.
- Configure_test: Perform test-specific actions such as, factory
replacements, option settings, scenario overrides, callback
extensions, etc. When multiple tests are concatenated in the
same simulation, each component in the verification
environment gets rolled back to this phase. Registered
vmm_unit::configure_test_ph() phases are called
bottom up.
- Start_of_sim: The additional phase you call prior to starting
simulation. Registered vmm_unit::start_of_sim_ph()
phases are called top down.
- Reset: Perform DUT reset, which is typically an activity of the
top-level environment. However, in some situations such as,
low-power mode/testcase, there are multiple resets happening
on different interfaces, in which case the lower level
components might implement some functionality in this phase.
Registered vmm_unit::reset_ph() phases are forked off.
Post-test timeline
- Final: Perform a final summary report and any action specific
to the verification environment such as ensuring the scoreboard
is empty, look into coverage bins, etc. Registered
vmm_unit::final_ph() phases are called bottom up
`include vip_trans.sv
class my_env extends vmm_group;
`vmm_typename(my_env)
vip
gen
bfm1;
gen1;
Without further actions, all generic voter interfaces consent and test
reaches the overall consensus. You can register additional
participants, transactors, channels and generic voters. For example,
you might register a transactor so it consents only when it is idle.
In Example 2-30, note how the transactor registers with the
consensus of its encapsulating vmm_group::vote and not with its
own vmm_consensus instance. This is to allow the user of a
transactor to decide whether or not the transactor being idle is a
required condition for the end of test.
Example 2-30
my_vip vip1;
my_vip vip2;
function new(string name = "", vmm_object parent = null);
super.new("vip", name, null);
super.set_parent_object(parent);
endfunction
virtual function void build_ph();
super.build_ph();
this.vip1 = new(this, "vip1");
this.vip2 = new(this, "vip2");
endfunction
virtual function void connect_ph();
super.connect_ph();
this.vote.register_xactor(this.vip1);
this.vote.register_xactor(this.vip1);
endfunction
endclass
mst;
slv;
gen;
sb;
vote;
endtask
task wait_for_end();
super.wait_for_end();
end_vote.wait_for_consensus();
endtask
Base Class
Transaction
vmm_data
Transactor
vmm_xactor
Sub-environments
Environments
Testcase
Explicitly phased
vmm_subenv
Implicitly phased
vmm_group
Explicitly phased
vmm_env
Implicitly phased
vmm_group
vmm_test
Transactions
Transactions for a specific protocol should extend from
vmm_data.
vmm_class_factory(simple_rw)
endclass
...
Transactors
Transactors are testbench components that create, execute or
observe transactions. Their transaction processing must be started
implicitly or explicitly. Transactors can stopped or reset, during which
they no longer perform their normal transaction processing.
Transactors have at least one transaction-level input or output
interface (using channels or sockets). They might have a physicallevel interface. They form the basic elements of a testbench.
Example 2-32 show a simple channel-based master transactor for a
simple read/write protocol. The first step is to define transactor
callbacks, which are needed for easily grabbing information and
modifying this transactor without changing it. For instance, this is
useful for injecting errors or add, delay, etc. Here, callback
pre_trans() is defined and is invoked after the transaction is
taken out from the input channel. The other post_trans()
callback is invoked after the transactor has fully executed the
transaction.
(master_rw driver,
simple_rw tr
);
endtask
endclass
Transactor Declaration
Transactor Constructor
task master_rw::main();
bit drop;
simple_rw
tr;
is_done = 0;
fork
while (1) begin : w0
this.in_chan.peek(tr);
if (is_done) break;
`vmm_trace (this.log, $psprintf ("Driver received a
transaction: %s", tr.psdisplay()));
`vmm_callback(master_rw_callbacks, pre_trans(this,
tr, drop));
case (tr.kind)
simple_rw::READ:
this.read(tr.addr, tr.data, tr.is_ok);
simple_rw::WRITE:
this.write(tr.addr, tr.data, tr.is_ok);
endcase
`vmm_callback(master_rw_callbacks, post_trans(this,
tr));
this.analysis_port.write(tr);
this.in_chan.get(tr);
wait_if_stopped();
if (is_done) break;
end : w0
join_none
endtask
Transactor Connection
Example 2-39
Transactor Shutdown
task master_rw::shutdown_ph();
is_done = 1;
endtask
Transactor Operations
Communication
VMM provides multiple ways of communicating transactors to each
other. You can achieve this transaction passing either with
vmm_channel, vmm_tlm, analysis_port or callback
interfaces.
Base Class
Master
vmm_channel
Monitor
vmm_tlm_b_transport
vmm_analysis_port
vmm_callback
Slave
Testing VIPs
This section gives a brief overview of how to verify your VIP. For
details, see Chapter 6, "Implementing Tests & Scenarios".
You implement testcases using the vmm_test base class. For
details, see Generating Stimulus on page 6-2.
If you write testcases on top of an implicitly-phased top-level
environment, you implement them by extending the predefined
phasing methods or by defining new phases. For details, see
Understanding Implicit and Explicit Phasing on page 31.
Advanced Usage
Mixed Phasing
It is possible to construct an environment with components using
different phasing models.
Example 2-43
Example 2-44
Example 2-45
fork
tl.run_phase("run");
begin
`vmm_note(log, "Running...");
#100;
end
join
endtask
virtual task stop();
super.stop();
tl.run_phase("shutdown");
`vmm_note(log, "Stopped...");
endtask
endclass
Example 2-48 shows how to instantiate this explicitly phased subenvironment in an implicitly phased environment.
Example 2-46
`include "vmm.sv"
class my_vip extends vmm_xactor;
`vmm_typename(my_vip)
function new(vmm_object parent = null, string name = "");
super.new("vip", name);
super.set_parent_object(parent);
endfunction
virtual function void start_xactor();
super.start_xactor();
`vmm_note(log, "Starting...");
endfunction
virtual function void stop_xactor();
super.stop_xactor();
`vmm_note(log, "Stopping...");
endfunction
endclass
Example 2-47
this.vip1.start_xactor();
this.vip2.start_xactor();
`vmm_note(log, "Started...");
endtask
virtual task stop();
super.stop();
this.vip1.stop_xactor();
this.vip2.stop_xactor();
`vmm_note(log, "Stopped...");
endtask
endclass
Example 2-48
3
Modeling Transactions
Overview
Methods
Constraints
Shorthand Macros
Overview
The challenge in transitioning from a procedural language such as
Verilog or VHDL, to an object-oriented language such as
SystemVerilog, is in making effective use of the object-oriented
programming model. This section provides guidelines and directives
that help modeling transactions by extending vmm_data.
Transactions should be modeled by using a class, not a struct or
a union. The common tendency is to model transactions as
procedure calls such as, read() and write(). This approach
complicates generating random streams of transactions,
constraining transactions and registering transactions with a
scoreboard.
As shown in Example 3-1, you can model the transactions better by
using a transaction descriptor.
Example 3-1
constraint valid_frame {
fcs == 0;
}
endclass
This approach enables turning off the array's rand attributes and
constraining them in a derived class, higher-level classes or via the
randomize-with statement. If the properties are local, none of
this is possible.
VMM User Guide
3-7
Context References
Some transactions are layer-based and depend upon lower-level
transactions. For instance, the USB protocol comes with high level
usb_transfer that consists of a list of usb_packets, which in turn
consists of a list of usb_packets. Transaction descriptors for higherlevel transactions should have a list of references to the lower-level
transactions used to implement them.
You can add lower-level transactors in the verification environment
to this list as they implement the higher-layer transaction. The
completed list is only valid when the transaction's processing has
ended. A scoreboard can then use the list of sub-transactions to
determine its status and the expected response.
Conversely, the descriptor for a low-level transaction should have a
reference to the higher-level transaction descriptor it implements.
This reference helps the scoreboard or other verification
environment components to make sense of the transaction and
determine the expected response.
In Example 3-6, the higher-layer transaction usb_packet is modeled
as a list of usb_transactions, which are modeled as a list of
usb_packets.
Example 3-6
...
endclass: usb_transaction
class usb_transfer extends vmm_data;
...
usb_transaction transactions[];
vmm_data
context_data;
...
endclass: usb_transfer
class eth_vlan_data;
rand bit [ 2:0] user_priority;
rand bit
cfi;
rand bit [11:0] id;
endclass: eth_vlan_data
class eth_frame extends vmm_data;
...
typedef enum {UNTAGGED, TAGGED, CONTROL}
frame_formats_e;
rand frame_formats_e format; // Discrimant
...
rand bit [47:0] dst;
rand bit [47:0] src;
rand eth_vlan_data vlan;
...
function void pre_randomize(); // Composition
if (this.vlan == null) this.vlan = new;
endfunction
function void post_randomize();
if (format != TAGGED) this.vlan = null;
endfunction
...
endclass: eth_frame
Methods
This section contains guidelines for using methods in data and
transaction models. As explained in previous section, definition and
implementation of transaction methods is unnecessary when using
shorthand macros. For details, see Shorthand Macros on page 23.
You encode the data protection class property simply as being valid
or not. Therefore, it must be possible to derive its actual value by
other means when necessary.
The method must be virtual to allow the introduction of a different
protection value computation algorithm if necessary. When it is
modeled as invalid, the packing method is responsible for corrupting
the value of a data protection class property, not the computation
method. For details, see Example 3-9.
Constraints
You might model some properties using a type that can yield invalid
values. For example, a length class property might need to be
equal to the number of bytes in a payload array. This constraint
ensures that the value of the class property and the size of the array
are consistent. Note that "valid" is not the same thing as "error-free."
Validity is a requirement of the descriptor implementation not the
data or transaction being described.
Example 3-12
Example 3-13
Use one constraint block per class property to make it easy to turn
off or override without affecting the distribution of other properties.
For details, see Example 3-13.
A conditional constraint block does not imply that the properties used
in the expression are solved before the properties in the body of the
condition.
If you solve a class property in the body of the condition with a value
that implies that the condition cannot be true, this result constrains
the value of the properties in the condition. If there is a greater
probability of falsifying the condition, it is unlikely to get an even
distribution over all discriminant values.
In Example 3-15, if you solve the length class property before the
kind class property, it is unlikely to produce CONTROL packets
because there is a low probability of you solving the length class
property as 1.
Example 3-15
class some_packet;
typedef enum {DATA, CONTROL} kind_typ;
rand kind_typ kind;
rand int unsigned length;
...
constraint valid_length {
if (kind == CONTROL) length == 1;
}
endclass: some_packet
class some_packet;
typedef enum {DATA, CONTROL} kind_typ;
rand kind_typ kind;
rand int unsigned length;
...
constraint valid_length {
if (kind == CONTROL) length == 1;
solve kind before length;
}
endclass: some_packet
You can randomly inject error by selecting an invalid value for error
protection properties. A constraint block should keep the value of
such properties valid by default. For details, see Example 3-16.
You use one constraint block per error injection class property to
make it easy to turn off or override without affecting the correctness
of other properties.
You define external constraint blocks outside the class that
declares them. If you leave them undefined, you consider them
empty and do not add constraints to the class instances. You can
define these constraint blocks later by individual tests to add
constraints to all instances of the class.
Example 3-17
Shorthand Macros
The implementation of an extension of the vmm_data class requires
the implementation of many methods. For example,
vmm_data::compare(), vmm_data::copy(), packing,
vmm_env::start(), etc...). Although you only need to implement
these methods once, they might be cumbersome to maintain and to
implement for trivial class extensions.
}
endclass
User-Defined Implementations
When you use shorthand macros, you provide all vmm_data virtual
methods with a default implementation. If it is necessary to provide
a different, explicitly-coded implementation for one of these methods
or data member, you can implement it using one of two approaches.
Example 3-20 shows how the default method implementation for the
da member can be user-specified to display an IP address using the
separated hexadecimal value instead of the decimal value provided
by the default implementation.
Example 3-20
end
end
DO_PACK: begin
if (pack.size() < offset + 6)
pack = new [offset + 6] (pack);
{pack[offset ], pack[offset+1], pack[offset+2],
pack[offset+3], pack[offset+4], pack[offset+5]} =
this.da;
offset += 6;
end
DO_UNPACK: begin
if (unpack.size() < offset + 6) return 0;
this.da = {unpack[offset ], unpack[offset+1],
unpack[offset+2], unpack[offset+3],
unpack[offset+4], unpack[offset+5]};
offset += 6;
end
endcase
endfunction
constraint valid_frame {
fcs == 0;
}
endclass
class vlan_tag; //
rand bit [ 2:0]
rand bit
rand bit [11:0]
endclass
no vmm_data extension
pri;
cfi;
tag;
DO_ALL-DO_PACK-DO_UNPACK)
vmm_data_member_end(eth_frame)
function bit do_vlan(
input vmm_data::do_what_e do_what,
input string prefix,
ref string image,
input eth_frame rhs,
input int kind,
ref int offset,
ref logic [7:0] pack1[],
const ref logic [7:0] unpack1());
do_da = 1; // Success, abort by returning 0
case (do_what)
DO_PRINT: begin
if (this.vlan == null) return 1;
$sformat(image, "%s\n%s
VLAN: %0d/%b (%h)",
this.pri, this.cfi, this.tag);
end
DO_COPY: begin
rhs.vlan = (this.vlan == null) ? null
: new this.vlan;
end
DO_COMPARE: begin
if (this.vlan == null && rhs.vlan == null)
return 1;
if (this.vlan == null) begin
image = "No VLAN on this but found on to";
return 0;
end
if (this.rhs == null) begin
image = "VLAN on this but not on to";
return 0;
end
if (this.vlan.pri != rhs.vlan.pri) begin
$sformat(image, "this.vlan.pri (%0d) != to.vlan.pri
(%0d)",
this.vlan.pri, rhs.vlan.pri);
return 0;
end
if (this.vlan.cfi != rhs.vlan.cfi) begin
$sformat(image, "this.vlan.cfi (%b) != to.vlan.cfi
(%b)",
this.vlan.cfi, rhs.vlan.cfi);
return 0;
end
if (this.vlan.tag != rhs.vlan.tag) begin
$sformat(image, "this.vlan.tag (%h) != to.vlan.tag
(%h)",
this.vlan.tag, rhs.vlan.tag);
return 0;
end
end
DO_PACK: begin
if (this.vlan == null) return 1;
if (pack.size() < offset + 4)
pack = new [offset + 4 (pack);
{pack[offset ], pack[offset+1] = h8100};
{pack[offset+2], pack[offset+3] =}
{this.vlan.pri, this.vlan.cfi, this.vlan.tag};
offset += 4;
end
DO_UNPACK: begin
if (unpack.size() < offset + 4) return 1;
if ({unpack[offset], unpack[offset+1]}
!= h8100) return 1;
this.vlan = new;
{this.vlan.pri, this.vlan.cfi, this.vlan.tag} =
{unpack[offset+2], pack[unoffset+3]};
offset += 4;
end
endcase
endfunction
constraint valid_frame {
fcs == 0;
}
endclass
`vmm_data_member_rand_handle_da(_name, _do)
`vmm_data_member_rand_handle_aa_scalar(_name,
_do)
`vmm_data_member_rand_handle_aa_string(_name,
_do)
`vmm_data_member_rand_vmm_data(_name, _do, _how)
`vmm_data_member_rand_vmm_data_array(_name,
_do, _how)
`vmm_data_member_rand_vmm_data_da(_name, _do,
_how)
`vmm_data_member_rand_vmm_data_aa_scalar(_name,
_do, _how)
`vmm_data_member_rand_vmm_data_aa_string(_name,
_do, _how)
Note: You should use these macros only on rand or randc
properties, else, a syntax error is generated.
The only purpose of these new macros is to copy the rand_mode()
state. To minimize the run-time performance impact of copying the
rand_mode() state on large arrays (which must be done on each
array element) and on classes with large number of members, the
recommendation is to not use it by default and, if needed, add it in a
derived class. It must thus be specified in addition to the non-rand
macro to complete the default implementation of the copy method.
class vip_tr extends vmm_data;
rand int huge[65535];
`vmm_data_member_begin(vip_tr)
`vmm_data_member_scalar_array(huge, DO_ALL)
`vmm_data_member_end(vip_tr)
VMM User Guide
3-35
endclass
class directed_tr extends vip_tr;
function new();
this.huge.rand_mode(0);
endfunction
`vmm_data_new(directed_tr)
`vmm_data_member_begin(directed_tr)
`vmm_data_member_rand_scalar_array(huge, DO_ALL)
`vmm_data_member_end(directed_tr)
endclass
4
Modeling Transactors and Timelines
Overview
Transactor Phasing
Physical-Level Interfaces
Transactor Callbacks
Advanced Usage
Overview
The term transactor is used to identify components of the verification
environment that interface between two levels of abstractions for a
particular protocol or to generate protocol transactions.
In Figure 2-2, the boxes labeled Driver, Monitor, Checker and
Generator are all transactors. The lifetime of transactors is static to
the verification environment. They are created at the beginning of the
simulation and stay in existence for the entire duration.
They are structural components of the verification components and
they are similar to modules in the DUT. Only a handful of transactors
get created. In comparison, transactions have a dynamic lifetime.
Thousands get created by generators, flow through transactors, get
recorded and compared in scoreboards and then freed.
Traditional bus-functional models (BFM) are called command-layer
transactors. Command-layer transactors have a transaction-level
interface on one side and a physical-level interface on the other.
Functional-layer and scenario-layer transactors only have
transaction interfaces and do not directly interface to physical
signals.
This section specifies guidelines designed to implement transactors
that are reusable, controllable and extendable. Note that reusability,
controllability and extensibility are not goals in themselves.
These features enable reusability of transactors by different
testcases and different verification environments. They enable
control of transactors to meet the specific needs of the testcases.
MII Transactors
class mii_cfg;
...
endclass: mii_cfg
...
class mii_mac_layer extends vmm_xactor;
...
endclass: mii_mac_layer
...
class mii_phy_layer extends vmm_xactor;
...
endclass: mii_phy
Transactors Declarations
package mii;
class mii_cfg extends vmm_data;
...
endclass: mii_cfg
...
class mii_mac_layer extends vmm_xactor;
...
endclass: mii_mac_layer
...
class mii_phy_layer extends vmm_xactor;
...
endclass: mii_phy_layer
...
endpackage: mii
Transactor Phasing
Transactors progress through a series of phases throughout
simulation. All transactors are synchronized so that they execute
their phases synchronously with other transactors during simulation
execution.
VMM supports two transactor phasing usage: implicit and explicit. In
explicit phasing, the transactors are under the control of a master
controller such as, vmm_env to call the transactor phases. In implicit
phasing, the transactors execute their phases automatically and
synchronously.
VMM predefines several simulation phases. The following table
summarizes these phases and their intended purpose:
Table 4-1
Intended Purpose
gen_cfg
rtl_config
gen_config
build
build
configure
Configure options
connect
configure_test_ph
start_of_sim
reset
Reset DUT
training
cfg_dut
config_dut
start
start
start_of_test
wait_for_end
run
stop
shutdown
reset
Implicit
Phase
Table 4-1
Implicit
Phase
Intended Purpose
cleanup
cleanup
report
report
final
task mii_mac_layer::main();
fork
super.main();
join_none
...
endtask: main
Example 4-5
function void
mii_mac_layer::reset_xactor(reset_e typ = SOFT_RST);
super.reset_xactor(typ);
...
endfunction: reset_xactor
class mii_cfg;
rand bit is_100Mb;
rand bit full_duplex;
endclass: mii_cfg
Modeling Transactor
Example 4-8
Example 4-9
Example 4-10
vmm_test_registry::run(env);
end
endprogram
Implicit Phasing
In the implicit phasing execution model, transactors are selfcontrolled through built-in phasing mechanism. The environment
automatically calls the phase specific methods in a top down, bottom
up and forked fashion.
Implicit phasing works only with transactors that you base on the
vmm_group or vmm_xactor class. The two use models are,
Implicit phasing works only with classes that you base on the
vmm_group class.
Phase
Method
Invocation Order
RTL config
function rtl_config_ph()
Top down
gen_config
function gen_config_ph()
build
function build_ph()
Top down
configure
function configure_ph()
Bottom up
connect
function connect_ph()
Top down
configure_test
configure_test_ph
Bottom up
start of sim
function start_of_sim_ph()
Top down
reset
task reset_ph()
Forked
training
task training_ph()
Forked
config_dut
task config_dut_ph()
Forked
start
task start_ph()
Forked
start of test
function start_of_test_ph()
Top down
run
task run_ph()
Forked
shutdown
task shutdown_ph()
Forked
cleanup
task cleanup_ph()
Forked
report
function report_ph()
Top down
final
function final_ph()
Top down
Example 4-13
Example 4-14
begin
`vmm_trace(log, "Config transaction...");
...
end
else begin
`vmm_trace(log, "Normal transactions...");
...
end
end
endtask
endclass
Physical-Level Interfaces
Command-level transactors and bus-functional models are
components of the command layer. They translate transaction
requests from the higher layers of the verification environment to
physical-level signals of the DUT.
In the opposite direction, they monitor the physical signals from the
DUT or between two DUT modules. They also notify the higher
layers of the verification environment of various transactions the
DUT initiates.
The physical-level interface of command-layer transactors must
interact with the signal-layer construct. As such, they must follow the
guidelines outlined in section Signal Layer on page 2-6.
This specification lets each instance of a transactor to connect to a
specific interface instance without hard-coding a signal naming or
interfacing mechanism.
The signal layer creates the necessary interface instances in the
top-level module. You can specify the appropriate interface
instance when constructing a transactor, to connect that transactor
to that interface instance.
Example 4-15
endinterface
//Instantiate interface in top level module
// and connect to DUT signals
module test_top();
//Interface instantiation
cpu_if cpuif(clk);
//DUT instantiation
cntrlr dut(.clk(clk),
.reset(reset),
.busAddr(cpuif.busAddr),
.busData(cpuif.busData),
.busRdWr_N(cpuif.busRdWr_N),
.adxStrb(cpuif.adxStrb));
endmodule
// Create a vmm_object wrapper which gets virtual
// interface handle through the constructor.
// Instantiate the object with the actual interface
// instantiation and allocate the vmm_object
// instance to appropriate transactor through
vmm_opts::set_object() method.
class cpuport extends vmm_object;
virtual cpu_if.drvprt iport;
function new(string name,virtual cpu_if.drvprt iport);
super.new(null, name);
this.iport = iport;
endfunction
endclass
program cntrlr_tb;
cpuport cpu_port; //Interface wrapper
cntrlr_env
env;
initial begin
env = new(env);
//Instantiating with the actual interface
// instance path
cpu_port = new("cpu_port",test_top.cpuif);
vmm_opts::set_object("CPU:CPUDrv:cpu_port",cpu_port,
env); //Sending the wrapper to driver
end
endprogram
// use vmm_opts::get_object_obj() method
// (or `vmm_unit_configure_obj macro)
// to get the object wrapper instance and hence the
// virtual interface handle
// in the vmm_xactor::connect_ph(). Since it is a dynamic
// allocation, it is recommended
// to have a null object check on the virtual interface
// instance before using it.
class cpu_driver extends vmm_xactor;
virtual cpu_if.drvprt
cpuport cpu_port_obj;
iport;
task mii_mac_layer::tx_driver();
...
@this.sigs.mtx;
this.sigs.mtx.txd <= nibble;
...
endtask: tx_driver
task mii_mac_layer::rx_monitor();
...
@(this.sigs.mrx);
if (this.sigs.mrx.rx_dv !== 1b1) break;
a_byte[7:4] = this.sigs.mrx.rxd;
...
endtask: rx_monitor
Transactor Callbacks
The behavior of a transactor shall be controllable as the verification
environment and individual testcases require without modifications
of the transactor itself.
These requirements are often unpredictable when you first write the
transactor. By allowing the execution of arbitrary user-defined code
in callback methods, you can adapt the transactors to the needs of
an environment or a testcase. For example, you can use callback
methods to monitor the data flowing through a transactor to check for
correctness, inject errors or collect functional coverage metrics.
`vmm_callback(cpu_driver_callbacks, pre_trans(this,
tr, drop));
if (tr.kind == cpu_trans::WRITE) begin
write_op(tr);
end
if (tr.kind == cpu_trans::READ) begin
read_op(tr);
end
`vmm_callback(cpu_driver_callbacks,
post_trans(this, tr));
endtask
endclass
// A subscriber extend the callback class, fill
// the necessary empty virtual methods.
class cpu_sb_callback extends cpu_driver_callbacks;
cntrlr_scoreboard sb;
function new(cntrlr_scoreboard sb);
this.sb = sb;
endfunction
virtual task pre_trans(cpu_driver drv, cpu_trans tr,ref
bit drop);
sb.cpu_trans_started(tr);
endtask
virtual task post_trans(cpu_driver drv, cpu_trans tr);
sb.cpu_trans_ended(tr);
endtask
endclass
//
//
//
//
//
//
//
Advanced Usage
User-defined vmm_xactor Member Default
Implementation
For the vmm_xactor class, you accomplish this by using the
'vmm_xactor_member_user_defined() macro and
implementing a function named "do_membername().
You implement this function using the following pattern:
function bit do_name(vmm_xactor::do_what_e do_what,
vmm_xactor::reset_e
rst_typ);
do_name = 1; // Success, abort by returning 0
case (do_what)
DO_PRINT: begin
// Add to the this.__vmm_image variable,
// using this.__vmm_prefix
end
DO_START: begin
// vmm_xactor::start_xactor() operations.
end
DO_START: begin
// vmm_xactor::stop_xactor() operations.
end
DO_RESET: begin
// vmm_xactor::reset_xactor() operations.
end
endcase
endfunction
You then add the new user defined phase definition to the parent
timeline at an appropriate point. You do this in the build phase as
shown in the following example:
environments, you might find it necessary to disable some blocklevel testbench components because their function is no longer
relevant within the system-level context.
A disabled unit instance (and all of its children objects) is no longer
considered by the timeline to which it belongs. It is no longer part of
the implicit phasing mechanism. You can disable a unit instance as
follows:
class top extends vmm_group;
`vmm_typename(top_unit)
ahb_driver drv0,drv1;
virtual function void build_ph();
drv0 = new(drv0, this);
drv1 = new(drv1, this);
endfunction
endclass
//single driver test
class my_test1 extends vmm_test;
`vmm_typename(my_test1)
virtual function void configure_ph();
// Disable drv1
top env = vmm_object::find_object_by_name("top");
env.drv1.disable_unit();
endfunction
endclass
Examples
To list all timelines in simulation:
./simv +vmm_list_timeline
Concatenation of Tests
In case of multiple tests top_test timeline is reset to the phase
identified as start phase for the test you need to execute. The test
can specify itself concatenable and specify the starting phase by
using vmm_test_concatenate() macro.
class test_concatenate1 extends vmm_test;
//Macro to indicate the rollback phase in
endclass
5
Communication
Overview
Channel
Advanced Usage
Overview
This section applies to the transaction-level interfaces connecting
independent transactors.
Transaction-level interfaces are mechanisms to exchange
transactions between two independent blocks such as between two
transactors or a directed testcase and a transactor.
In command-layer transactors such as drivers and monitors, the
transaction-level interface allows the higher layers of the verification
environment to stimulate the DUT by specifying which transactions
should be executed. Also, the higher layers can be notified of
transactions that have been observed on a DUT interface.
VMM supports multiple ways of passing transactions between
transactors. The supported interfaces are:
- Channel
- TLM Blocking transport
- TLM Non-Blocking transport
- TLM Analysis port
- Callback
Channel
A connection can be established between two transactors or a
testcase and a transactor by having each endpoint, the producer and
the consumer, refer to the same conduit. This is shown in Figure 51. You can make the connection by instantiating the endpoints in any
order to allow the bottom-up or top-down building of verification
environments.
The conduit allows a transactor, whether upstream or downstream to
connect to any other transactor with a compatible conduit. This
occurs without any source code modification requirement or
knowledge of the other endpoint.
Figure 5-1
Transactor
Channel
Producer
(upstream)
Consumer
(downstream)
vmm_data_member_scalar(len_typ, DO_ALL)
vmm_data_member_scalar_array(data, DO_ALL)
vmm_data_member_scalar(fcs, DO_ALL)
vmm_data_member_end(eth_frame)
endclass
typedef vmm_channel_typed #(eth_frame)
eth_frame_channel;
vmm_channel(eth_frame)
Transactor
Channel
Producer
(upstream)
Consumer
(downstream)
Note: This channel becomes blocking if the channel can only retain
one transaction and the attached transactor has not carried out a
vmm_channel::get() method access. Any other configuration
creates a non-blocking interface.
To ensure that input channels are "full", and therefore blocking when
there is one transaction in the channel, consumer transactors must
explicitly reconfigure the input channel instances.
Example 5-6
To ensure the producer does not push a new transaction right after
the vmm_channel::put() and that this transaction remains
unchanged while its being processed, you should use the
vmm_channel::peek() or vmm_channel::activate()
method to obtain the next transaction you execute from the input
channel.
Example 5-7
Channel Record/Playback
VMM channel provides a facility to record the transactions going
through and save them into a file. You can then playback these
transactions from the same file. As playback avoids randomization
of the transaction/corresponding scenarios, you can improve
performance in case of complex transaction/scenario constraints.
Also, generation is not scheduling-dependent and will work with
different versions of the simulator and with different simulators. You
can use this record/replay mechanism to go through known states at
one interface while stressing another interface with random
scenarios within the same simulation itself. This guarantees you
random stability.
The use model is as follows:
Example 5-9
eth_frame fr;
...
function build_ph();
tx_chan = eth_frame_channel::create_instance(
this,"TxChan");
mac = new(this, "Mac");
mii = new(this, "Mii");
endfunction
function configure_ph();
// Enable run time option to specify the
// record/playback mode
// Available with _vmm_opts_mode=MODE
md = vmm_opts::get_string("MODE", // Switch name
"NORMAL" , // Default
"Specifies the mode"); // Doc
case(md)
"NORMAL" : mode = NORMAL;
"RECORD" : mode = RECORD;
"PLAYBACK" : mode = PLAYBACK;
endcase
endfunction
function connect_ph();
mii.tx_chan = tx_chan;
case(mode)
NORMAL: begin
mac.pls_tx_chan = tx_chan;
end;
RECORD: begin
// record all eth_frame to tx_chan.dat
mac.pls_tx_chan = tx_chan;
tx_chan.record(filename);
end;
PLAYBACK: begin
// playback eth_frame from tx_chan.dat
// Dont connect the mac xactor
tx_chan.playback(success, filename, fr);
if(!success)
`vmm_error(log,
"Playback mode failed for channel");
end;
endcase
endfunction
...
endclass
Figure 5-3
Notification Interface
Notifications
Transactor
Transactor
Channel
Producer
(upstream)
Consumer
(downstream)
eth_pls_indications indications;
...
endclass: eth_mac
Notify Observer
VMM Notify Observer simplifies subscription to a notify callback
class. It is a parameterized extension of vmm_notify_callbacks.
Any subscriber (such as, a scoreboard, coverage model, etc.) can
get the transaction status whenever you indicate a notification event.
Call the `vmm_notify_observer macro, specifying the observer
and its method name.
class vmm_notify_observer #(type T, type D = vmm_data)
extends vmm_notification_callbacks
The transaction object itself does not contain any timing information
by design. Or even events and status information concerning the
API. You can pass the delays as arguments to b_transport /
nb_transport and push the actual realization of any delay in the
simulator kernel downstream and defer (for simulation speed).
In summary:
Blocking Transport
As given in the OSCI-TLM2.0 user manual,
The new TLM-2 blocking transport interface is intended to
support the loosely-timed coding style. The blocking transport
interface is appropriate where an initiator wishes to complete a
transaction with a target during the course of a single function call,
the only timing points of interest being those that mark the start
and the end of the transaction. The blocking transport interface
only uses the forward path from initiator to target.
Due to its loosely timed application with single socket, the blocking
transport interface is simpler than non-blocking transports. It only
implements the forward path port called
vmm_tlm_b_transport_port for issuing transactions and
vmm_tlm_b_transport_export for receiving transactions
Example 5-13 shows how to build up the parent-child association
during construction. It instantiates the port in the initiator and call the
b_transport() method from within the port.
Example 5-13
Example 5-14 shows how to instantiate the export in the target and
implement the b_transport() functionality locally.
Example 5-14
Non-Blocking Transport
As given in the OSCI-TLM2.0 user manual,
The non-blocking transport interface is intended to support the
approximately-timed coding style. The non-blocking transport
interface is appropriate where it is desired to model the detailed
sequence of interactions between initiator and target during the
course of each transaction. In other words, to break down a
transaction into multiple phases, where each phase transition
marks an explicit timing point.
Both forward and backward directions are available in the nonblocking transports called vmm_tlm_nb_transport_fw_port
and vmm_tlm_nb_transport_fw_export respectively. These
classes are virtual and are used as a foundation for other TLM
transport interfaces as described in this chapter.
Example 5-16 shows how to use a non-blocking forward port for nonblocking transportation, instantiate the port in the initiator and call the
nb_transport_fw() API from within the port.
Example 5-16
Example 5-17 shows how to instantiate the export in the target and
implement the nb_transport_fw() functionality locally:
Example 5-17
Example 5-18 shows how to instantiate the initiator and target and bind
the nb_export with the nb_port.
Example 5-18
Sockets
OSCI-TLM 2.0 uses sockets to communicate between transaction
level elements. A similar set of methods is in VMM, which helps
lowering the learning curve for SystemC engineers. This section
describes how you can connect VMM objects to fulfill necessary
communication completion models.
Sockets group together all the necessary core interfaces for
transportation and binding, allowing more generic usage models
than just TLM core interfaces.
OSCI-TLM 2.0 does not recommend the usage of TLM coreinterfaces without sockets. However, the socket infrastructure
restricts the binding model and in SystemVerilog. You need to
implement all functions even if you do not use them. You can
consider this to be unnecessary as the flexibility of the coreinterfaces is more suitable for verification connection models.
The vmm_tlm_initiator_socket and
vmm_tlm_target_socket are generic convenience sockets
ready for you to use. You can use these sockets as blocking or nonblocking transportation mechanisms.
Example 5-19 shows how to instantiate an initiator socket in the
initiator and call the nb_transport_fw method. You must
implement the backward path function nb_transport_bw even if it
is not used, because other sockets might call this function.
Example 5-19
...
virtual function vmm_tlm::sync_e nb_transport_bw(
int id=-1, my_trans trans,
vmm_tlm::phase_e ph,ref int delay);
// Implement incoming backward path function
return vmm_tlm::TLM_COMPLETED;//finish transaction
endfunction: nb_transport_bw
virtual task run_ph();
...
socket.nb_transport_fw(trans, ph, delay); // Forward
path
endtask: run_ph
endclass: initiator
Example 5-21 shows how to instantiate the initiator and target and
bind the sockets together.
Example 5-21
vmm_tlm::phase_e)
nb_export = new(this,"target_export");
...
function vmm_tlm::sync_e nb_transport_fw(
int id=-1,
my_trans trans,
ref vmm_tlm ph,
ref int delay);
trans.display("From Target"); //execute transaction
return vmm_tlm::TLM_ACCEPTED; //finish completion
//model
endfunction: nb_transport
endclass: target
Generic Payload
Generic payload is a class that has been introduced in OSCI TLM
2.0. It is primarily aimed at bus-oriented protocols, such as, AHB,
OCP, etc. Generic payload contains data members such as,
address, payload, command, etc. It can support other protocols with
this base class by using the extension member.
You should derive a transaction from vmm_data to have complete
control over the data object and an abstract implementation that you
can reuse throughout the environment. You can use this vmm_data
with all objects including generators and channels.
You derive the vmm_tlm_generic_payload from
vmm_rw_access and use it to mainly simplify the task of bringing
existing TLM SystemC generic payload objects into a VMM
environment.
Example 5-25 shows the use of a generic payload, where the initiator
class has a bi-directional non-blocking port parameterized on
vmm_tlm_generic_payload.
The following initiator class has a bi-directional non-blocking port
parameterized on vmm_tlm_generic_payload.
Example 5-25
vmm_tlm::phase_e ph;
vmm_tlm::sync_e status;
...
ph = vmm_tlm::BEGIN_REQ;
status = nb_port.nb_transport_fw(trans, ph, delay);
endtask: run_ph
function vmm_tlm::sync_e nb_transport_bw(int id=-1,
vmm_tlm_generic_payload trans,
ref vmm_tlm::phase_e ph,
ref int delay);
...
ph = vmm_tlm::END_RESP;
return vmm_tlm::TLM_COMPLETED;
endfunction: nb_transport_bw
endclass: initiator
endtask: run_ph
endclass: target
//observers
endtask: run_ph
endclass: monitor
Example 5-30 shows how to instantiate the objects and connect the
ports.
Example 5-30
Example 5-33 shows how to instantiate the objects and bind the
ports to respective places.
Example 5-33
Peer IDs
When you use peer IDs, you need only one write()
implementation. Within it you can identify which port is performing
the access and execute the appropriate functionality.
Example 5-34 shows how to use single_export with peer_id. It
instantiates the analysis_port within the transmitter and call the
write() function.
Example 5-34
Example 5-36 shows how to instantiate the objects and bind the
ports to respective places using peer IDs.
Example 5-36
endfunction: connect_ph
endclass: env
Example 5-43 shows how to create a consumer class with a nonblocking forward transport export.
Example 5-43
...
//process the transactions received from the initiator
endfunction: nb_transport_fw
endclass: target
Example 5-47 shows how to bind the channels non-blocking bidirectional export to the non-blocking bi-directional port of the
initiator using the vmm_connect#(.D(d))::tlm_bind utility
class method.
Example 5-47
t0.in_chan,
i0.nb_port,
vmm_tlm::TLM_NONBLOCKING_EXPORT);
endfunction: connect_ph
endclass: subenv
Advanced Usage
Updating Data in Analysis Ports From vmm_notify
VMM has a default subscription based listener model based on
vmm_notify. You can use VMM notification service (vmm_notify)
to connect a transactor, a channel, or any other testbench
component to a scoreboard or functional coverage collector or any
other passive observer. There can be multiple observers, and they
will all see the same transaction stream.
There are pre-defined notification in vmm_xactor and
vmm_channel readily available for review and use.
Example 5-48 shows how to configure your notification normally and
call the indicate() API as usual.
Example 5-48
...
endclass
endclass
Finally, you instance the objects and bind the analysis port to any
subscribing analysis_export. Thus, when vmm_notifier
indicates the data object, analysis_exports observes it.
The vmm_connect class has the following methods that you can
use for channel/notification connectivity.
class vmm_connect#(T)::channel(ref T upstream, downstream,
string name= , vmm_object parent = null);
You should not attempt to connect two channels that are already
connected together or to another channel.
Example 5-52 shows how to use the vmm_connect#(T,N,
D)::notify() method to connect notification to the subscriber
such as, scoreboard.
Example 5-52
Using vmm_connect::notify()
class scoreboard;
virtual function void observe_trans(ahb_trans tr);
...
endfunction
endclass
`vmm_notify_observer(scoreboard, observe_trans)
class ahb_unit extends vmm_group;
scoreboard sb;
virtual function void build_ph();
sb = new();
endfunction
virtual function void connect_ph();
vmm_connect#(.N(scoreboard), .D(ahb_trans))::notify(
sb, mon.notify, mon.TRANS_STARTED);
endfunction
endclass
The order in which you select transactions for execution is protocolspecific and out of the scope of this book. Such transactors use a
non-blocking completion model.
As shown in Figure 5-4, you do not block the execution thread from
the producer transactor (depicted as a dotted line) while the
transaction descriptor flows through the channel and the consumer
transactor executes it. You block it only when the channel is full and
it unblocks as soon as the channel is empty, regardless of whether
the transaction is complete or not.
Figure 5-4
Transactor
Transactor
Channel
Producer
(upstream)
Consumer
(downstream)
...
... begin
transaction tr;
...
out_chan.put(tr);
fork
begin
automatic transaction w4tr = tr;
w4tr.wait_for(vmm_data::ENDED);
...
end
join_none
...
end
endtask: main
...
endclass: producer
Example 5-55
Completion Channel
Transactor
Transactor
Input Channel
Completion Channel
Producer
(upstream)
Consumer
(downstream)
forever begin
...
this.in_chan.get(tr);
tr.notify.indicate(vmm_data::STARTED);
...
begin
transaction_resp resp = new(...);
tr.notify.indicate(vmm_data::ENDED, resp);
this.compl_chan.sneak(resp);
end
end
endtask: main
endclass: consumer
When you can use the transaction descriptor 's properties to specify
completion status information, you modify these properties by the
consumer transactor to provide status information back to the
producer transactor.
A single transaction descriptor might result in multiple completion
responses back through the completion channel. When you use the
same instance, subsequent responses might modify the content of
prior responses before the producer transactor has time to process
them.
Using separate instances for each response ensures that you
receive an accurate report of the history of the transaction execution
via the completion channel.
If the transaction descriptor does not have properties that you can
use to specify completion status information, the consumer
transactor can provide status information back to the upstream
transactor via a different status descriptor supplied through the
completion channel.
Figure 5-6
Transactor
Channel
Producer
(upstream)
Consumer
(downstream)
Example 5-58
Transactor
Resp Req Channel
Response Channel
Requestor
(upstream)
Responder
(downstream)
Note: You only use the reactive response model to obtain higher-level
data the protocol carries. Where the protocol fully defines the
entire set of possible responses, the reactive transactor internally
generates the response.
For example, deciding to reply to a USB transaction with an ACK,
NACK, STALL packet or not replying at all can be entirely decided
internally. However, a reactive response model should provide the
content and length of a DATA packet in reply to an IN transaction.
Note you provide the response within sufficient time to avoid
breaking the protocol.
The suitability and proper implementation of this response model
requires that reactive transactors adhere to the following guidelines.
VMM User Guide
5-58
Requesting a Response
this.resp_chan.get(resp);
#(...);
join_any
disable fork;
if (resp == null) ...
...
end
endtask: main
endclass: responder
end
endtask: main
endclass: responder
vmm_tlm_reactive_if
VMM provides a methodology to facilitate writing reactive
transactors using a polling approach rather than an interrupt
approach. The reactive interface should be instantiated in a
consumer transactor to connect to multiple producers.
It provides blocking and non-blocking (forward and bi-directional)
transport exports and can be bound to more than one transport port.
b_port.b_transport(tr,delay);
endtask: run_ph
endclas: producer
Consumer with TLM reactive interface
class consumer extends vmm_xactor;
vmm_tlm_reactive_if#(my_trans, 4) reac_export1 =
new(this, "export1");
virtual task run_ph();
my_trans trans;
fork
while (1)
begin
reac_export1.get(trans);
reac_export1.completed();
end
join_none
endtask : run_ph
endclass : consumer
Binding reactive interface and TLM Blocking interface
class my_env extends vmm_group;
producer p1;
producer p2;
consumer c;
function void connect_ph();
c.reac_export1.tlm_bind(p.b_port,
vmm_tlm::TLM_BLOCKING_EXPORT);
c.reac_export1.tlm_bind(p.b_port,
vmm_tlm::TLM_BLOCKING_EXPORT);
endfunction
endclass
6
Implementing Tests & Scenarios
Overview
Generating Stimulus
Modeling Scenarios
Modeling Generators
Implementing Testcases
Overview
The verification planning process outlined in Chapter 2 of the VMM
book produces the following three distinct sets of requirements:
- functional coverage
- stimulus generation
- response checking
This chapter focuses on the stimulus generation requirement.
This chapter is of interest to those responsible for creating reusable
test scenarios and testcases through directed or random stimulus.
Directed stimulus can be considered as a subset of random stimulus
and with a properly designed random generator, which can be
created simply. Random generators are aimed at exercising the DUT
according to the requirements outlined in the verification planning
process (VMM Book, Chapter 2).
Random generators should be controllable to cover the entire
spectrum of randomness between pure random and directed
stimulus.
Generating Stimulus
In a typical simulation, thousands of data items or transaction
descriptors are created, which flow through transactors, record and
compare in the self-checking structure. Also, only a handful of data
and transaction sources that need to exist at the beginning of the
simulation and remain in existence until the end are there.
You should model the generation of data (packets, frames,
instructions) or transaction descriptors separately from the data
models themselves because of the different dynamics of their
respective lifetimes.
Random Stimulus
Random stimulus is traditionally used to generate background noise.
However, it should be used in lieu of directed stimulus to implement
the bulk of the testbenches. Coupled with functional coverage to
identify if the random stimulus has exercised the required
functionality, it uses constraints to direct the generation process in
appropriate corner cases.
This section specifies guidelines on how to write autonomous
generators that create a stream of random data or transaction
descriptors.
You should design generators to be easily externally constrained
without requiring modifications of their source code. You then write
constrained-random tests - not by writing a completely new or
slightly modified generator - but by adding constraints and scenario
definitions to the reusable generators that already exist.
Some predefined atomic and scenario generators are available in
the VMM Standard Library. You can then use the
vmm_atomic_gen() and vmm_scenario_gen() macros to
automatically create generators that follow all guidelines outlined in
this section for any user-defined type.
The Multi Stream Scenario Generator (MSSG)
vmm_ms_scenario_gen() provides the capability to implement
hierarchical and reusable transaction scenarios. It controls and
coordinates existing scenarios to achieve a fine-grained control over
stimulus.
As such, all guidelines applicable to transactors are applicable to
generators unless explicitly superseded in this section.
Example 6-1
Example 6-2
Transactor
Channel
Example 6-5
if (!this.randomized_fr.randomize()) begin
vmm_error(this.log, "Unable to find a solution");
continue;
end
Example 6-8 shows how to set the value of the stream identifier class
property. It should be set before every randomization attempt, to
ensure that the user does not accidentally modify the stream
identifier in the randomized instance. It also ensures that the stream
identifier is set consistently even if the randomized instance is
substituted with another instance (for example, using the factory
service).
Example 6-8
constraint eth_frame::tc1 {
...
if (stream_id == 2) {
...
}
}
Directed Stimulus
Directed stimulus is manually constructed to verify a specific feature
of the design or to hit a specific functional coverage point. Not all of
the stimulus needs to be directed.
Random values can be used to fill portions of the stimulus that are
not directly relevant to the feature being exercised. For example, the
content of a packet payload is irrelevant to the correctness of the
packet routing. The only requirement is that it to be transferred
unmodified.
Similarly, the content and identity of the general purpose registers
used in an ADD instruction is not relevant as long as the destination
register eventually contains the accurate sum of the values
contained in the two source registers.
You might also use random stimulus as background noise on the
interfaces, not directly related to the feature you are verifying. The
directed stimulus is focused on the interfaces directly implicated in
the verification of the targeted functionality.
Similarly, directed stimulus might be injected in the middle of random
stimulus. This sequence might help identify problems that might not
be apparent, should the directed stimulus be applied from the reset
state.
Directed stimulus is typically meant to replace random stimulus, not
intermix with it. If the random generator is still running while directed
stimulus are injected into its output stream, the resulting stimulus
sequence is unpredictable.
Generators might be stopped for the duration of the simulation, while
others providing background noise, might keep running as usual.
Generators might be stopped at some points during the simulation,
and then restart after you inject the directed stimulus.
...
task inject(eth_frame fr,
ref bit dropped);
dropped = 0;
vmm_callback(eth_frame_gen_callbacks,
post_inst_gen(this, fr, dropped));
if (!dropped) this.out_chan.put(fr);
endtask: inject
endclass: eth_frame_gen
task directed_stimulus;
eth_frame to_phy, to_mac;
...
to_phy = eth_frame::create_instance(this,"to_phy");
to_phy.randomize();
...
fork
this.host_src_gen0.inject(to_phy, dropped);
begin
// Force the earliest possible collision
@ (posedge this.vif.tx_en); //virtual interface
this.phy_src_gen1.inject(to_mac, dropped);
end
join
...
endtask: directed_stimulus
Generating Exceptions
By default, transactors execute transactions without errors, as fast
as possible. However, the verification of a design necessitates that
the limits of a protocol are stretched and sometimes broken. A
verification environment and the transactors that compose it must
provide a mechanism for injecting exceptions in the execution of a
transaction.
As described in Transactor Callbacks on page 26, you can use the
callback mechanism to cause a transactor to deviate from its default
behavior.
You can inject within a callback, protocol exceptions such as, extra
delays, negative replies or outright errors without modifying the
original transactor. You can define many exceptions and implement
in the callback methods themselves such as, inserting delays or
corrupting the information in the transaction descriptor.
You must implement some exceptions in the transactor itself, such
as ignoring an entire transaction or prematurely terminating a
transaction. In the latter case, callback methods provide the
necessary control mechanism to trigger them.
class mii_mac_collision;
typedef enum {NONE, EARLY, LATE} kind_e;
rand kind_e
kind;
rand int unsigned on_symbol;
int unsigned n_symbols;
constraint early_collision {
if (kind == EARLY) on_symbol < 112;
}
constraint late_collision {
if (kind == LATE) {
on_symbol >= 112;
on_symbol < n_symbols;
}
}
constraint no_collision {
kind == NONE;
}
endclass: mii_mac_collision
Example 6-15
class mii_mac_collision;
...
eth_frame frame;
...
endclass: mii_mac_collisions
Example 6-17
You can also build the random exception generation into a callback
extension. You can use this mechanism to add exception injection
capabilities into a transactor that does not already support them or to
supplement the exceptions the transactor already provides.
Example 6-18 shows how you build the exception generation into a
callback extension.
Example 6-18
Embedded Stimulus
Stimulus is generally understood as being applied to the external
inputs of the design under verification. However, limiting stimulus to
external interfaces might only make it difficult for you to perform
some testcases.
If the verification environment does not have a sufficient degree of
controllability over the design, you might spend much effort trying to
create a specific stimulus sequence to an internal design structure.
This is because; it is too far removed from the external interfaces.
This problem is particularly evident in systems where internal buses
or functional units are not directly controllable from the outside.
You might not need transactors to be limited to driving external
interfaces. You can use them to replace an internal design unit and
provide control over that unit's interfaces.
The transaction-level interface of the embedded transactor remains
externally accessible, making the replaced unit interfaces logically
external. You can similarly replace monitors for slave devices.
For example, an embedded ARM core can be replaced with an
AMBA AHB Interface master transactor as shown in Figure 6-2.
Example 6-19 and Example 6-20 show how to instantiate an
interface in a module and to bind it in the top environment.
Thus generation if transactions is achieved not by executing
instructions but by having the transactor execute the transaction
descriptors.
ARM Core
AMBA AHB
Interface
Master
AMBA AHB Interconnect
You might turn off the rand mode of some properties by default to
prevent generation of invalid data. Errors can be injected by turning
them back on and adding relevant constraints. This procedural
constraint modification can be executed at any time during the
execution of a testcase.
Example 6-21
vmm_xactor host_src;
$cast(host_src,
vmm_object::find_object_by_name("host_src"));
host_src.randomized_obj.dst = this.cfg.mac.addr;
host_src.randomized_obj.dst.rand_mode(0);
host_src.randomized_obj.src = this.cfg.dut_addr;
host_src.randomized_obj.src.rand_mode(0);
class test;
...
class long_eth_frame extends eth_frame;
vmm_typename(long_eth_frame)
constraint long_frames {
data.size() == max_len;
}
endclass: long_eth_frame
...
virtual function start_of_test_ph;
begin
//override default with long_eth_frame derived type
eth_frame::override_with_new(
"@env:host_src:randomized_obj",
long_eth_frame::this_type,
log);
end
endfunction
endclass: test
Example 6-25
Modeling Scenarios
The atomic generator creates a stream of individually randomized
transactions. This is fine for creating broad-spectrum stimulus, but
corner cases are likely to require a more constrained sequence of
transactions.
Scenarios are short sequences of transactions that are directed or
mutually constrained, or a combination of both.
This chapter describes specification of single-stream and multistream scenarios - both random and directed - and hierarchical
scenarios.
Note: The multi-stream scenarios are the recommended way to
model scenarios going forward.
Appendix A includes detailed documentation for,
vmm_scenario_gen and
vmm_scenario::define_scenario(),
vmm_ms_scenario_gen and vmm_ms_scenario.
Scenario Selection
As shown in Figure 6-3, a generator selects to generate the next
scenario among all of the scenarios you register with it, by
randomizing its vmm_scenario_gen::select_scenario or
vmm_ms_scenario_gen::select_scenario class property.
The final value of the vmm_scenario_election::select or
vmm_ms_scenario_election::select identifies the scenario.
The generator interprets it as the index in the
vmm_scenario_gen::scenario_set[$] or
vmm_ms_scenario_gen::scenario_set[$] of the scenario
generated.
Figure 6-3
Scenario Generator
1. randomize()
select_scenario
2. randomize()
scenario_set[$]
Scenario Descriptor
virtual task apply()
virtual task execute()
3. apply() or execute()
Output Channel(s)
Modeling Generators
Atomic Generation
Atomic generation is the generation of individual data items or
transaction descriptors. It generates each of them independent of
the items or descriptors that was previously or subsequently
generated.
Atomic generation is like using a random function that returns a
complex data structure instead of a scalar value.
Atomic generation is simple to describe and use as shown in
Example 6-28. Its ease of use is the reason why you use atomic
generation to illustrate most of the generation and constraints
examples in this book and in other literature.
However, it is unlikely to create interesting stimulus sequences on its
own even with the addition of constraints.
Example 6-28
Atomic Generator
Multiple-Stream Scenarios
Multi-stream scenarios are able to inject stimulus on multiple output
channels. Unlike single-stream scenarios, you do not tie multistream scenarios to a particular channel. They have the flexibility to
access any channel in the environment. You must explicitly define
them by extending their vmm_ms_scenario::execute() method.
That is not to say that random multi-stream scenarios are not
possible! You can implement a random multi-stream scenario by
defining properties as rand or by calling randomize() from within
the vmm_ms_scenario::execute() method.
As shown in Figure 6-4, multi-stream scenarios interact with
channels identified by logical names. This allows to execute the
same scenario on a different set of channels.
Channels are associated with a logical name by registering them
with an instance of a multi-stream scenario generator by using the
vmm_ms_scenario_gen::register_channel() method.
"Rx".get()
"Tx".put()
"Bb"
Transactor
Scenario Descriptor
Scenario Descriptor
Channel Registry
"Rx"
"Tx"
Transactor
"Rx".get()
"Tx".put()
Procedural Scenarios
Multi-stream scenarios are procedural scenarios, which do not have
a pre-defined default random scenario. The only implicit
randomization is the randomization of the multi-stream scenario
descriptor before you execute it.
The body of the multi-stream scenario is completely under your
control and could include further randomization of local variables and
data members. Or the hierarchical execution of child scenarios,
depending on the your intention.
You must specify a multi-stream scenario by overloading the
vmm_ms_scenario::execute() task in an extension of the
vmm_ms_scenario class. You must specify each multi-stream
scenario as a separate class extension. The execution of this task
constitutes the multi-stream scenario.
It is required that for each scenario the
vmm_ms_scenario::copy() should be overloaded for
multistream scenarios to return the copy of the scenario.
The easiest way to achieve this is to use the shorthand macros.
`vmm_scenario_member_begin(..)
...
vmm_scenario_member_end(..)
Example 6-30
endclass
endfunction
virtual function vmm_data copy(vmm_data to = null);
exclusive_scenario cpy;
if (to == null)
cpy = new(this.get_parent_scenario());
else $cast(cpy, to);
$cast(cpy.ahb, this.ahb.copy());
endfunction
virtual task execute(ref int n);
vmm_channel chan = this.get_channel("AHB");
chan.grab(this);
repeat (10) chan.put(this.ahb, .grabber(this));
chan.ungrab(this);
n += 2;
endtask
vmm_class_factory(exclusive_access)
endclass
Hierarchical Scenarios
Multi-stream scenarios can be composed of other single-stream and
multi-stream scenarios. There are two types of hierarchical
scenarios: "contained" and "distributed".
A contained multi-stream scenario is entirely described and
executed by a multi-stream scenario descriptor. It executes within
the context of a single multi-stream scenario generator, as shown in
Figure 6-4. The sub-scenarios in a contained hierarchical scenario
execute on the same logical channels as the top-level scenario.
Example 6-32
Figure 6-5
Scenario Descriptor
Tx.put()
IO.Aa.execute()
BUS.Xx.execute()
BUS.OCP.put()
Channel Registry
Tx
Transactor
Generator Registry
IO
BUS
Rx.get()
Tx.put()
Bb
Transactor
Scenario Descriptor
Scenario Descriptor
Channel Registry
Rx
Tx
Transactor
AHB.put()
OCP.put()
AHB.put()
OCP.put()
Xx
Scenario Descriptor
AHB.put()
OCP.put()
Transactor
Scenario Descriptor
Channel Registry
AHB
OCP
Transactor
Example 6-33
...
end
Available Scenarios
The scenarios that are available to be generated by the generator
must be registered with a generator. By default, single-stream
scenario generators only know about the "atomic" scenario and
multi-stream scenario generators do not know about any scenarios.
Example 6-36 shows how to remove the default atomic scenario
from a single-stream scenario generator instance.
Example 6-36
Example 6-37
Registering Scenarios
if (scenario_id == 0) select == 0;
if (scenario_id == 1) select == 1;
if (scenario_id > 1) select > 1;
}
endclass
task my_test::run(vmm_env env);
env.build();
begin
a_then_b_then_random sel = new;
foreach_vmm_xactor(vmm_ms_scenario_gen,
"/./", "/./") begin
a_scenario a = new;
b_scenario b = new;
xact.scenario_set.push_front(b);
xact.scenario_set.push_front(a);
xact.select_scenario = sel;
end
end
env.run();
endtask
vmm_object::find_object_by_name("top_gen"));
directed_test test = new;
top_gen.push_front(test);
top_gen.stop_after_n_scenarios = 1;
end
env.run();
endtask
Constraining Transactions
The items class property in single-stream scenario descriptors
implements a two-stage factory for generating random transactions:
env.build();
begin
my_ahb_tr tr = new;
foreach (env.gen.scenario_set[i]) begin
env.gen.scenario_set[i].using = tr;
end
end
env.run();
end
Single-Stream Scenarios
The single-stream scenario generator is a type-specific generator
that you declare using the vmm_scenario_gen() macro as shown
in Example 6-44. This creates a class named
class_name_scenario_gen where class_name is the name of
the user-defined class you supply to the macro.
Random Scenarios
By default, single-stream scenarios are randomly generated. The
combination of three things makes this happen:
A single-stream scenario descriptor contains a rand array of userdefined transaction descriptors in the
class_name_scenario::items[] class property.
vmm_typename(bad_eth_frames)
function new();
this.define_scenario("Bad Frames", 10);
endfunction
constraint bad_eth_frames_valid {
foreach (this.items) {
this.items[i].fcs != 0;
}
}
vmm_class_factory(bad_eth_frames)
endclass
Procedural Scenarios
Procedural or directed scenarios are specified by overloading the
class_name_scenario::apply()method. Any user-defined
code can use the procedural scenario that puts transaction
descriptors into the supplied output channel. The total number of
procedurally generated transactions is then returned via the
n_insts argument.
Note: It is important that you do not call super.apply(), else any
transaction descriptor found in the
class_name_scenario::items[] class property will also be
injected into the output channel.
You can create random transactions by using rand class properties
(such as, the predefined class_name_scenario::items[]
class property), or by explicitly calling randomize() on local
variables or non-random class properties.
Example 6-47
bit is_set;
mii_if_wrapper if_wrapper;
this.define_scenario("Collision", 1);
$cast(if_wrapper,
vmm_opts::get_object_obj(is_set, this,
"mii_if_wrapper"));
this.sigs = if_wrapper.sigs;
endfunction
virtual task apply(eth_frame_channel channel,
ref int unsigned n_insts);
@ (posedge this.sigs.crs);
channel.put(this.items[0]);
n_insts++;
endtask
vmm_class_factory(collision)
endclass
Hierarchical Scenarios
You can describe scenarios hierarchically by composing them of
lower-level scenarios. A hierarchical scenario is a procedural
scenario. You simply instantiate the lower-level scenario descriptors
in the higher-level scenario descriptor.
The higher-level scenarios apply() method calls the lower-level
scenarios respective apply() method in the appropriate
sequence.
Example 6-49
vmm_class_factory(bad_frames)
endclass
foreach_vmm_xactor(eth_frame_scenario_gen,
"/./", "/./") begin
mii_phy
phy;
if ($cast(phy, xact.out_chan.get_consumer())) begin
bad_frames_then_collision btc =
bad_frames_then_collision::create_instance(
this,"bad_col");
bad_eth_frames
bad =
bad_eth_frames::create_instance(this,"bad");
xact.register_scenario("Bad then Col", btc);
xact.register_scenario("Bad Burst", bad);
end
end
this.col = collision::create_instance(...);
this.ddd.set_parent_scenario(this);
this.bad.set_parent_scenario(this);
this.col.set_parent_scenario(this);
endfunction
virtual task apply(eth_frame_channel channel,
ref int unsigned n_insts);
channel.grab(this);
this.bad.apply(channel, n_insts);
this.col.apply(channel, n_insts);
channel.ungrab(this);
endtask
vmm_class_factory(bad_frames_then_collision)
endclass
By using macros
Implementing Testcases
The vmm_test base class must be used to implement test cases.
For each testcase, you should create a new class that extends
vmm_test. You must implement a testcase using the phasing
mechanism of the environment for which it is written.
You can write testcases using an implicitly-phased or explicitlyphased top-level environment. For details, see Understanding
Implicit and Explicit Phasing on page 31.
super.new(test1);
endfunction
endclass: test1
`include vip_trans.sv
class test2_trans extends vip_trans;
`vmm_typename(test2_trans)
constraint { }
vmm_data_member_begin(test2_trans)
vmm_data_member_end(test2_trans)
endclass: test2_trans
class test2 extends vmm_test;
function new();
super.new(test2);
endfunction
virtual function void configure_test_ph();
// Replace factory transaction with extended type
vip_trans::override_with_new(@%*,
test2_trans::this_type(), log);
endfunction
endclass: test2
Running Tests
An explicitly phased verification environment can simulate only one
test per run. The test is run by calling
vmm_test_registry::run() in a program thread. If a single test
class exists in the simulation, that is the test that is run by default. If
multiple test classes exist, you must specify the name of the test to
run using the +vmm_test option.
Example 6-57 shows how to register multiple tests and run them, this
is the recommended way for explicitly phased environments.
Example 6-57
Example 6-58
program top;
initial
begin
my_env env = new("env");
test1 t1 = new("test1");
test2 t2 = new("test2");
vmm_simulation::run_tests();
end
endprogram
7
Common Infrastructure and Services
Common Object
Message Service
Common Object
Overview
The vmm_object is a virtual class that is used as the common base
class for all VMM-related classes. It provides parent/child
relationships for all VMM class instances. Additionally, it provides
local, relative and absolute hierarchical naming. Combined with
regular expressions, it makes it easy to locate all specific objects that
match a given pattern in any hierarchy. This base class comes with
a rich set of methods for assigning, querying, printing and traversing
object hierarchies.
This section contains the following topics:
- Setting Object Relationships
- Finding Objects
- Printing and Displaying Objects
- Object Traversing
- Namespaces
[e1]
|--[v1]
|-----[c1]
[orphan]
[e1]
|--[v1]
[orphan]
|--[c1]
vmm_object parent;
env e1 = new ("env","e1");
parent = e1.v1.c1.get_parent_object();
// parent of c1 is now v1
Finding Objects
Given that different components directly or indirectly extend the
vmm_object base class, you can use pre-defined methods to query
hierarchical names, find objects and children by name, find the root
of an object and so on. While invoking these functions, you can use
the simple match patterns or complete regular expressions to define
the search criteria.
The get_object_hiername() and get_object_name()
methods return the full hierarchical name and local name of the
object respectively. A hierarchical name is composed of series of
colon-separated object names, usually starting from a root object
through parent-child relationships.
The methods find_child_by_name() and
find_object_by_name() find the named object as a hierarchical
name relative to this object or absolute hierarchical name
respectively in the specified namespace.
The get_nth_root() and the get_nth_child() methods
return the nth root and the nth child respectively of the specified
object.
Example 7-5 shows how to use the various methods to find and
query objects.
Example 7-5
obj = e1.find_child_by_name("c1");
// obj is now c1
obj = e1.get_nth_child(0);
// obj name is now "v1"
root = E::get_nth_root(1);
// root name is now "orphan"
vmm_object::print_hierarchy(e1);
Object Traversing
The vmm_object_iter class traverses the hierarchy rooted at the
specified object, looking for objects whose relative hierarchical name
matches the specified name. Beginning at a specific object, it can
traverse through the hierarchy via the
vmm_object_iter::first() and
vmm_object_iter::last() methods.
Continuing from the previous example, Example 7-7 shows how to
traverse an object hierarchy.
Example 7-7
Namespaces
VMM introduces the concept of namespace for object. The main
purpose of namespace is to attach objects to a given space. This is
particularly useful when a given lower-stream transactor must
execute transactions from various upper-stream transactors like
multi-stream scenario generator, RAL and other transactors.
Because each upper-stream transactor can tag its transaction to be
executed with its namespace, it is easier to determine where this
transaction is coming from by simply looking into its namespace.
For instance, all transactions that a RAL application initiates belong
to its space event though signal-level transactors execute them.
More explicitly, if you initiate an abstract call to register like
my_ral.write(IRQ_EN, 32'h01), the associated bus
transaction like AXI.WRITE(32'h1000, 32'h01) becomes
tagged with the RAL namespace and you can easily associate its
source.
You can specify a namespace optionally at the beginning of a pattern
using the namespace scope operator ::. A namespace might contain
any character except a colon (:). If you do not specify a namespace,
you use the object namespace. An error is issued if an unknown
namespace is specified.
For example, looking for a leaf object named X in the RAL
namespace would be specified as,
RAL::%:X
Message Service
This section contains the following topics:
- Overview
- Message Source
- Message Type
- Message Severity
- Message Filters
- Simulation Handling
- Issuing Messages
- Shorthand Macros
- Filtering Messages
- Redirecting Message to File
- Promotion and Demotion
- Message Catcher
- Message Callbacks
- Stop Simulation Depending Upon Error Number
Overview
Transactors, scoreboards, assertions, environment and testcases
use messages to report any definite or potential errors detected.
They might also issue messages to indicate the progress of the
simulation or provide additional processing information to help
diagnose problems.
To ensure a consistent look and feel to the messages issued from
different sources, you should use a common message service. It
only concerns a message service with the formatting and issuance
of messages, not their cause. For example, the time reported in a
message is the time at which the message was issued, not the time
a failed assertion started.
VMM message service uses the following concepts to describe and
control messages:
Message Source
Each instance of the message service interface object represents a
message source. A message source can be any component of a
testbench: a command-layer transactor, a sub-layer of the selfchecking structure, a testcase, a generator, a verification IP block or
a complete verification environment. Messages from each source
can be controlled independently of the messages from other
sources.
Message Type
Individual messages are categorized into different types by the
author of the code used to issue the message. Assigning messages
to their proper type lets a testcase or simulation produce and save
only (or all) messages that are relevant to the concerns addressed
by a simulation. Table 7-1 summarizes the available message types
and their intended purposes:
Table 7-1
Message Types
Message Type
Purpose
vmm_log::FAILURE_TYP
vmm_log::NOTE_TYP
vmm_log::DEBUG_TYP
vmm_log::TIMING_TYP
vmm_log::XHANDLING_TYP
Message Type
Purpose
vmm_log::REPORT_TYP
vmm_log::PROTOCOL_TYP
vmm_log::TRANSACTION_TYP
vmm_log::COMMAND_TYP
vmm_log::CYCLE_TYP
vmm_log::INTERNAL_TYP
Message Severity
Individual messages are categorized into different severities by the
author of the code used to issue the message. A messages severity
indicates its importance and seriousness and must be chosen with
care. For fail-safe reasons, certain message severities cannot be
demoted to arbitrary severities. Table 7-2 summarizes the available
message severities and their meaning:
Table 7-2
Message Severities
Message Severity
Indication
vmm_log::FATAL_SEV
vmm_log::ERROR_SEV
vmm_log::WARNING_SEV
vmm_log::NORMAL_SEV
vmm_log::TRACE_SEV
Message Severity
Indication
vmm_log::DEBUG_SEV
vmm_log::VERBOSE_SEV
Message Filters
Filters can prevent or allow a message from being issued. Filters are
associated and disassociated with message sources. They are
applied in order of association and control messages based on their
identifier, type, severity or content. Message filters can promote or
demote messages severities, modify message types and their
simulation handling. After a message has been subjected to all the
filters associated with its source, its effective type and severity may
be different from the actual type and severity originally specified in
the code used to issue a message.
Simulation Handling
Different messages require different action by the simulator once the
message has been issued. Table 7-3 summarizes the available
message handling and their default trigger:
Table 7-3
Simulation Handlings
Simulation Handling
Action
vmm_log::ABORT_SIM
vmm_log::COUNT_ERROR
vmm_log::STOP_PROMPT
vmm_log::DEBUGGER
vmm_log::DUMP_STACK
vmm_log::CONTINUE
Shorthand Macros
A simple way of issuing messages can be achieved with macros.
These macros provide a shorthand notation for issuing single-line
failure messages.
Available shorthand macros are:
- vmm_normal(log, str)
- vmm_trace(log, str)
- vmm_debug(log, str)
- vmm_warning(log, str)
- vmm_error(log, str)
- vmm_fatal(log, str)
Example 7-9
`vmm_debug(this.log,
$psprintf("Transmitting frame...%s",
fr.psdisplay("
")));
Issuing Messages
This section describes how to issue messages from within
transactors, data and transaction models, the self-checking
structure, the verification environment itself or testcases.
Issuing messages is simply done by instantiating a vmm_log object
and using its methods log::start_msg(), log::text(),
log::end_msg().
Do not use $display() to manually produce output messages. If
you must invoke a predefined method that produces output text
(such as, the vmm_data::psdisplay() method), do so within the
context of a message.
Example 7-11 shows how to issue a message with DEBUG severity.
It is similar to Example 7-10.
Filtering Messages
It is possible to filter out messages based on their specific type and
severity. The default severity of vmm_log can be set globally using
a run time switch
+vmm_log_default=<sev>
program automatic P;
class A;
vmm_log log = new("SEQ_GT_COLLECTOR", "seq_cltr");
task call_msg();
begin
`vmm_warning(log, "Warning: Hello collected");
`vmm_error(log, "Error: Hello collected");
end
endtask
endclass
vmm_log log=new("Top", "program");
A a;
initial begin
a = new;
// Disable message type of all "SEQ_GT_COLLECTOR"
// instances to a FAILURE
log.disable_types(vmm_log::FAILURE_TYP,
"SEQ_GT_COLLECTOR", "seq_cltr",);
// Change message verbosity of all "SEQ_GT_COLLECTOR"
// instances to an ERROR
log.set_verbosity(vmm_log::ERROR_SEV,
"SEQ_GT_COLLECTOR", "seq_cltr",);
a.call_msg();
end
endprogram
Note: You can globally force the minimum severity level with
+vmm_force_verbosity=<sev> runtime command-line
option.
Example 7-13
log.log_stop(log_descr, "program","Test");
`vmm_error(log, "message in STDOUT") ;
end
endprogram
Note: The last argument specifies the log to call the debugger.
For details, see vmm_log::modify() in Annex A.
Message Catcher
In some cases, you might want your environment to execute specific
code whenever a given message is issued by any of its components.
endclass
initial begin
env = new();
error_catcher catcher = new();
env.build();
catcher_id = env.sb.log.catch(catcher,,,1,,
vmm_log::ERROR_SEV,
"/Mismatch/");
env.run();
end
initial begin
env = new();
error_catcher catcher = new();
env.build();
catcher_id = env.sb.log.catch(catcher,/./,/./,1,,
vmm_log::ERROR_SEV,
"/Mismatch/");
env.run();
end
Message Callbacks
The Message Service Class provides an efficient way of controlling
the simulation and debugging your environment when certain
messages are issued.
vmm_log provides pre-defined callbacks that are defined in
vmm_log_callbacks object. Callbacks are associated with the
message service itself, not a particular message service instance.
The available virtual methods are:
vmm_log_callbacks::pre_abort()
vmm_log_callbacks::pre_stop()
vmm_log_callbacks::pre_debug()
`include "vmm.sv"
program automatic test_log;
class cb extends vmm_log_callbacks;
virtual function void pre_abort(vmm_log log);
`vmm_note(log, "pre_abort cb has been invoked");
endfunction
endclass
initial begin
vmm_log log = new("", "");
cb cb0 = new;
log.append_callback(cb0);
vmm_fatal(log, "Aborting...");
end // initial begin
endprogram
Overview
Factory Service provides an easy way to replace any kind of object,
transaction, scenario, or transactor by a similar object. This
replacement can take place from anywhere in the verification
environment or in the test case.
The following typical situations are for object oriented extensions:
create_instance()
start_of_sim_ph()
N/A (built-in)
override_with_()
configure_test_ph()
configure_test_ph()
1'b0} kind_e;
`vmm_data_member_begin(cpu_trans)
`vmm_data_member_scalar(address, DO_ALL)
`vmm_data_member_scalar(data, DO_ALL)
`vmm_data_member_scalar(trans_delay, DO_ALL)
`vmm_data_member_enum(kind, DO_ALL)
`vmm_data_member_end(cpu_trans)
`vmm_class_factory(cpu_trans)
endclass
`vmm_channel(cpu_trans)
endclass
Creating Factories
The previous section explains how to model a transaction so that it
can be considered as a factory. This section describes how to
instantiate this object in a transactor.
Usually, an object is declared in a transactor and constructed in its
new() task. This modeling style does not apply for factories. A
factory must be explicitly created in start_of_sim phase.
Note: The create_instance() method is static and must be
prefixed with its class name.
Example 7-21 shows how to instantiate and use the previously
created transaction factory in a Multi-Stream Scenario (MSS). The
scenario has to be instantiated in start_of_sim phase.
Example 7-21
vmm_channel chan;
if (chan == null) chan = get_channel("cpu_chan");
$cast(tr, blueprint.copy());
res = tr.randomize();
chan.put(tr);
endtask
`vmm_class_factory(cpu_rand_scenario)
endclass
Replacing Factories
The factory is now available in the transactor, so you can use it as is
or replace in the test, either by copying it from another transaction or
by constructing it from scratch.
Both use models are made possible using the
class_name::override_with_copy() or
class_name::override_with_new() functions.
Example 7-22 shows how to add two transactors to a program block
and use the default factory, i.e. cpu_trans.
Example 7-22
Example 7-24 shows how to replace the initial factory with a derived
object.
Example 7-24
program P;
class cpu_trans #(type T=int) extends vmm_data;
`vmm_typename(cpu_trans#(T))
T value;
`vmm_data_member_begin(cpu_trans#(T))
`vmm_data_member_end(cpu_trans#(T))
`vmm_class_factory(cpu_trans#(T))
endclass
class cpu_gen #(type T=int) extends vmm_xactor;
`vmm_typename(cpu_gen#(T))
cpu_trans #(T) tr;
function new(string inst, vmm_unit parent=null);
super.new("cpu_driver", inst, , parent);
tr = cpu_trans#(T)::create_instance(this, "MY_TRANS");
tr.display();
endfunction
endclass
class my_cpu_trans #(type T=int) extends cpu_trans#(T);
`vmm_typename(my_cpu_trans#(T))
`vmm_data_member_begin(my_cpu_trans#(T))
`vmm_data_member_end(my_cpu_trans#(T))
T value;
`vmm_class_factory(my_cpu_trans#(T))
endclass
class tb_env extends vmm_group;
cpu_gen#(string) gen;
function new(string inst = "env");
super.new("tb_env", inst);
endfunction
virtual function void build_ph();
gen = new("gen", this);
endfunction
endclass
endfunction
endclass: test
allocate = scn;
endfunction
function vmm_data copy(vmm_data to = null);
test_scenario scn = new;
scn.TST_KIND = this.TST_KIND;
scn.stream_id = this.stream_id;
scn.scenario_id = this.scenario_id;
copy = scn;
endfunction
`vmm_class_factory(test_scenario)
endclass
endfunction
endclass
Overview
VMM comes with comprehensive ways of configuring transactors,
components and verification environments.
You can use,
- Hierarchical options to get options from command line,
command file or in the VMM code directly.
- Structural options to configure transactors and ensure their
configuration are well set in the configure phase in a given
phase called configure.
- RTL configuration to configure both RTL and verification
environment.
function build_ph();
vip vip0 = new("vip0", null);
vip vip1 = new("vip1", null);
endfunction
VMM User Guide
7-45
function start_ph();
vmm_opts::set_bit("vip0:b",null);
vmm_opts::set_int("vip0:i",null);
vmm_opts::set_bit("vip1:b",null);
vmm_opts::set_int("vip1:i",null);
$display("
$display("
$display("
$display("
endfunction
Value
Value
Value
Value
of
of
of
of
vip0:b
vip0:i
vip1:b
vip1:i
is
is
is
is
%0b",
%0d",
%0b",
%0d",
vip0.b);
vip0.i);
vip1.b);
vip1.i);
Example 7-34
Option File
+B =88@d2:b1
+B =99@d1*
+I = 0
+STR=NEW_VAL2@c2:b1
The following example shows how its default values are returned
when no options are specified on the command line:
% ./simv
Chronologic VCS simulator copyright 1991-2008
Contains Synopsys proprietary information.
Value of vip0:b is 0
Value of vip0:i is 0
Value of vip1:b is 0
Value of vip1:i is 0
Simulation PASSED on /./ (/./) at
0
(0 warnings, 0 demoted errors & 0 demoted warnings)
V C S
S i m u l a t i o n
R e p o r t
Time: 0
CPU Time:
0.020 seconds;
Data structure size:
0.0Mb
For details on all available options, see the VMM Reference Guide.
Structural Configurations
Structural configuration is an important aspect of verification
environment composition. This is usually required for dynamically
building verification components based upon configurations
specified either on the command line or in a command file. You can
set these configurations on an instance basis or hierarchically by
using regular expressions.
Configuration parameters that affect the structure of the environment
itself you must set during the "build" phase and implement the
vmm_unit::build_ph() method.
You can specify these configuration parameters using options, but
you typically set using RTL configuration parameters. Because you
invoke the vmm_unit::build_ph() methods in a top-down order,
procedural parameter settings from higher-level modules supersede
procedural parameter settings from lower-level modules.
Due to the nature of structural configurations, there is no need for
automatic randomization of structural configuration parameters.
command-line options.
int_data_member,doc",
def_value, transactor)
vmm_unit_config_boolean(boolean_data_member,"doc",
def_value, transactor)
vmm_unit_config_string( string_data_member,"doc",
def_value, transactor)
Example 7-36
RTL Configuration
RTL configuration is an important aspect for ensuring that the RTL
and testbench share the same configuration. This can be handy for
sharing parameters such as,
(RTL_config_name,
RTL_config_fname)
`vmm_rtl_config_boolean(RTL_config_name,
RTL_config_fname)
`vmm_rtl_config_string (RTL_config_name,
RTL_config_fname)
endfunction
function void configure_ph();
$cast(cfg, vmm_rtl_config::get_config(this);
endfunction
endclass
You activate the file generation when running the simulation with
+vmm_gen_rtl_config option.
In this case, the simulator considers all objects that extend
vmm_rtl_config base class. During this phase, all transactor
configurations are created, randomized and their content is dumped
to multiple RTL configuration files. No simulation is run during this
pass.
The following example shows how to create RTL configuration files
by prefixing all output files with RTLCFG:
% ./simv +vmm_rtl_config=RTLCFG +vmm_gen_rtl_config
% more RTLCFG:env_cfg:mst_cfg.rtl_conf
mst_width : 64;
mst_enable : 1;
kind
: MSTR;
Overview
Simple match pattern performs hierarchical name matching in a
specific hierarchical namespace. As vmm_object instance names
are in the form of top::subenv::vip, writing usual regular
expressions can be cumbersome and require to escape all delimiters
consisting of :. character.
To overcome this issue, VMM comes with a rich set of custom regular
expressions. These expressions perform hierarchical name
matching in a specific hierarchical namespace. Using this custom
regular expression is turned on by simply appending the@
character before the expression.
Here is a description of specific character that VMM regular
expression interprets:
- : is used as hierarchical name separator, . character with
no need to be escaped
- @ is used to indicate a match pattern
- / is used for normal regular expressions
A match pattern matches every character as-is, except for metacharacters, which match in the following manner:
Pattern
Description
@%.
t:sub_env
@%*
top
top:sub_env
top:sub_env:vip
top:
top:sub_env:
top:sub_env:vip:
@%?
t
t:s
t:s:v
t ::v
top
top:sub_env
top:sub_env:vip
top:sub_env0:vip
top:sub_env1:vip
top:vip
top:sub_env0:slice0:vip
Matches
top:sub_env0:vip
8
Methodology Guide
Recommendations
Transactions
If the transaction object has a parent, only then you should copy
the parent handle while creating a new object in the copy()
method. Deep copy of the parent object is not recommended.
Message Service
Make calls to text output tasks only once it you have confirmed
that a message is issued.
Transactors
Callbacks
Channels
Environments
You should not directly add directed stimulus to the public output
channel.
Use analysis ports for events with status/data because they are
strongly-typed.
Configuration
Rules
Transactions
You shall derive data and transaction model classes from the
vmm_data class.
All data classes shall have a public static class property referring
to an instance of the message service vmm_log.
Data protection class properties shall model their validity, not their
value.
Message Service
Transactors
Callbacks
Arguments that you must not modify shall have the const
attribute.
You must use callback and not analysis ports to convey the
transactions that may be modified.
Channels
Environments
Use the bit type for all clock and reset signals.
Notifications
For implicitly phased tests, you should not have any code in the
build, configure and connect phases as they will not be executed
when the tests are concatenated.
9
Optimizing, Debugging and Customizing
VMM
Customizing VMM
Killing Objects
class sb;
packet expected[$];
...
function void observed(packet obs);
packet exp = expected.pop_front();
if (!exp.compare(obs)) ...
exp.kill_object();
obs.kill_object();
endfunction
...
endclass
Example 9-3
Usage
Transaction recording is not turned on by default, it needs to be
activated while compiling your VMM environment. You simply need
to provide the +define+VMM_TR_RECORD switch and -debug_pp
option to allow the activation of underlying system tasks.
The following command line shows how to turn on transaction
recording:
% vcs
-sverilog your_vmm_files.sv \
+define+VMM_TR_RECORD \
-debug_pp
+vmm_tr_verbosity=trace
Debugging vmm_channel
The vmm_channel records the new transactions that are stored in
the channel and the commands that might affect these transactions.
To ease vmm_channel instances debug, the channel transaction is
tagged as TRACE_SEV and channel commands are tagged as
DEBUG_SEV.
The following screenshot shows the content of vmm_channel
instance with size=1 and +vmm_tr_verbosity=trace. In this
mode, only the channel content is recorded.
Debugging vmm_simulation
The vmm_simulation base class records the pre_test, top_test
and post_test status at any point of time. To ease vmm_simulation
instance debug, the status is tagged as TRACE_SEV. You should
use +vmm_tr_verbosity=trace to activate its recording.
The following screenshot shows the content of vmm_simulation.
In DVE waveform viewer, its fairly easy to see that pre_test
timeline invokes the rtl_config phase followed by build,
configure and connect.Then, the top_test phases are
invoked. The post_test phases are empty as they are not invoked
yet.
Debugging vmm_env
The vmm_env records the environment status at any point of time.
To ease vmm_env instances debug, the status is tagged as
TRACE_SEV. You should use +vmm_tr_verbosity=trace to
activate its recording.
The following screenshot shows the content of vmm_env. In DVE
waveform viewer, its fairly easy to see that
RAL_Based_verif_Env environment invokes the gen_cfg step
followed by build and reset_dut.
Debugging vmm_consensus
The vmm_consensus records the consensus status at any point of
time. To ease vmm_consensus instances debug, the status is
tagged as TRACE_SEV. You should use
+vmm_tr_verbosity=trace to activate its recording.
The following screenshot shows the content of vmm_consensus.
In DVE waveform viewer, its fairly easy to see that EOT consensus
opposes the end of test as its registered vmm_notify instance is
not indicated, followed by its registered vmm_channel instance that
is not empty.
Customizing VMM
The components of VMM Standard Library are designed to meet the
needs of the vast majority of users without additional customization.
However, some organizations may wish to customize the
components of VMM Standard Library to offer organization-specific
features and capabilities not readily available in the standard
version. You should use the Standard Library customization
mechanisms described in this chapter.
It is recommended to use the user-defined extension mechanisms
provided by the various base and utility classes such as, virtual and
callback methods.
include VMM_PRE_INCLUDE
...
package _vcs_vmm;
typedef class vmm_xactor;
ifdef VMM_XACTOR_BASE
typedef class VMM_XACTOR_BASE
endif
...
include VMM_POST_INCLUDE
...
class vmm_broadcast extends VMM_XACTOR;
...
endpackage
You can use the following techniques to customize the VMM base
classes. Although you describe the techniques using the
vmm_xactor base class, you can apply the same techniques to the
vmm_data and vmm_env base classes as well.
The only difference is that their respective symbols would start with
"VMM_DATA" and "VMM_ENV" respectively, instead of
"VMM_XACTOR".
Customizing VMM on page 16 details the customization macros
available with all predefined components in the VMM standard
library.
Example 9-14
You can then use an alternate transactor base class by defining the
symbolic constructor argument macros appropriately. Example 9-16
shows how to use the alternate base class shown in Example 9-17.
Example 9-16
define VMM_XACTOR
acme_xactor
define VMM_XACTOR_NEW_ARGS
class vmm_xactor;
vmm_log log;
...
endclass: vmm_xactor
You can use the following techniques to customize the VMM utility
classes. Although the techniques are described using the vmm_log
utility class, you can apply them to the vmm_notify and
vmm_consensus utility classes as well. The only difference is that
their respective symbols would start with "VMM_NOTIFY" and
"VMM_CONSENSUS" respectively instead of "VMM_LOG".
Customizing VMM on page 16 details the customization macros
available with all predefined components in VMM standard library.
class vmm_xactor;
VMM_LOG log;
...
endclass: vmm_xactor
Example 9-21
class scoreboard;
VMM_LOG log;
...
endclass: scoreboard
Example 9-22
Underpinning Classes
SystemVerilog does not support multiple inheritance. You should
limit class inheritance to a single lineage. It might be desirable to
have all transactors derived from more than one base class.
For example, it might be useful to have all transactors derived from
the organization-specific transactor base class and the organizationspecific "any class" base class. Figure 9-1(a) displays how to
accomplish this in a language supporting multiple inheritance such
as, C++. Figure 9-1(b) and Figure 9-1(c) show two alternative
implementations in a single-inheritance language such as,
SystemVerilog.
Figure 9-1
any_class
vmm_xactor any_class
any_class
vmm_xactor
acme_xactor
acme_xactor
acme_xactor
ocp_master
ocp_master
ocp_master
(a)
(b)
(c)
Any Standard Library base or utility class can be based on a userdefined class by appropriately defining the following macros:
VMM_XACTOR_BASE
VMM_XACTOR_BASE_NEW_ARGS
VMM_XACTOR_BASE_NEW_CALL
VMM_XACTOR_BASE_METHODS
If you define the VMM_XACTOR_BASE macro, the vmm_xactor
base class becomes implemented as shown in Example 9-23.
Example 9-23
define VMM_XACTOR_BASE
define VMM_XACTOR_BASE_METHODS \
virtual function string whoami(); \
return "vmm_xactor"; \
endfunction: whoami
VMM User Guide
9-26
any_class
Example 9-25
Base Classes as IP
You can apply the base class underpinning mechanism shown prior
recursively to any class hierarchy. This allows the creation of base
class IP that you can position between the inheritances of two
appropriately written classes.
Example 9-26 shows a VMM-compliant transactor base class
provided by company XYZ. Any organization, whose transactor base
class has a structure similar to this one can then leverage that base
class by inserting it into their transactor class hierarchy.
Example 9-26
include "vmm.sv"
ifndef XYZ_XACTOR_BASE
define XYZ_XACTOR_BASE
VMM_XACTOR
endif
ifndef XYZ_XACTOR_BASE_NEW_ARGS
define XYZ_XACTOR_BASE_NEW_ARGS VMM_XACTOR_NEW_ARGS
define XYZ_XACTOR_BASE_NEW_CALL VMM_XACTOR_NEW_CALL
endif
class xyz_xactor extends XYZ_XACTOR_BASE;
...
function new(string
name,
string
inst,
int
stream_id = -1,
bit
foo
= 0
XYZ_XACTOR_BASE_NEW_ARGS);
super.new(name, inst, stream_id
XYZ_XACTOR_BASE_NEW_CALL);
...
endfunction: new
...
endclass: xyz_xactor
define ACME_XACTOR_BASE
define ACME_XACTOR_BASE_NEW_ARGS
xyz_xactor
, bit foo = 0 \
XYZ_XACTOR_BASE_NEW_ARGS
define ACME_XACTOR_BASE_NEW_CALL
Example 9-28
define XYZ_XACTOR_BASE
define XYZ_XACTOR_BASE_NEW_ARGS
null, \
define XYZ_XACTOR_BASE_NEW_CALL
acme_base
, acme_xactor parent =
int key = -1
, parent, key
define VMM_XACTOR
define VMM_XACTOR_NEW_ARGS
define VMM_XACTOR_NEW_CALL
xyz_xactor
, bit foo = 0 \
XYZ_XACTOR_BASE_NEW_ARGS
XYZ_XACTOR_BASE_NEW_CALL
10
Primers
vmm_scenario_new(my_scenario)
`vmm_scenario_member_begin(my_scenario)
`vmm_scenario_member_int(NUM, DO_ALL)
`vmm_scenario_member_end(my_scenario)
constraint cst_num {
NUM inside {[1:10]};
}
`vmm_scenario_member_begin(my_scenario)
`vmm_scenario_member_scalar(SCN_KIND, DO_ALL)
`vmm_scenario_member_end(my_scenario)
function new(vmm_ms_scenario parent = null);
super.new(parent);
trans = new();
endfunction
task execute(ref int n);
for (int i=0; i<NUM; i++) begin
$display(This is a dummy transaction: %0d, n);
n++; // Incrementing n after execution
// of every transaction
end
endtask
endclass
Example 10-2
gen.register_ms_scenario(MY_SCN, scn);
// Generator randomizes and executes the registered
// scenario 5 times.
gen.stop_after_n_scnearios = 5;
//ALU transaction
class alu_trans extends vmm_data;
typedef enum bit [2:0] {ADD=3'b000, SUB=3'b001,
MUL=3'b010, LS=3'b011,
RS=3'b100} kind_t;
rand kind_t kind;
rand bit [3:0] a, b;
rand bit [6:0] y;
`vmm_data_member_begin(alu_trans)
`vmm_data_member_enum(kind, DO_ALL)
`vmm_data_member_scalar(a, DO_ALL)
`vmm_data_member_scalar(b, DO_ALL)
`vmm_data_member_scalar(y, DO_ALL)
`vmm_data_member_end(alu_trans)
endclass
`vmm_channel(alu_trans)
//APB transaction
class apb_trans extends vmm_data;
typedef enum bit {READ=1'b0, WRITE=1'b1} kind_e;
Implementation of MSSG
program automatic P;
initial begin
alu_trans_channel alu_chan = new("ALU_CHAN", "Chan");
apb_trans_channel apb_chan = new("APB_CHAN", "Chan");
vmm_ms_scenario_gen gen = new("Gen"); //MSSG
my_scenario scn = new;
// Register alu_chan channel to the generator
gen.register_channel("ALU_SCN_CHAN", alu_chan);
//register apb_chan channel to the generator
gen.register_channel("APB_SCN_CHAN", apb_chan);
// register multi stream scenario to the generator
gen.register_ms_scenario("SCN", scn);
gen.stop_after_n_scenarios = 5;
gen.start_xactor();
fork
repeat(5) begin
alu_trans tr;
alu_chan.get(tr);
tr.display("ALU:");
end
repeat(5) begin
apb_trans tr;
apb_chan.get(tr);
tr.display("APB:");
end
join
end
endprogram
CPU driver that is responsible for driving and sampling the DUT
signals through the interface.
1'b0} kind_e;
`vmm_class_factory(cpu_rand_scenario)
endclass
$cast(tr, blueprint.copy());
res = tr.randomize();
chan.put(tr);
endtask
`vmm_class_factory(cpu_rand_scenario)
endclass
After you have created the MSS in the build_ph() phase of the
CPU subenvironment, it is ready to be replaced using
override_with_new() and override_with_copy() methods,
as shown in the examples below.
For an object that needs to be replaced by an extended object with
added constraints and/or data members, you should use the
override_with_new() method.
For an object that needs to be replaced by a similar object but with
different data member values, you should use the
override_with_copy() method. These examples also
demonstrate how both the transaction and the transaction scenario
factories can be replaced.
super.new(name);
endfunction
Summary
VMM provides a pre-defined factory API that greatly eases the
implementation of object factories.
You should perform the following three steps to create an effective
factory service:
The following sections walks you through different ways how global,
hierarchical and structural options can be set and the values
collected from within the code. Except for specifying instance paths
through match patterns in the case of hierarchical options and
structural options, the techniques of setting such options is the same
across all three modes. Therefore, setting these different type of
configuration options are discussed at the end.
You will now learn how to assign options that affect the structure of
the testbench components in the verification environment, a.k.a
structural options. For instance, configuring transactors could be
necessary for setting memory spaces, number of transactions or
scenarios, protocol-specific parameters, etc.
Structural options should be declared in the transactors that extend
vmm_xactor or the environments/subenvironments that extend
vmm_group.
VMM provides a set of shorthand macros called
`vmm_unit_config_*() to take advantage of the
vmm_opts::get_object_*() methods. When the
`vmm_unit_config_begin() and `vmm_unit_config_end
macros are used, it is ensured that that these methods are called in
the right phase, i.e. in configure_ph(). You should use these
macros to declare these structural options and to provide default
values. These structural options can then be set by using the
vmm_opts::set_*() methods procedurally or with the run-time
command line arguments or option files.
Example 10-15 shows how to model a cpu subenvironment with
some structural options. The enable_gen option is non-random
and specifies whether the generator is enabled. The
num_scenarios option is randomized and specifies number of
scenarios to be generated.
Example 10-15 Getting Structural Options
class cpu_subenv extends vmm_group;
`vmm_typename (cpu_subenv)
bit enable_gen;
rand int num_scenarios;
vmm_ms_scenario_gen gen;
function void configure_ph();
`vmm_unit_config_bit(enable_gen, 1,
"Enable/disable the scenario generator",
0, DO_ALL);
endfunction
function void start_of_sim();
`vmm_unit_config_rand_int (num_scenarios, 1,
"runs n scenarios", 0, DO_ALL);
void'(this.randomize());
this.gen.stop_after_n_scenarios = num_scenarios;
endfunction
endclass
The simulation will run for 5 scenarios, instead of 50, specified in the
test. Overriding the options in the command line takes a high
precedence than the set_*() methods.
prj_opts.txt
+num_scenarios=10
The command line options have the highest precedence, then the
option file, and last the set_*() methods in the code.
Conclusion
VMM provides the vmm_opts utility class to configure options in any
level of the testbench hierarchy. You can set these options
dynamically from the command line, option file, or from procedurally
from the testbench code.
CPU Address Width: This is the physical address width of the CPU
interface on the DUT.
...
constraint cst_sram_config_valid {
num_sram_devices inside {1, 2, 4};
}
`vmm_rtl_config_begin (sram_config)
`vmm_rtl_config_int (num_sram_devices,
num_sram_devices)
`vmm_rtl_config_end (sram_config)
function new (string name = "",
vmm_rtl_config parent = null);
super.new (name, instance);
endfunction
endclass
endclass
Figure 10-4
Conclusion
Some designs in RTL are configurable using `ifdef/`endif or
parameter values, which must all be set before simulation runs.
VMM provides the capability to randomize and generate the RTL
configuration to use and then in a separate pass, verify the design in
the specified configuration. The RTL configuration can also be
created manually with directed parameters.
The RTL configuration files are organized in the directories and
subdirectories representing the same object hierarchies in the
testbench. You can customize the file format by using the file format
class.
The Protocol
The protocol used in this primer is the AMBA Peripheral Bus (APB)
protocol. It is a simple single-master address-based parallel bus
providing atomic individual read and write cycles. The protocol
specification can be found in the AMBA Specification (Rev 2.0)
available from ARM (http://arm.com).
When writing a reusable transactor, you should think of all possible
applications it might be used in and not just the device you are using
it for the first time. Therefore, even though the device in this primer
only supports 8 address bits and 16 data bits, the APB transactors
should be written for the entire 32-bit of address and data
information.
`ifndef APB_IF__SV
`define APB_IF__SV
3
4
5
6
7
8
9
10
11
12
13
14
modport master(clocking mck);
15 endinterface: apb_if
16 `endif
Set this object using VMM configuration options either from the
enclosing environment or from the top level.
class apb_master_port extends vmm_object;
virtual apb_if.master mstr_if;
function new(string name,
virtual apb_if.master mstr_if);
super.new(null, name);
this.mstr_if = mstr_if;
endfunction
endclass
14
endmodule: tb_top
This works well for directed tests, but not at all for random tests. A
random test requires a transaction descriptor. This descriptor is a
class extended from the vmm_data class, containing a public rand
property enumerating the directed tasks and public rand properties
for each task argument. If an argument is the same across multiple
tasks, a single property can be used. It also needs a static vmm_log
property instance used to issue messages from the transaction
descriptor. This instance of the message service interface is passed
to the vmm_data constructor [Line 6-8] and it is done by using the
shorthand macros.
Note how the same property is used for "data". It is interpreted
differently depending on the transaction kind. In a WRITE
transaction, it is interpreted as the data to be written. In a READ
transaction, the random content is initially ignored and it is replaced
by the data value that was read. The type for the "data" property is
logic as it is a superset of the bit type and allows the description of
READ cycles to reflect the unknown results.
A transaction-level interface is required to transfer transaction
descriptors to a transactor to be executed. This is done by using the
`vmm_channel macro [Line 16].
`ifndef APB_TRANS__SV
`define APB_TRANS__SV
`include "vmm.sv"
4
5
6
7
8
9
10
11
12
13
`vmm_data_member_begin(apb_trans)
`vmm_data_member_scalar(addr, DO_ALL)
`vmm_data_member_scalar(data, DO_ALL)
`vmm_data_member_enum(kind, DO_ALL)
`vmm_data_member_end(apb_trans)
14
15
`vmm_class_factory(apb_trans)
endclass: apb_trans
16 `vmm_channel(apb_trans)
17 ...
18 `endif
It is important that this transactor gets associated with its parent. The
main reason is to allow it to be replaced, queried or its options to be
modified. This association is established in the constructor:
function apb_master::new(string inst="",
vmm_unit parent=null);
super.new(get_typename(), inst, 0, parent);
endfunction
initialized");
end
endfunction: connect_ph
The transaction descriptors are pulled from the input channel and
translated into method calls in the main() task. The most flexible
transaction execution mechanism uses the active slot as it supports,
block, non-blocking and out-of-order execution models.
Because the protocol supports being suspended between
transactions, the
vmm_xactor::wait_if_stopped_or_empty() method is used
to suspend the execution of the transactor if it is stopped.
The main apb master transactor functionality is implemented in the
main() task of the transactor. You have a choice to use the main
method or the run phase to implement this behavior.
There is no difference between using the main method (VMM 1.1
style) over the run phase (VMM 1.2 style).
Note: After processing the current transaction, the analysis port's
write method is called to issue the observed transaction to the
other testbench components for further analysis.
task apb_master::run_ph();
apb_trans tr;
bit drop;
fork
forever begin
this.wait_if_stopped_or_empty(this.in_chan);
this.in_chan.activate(tr);
...
this.in_chan.start();
case (tr.kind)
apb_trans::READ: this.read(tr.addr, tr.data);
apb_trans::WRITE: this.write(tr.addr, tr.data);
endcase
this.in_chan.complete();
...
this.analysis_port.write(tr);
this.in_chan.remove();
end
join_none
endtask: run_ph
The READ and WRITE tasks are coded exactly as they would be if
good old Verilog was used. It is a simple matter of assigning output
signals to the proper value then sampling input signals at the right
point in time. The only difference is that the physical signals are
accessed through the clocking block of the virtual modport instead of
pins on a module and they can only be assigned using non-blocking
assignments.
drv = this.allocate();
return drv;
endfunction
function apb_master apb_master::allocate();
vmm_unit prnt;
apb_master drv;
$cast(prnt, this.get_parent_object());
drv = new(this.get_object_name(), prnt);
return drv;
endfunction
The callback methods are first defined as virtual tasks or virtual void
functions in a callback faade class extended from the
vmm_xactor_callbacks base class. It is a good idea to create a
mechanism in the "pre-transaction" callback method to allow an
entire transaction to be skipped or dropped.
typedef class apb_master;
class apb_master_cbs extends vmm_xactor_callbacks;
virtual task pre_cycle(apb_master xactor,
apb_trans
cycle,
ref bit
drop);
endtask: pre_cycle
virtual task post_cycle(apb_master xactor,
apb_trans
cycle);
endtask: post_cycle
endclass: apb_master_cbs
`include "vmm.sv"
`include "apb.sv"
class tb_env extends vmm_group;
`vmm_typename(tb_env)
apb_master
mstr;
apb_trans_channel gen_to_drv_chan;
observer
obsrv_apb_trans;
vmm_log log = new("log", "TB_ENV_LOG");
function new(string inst, vmm_unit parent);
super.new(get_typename(), inst, parent);
endfunction
extern function void build_ph();
extern function void connect_ph();
endclass: tb_env
`endif
};
if (!ok)
`vmm_fatal(log, "Unable to randomize READ cycle");
env.mstr.in_chan.put(rd);
// Compare the Read data
if (rd.data[15:0] !== wr.data[15:0]) begin
`vmm_error(log, "Readback value != write value");
end
endtask: run_ph
endclass
You can run this test many times, each time with a different seed to
verify the transactor and the DUT using different addresses.
To simplify, the test scenario is added directly in the run phase of
example. However, it is recommended to use MSSG for achieving
the same result.
Appendix A
The following example is the complete code of the APB master.
File: apb/apb_master.sv
`ifndef APB_MASTER__SV
`define APB_MASTER__SV
`include "apb_if.sv"
`include "apb_trans.sv"
////// Transactor Extension Callback methods /////
typedef class apb_master;
class apb_master_cbs extends vmm_xactor_callbacks;
virtual task pre_cycle(apb_master xactor,
apb_trans
cycle,
ref bit
drop);
endtask: pre_cycle
virtual task post_cycle(apb_master xactor,
apb_trans
cycle);
endtask: post_cycle
endclass: apb_master_cbs
/////////// APB Master Driver Class //////////
class apb_master extends vmm_xactor;
`vmm_typename(apb_master)
// Variables declaration
apb_trans_channel in_chan;
apb_master_port mstr_port_obj;
virtual apb_if.master mstr_if;
// Analysis port
vmm_tlm_analysis_port#(apb_master, apb_trans)
analysis_port;
// Component phases
extern function new(string inst="", vmm_unit
parent=null);
extern virtual function void reset_xactor(reset_e
rst_typ = SOFT_RST);
extern virtual function void build_ph();
extern virtual function void connect_ph();
extern virtual function void start_of_sim_ph();
extern virtual task run_ph();
extern virtual task shutdown_ph();
// Supporting tasks
extern virtual protected task read(input bit
[31:0]
addr, output logic [31:0] data);
extern virtual protected task write(input bit [31:0]
addr, input bit [31:0] data);
// Factory enablement
extern virtual function apb_master allocate();
extern virtual function apb_master copy();
`vmm_class_factory(apb_master)
endclass: apb_master
////////////// Constructor //////////////////
function apb_master::new(string inst, vmm_unit parent);
super.new(get_typename(), inst, 0, parent);
endfunction
/////////////// Build Phase /////////////////
function void apb_master::build_ph();
// Construct the analysis port
analysis_port = new(this, {get_object_name(),
"_analysis_port"});
endfunction: build_ph
////////////// Connect Phase ////////////////
function void apb_master::connect_ph();
begin
bit is_set;
`vmm_note(log,$psprintf("**** %s: Entering
connect_ph ....\n",get_object_hiername()));
//
if ($cast(this.mstr_port_obj,
vmm_opts::get_object_obj(is_set,this,"apb_mstr_port")))
begin
if (mstr_port_obj != null)
this.mstr_if = mstr_port_obj.mstr_if;
else
`vmm_fatal(log, "Virtual port [Master] wrapper
not initialized");
end
// Initialize the port signals
this.mstr_if.mck.psel
<= '0;
this.mstr_if.mck.penable <= '0;
//
`vmm_note(log,$psprintf("**** %s: Exiting
connect_ph ....\n",get_object_hiername()));
end
endfunction: connect_ph
////////////// start_of_sim_ph Phase /////////
function void apb_master::start_of_sim_ph();
if (mstr_port_obj == null)
`vmm_fatal(log, "Virtual port is not connected to
the actual interface instance");
endfunction
//
function void apb_master::reset_xactor(reset_e rst_typ =
SOFT_RST);
super.reset_xactor(rst_typ);
this.in_chan.flush();
this.mstr_if.mck.psel
<= '0;
this.mstr_if.mck.penable <= '0;
endfunction: reset_xactor
//
task apb_master::run_ph();
apb_trans tr;
bit drop;
fork
forever begin
//
this.wait_if_stopped_or_empty(this.in_chan);
this.in_chan.activate(tr);
@ (this.mstr_if.mck);
drop = 0;
apb_master drv;
$cast(prnt, this.get_parent_object());
drv = new(this.get_object_name(), prnt);
return drv;
endfunction
///////////// APB BUS READ task //////////
task apb_master::read(input bit
[31:0] addr, output
logic [31:0] data);
this.mstr_if.mck.paddr
<= addr;
this.mstr_if.mck.pwrite <= '0;
this.mstr_if.mck.psel
<= '1;
@ (this.mstr_if.mck);
this.mstr_if.mck.penable <= '1;
@ (this.mstr_if.mck);
data = this.mstr_if.mck.prdata;
this.mstr_if.mck.psel
<= '0;
this.mstr_if.mck.penable <= '0;
endtask: read
///////////// APB BUS WRITE task ////////
task apb_master::write(input bit [31:0] addr, input bit
[31:0] data);
this.mstr_if.mck.paddr
<= addr;
this.mstr_if.mck.pwdata <= data;
this.mstr_if.mck.pwrite <= '1;
this.mstr_if.mck.psel
<= '1;
@ (this.mstr_if.mck);
this.mstr_if.mck.penable <= '1;
@ (this.mstr_if.mck);
this.mstr_if.mck.psel
<= '0;
this.mstr_if.mck.penable <= '0;
endtask: write
//
`endif
A
Standard Library Classes (Part 1)
Note:
Each method, explained in this appendix, uses the SystemVerilog
name in the heading to introduce it. Additionally, there are a few
instances where a _t suffix is appended to indicate that it may be
a blocking method.
factory
vmm_atomic_gen#(T)
<class-name>_atomic_gen_callbacks
vmm_atomic_scenario#(T)
vmm_broadcast
vmm_channel
vmm_connect#(T,N,D)
vmm_consensus
vmm_data
vmm_env
vmm_group
vmm_group_callbacks
vmm_log
vmm_log_msg
vmm_log_callback
vmm_log_catcher
vmm_log_format
vmm_ms_scenario
vmm_ms_scenario_gen
vmm_notification
vmm_notify
vmm_notify_callbacks
vmm_notify_observer#(T,D)
vmm_object
vmm_object_iter
vmm_opts
factory
The factory class is the utility class to generate instances of any
class through the factory mechanism.
Summary
factory::create_instance() .........................
factory::override_with_new() .......................
factory::override_with_copy() ......................
factory::this_type() ..............................
`vmm_class_factory(classname) .....................
page A-5
page A-7
page A-9
page A-11
page A-12
factory::create_instance()
Creates an instance of the specified class type.
SystemVerilog
static function classname
classname::create_instance(vmm_object parent, string name,
string fname = "", int lineno = 0);
Description
Creates an instance of the specified class type, for the specified
name in the scope, created by the specified parent vmm_object.
The new instance is created by calling allocate() or copy() on
the corresponding factory instance, specified using the
override_with_new() or override_with_copy() method, in
this class, or any of its parent (base) classes. If you do not specify
any factory instance, then it creates an instance of this class.
The newly created instance contains the specified name and the
specified vmm_object as parent, if the newly created instance is
extended from vmm_object.
The fname and lineno arguments are used to track the file name
and the line number where the instance is created using
create_instance.
Example
class ahb_trans extends vmm_object;
`vmm_class_factory(ahb_trans)
endclass
class ahb_gen extends vmm_group;
ahb_trans tr;
virtual function void_build_ph();
tr = ahb_trans::create_instance(this, "Ahb_Tr0",
`__FILE__, `__LINE__);
...
endfunction
endclass
factory::override_with_new()
Sets the specified class instance as the create-by-construction
factory.
SystemVerilog
static function void classname::override_with_new(
string name, classname factory, vmm_log log,
string fname = "", int lineno = 0);
Description
Sets the specified class instance as the create-by-construction
factory, when creating further instances of that class under the
specified instance name. You can specify the instance name as a
match pattern or regular expression. Also, you can specify an
instance name in a specific namespace by prefixing it with
spacename::. The classname::create_instance() method
uses the allocate() method to create a new instance of this
class.
You should call this method using the following pattern:
master::override_with_new(
"@*", extended_master::this_type(), this.log, `__FILE__,
`__LINE__);
Example
class my_ahb_trans extends vmm_object;
`vmm_class_factory(my_ahb_trans)
endclass
initial begin
ahb_trans::override_with_new("@%*",
my_ahb_trans::this_type, log,
`__FILE__, `__LINE__);
end
factory::override_with_copy()
Schedules creation of a factory instance by copying the provided
instance.
SystemVerilog
static function void classname::override_with_copy(
string name, classname factory, vmm_log log,
string fname = "", int lineno = 0);
Description
Sets the specified class instance as the create-by-copy factory,
when creating further instances of that class under the specified
instance name. You can specify the instance name as a match
pattern or regular expression. Also, you can specify an instance
name in a specific namespace by prefixing it with spacename::.
The classname::create_instance() method uses the
copy() method to create new instance of this class.
If the specified name matches the hierarchical name of atomic,
single-stream, or multi-stream scenario generators of the
appropriate type, the matching factory instances they contain are
immediately replaced with copies of the specified factory
instance. If you call this method before the build phase, this
replacement is delayed until the completion of that phase.
The log argument is the message interface used by factory to report
various messages. The fname and lineno arguments are used to
track the file name and the line number where the instance is created
using create_instance.
Example
class ahb_trans extends vmm_object;
rand bit [7:0] addr;
`vmm_class_factory(ahb_trans)
endclass
initial begin
ahb_trans tr;
tr = new("gen_trans");
tr.addr = 5;
ahb_trans::override_with_copy("@%*", tr, log,
`__FILE__, `__LINE__);
end
factory::this_type()
Returns a dummy instance of the factory class.
SystemVerilog
static function classname classname::this_type();
Description
Returns a dummy instance of this class. You can use this class to call
the classname::allocate() method.
Example
ahb_trans::override_with_new("@%*",
my_ahb_trans::this_type,
log, `__FILE__, `__LINE__);
`vmm_class_factory(classname)
This is a macro for defining factory class.
Description
Creates the factory class methods for the specified class. You
must specify this method within the class declaration, with virtual
allocate() and copy() methods. These virtual methods can be
called without any arguments.
Example
class ahb_trans extends vmm_object;
rand bit [7:0] addr;
...
`vmm_class_factory(ahb_trans)
endclass
vmm_atomic_gen#(T)
Creates a parameterized version of the VMM atomic generator.
SystemVerilog
class vmm_atomic_gen #(type T= vmm_data,
C=vmm_channel_typed#(T), string text = "") extends
vmm_atomic_gen_base;
Description
The `vmm_atomic_generator macro creates a parameterized
atomic generator. This generator can generate non-vmm_data
transactions as well.
A macro is used to define a class named classname_atomic_gen for any user-specified class derived from
vmm_data1, using a process similar to the vmm_channel macro.
The atomic generator class is an extension of the vmm_xactor
class and as such, inherits all the public interface elements provided
in the base class.
Example
class ahb_trans extends vmm_data;
rand bit [31:0] addr;
rand bit [31:0] data;
endclass
`vmm_channel(ahb_trans)
1. With a constructor callable without any arguments.
Summary
page
page
page
page
page
page
page
page
page
page
A-15
A-16
A-17
A-18
A-20
A-22
A-23
A-25
A-27
A-28
vmm_atomic_gen::<class-name>_channel out_chan
Reference the output channel for the instances generated by this
transactor.
SystemVerilog
class-name_channel out_chan;
OpenVera
Not supported.
Description
The output channel may have been specified through the
constructor. If you did not specify any output channel instances, a
new instance is automatically created. You may dynamically replace
this reference in this property, but you should stop the generator
during replacement.
Example
Example A-1
program t( );
`vmm_atomic_gen(atm_cell, "ATM Cell")
atm_cell_atomic_gen gen = new("Singleton");
atm_cell cell;
...
gen.out_chan.get(cell);
...
endprogram
vmm_atomic_gen::enum {DONE}
Notification identifier for the notification service.
SystemVerilog
enum {DONE};
OpenVera
Not supported.
Description
Notification identifier for the notification service that is in the
vmm_xactor::notify property, provided by the vmm_xactor
base class. It is configured as a vmm_xactor::ON_OFF notification,
and is indicated when the generator stops, because the specified
number of instances are generated. No status information is
specified.
Example
Example A-2
gen.notify.wait_for(atm_cell_atomic_gen::DONE);
vmm_atomic_gen::enum {GENERATED}
Notification identifier for the notification service.
SystemVerilog
enum {GENERATED};
OpenVera
Not supported.
Description
Notification identifier for the notification service interface that is in the
vmm_xactor::notify property, provided by the vmm_xactor
base class. It is configured as a vmm_xactor::ONE_SHOT
notification, and is indicated immediately before an instance is added
to the output channel. The generated instance is specified as the
status of the notification.
Example
Example A-3
gen.notify.wait_for(atm_cell_atomic_gen::GENERATED);
vmm_atomic_gen::inject()
Injects the specified transaction or data descriptor in the output
stream.
SystemVerilog
virtual task inject(class-name data obj, ref bit dropped);
OpenVera
Not supported.
Description
You can use this method to inject directed stimulus, while the
generator is running (with unpredictable timing) or when the
generator is stopped.
Unlike injecting the descriptor directly in the output channel, it counts
toward the number of instances generated by this generator and will
be subjected to the callback methods. The method returns once the
instance is consumed by the output channel or it is dropped by the
callback methods.
Example
Example A-4
task directed_stimulus;
eth_frame to_phy, to_mac;
...
to_phy = new;
to_phy.randomize();
...
fork
env.host_src.inject(to_phy, dropped);
begin
// Force the earliest possible collision
@ (posedge tb_top.mii.tx_en);
env.phy_src.inject(to_mac, dropped);
end
join
...
-> env.end_test;
endtask: directed_stimulus
vmm_atomic_gen::new()
Creates a new instance of the class-name_atomic_gen class
SystemVerilog
function new(string instance, int stream_id = -1,
class-name_channel out_chan = null, vmm_object parent =
null);
OpenVera
Not supported.
Description
Creates a new instance of the class-name_atomic_gen class,
with the specified instance name and optional stream identifier. You
can optionally connect the generator to the specified output channel.
If you did not specify any output channel instance, one will be
created internally in the class-name_atomic_gen::out_chan
property.
The name of the transactor is defined as the user-defined class
description string specified in the class implementation macro
appended with Atomic Generator. The parent argument should
be passed if implicit phasing needs to be enabled.
Example
Example A-5
`vmm_channel(alu_data)
Class alu_env extends vmm_group;
vmm_atomic_gen#(alu_data, ,"AluGen") gen_a;
alu_data_channel alu_chan;
. . .
function void build_ph();
alu_chan
= new ("ALU", "channel");
gen_a
= new("Gen", 0,alu_chan ,this);
endfunction
. . .
endclass
vmm_atomic_gen::post_inst_gen()
Invokes callback method, after a new transaction or data descriptor
is created.
SystemVerilog
virtual task post_inst_gen(class-name_atomic_gen gen,
class-name obj, ref bit drop);
OpenVera
Not supported.
Description
The generator invokes the callback method, after a new transaction
or data descriptor is created and randomized, but before it is added
to the output channel.
The gen argument refers to the generator instance that is invoking
the callback method (if the same callback extension instance is
registered with more than one transactor instance). The data
argument refers to the newly generated descriptor, which can be
modified. If the value of the drop argument is set to non-zero, the
generated descriptor will not be forwarded to the output channel.
However, the remaining registered callbacks will be invoked.
vmm_atomic_gen::randomized_obj
Randomizes the creation of random content of the output descriptor
stream.
SystemVerilog
class-name randomized_obj;
OpenVera
Not supported.
Description
Transaction or data descriptor instance that is repeatedly
randomized to create the random content of the output descriptor
stream. The individual instances of the output stream are copied
from this instance, after randomization, using the
vmm_data::copy() method.
The atomic generator uses a class factory pattern to generate the
output stream instances. Using various techniques, you can
constrain the generated stream on this property.
The vmm_data::stream_id property of this instance is set to the
stream identifier of the generator, before each randomization. The
vmm_data::data_id property of this instance is also set before
each randomization. It will be reset to 0 when the generator is reset,
and after the specified maximum number of instances are
generated.
Example
Example A-6
program test_...;
...
class long_eth_frame extends eth_frame;
constraint long_frames {
data.size() == max_len;
}
endclass: long_eth_frame
...
initial begin
env.build();
begin
long_eth_frame fr = new;
env.host_src.randomized_obj = fr;
end
...
top.env.run();
end
endprogram
vmm_atomic_gen::stop_after_n_insts
Stops, after the specified number of object instances are generated.
SystemVerilog
int unsigned stop_after_n_insts;
OpenVera
Not supported.
Description
The generator stops, after the specified number of object instances
are generated and consumed by the output channel. You must reset
the generator, before it can be restarted. If the value of this property
is 0, the generator will not stop on its own.
The default value of this property is 0.
Example
Example A-7
program t( );
`vmm_atomic_gen(atm_cell, "ATM Cell")
atm_cell_atomic_gen gen = new("Singleton");
gen.stop_after_n_insts = 10;
...
endprogram
<class-name>_atomic_gen_callbacks
This class implements a faade for atomic generator, transactor, and
callback methods. This class is automatically declared, and
implemented for any user-specified class by the atomic generator
macro.
Summary
vmm_atomic_gen()
Defines an atomic generator class.
SystemVerilog
vmm_atomic_gen(class-name, "Class Description")
OpenVera
Not supported.
Description
Defines an atomic generator class named classname_atomic_gen, to generate instances of the specified class.
The generated class must be derived from the vmm_data class, and
the class-name_channel class must exist.
vmm_atomic_gen_using()
Defines an atomic generator class.
SystemVerilog
vmm_atomic_gen_using(class-name, channel-type, "Class
Description")
OpenVera
Not supported.
Description
Defines an atomic generator class named classname_atomic_gen to generate instances of the specified class,
with the specified output channel type. The generated class must be
compatible with the specified channel type, and both must exist.
You should use this macro, only while generating instances of a
derived class that must be applied to a channel of the base class.
vmm_atomic_scenario#(T)
Parameterized version of the VMM atomic scenario.
SystemVerilog
class vmm_atomic_scenario #(T) extends vmm_ss_scenario#(T)
Description
The parameterized atomic scenario is a generic typed scenario,
extending vmm_ss_scenario. It is used by the parameterized
scenario generator as the default scenario.
Example
class ahb_trans extends vmm_data;
rand bit [31:0] addr;
rand bit [31:0] data;
endclass
`vmm_channel(ahb_trans)
`vmm_scenario_gen(ahb_trans, "AHB Scenario Gen")
class vmm_atomic_scenario#(ahb_trans) extends
vmm_ss_scenario#(ahb_trans);
endclass
vmm_broadcast
Channels are point-to-point data transfer mechanisms. If multiple
consumers are extracting transaction descriptors from a channel,
the transaction descriptors are distributed among various
consumers and each of the N consumers view 1/N descriptors. If a
point-to-multi-point mechanism is required, where all consumers
must view all transaction descriptors in the stream, then a
vmm_broadcast component can be used to replicate the stream of
transaction descriptors from a source channel to an arbitrary and
dynamic number of output channels. If only two output channels are
required, the vmm_channel::tee() method of the source channel
may also be used.
You can configure individual output channels to receive a copy of the
reference to the source transaction descriptor (most efficient but the
same descriptor instance is shared by the source and all likeconfigured output channels) or to use a new descriptor instance
copied from the source object (least efficient but uses a separate
instance that can be modified without affecting other channels or the
original descriptor). A vmm_broadcast component can be
configured to use references or copies in output channels by default.
In the As Fast As Possible (AFAP) mode, the full level of output
channels is ignored. Only the full level of the source channel controls
the flow of data through the broadcaster. Output channels are kept
non-empty, as much as possible. As soon as an active output
channel becomes empty, the next descriptor is removed from the
source channel (if available), and added to all output channels, even
if they are already full.
Summary
vmm_broadcast::add_to_output() ....................
vmm_broadcast::bcast_off() ........................
vmm_broadcast::bcast_on() .........................
vmm_broadcast::broadcast_mode() ...................
vmm_broadcast::log ................................
vmm_broadcast::new() ..............................
vmm_broadcast::new_output() .......................
vmm_broadcast::reset_xactor() .....................
vmm_broadcast::set_input() ........................
vmm_broadcast::start_xactor() .....................
vmm_broadcast::stop_xactor() ......................
page
page
page
page
page
page
page
page
page
page
page
A-32
A-34
A-35
A-36
A-37
A-38
A-39
A-40
A-41
A-42
A-43
vmm_broadcast::add_to_output()
Overloads to create broadcaster components with different
broadcasting rules.
SystemVerilog
virtual protected function bit
add_to_output(int unsigned decision_id,
int unsigned output_id,
vmm_channel channel,
vmm_data obj);
OpenVera
Not supported.
Description
Overloading this method, allows the creation of broadcaster
components with different broadcasting rules. If this function returns
TRUE (that is, non-zero), then the transaction descriptor will be
added to the specified output channel. If this function returns FALSE
(that is, zero), then the descriptor is not added to the channel. If the
output channel is configured to use new descriptor instances, the
obj parameter is a reference to that new instance.
This method is not necessarily invoked in increasing order of output
identifiers. It is only called for output channels currently configured
as ON. If this method returns FALSE for all output channels, for a
given broadcasting cycle, lock-up may occur. The decision_id
argument is reset to 0 at the start of every broadcasting cycle, and is
incremented after each call to this method in the same cycle. It can
be used to identify the start of broadcasting cycles.
vmm_broadcast::bcast_off()
Turns broadcasting to the specified output channel off.
SystemVerilog
virtual function void bcast_off(int unsigned output_id);
OpenVera
Not supported.
Description
By default, broadcasting to an output channel is on. When
broadcasting is turned off, the output channel is flushed and the
addition of new transaction descriptors from the source channel is
inhibited. The addition of descriptors from the source channel is
resumed, as soon as broadcasting is turned on.
If all output channels are off, the input channel is continuously
drained to avoid data accumulation.
Any user extension of this method should call
super.bcast_off().
vmm_broadcast::bcast_on()
Turns-on broadcasting to the specified output channel.
SystemVerilog
virtual function void bcast_on(int unsigned output-id);
OpenVera
Not supported.
Description
By default, broadcasting to an output channel is on. When
broadcasting is turned off, the output channel is flushed and the
addition of new transaction descriptors from the source channel is
inhibited. The addition of descriptors from the source channel is
resumed, as soon as broadcasting is turned on.
If all output channels are off, the input channel is continuously
drained to avoid data accumulation.
Any user extension of these methods should call
super.bcast_on().
vmm_broadcast::broadcast_mode()
Changes the broadcasting mode to the specified mode.
SystemVerilog
virtual function void broadcast_mode(bcast_mode_e mode);
OpenVera
Not supported.
Description
The new mode takes effect immediately. The available modes are
specified by using one of the class-level enumerated symbolic
values shown in Table A-1.
Table A-1
Table A-2
Enumerated Value
Broadcasting Operation
vmm_broadcast::ALAP
As Late As Possible.
Data is broadcast only when all active output channels are empty.
This delay ensures that data is not broadcast any faster than the
slowest of all consumers can digest it.
vmm_broadcast::AFAP
As Fast As Possible.
Active output channels are kept non-empty, as much as possible.
As soon as an active output channel becomes empty, the next
descriptor from the input channel (if available) is immediately
broadcast to all active output channels, regardless of their fill level
This mode must not be used if the data source can produce data
at a higher rate than the slowest data consumer, and if broadcast
data in all output channels are not consumed at the same average
rate.
vmm_broadcast::log
Message service interface for the broadcast class.
SystemVerilog
vmm_log log;
OpenVera
Not supported.
Description
Sets by the constructor, and uses the name and instance name
specified in the constructor.
vmm_broadcast::new()
Creates a new instance of a channel broadcaster object.
SystemVerilog
function new(string name,
string instance,
vmm_channel source,
bit use_references = 1,
bcast_mode_typ mode = AFAP);
OpenVera
Not supported.
Description
Creates a new instance of a channel broadcaster object with the
specified name, instance name, source channel, and broadcasting
mode. If use_references is TRUE (that is, non-zero), references
to the original source transaction descriptors are assigned to output
channels by default (unless individual output channels are
configured otherwise). The source can be assigned to null and set
later by using vmm_broadcast::set_input() .
For more information on the available modes in the
broadcast_mode() method, see the section virtual function void
broadcast_mode(bcast_mode_e mode); on page 36.
Example
Example A-8
vmm_broadcast bcast = new("Bcast", "", in_chan, 1);
vmm_broadcast::new_output()
Adds the specified channel instance as a new output channel.
SystemVerilog
virtual function int new_output(vmm_channel channel,
logic use_references = 1'bx);
OpenVera
Not supported.
Description
Adds the specified channel instance as a new output channel to the
broadcaster. If use_references is TRUE (that is, non-zero),
references to the original source transaction descriptor is added to
the output channel. If FALSE (that is, zero), a new instance copied
from the original source descriptor is added to the output channel. If
unknown (that is, 1'bx), the default broadcaster configuration is
used.
If there are no output channels, the data from the input channel is
continuously drained to avoid data accumulation.
This method returns a unique identifier for the output channel that
must be used to modify the configuration of the output channel.
Any user extension of this method must call
super.new_output().
vmm_broadcast::reset_xactor()
Resets this vmm_broadcast instance.
SystemVerilog
virtual function void
reset_xactor(reset_e rst_type = SOFT_RST);
OpenVera
Not supported.
Description
The broadcaster can be restarted. The input channel and all output
channels are flushed.
vmm_broadcast::set_input()
Specifies the channel as the source if not set previously
System Verilog
function void set_input(vmm_channel source);
Open Vera
Not supported
Description
Identifies the channel as the source of the broadcaster, if the source
is not set previously. If source is already set, then a warning is issued
stating that this particular call has been ignored.
Example
Example A-9
vmm_broadcast bcast = new("Bcast", "", null, 1);
bcast.set_input(in_chan);
vmm_broadcast::start_xactor()
Starts this vmm_broadcast instance.
SystemVerilog
virtual function void start_xactor();
OpenVera
Not supported.
Description
The broadcaster can be stopped. Any extension of this method must
call super.start_xactor().
Example
Example A-10
vmm_broadcast bcast = new("Bcast", "", in_chan, 1);
bcast.start_xactor();
vmm_broadcast::stop_xactor()
Suspends this vmm_broadcast instance.
SystemVerilog
virtual function void stop_xactor();
OpenVera
Not supported.
Description
The broadcaster can be restarted. Any extension of this method
must call super.stop_xactor().
Example
Example A-11
program test_directed;
...
initial begin
...
env.start();
env.host_src.stop_xactor();
env.phy_src.stop_xactor();
fork
directed_stimulus;
join_none
env.run();
end
task directed_stimulus;
...
endtask: directed_stimulus
endprogram: test
vmm_channel
This class implements a generic transaction-level interface
mechanism.
Offset values, either accepted as arguments or returned values, are
always interpreted the same way. A value of 0 indicates the head of
the channel (first transaction descriptor added). A value of 1
indicates the tail of the channel (last transaction descriptor added).
Positive offsets are interpreted from the head of the channel.
Negative offsets are interpreted from the tail of the channel. For
example, an offset value of 2 indicates the transaction descriptor
just before the last transaction descriptor in the channel. It is illegal
to specify a non-zero offset that does not correspond to a transaction
descriptor, which is already in the channel.
The channel includes an active slot that can be used to create more
complex transactor interfaces. The active slot counts toward the
number of transaction descriptors currently in the channel, for
control-flow purposes, but cannot be accessed nor specified through
an offset specification.
The implementation uses a macro to define a class named classname_channel, derived from the class named vmm_channel, for
any user-specified class named class-name.
Summary
page
page
page
page
page
page
page
page
page
A-45
A-47
A-49
A-51
A-52
A-54
A-55
A-56
A-57
vmm_channel::for_each() ...........................
vmm_channel::for_each_offset() ....................
vmm_channel::full_level() .........................
vmm_channel::get() ................................
vmm_channel::get_consumer() .......................
vmm_channel::get_producer() .......................
vmm_channel::grab() ...............................
vmm_channel::level() ..............................
vmm_channel::is_full() ............................
vmm_channel::is_grabbed() .........................
vmm_channel::is_locked() ..........................
vmm_channel::kill() ...............................
vmm_channel::lock() ...............................
vmm_channel::log ..................................
vmm_channel::new() ................................
vmm_channel::notify ...............................
vmm_channel::peek() ...............................
vmm_channel::playback() ...........................
vmm_channel::put() ................................
vmm_channel::reconfigure() ........................
vmm_channel::record() .............................
vmm_channel::register_vmm_sb_ds() .................
vmm_channel::remove() .............................
vmm_channel::set_consumer() .......................
vmm_channel::set_producer() .......................
vmm_channel::sink() ...............................
vmm_channel::size() ...............................
vmm_channel::sneak() ..............................
vmm_channel::start() ..............................
vmm_channel::status() .............................
vmm_channel::tee() ................................
vmm_channel::tee_mode() ...........................
vmm_channel::try_grab() ..........................
vmm_channel_typed#(type) .........................
vmm_channel::ungrab() ............................
vmm_channel::unlock() ............................
vmm_channel::unput() .............................
vmm_channel::unregister_vmm_sb_ds() ..............
vmm_channel() ...................................
page A-58
page A-59
page A-60
page A-61
page A-62
page A-63
page A-64
page A-66
page A-67
page A-68
page A-70
page A-71
page A-72
page A-73
page A-74
page A-75
page A-77
page A-78
page A-81
page A-83
page A-85
page A-86
page A-87
page A-88
page A-90
page A-92
page A-93
page A-94
page A-96
page A-97
page A-98
page A-99
page A-100
page A-102
page A-104
page A-106
page A-107
page A-108
page A-109
vmm_channel::activate()
Removes the transaction descriptor, which is currently in the active
slot.
SystemVerilog
task activate(output class-name obj, input int offset = 0);
OpenVera
Not supported.
Description
If the active slot is not empty, then this method first removes the
transaction descriptor, which is currently in the active slot.
Move the transaction descriptor at the specified offset in the channel
to the active slot ,and update the status of the active slot to
vmm_channel::PENDING. If the channel is empty, then this method
will wait until a transaction descriptor becomes available. The
transaction descriptor is still considered as being in the channel.
It is an error to invoke this method with an offset value greater than
the number of transaction descriptors currently in the channel, or to
use this method with multiple concurrent consumer threads.
Example
Example A-12
class consumer extends vmm_xactor;
...
virtual task main();
...
forever begin
transaction tr;
...
this.in_chan.activate(tr);
this.in_chan.start();
...
this.in_chan.complete();
this.in_chan.remove();
end
endtask: main
...
endclass: consumer
vmm_channel::active_slot()
Returns the transaction descriptor, which is currently in the active
slot.
SystemVerilog
function class-name active_slot();
OpenVera
Not supported.
Description
Returns the transaction descriptor, which is currently in the active
slot. Returns null, if the active slot is empty.
vmm_channel::connect()
Connects the output of this channel instance to the input of the
specified channel instance.
SystemVerilog
function void connect(vmm-channel downstream);
OpenVera
Not supported.
Description
The connection is performed with a blocking model to communicate
the status of the downstream channel, to the producer interface of
the upstream channel. Flushing this channel causes the downstream
connected channel to be flushed as well. However, flushing the
downstream channel does not flush this channel.
The effective full and empty levels of the combined channels is equal
to the sum of their respective levels minus one. However, the
detailed blocking behavior of various interface methods differ from
using a single channel, with an equivalent configuration. Additional
zero-delay simulation cycles may be required, while transaction
descriptors are transferred from the upstream channel to the
downstream channel.
Connected channels need not be of the same type, but must carry
compatible polymorphic data.
vmm_channel::complete()
Updates the status of an active slot to
vmm_channel::COMPLETED.
SystemVerilog
function class-name complete(vmm_data status = null);
OpenVera
Not supported.
Description
The transaction descriptor remains in the active slot, and may be
restarted. It is an error to call this method, if the active slot is empty.
The vmm_data::ENDED notification of the transaction descriptor in
the active slot is indicated with the optionally specified completion
status descriptor.
Example
Example A-13
class consumer extends vmm_xactor;
virtual task main();
forever begin
transaction tr;
this.in_chan.activate(tr);
this.in_chan.start();
this.in_chan.complete();
this.in_chan.remove();
end
endtask: main
endclass: consumer
vmm_channel::empty_level()
Returns the currently configured empty level.
SystemVerilog
function int unsigned empty_level();
OpenVera
Not supported.
vmm_channel::flow()
Restores the normal flow of transaction descriptors through the
channel.
SystemVerilog
function void flow();
OpenVera
Not supported.
vmm_channel::flush()
Flushes the content of the channel.
SystemVerilog
function void flush();
OpenVera
Not supported.
Description
Flushing unblocks any thread, which is currently blocked in the
vmm_channel::put() method. This method causes the FULL
notification to be reset, or the EMPTY notification to be indicated.
Flushing a channel unlocks all sources and consumers.
vmm_channel::for_each()
Iterates over all transaction descriptors, which are currently in the
channel.
SystemVerilog
function class-name for_each(bit reset = 0);
OpenVera
Not supported.
Description
The content of the active slot, if non-empty, is not included in the
iteration. If the reset argument is TRUE, a reference to the first
transaction descriptor in the channel is returned. Otherwise, a
reference to the next transaction descriptor in the channel is
returned. Returns null, when the last transaction descriptor in the
channel is returned. It keeps returning null, unless reset.
Modifying the content of the channel in the middle of an iteration
yields unexpected results.
vmm_channel::for_each_offset()
Returns the offset of the last transaction descriptor, which is returned
by the vmm_channel::for_each() method.
SystemVerilog
function int unsigned for_each_offset();
OpenVera
Not supported.
Description
Returns the offset of the last transaction descriptor, which is returned
by the vmm_channel::for_each() method. An offset of 0
indicates the first transaction descriptor in the channel.
vmm_channel::full_level()
Returns the currently configured full level.
SystemVerilog
function int unsigned full_level();
OpenVera
Not supported.
vmm_channel::get()
Retrieves the next transaction descriptor in the channel, at the
specified offset.
SystemVerilog
task get(output class-name obj, input int offset = 0);
OpenVera
Not supported.
Description
If the channel is empty, the function blocks until a transaction
descriptor is available to be retrieved. This method may cause the
EMPTY notification to be indicated, or the FULL notification to be
reset. It is an error to invoke this method, with an offset value greater
than the number of transaction descriptors, which are currently in the
channel or with a non-empty active slot.
Example
Example A-14
virtual function void build();
fork
forever begin
eth_frame fr;
this.mac.rx_chan.get(fr);
this.sb.received_by_phy_side(fr);
end
join_none
endfunction: build
vmm_channel::get_consumer()
Returns the current consumer for a channel.
SystemVerilog
function vmm_xactor get_consumer();
OpenVera
Not supported.
Description
Returns the transactor that is specified as the current consumer for
the channel instance. Returns NULL, if no consumer is identified.
Example
Example A-15
class tr extends vmm_data;
endclass
`vmm_channel(tr)
class xactor extends vmm_xactor;
endclass
program prog;
initial begin
tr_atomic_gen agen = new("Atomic Gen");
xactor xact = new("Xact", agen.out_chan);
if (agen.out_chan.get_consumer() != xact) begin
`vmm_error(log, "Wrong consumer for agen.out_chan");
end
end
endprogram
vmm_channel::get_producer()
Returns the current producer for a channel.
SystemVerilog
function vmm_xactor get_producer();
OpenVera
Not supported.
Description
Returns the transactor that is specified as the current producer, for
the channel instance. Returns NULL, if no producer is identified.
Example
Example A-16
class tr extends vmm_data;
endclass
`vmm_channel(tr)
class xactor extends vmm_xactor;
endclass
program prog;
initial begin
tr_atomic_gen agen = new("Atomic Gen");
xactor xact = new("Xact", agen.out_chan);
if (xact.in_chan.get_producer() != agen) begin
`vmm_error(log, "Wrong producer for xact.in_chan");
end
end
endprogram
vmm_channel::grab()
Grabs a channel for exclusive use.
SystemVerilog
task grab(vmm_scenario grabber);
OpenVera
task grab_t(rvm_scenario grabber);
Description
Grabs a channel for the exclusive use of a scenario and its subscenarios. If the channel is currently grabbed by another scenario,
the task blocks until the channel can be grabbed by the specified
scenario descriptor. The channel will remain as grabbed, until it is
released by calling the vmm_channel::ungrab() method.
If a channel is grabbed by a scenario that is a parent of the specified
scenario, then the channel is immediately grabbed by the scenario.
If exclusive access to a channel is required outside of a scenario
descriptor, then allocate a dummy scenario descriptor and use its
reference.
When a channel is grabbed, the vmm_channel::GRABBED
notification is indicated.
Example
Example A-17
class my_data extends vmm_data;
...
endclass
`vmm_channel(my_data)
class my_scenario extends vmm_ms_scenario;
...
endclass
program test_grab
my_data_channel chan = new("Channel", "Grab", 10, 10);
my_scenario scenario_1 = new;
my_scenario scenario_2 = new;
initial begin
...
chan.grab(scenario_1);
...
chan.ungrab(scenario_1);
chan.grab(scenario_2);
...
end
endprogram
vmm_channel::level()
Returns the current fill level of the channel.
SystemVerilog
function int unsigned level();
OpenVera
Not supported.
Description
The interpretation of the fill level depends on the configuration of the
channel instance.
vmm_channel::is_full()
Returns an indication of whether the channel is full or not.
SystemVerilog
function bit is_full();
OpenVera
Not supported.
Description
Returns TRUE (that is, non-zero), if the fill level is greater than or
equal to the currently configured full level. Otherwise, returns
FALSE.
vmm_channel::is_grabbed()
Checks if a channel is currently under exclusive use.
SystemVerilog
function bit is_grabbed();
OpenVera
function bit is_grabbed();
Description
Returns TRUE, if the channel is currently grabbed by a scenario.
Otherwise, returns FALSE.
Example
Example A-18
class my_data extends vmm_data;
...
endclass
`vmm_channel(my_data)
class my_scenario extends vmm_ms_scenario;
...
endclass
program test_grab
my_data_channel chan = new("Channel", "Grab", 10, 10);
my_scenario scenario_1 = new;
bit chan_status;
initial begin
...
VMM User Guide
A-68
chan_status = chan.is_grabbed();
if(chan_status == 1)
`vmm_note(log, "The channel is currently grabbed");
else if(parent_grab == 0)
`vmm_note(log, "The channel is currently not grabbed ");
...
end
endprogram
vmm_channel::is_locked()
Returns TRUE (non-zero), if any of the specified sides is locked.
SystemVerilog
function bit is_locked(bit [1:0] who);
OpenVera
Not supported.
Description
Returns TRUE (non-zero), if any of the specified sides is locked. If
both sides are specified, and if any side is locked, then returns
TRUE.
Example
Example A-19
while (chan.is_locked(vmm_channel::SOURCE
vmm_channel::SINK))
begin
chan.notify.wait_for(vmm_channel::UNLOCKED);
end
vmm_channel::kill()
Prepares a channel for deletion.
SystemVerilog
function void kill();
OpenVera
Not supported.
Description
Prepares a channel for deletion and reclamation by the garbage
collector.
Remove this channel instance from the list of input and output
channels of the transactors, which are identified as its producer and
consumer.
Example
Example A-20
program test_grab
vmm_channel chan;
initial begin
chan = new("channel" ,"chan");
...
chan.kill();
...
end
endprogram
vmm_channel::lock()
Blocks any source (consumer), as if the channel was full (empty),
until explicitly unlocked.
SystemVerilog
function void lock(bit [1:0] who);
OpenVera
Not supported.
Description
The side that is to be locked or unlocked is specified using the sum
of the symbolic values, as shown in Table A-3.
Although the source and sink contain same control-flow effect,
locking a source does not indicate the FULL notification, nor does
locking the sink indicate the EMPTY notification.
Table A-3
Table A-4
Symbolic Property
Channel Endpoint
vmm_channel::SOURCE
vmm_channel::SINK
vmm_channel::log
Messages service interface for messages, issued from within the
channel instance.
SystemVerilog
vmm_log log;
OpenVera
Not supported.
vmm_channel::new()
Creates a new instance of a channel with the specified name,
instance name, and full and empty levels.
SystemVerilog
function new(string name,
string instance,
int unsigned full = 1,
int unsigned empty = 0,
bit fill_as_bytes = 0,
vmm_object parent = null);
OpenVera
Not supported.
Description
If the fill_as_bytes argument is TRUE (non-zero), then the full
and empty levels and the fill level of the channel are interpreted as
the number of bytes in the channel, as computed by the sum of
vmm_data::byte_size() of all transaction descriptors in the
channel and not the number of objects in the channel.
If the value is FALSE (zero), the full and empty levels, and the fill
level of the channel are interpreted as the number of transaction
descriptors in the channel.
It is illegal to configure a channel with a full level, lower than the
empty level. The parent argument specifies the type of parent class
which instantiates this channel.
vmm_channel::notify
Indicates the occurrence of events in the channel.
SystemVerilog
vmm_notify notify
OpenVera
Not supported.
Description
An event notification interface used to indicate the occurrence of
significant events within the channel. The notifications shown in
Table A-5 are pre-configured
Table A-5
Symbolic Property
vmm_channel::FULL
vmm_channel::EMPTY
vmm_channel::PUT
vmm_channel::GOT
vmm_channel::PEEKED
Symbolic Property
vmm_channel::
ACTIVATED
vmm_channel::
ACT_STARTED
vmm_channel::
ACT_COMPLETED
vmm_channel::
ACT_REMOVED
vmm_channel::LOCKED
vmm_channel::
UNLOCKED
vmm_channel::
GRABBED
vmm_channel::
UNGRABBED
vmm_channel::
RECORDING
vmm_channel::
PLAYBACK
vmm_channel::
PLAYBACK_DONE
vmm_channel::peek()
Gets a reference to the next transaction descriptor that will be
retrieved from the channel, at the specified offset.
SystemVerilog
task peek(output class-name obj, input int offset = 0);
OpenVera
Not supported.
Description
Gets a reference to the next transaction descriptor that will be
retrieved from the channel, at the specified offset, without actually
retrieving it. If the channel is empty, then the function will block until
a transaction descriptor is available to be retrieved.
It is an error to invoke this method with an offset value greater than
the number of transaction descriptors currently in the channel, or
with a non-empty active slot.
Example
Example A-21
class consumer extends vmm_xactor;
virtual task main();
forever begin
transaction tr;
this.in_chan.peek(tr);
this.in_chan.get(tr);
end
endtask: main
endclass: consumer
VMM User Guide
A- 77
vmm_channel::playback()
Plays-back a recorded transaction stream.
SystemVerilog
task playback(output bit success,
input string
filename,
input vmm_data
factory,
input bit
metered = 0,
input vmm_scenario grabber = null);
OpenVera
task playback_t(var bit success,
string
filename,
rvm_data
factory,
bit
metered = 0);
Description
Injects the recorded transaction descriptors into the channel, in the
same sequence in which they were recorded. The transaction
descriptors are played back one-by-one, in the order found in the file.
The recorded transaction stream replaces the producer for the
channel. Playback does not need to happen in the same simulation
run as recording. It can be executed in a different simulation run.
You must provide a non-null factory argument, of the same
transaction descriptor type, as that with which recording was done.
The vmm_data::byte_unpack() or vmm_data::load()
method must be implemented for the transaction descriptor passed
in to the factory argument.
Example
Example A-22
class packet_env extends vmm_env;
...
task start();
...
`ifndef PLAY_DATA
this.gen.start_xactor();
`else
fork
begin
bit success;
data_packet factory = new;
this.gen.out_chan.playback(success,
"stimulus.dat",
factory, 1);
if (!this.success) begin
`vmm_error(this.log,
"Error during playback");
end
end
join_none
`endif
endtask
...
endclass::packet_env
vmm_channel::put()
Puts a transaction descriptor in the channel.
SystemVerilog
task put(vmm_data obj,
int offset = -1,
vmm_scenario grabber = null);
OpenVera
task put_t(rvm_data obj,
integer offset = -1);
Description
Adds the specified transaction descriptor to the channel. If the
channel is already full, or becomes full after adding the transaction
descriptor, then the task will block until the channel becomes empty.
If an offset is specified, then the transaction descriptor is inserted in
the channel at the specified offset. An offset of 0 specifies at the
head of the channel (LIFO order). An offset of -1 indicates the end of
the channel (FIFO order).
If the channel is currently grabbed by a scenario other than the one
specified, then this method will block and not insert the specified
transaction descriptor in the channel, until the channel is ungrabbed
or grabbed by the specified scenario.
Example
Example A-23
class my_data extends vmm_data;
VMM User Guide
A- 81
...
endclass
`vmm_channel(my_data)
class my_scenario extends vmm_ms_scenario;
...
endclass
program test_grab
my_data_channel chan = new("Channel", "Grab", 10, 10);
my_data md1 = new;
my_scenario scenario_1 = new;
initial begin
...
chan.grab(scenario_1);
chan.put(md1,scenario_1);
...
end
endprogram
vmm_channel::reconfigure()
Reconfigures the full or empty levels of the channel.
SystemVerilog
function void reconfigure(int full = -1,
int empty = -1,
logic fill_as_bytes = 1'bx);
OpenVera
Not supported.
Description
If not negative, this method reconfigures the full or empty levels of
the channel to the specified levels . Reconfiguration may cause
threads, which are currently blocked on a vmm_channel::put()
call to unblock. If the fill_as_bytes argument is specified as 1b1
or 1b0, then the interpretation of the fill level of the channel is
modified accordingly. Any other value, leaves the interpretation of
the fill level unchanged.
Example
Example A-24
class consumer extends vmm_xactor;
transaction_channel in_chan;
...
function new(transaction_channel in_chan = null);
...
if (in_chan == null)
in_chan = new(...);
in_chan.reconfigure(1);
this.in_chan = in_chan;
endfunction: new
...
endclass: consumer
vmm_channel::record()
Starts recording the flow of transaction descriptors.
SystemVerilog
function bit record(string filename);
OpenVera
function bit record(string filename)
Description
Starts recording the flow of transaction descriptors, which are added
through the channel instance in the specified file. The
vmm_data::save() method must be implemented for that
transaction descriptor, and defines the file format. A transaction
descriptor is recorded, when added to the channel by the
vmm_channel::put() method.
A null filename stops the recording process. Returns TRUE, if the
specified file was successfully opened.
vmm_channel::register_vmm_sb_ds()
For more information, refer to the VMM Scoreboard User Guide.
vmm_channel::remove()
Updates the status of the active slot to vmm_channel::INACTIVE.
SystemVerilog
function class-name remove();
OpenVera
Not supported.
Description
Updates the status of the active slot to
vmm_channel::INACTIVE, and removes the transaction
descriptor from the active slot from the channel. This method may
cause the EMPTY notification to be indicated, or the FULL notification
to be reset. It is an error to call this method with an active slot in the
vmm_channel::STARTED state. The vmm_data::ENDED
notification of the transaction descriptor in the active slot is indicated.
Example
Example A-25
class consumer extends vmm_xactor;
virtual task main();
forever begin
transaction tr;
this.in_chan.activate(tr);
this.in_chan.start();
this.in_chan.complete();
this.in_chan.remove();
end
endtask: main
endclass: consumer
vmm_channel::set_consumer()
Specifies the current consumer for a channel.
SystemVerilog
function void set_consumer(vmm_xactor consumer);
OpenVera
Not supported.
Description
Identifies the specified transactor as the current consumer for the
channel instance. This channel will be added to the list of input
channels for the transactor. If a consumer is previously identified, the
channel instance is removed from the previous list of consumer input
channels.
Specifying a NULL transactor indicates that the channel does not
contain any consumer.
Although a channel can contain multiple consumers (even though
with unpredictable distribution of input of each consumer from the
channel, only one transactor can be identified as a consumer of a
channel, as they are primarily a point-to-point transaction-level
connection mechanism.
Example
Example A-26
class tr extends vmm_data;
...
endclass
`vmm_channel(tr)
class xactor extends vmm_xactor;
...
endclass
program prog;
initial begin
xactor xact = new("xact");
tr_channel chan1 = new("tr_channel", "chan1");
...
chan1.set_consumer(xact);
...
end
endprogram
vmm_channel::set_producer()
Specifies the current producer for a channel.
SystemVerilog
function void set_producer(vmm_xactor producer);
OpenVera
Not supported.
Description
Identifies the specified transactor as the current producer for the
channel instance. This channel will be added to the list of output
channels for the transactor. If a producer is previously identified, the
channel instance is removed from the previous list of producer
output channels.
Specifying a NULL transactor indicates that the channel does not
contain any producer.
Although a channel can have multiple producers (even though with
unpredictable ordering of each contribution of a producer to the
channel, only one transactor can be identified as a producer of a
channel, as they are primarily a point-to-point transaction-level
connection mechanism.
Example
Example A-27
class tr extends vmm_data;
...
endclass
`vmm_channel(tr)
`vmm_scenario_gen(tr, "tr")
program prog;
initial begin
tr_scenario_gen sgen = new("Scen Gen");
tr_channel chan1 = new("tr_channel", "chan1");
...
chan1.set_producer(sgen);
...
end
endprogram
vmm_channel::sink()
Flushes the content of the channel, and sinks any further objects put
into it.
SystemVerilog
function void sink();
OpenVera
Not supported.
Description
No transaction descriptors will accumulate in the channel, while it is
sunk. Any thread attempting to obtain a transaction descriptor from
the channel will be blocked, until the flow through the channel is
restored using the vmm_channel::flow() method. This method
causes the FULL notification to be reset, or the EMPTY notification
to be indicated.
vmm_channel::size()
Returns the number of transaction descriptors, which are currently in
the channel.
SystemVerilog
function int unsigned size();
OpenVera
Not supported.
Description
Returns the number of transaction descriptors, which are currently in
the channel, including the active slot, regardless of the interpretation
of the fill level.
vmm_channel::sneak()
Sneaks a transaction descriptor in the channel.
SystemVerilog
function void sneak(vmm_data obj,
int offset = -1,
vmm_scenario grabber = null);
OpenVera
task sneak(rvm_data obj,
integer offset = -1);
Description
Adds the specified transaction descriptor to the channel. This
method will never block, even if the channel is full. An execution
thread calling this method must contain some other throttling
mechanism, to prevent an infinite loop from occurring.
This method is designed to be used in circumstances, where
potentially blocking the execution thread could yield invalid results.
For example, monitors must use this method to avoid missing
observations.
If an offset is specified, the transaction descriptor is inserted in the
channel at the specified offset. An offset of 0 specifies at the head of
the channel (for example, LIFO order). An offset of -1 indicate the
end of the channel (for example, FIFO order).
If the channel is currently grabbed by a scenario, other than the one
specified, the transaction descriptor will not be inserted in the
channel.
Example
Example A-28
class my_data extends vmm_data;
...
endclass
`vmm_channel(my_data)
class my_scenario extends vmm_ms_scenario;
...
endclass
program test_grab
my_data_channel chan = new("Channel", "Grab", 10, 10);
my_data md1 = new;
my_scenario scenario_1 = new;
initial begin
...
chan.grab(scenario_1);
chan.sneak(md1,,scenario_1);
...
end
endprogram
vmm_channel::start()
Updates the status of the active slot to vmm_channel::STARTED.
SystemVerilog
function class-name start();
OpenVera
Not supported.
Description
The transaction descriptor remains in the active slot. It is an error to
call this method, if the active slot is empty. The
vmm_data::STARTED notification of the transaction descriptor in
the active slot is indicated.
Example
Example A-29
class consumer extends vmm_xactor;
...
virtual task main();
forever begin
transaction tr;
...
this.in_chan.activate(tr);
this.in_chan.start();
...
this.in_chan.complete();
this.in_chan.remove();
end
endtask: main
...
endclass: consumer
vmm_channel::status()
Returns an enumerated value indicating the status of the transaction
descriptor in the active slot.
SystemVerilog
function active_status_e status();
OpenVera
Not supported.
Description
Returns one of the enumerated values, as shown in Table A-6,
indicating the status of the transaction descriptor in the active slot.
Table A-6
Table A-7
Symbolic Property
vmm_channel::INACTIVE
vmm_channel::PENDING
vmm_channel::STARTED
vmm_channel::COMPLETED
vmm_channel::tee()
Retrieves a copy of the transaction descriptor references that have
been retrieved by the get() or activate() methods.
SystemVerilog
task tee(output class-name obj);
OpenVera
Not supported.
Description
When the tee mode is ON, retrieves a copy of the transaction
descriptor references that is retrieved by the get() or activate()
methods. The task blocks until one of the get() or activate()
methods successfully completes.
This method can be used to fork off a second stream of references
to the transaction descriptor stream.
Note:The transaction descriptors themselves are not copied.
The references returned by this method are referring to the same
transaction descriptor instances obtained by the get() and
activate() methods.
vmm_channel::tee_mode()
Turns the tee mode ON or OFF for this channel.
SystemVerilog
function bit tee_mode(bit is_on);
OpenVera
Not supported.
Description
Returns TRUE, if the tee mode was previously ON. A thread that is
blocked on a call to the vmm_channel::tee() method will not
unblock execution, if the tee mode is turned OFF. If the stream of
references is not drained through the vmm_channel::tee()
method, data will accumulate in the secondary channel when the tee
mode is ON.
vmm_channel::try_grab()
Tries grabbing a channel for exclusive use.
SystemVerilog
function bit try_grab(vmm_scenario grabber);
OpenVera
function bit try_grab(rvm_scenario grabber);
Description
Tries grabbing a channel for exclusive use and returns TRUE, if the
channel was successfully grabbed by the scenario. Otherwise, it
returns FALSE.
For more information on the channel grabbing rules, see the section
vmm_channel::grab().
Example
Example A-30
class my_data extends vmm_data;
...
endclass
`vmm_channel(my_data)
class my_scenario extends vmm_ms_scenario;
...
endclass
program test_grab
my_data_channel chan = new("Channel", "Grab", 10, 10);
vmm_channel_typed#(type)
Parameterized transaction-level interface.
SystemVerilog
class vmm_channel_typed #(type T) extends vmm_channel;
OpenVera
Not supported.
Description
Parameterized class implementing a strongly typed transaction-level
interface. The specified type parameter, T must be based on the
vmm_data base class.
This class is the underlying class corresponding to the T_channel
class that is created when using the vmm_channel(T) macro.
They are both interchangeable. The parameterized class may be
used directly, without having to declare the strongly-typed channel
using the vmm_channel() macro beforehand.
The parameterized class also allows channels of parameterized
classes to be defined without having to define an intermediate
typedef.
Example
Example A-31 Equivalent definitions
vmm_channel(eth_frame)
eth_frame_channel in_chan;
vmm_channel_typed#(eth_frame) in_chan;
Example A-32
Equivalent definitions
vmm_channel::ungrab()
Releases a channel from exclusive use.
SystemVerilog
function void ungrab(vmm_scenario grabber);
OpenVera
task ungrab(rvm_scenario grabber);
Description
Releases a channel that is previously grabbed for the exclusive use
of a scenario, using the vmm_channel::grab() method. If
another scenario is waiting to grab the channel, it will be immediately
grabbed.
A channel must be explicitly ungrabbed, after the execution of an
exclusive transaction stream is completed, to avoid creating
deadlocks.
When a channel is ungrabbed, the vmm_channel::UNGRABBED
notification is indicated.
Example
Example A-33
class my_data extends vmm_data;
...
endclass
`vmm_channel(my_data)
class my_scenario extends vmm_ms_scenario;
...
endclass
program test_grab
my_data_channel chan = new("Channel", "Grab", 10, 10);
my_scenario scenario_1 = new;
my_scenario scenario_2 = new;
initial begin
...
chan.grab(scenario_1);
...
chan.ungrab(scenario_1);
chan.grab(scenario_2);
...
end
endprogram
vmm_channel::unlock()
Blocks any source (consumer), as if the channel was full (empty),
until explicitly unlocked.
SystemVerilog
function void unlock(bit [1:0] who);
OpenVera
Not supported.
Description
The side that is to be locked or unlocked is specified using the sum
of the symbolic values, as shown in Table A-3.
Although the source and sink contain the same control-flow effect,
locking a source does not indicate the FULL notification, nor does
locking the sink indicate the EMPTY notification.
vmm_channel::unput()
Removes the specified transaction descriptor from the channel.
SystemVerilog
function class-name unput(int offset = -1);
OpenVera
Not supported.
Description
It is an error to specify an offset to a transaction descriptor that does
not exist.
This method may cause the EMPTY notification to be indicated, and
causes the FULL notification to be reset.
vmm_channel::unregister_vmm_sb_ds()
For more information, refer to the VMM Scoreboard User Guide.
vmm_channel()
Defines a channel class to transport instances of the specified class.
SystemVerilog
vmm_channel(class-name)
OpenVera
Not supported.
Description
The transported class must be derived from the vmm_data class.
This macro is typically invoked in the same file, where the specified
class is defined and implemented.
This macro creates an external class declaration, and no
implementation. It is typically invoked when the channel class must
be visible to the compiler, but the actual channel class declaration is
not yet available.
vmm_connect#(T,N,D)
Utility class for connecting channels and notifications in the
vmm_unit::connect_ph() method.
SystemVerilog
class vmm_connect #(type T=vmm_channel, type N=T, type
D=vmm_data);
Description
The vmm_connect utility class can be used for connecting channels
and notifications in the vmm_unit::connect_ph() method. It
performs additional check to verify whether the channels are already
connected.
Summary
vmm_connect::channel() ...........................
vmm_connect::notify() ............................
vmm_connect::tlm_bind() ..........................
vmm_connect::tlm_transport_interconnect() ........
page
page
page
page
A-111
A-112
A-113
A-115
vmm_connect::channel()
Connects the specified channel ports.
SystemVerilog
class vmm_connect#(T)::channel(ref T upstream, downstream,
string name = "", vmm_object parent = null);
Description
Connects the specified channel ports (upstream and
downstream). If both specified channels are not null, then they are
connected using the upstream.connect(downstream)
statement. Otherwise, both channels are connected by referring to
the same channel instance. It is an error to attempt to connect two
channels that are already connected together or to another channel.
The optional argument name specifies the name of the binding, while
parent is the component in which this binding is done.
Example
class ahb_unit extends vmm_group;
ahb_trans_channel gen_chan;
ahb_trans_channel drv_chan;
virtual function void build_ph();
gen_chan = new("ahb_chan", "gen_chan");
drv_chan = new("ahb_chan", "drv_chan");
endfunction
virtual function void connect_ph();
vmm_connect#(ahb_trans_channel)::channel(
gen_chan, drv_chan, "gen2drv", this);
endfunction
endclass
vmm_connect::notify()
Connects the specified observer to the specification notification.
SystemVerilog
class vmm_connect#(T,N,D)::notify(N observer,
vmm_notify ntfy, int notification_id);
Description
Connects the specified observer to the specification notification,
using an instance of the vmm_notify_observer class. The
specified argument ntfy indicates the notify class under which
specified notification notification_id is registered. Each
subsequent call to ntfy.indicate(notification_id, tr)
allow to directly pass the transaction tr to the observer.
Example
class scoreboard;
virtual function void observe_trans(ahb_trans tr);
endfunction
endclass
`vmm_notify_observer(scoreboard, observe_trans)
class ahb_unit extends vmm_group;
scoreboard sb;
virtual function void build_ph();
sb = new();
endfunction
virtual function void connect_ph();
vmm_connect#(.N(scoreboard), .D(ahb_trans))::notify(
sb, mon.notify, mon.TRANS_STARTED);
endfunction
endclass
vmm_connect::tlm_bind()
Connects a VMM channel to a TLM interface.
SystemVerilog
class vmm_connect#(.D(d))::tlm_bind(
vmm_channel_typed#(D) channel ,
vmm_tlm_base tlm_intf,
vmm_tlm::intf_e intf,
string fname = "", int lineno = 0);
Description
Connects the specified VMM channel channel to the specified TLM
interface tlm_intf. The TLM interface can be of any type as
provided with intf such as vmm_tlm::TLM_BLOCKING_PORT,
vmm_tlm::TLM_BLOCKING_EXPORT.
Example
class Environment extends vmm_env;
packet_atomic_gen gen[];
tlm_driver
drv[];
virtual function void build_ph();
gen = new[4];
drv = new[4];
for(int i=0; i<drv.size; i++) begin
drv[i] = new($psprintf("Driver[%0d]", i), i, router);
gen[i] = new($psprintf("Gen[%0d]", i), i);
end
endfunction
virtual function void connect_ph();
for(int i=0; i<drv.size; i++) begin
vmm_connect #(.D(Packet))::tlm_bind(
gen[i].out_chan,
VMM User Guide
A- 113
drv[i].socket,
vmm_tlm::TLM_BLOCKING_PORT);
end
endfunction
endclass
vmm_connect::tlm_transport_interconnect()
Connects TLM port to TLM export.
SystemVerilog
static function tlm_transport_interconnect(vmm_tlm_base
tlm_intf_port, vmm_tlm_base tlm_intf_export,
vmm_tlm::intf_e intf, vmm_object parent = null, string fname
= "", int lineno = 0);
Description
Binds the tlm_intf_port to tlm_intf_export, which are
passed as arguments to the function.
First argument to the function is tlm port and the second argument is
tlm export. If wrong types are passed to first or second argument
then an error is issued.
Third argument takes the following values:
vmm_tlm::TLM_NONBLOCKING_EXPORT
This is used when producer is vmm_tlm_b_transport_port
and consumer is vmm_tlm_nb_transport_export.
vmm_tlm::TLM_NONBLOCKING_FW_EXPORT
This is used when producer is vmm_tlm_b_transport_port
and consumer is vmm_tlm_nb_transport_fw_export.
vmm_tlm::TLM_NONBLOCKING_PORT
This is used when producer is vmm_tlm_nb_transport_port
and consumer is vmm_tlm_b_transport_export.
vmm_tlm::TLM_NONBLOCKING_FW_PORT
This is used when producer is
vmm_tlm_nb_transport_fw_port and consumer is
vmm_tlm_b_transport_export.
Any other values for third argument will issue an error.
Example
class Environment extends vmm_env;
tlm_gen gen;
tlm_driver drv;
virtual function void build_ph();
gen = new(this,tlm_gen);
drv = new(this,tlm_driver);
endfunction
virtual function void connect_ph();
vmm_connect#(vmm_channel,vmm_channel,my_trans)::tlm_transp
ort_interconnect(gen.socket,drv.socket,vmm_tlm::TLM_NONBLO
CKING_EXPORT,this);
endfunction
endclass
vmm_consensus
This class is used to determine when all the elements of a testcase,
a verification environment, or a sub-environment agree that the test
may be terminated.
Summary
vmm_consensus::consensus_force_thru() ............
vmm_consensus::forcing() .........................
vmm_consensus::is_forced() .......................
vmm_consensus::is_reached() ......................
vmm_consensus::log ...............................
vmm_consensus::nays() ............................
vmm_consensus::new() .............................
vmm_consensus::notifications_e ...................
vmm_consensus::psdisplay() .......................
vmm_consensus::register_channel() ................
vmm_consensus::register_consensus() ..............
vmm_consensus::register_no_notification() ........
vmm_consensus::register_notification() ...........
vmm_consensus::register_voter() ..................
vmm_consensus::register_xactor() .................
vmm_consensus::request() .........................
vmm_consensus::unregister_channel() ..............
vmm_consensus::unregister_consensus() ............
vmm_consensus::unregister_notification() .........
vmm_consensus::unregister_voter() ................
vmm_consensus::unregister_xactor() ...............
vmm_consensus::wait_for_consensus() ..............
vmm_consensus::wait_for_no_consensus() ...........
vmm_consensus::yeas() ............................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-118
A-119
A-120
A-121
A-122
A-123
A-124
A-125
A-126
A-127
A-128
A-130
A-132
A-134
A-136
A-137
A-138
A-139
A-140
A-142
A-143
A-144
A-145
A-146
vmm_consensus::consensus_force_thru()
Forces sub-consensus through or not.
SystemVerilog
function void consensus_force_thru(
vmm_consensus vote,
bit force_through = 1);
OpenVera
Not supported
Description
If the force_through argument is TRUE, any consensus forced
on the specified sub-consensus instance will force the consensus on
this vmm_consensus instance.
If the force_through argument is FALSE, any consensus forced
on the specified sub-consensus instance will simply consent to the
consensus on this vmm_consensus instance.
vmm_consensus::forcing()
Returns a description of the forcing participants.
SystemVerilog
function void forcing(ref string who[],
ref string why[]);
OpenVera
task forcing(var string who[*],
var string why[*]);
Description
Returns a description of the testbench elements that are currently
forcing the end of test, and their respective reasons.
Example
Example A-34
program test_consensus;
string who[];
string why[];
vmm_consensus vote = new("Vote", "Main");
initial begin
...
vote.forcing(who,why);
for(int i=0; i<who.size; i++)
$display(" %s ------ %s",who[i],why[i]);
...
end
endprogram
vmm_consensus::is_forced()
Checks if a consensus is being forced.
SystemVerilog
function bit is_forced();
OpenVera
function bit is_forced();
Description
This method returns an indication, if a participant forces a
consensus. If the consensus is forced, a non-zero value is returned.
If there is no consensus, or the consensus is not being forced, a zero
value is returned.
Example
Example A-35
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
...
if (vote.is_forced())
`vmm_note (vote.log, "Consensus is forced");
end
...
end
endprogram
vmm_consensus::is_reached()
Checks if a consensus is reached.
SystemVerilog
function bit is_reached();
OpenVera
function bit is_reached();
Description
This method returns an indication, if a consensus is reached. If a
consensus exists (whether forced or not), a non-zero value is
returned. If there is no consensus, and the consensus is not being
forced, a zero value is returned.
Example
Example A-36
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
...
if (vote.is_reached())
`vmm_note (vote.log, "Consensus is reached");
else
`vmm_error (vote.log, "Consensus has not reached");
...
end
endprogram
vmm_consensus::log
Message service interface for the consensus class.
SystemVerilog
vmm_log log;
OpenVera
rvm_log log;
Description
This property is set by the constructor using the specified name and
instance name. These names may be modified afterward, using the
vmm_log::set_name() or vmm_log::set_instance()
methods.
Example
Example A-37
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
...
if (vote.is_reached()) begin
`vmm_note(vote.log, "Consensus has reached ");
end else begin
`vmm_note(vote.log, "Consensus has not reached yet");
end
...
end
endprogram
vmm_consensus::nays()
Returns a description of the opposing participants.
SystemVerilog
function void nays(ref string who[],
ref string why[]);
OpenVera
task nays(var string who[*],
var string why[*]);
Description
Returns a description of the testbench elements, which are currently
opposing to the end of test, and their respective reasons.
Example
Example A-38
program test_consensus;
string who[];
string why[];
vmm_consensus vote = new("Vote", "Main");
initial begin
...
vote.nays(who,why);
for(int i=0; i<who.size; i++)
$display(" %s ------ %s",who[i],why[i]);
...
end
endprogram
vmm_consensus::new()
Creates a consensus, usually to determine the end-of-test.
SystemVerilog
function new(string name, string inst, vmm_log log = null);
OpenVera
task new(string name,
string inst);
Description
Creates a new instance of this class with the specified name and
instance name. The specified name and instance names are used as
the name and instance names of the log class property. You can
pass a massage service interface(log) to consensus through
constructor, if log is not being passed the it will create a new instance
of log.
Example
Example A-39
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
...
end
endprogram
vmm_consensus::notifications_e
Predefined notifications.
SystemVerilog
typedef enum int { NEW_VOTE = 999_999,
REACHED = 999_998,
REQUEST = 999_997} notifications_e;
OpenVera
static integer NEW_VOTE;
Description
Predefined notifications that are configured in
vmm_consensus::notify object.
NEW_VOTE is a ONE_SHOT notification that is indicated whenever a
participant changes its vote (using vmm_consensus::consent,
vmm_consensus::oppose or vmm_consensus::forced).
REACHED is a ON_OFF notification that is indicated whenever a test
case end condition is reached or unregister_all method is
called. REQUEST is a ONE_SHOT notification that is indicated
whenever a request method is called.
vmm_consensus::psdisplay()
Describes the status of the consensus.
SystemVerilog
function string psdisplay(string prefix = "");
OpenVera
function string psdisplay(string prefix = "");
Description
Returns a human-readable description of the current status of the
consensus, and who is opposing or forcing the consensus and why.
Each line of the description is prefixed with the specified prefix.
Example
Example A-40
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
...
$display(vote.psdisplay());
...
end
endprogram
vmm_consensus::register_channel()
Registers a channel as a participant.
SystemVerilog
function void register_channel(vmm_channel chan);
OpenVera
task register_channel(rvm_channel chan);
Description
Adds a channel that can participate in this consensus. By default, a
channel opposes the end of test if it is not empty, and consents to the
end of test if it is currently empty. The channel may be later
unregistered from the consensus using the
vmm_consensus::unregister_channel() method.
Example
Example A-41
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_channel v1 =new("Voter", "#1");
...
vote.register_channel(v1);
...
end
endprogram
vmm_consensus::register_consensus()
Registers a sub-consensus as a participant.
SystemVerilog
function void register_consensus(vmm_consensus vote,
bit force_through = 0);
OpenVera
task register_consensus(vmm_consensus vote
bit force_through = 0);
Description
Adds a sub-consensus that can participate in this consensus. By
default, a sub-consensus opposes the higher-level end of test if it is
not reached its own consensus. Also, it consents to the higher-level
end of test, if it is reached (or forced) its own consensus. The subconsensus may be later unregistered from the consensus, using the
vmm_consensus::unregister_consensus() method.
By default, a sub-consensus that has reached its consensus by force
will not force a higher-level consensus, only consent to it. If the
force_through parameter is specified as non-zero, a forced subconsensus will force a higher-level consensus.
Example
Example A-42
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_consensus c1;
c1 = new("SubVote", "#1");
...
vote.register_consensus(c1, 0);
...
end
endprogram
vmm_consensus::register_no_notification()
Registers a notification as a participant.
SystemVerilog
function void register_no_notification(vmm_notify notify,
int notification);
OpenVera
task register_no_notification(rvm_notify notify,
integer notification);
Description
Adds an ON or OFF notification that can participate in this
consensus. By default, a notification opposes the end of test if it is
indicated, and consents to the end of test if it is not currently
indicated. The notification may be later unregistered from the
consensus using the
vmm_consensus::unregister_notification() method.
For more information on the opposite polarity participation, see the
section, vmm_consensus::register_notification() .
Example
Example A-43
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_notify v1;
vmm_log notify_log;
notify_log = new ("Voter", "#1");
v1 = new (notify_log);
v1.configure(1, vmm_notify::ON_OFF);
...
vote.register_no_notification(v1,1);
...
end
endprogram
vmm_consensus::register_notification()
Registesr a notification as a participant.
SystemVerilog
function void register_notification(vmm_notify notify,
int notification);
OpenVera
task register_notification(rvm_notify notify,
integer notification);
Description
Adds an ON or OFF notification that can participate in this
consensus. The specified argument notify is the handle of
vmm_notify class under which specified notification is registered.
By default, a notification opposes the end of test if it is not indicated,
and consents to the end of test if it is currently indicated. The
notification may be later unregistered from the consensus using the
vmm_consensus::unregister_notification() method.
For more information on opposite polarity participation, see the
vmm_consensus::register_no_notification()
method.
Example
Example A-44
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_notify v1;
vmm_log notify_log;
notify_log = new ("Voter", "#1");
v1 = new (notify_log);
v1.configure(1, vmm_notify::ON_OFF);
...
vote.register_notification(v1,1);
...
end
endprogram
vmm_consensus::register_voter()
Registers a new general purpose participant.
SystemVerilog
function vmm_voter register_voter(string name, vmm_voter
voter = null);
OpenVera
function vmm_voter register_voter(string name);
Description
Creates a new general-purpose voter interface that can participate
in this consensus. The specified argument name indicates the name
of a voter. If null is specified to the vmm_voter argument, an
instance of vmm_voter will be internally allocated. By default, a
voter opposes the end of test. The voter interface may be later
unregistered from the consensus using the
vmm_consensus::unregister_voter() method.
For more information on the general-purpose participant interface,
see the section vmm_voter .
Example
Example A-45
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_voter v1;
...
v1 = vote.register_voter("Voter #1");
...
end
endprogram
vmm_consensus::register_xactor()
Registers a transactor as a participant.
SystemVerilog
function void register_xactor(vmm_xactor xact);
OpenVera
task register_xactor(rvm_xactor xact);
Description
Adds a transactor that can participate in this consensus. A
transactor opposes the end-of-test, if it is currently indicating the
vmm_xactor::IS_BUSY notification. Moreover, it consents to the
end of test, if it is currently indicating the vmm_xactor::IS_IDLE
notification. The transactor may be later unregistered from the
consensus using the
vmm_consensus::unregister_xactor() method.
Example
Example A-46
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_xactor v1 =new("Voter", "#1");
...
vote.register_xactor(v1);
...
end
endprogram
vmm_consensus::request()
Requests that a consensus be reached.
SystemVerilog
task request(string why = No reason specified,
vmm_consensus requester = null);
OpenVera
Not supported
Description
Makes a request of all currently-opposing participants, in this
consensus instance that they consent to the consensus.
A request is made by indicating the vmm_consensus::REQUEST
notification on the vmm_consensus::notify notification interface
of this consensus instance, and all currently-opposing subconsensus instances. If a request is made on a consensus instance
that is a child of a vmm_unit instance, the
vmm_unit::consensus_requested() method is also invoked.
If this consensus forces through to a higher-level consensus, the
consensus request is propagated upward as well.
This task returns when the local consensus is reached.
vmm_consensus::unregister_channel()
Unregisters a channel participant.
SystemVerilog
function void unregister_channel(vmm_channel chan);
OpenVera
task unregister_channel(rvm_channel chan);
Description
Removes a previously registered channel from this consensus. If the
channel was the only participant that objected to the consensus, the
consensus will subsequently be reached.
Example
Example A-47
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_channel v1 =new("Voter", "#1");
...
vote.register_channel(v1);
...
vote.unregister_channel(v1);
...
end
endprogram
vmm_consensus::unregister_consensus()
Unregisters a sub-consensus participant.
SystemVerilog
function void unregister_consensus(vmm_consensus vote);
OpenVera
task unregister_consensus(vmm_consensus vote);
Description
Removes a previously registered sub-consensus from this
consensus. If the sub-consensus was the only participant that
objected to the consensus, the consensus will subsequently be
reached. If the sub-consensus was forcing the consensus despite
other objections, the consensus will subsequently no longer be
reached.
Example
Example A-48
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_consensus c1;
c1 = new("SubVote", "#1");
vote.register_consensus(c1, 0);
...
vote.unregister_consensus(c1);
end
endprogram
VMM User Guide
A- 139
vmm_consensus::unregister_notification()
Unregisters a notification participant.
SystemVerilog
function void unregister_notification(vmm_notify notify,
int notification);
OpenVera
task unregister_notification(rvm_notify notify,
integer notification);
Description
Removes a previously registered ON or OFF notification from this
consensus. The specified argument notify is the handle of
vmm_notify class under which specified notification is registered.
If the notification was the only participant that objected to the
consensus, the consensus will subsequently be reached.
Example
Example A-49
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_notify v1;
vmm_log notify_log;
notify_log = new ("Voter", "#1");
v1 = new (notify_log);
v1.configure(1, vmm_notify::ON_OFF);
vote.register_notification(v1,1);
vote.unregister_notification(v1,1);
end
endprogram
vmm_consensus::unregister_voter()
Unregisters a general purpose participant.
SystemVerilog
function void unregister_voter(vmm_voter voter);
OpenVera
task unregister_voter(vmm_voter voter);
Description
Removes a previously registered general-purpose voter interface
from this consensus. If the voter was the only participant that
objected to the consensus, the consensus will subsequently be
reached.
Example
Example A-50
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_voter v1;
...
v1 = vote.register_voter("Voter #1");
...
vote.unregister_voter(v1);
...
end
endprogram
vmm_consensus::unregister_xactor()
Unregisters a transactor participant.
SystemVerilog
function void unregister_xactor(vmm_xactor xact);
OpenVera
task unregister_xactor(rvm_xactor xact);
Description
Removes a previously registered transactor from this consensus. If
the transactor was the only participant that objected to the
consensus, then the consensus will subsequently be reached.
Example
Example A-51
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vmm_xactor v1 =new("Voter", "#1");
...
vote.register_xactor(v1);
...
vote.unregister_xactor(v1);
...
end
endprogram
vmm_consensus::wait_for_consensus()
Waits until a consensus is reached.
SystemVerilog
task wait_for_consensus();
OpenVera
task wait_for_consensus_t();
Description
Waits until all participants, which explicitly consent and none oppose.
There can be no abstentions.
If a consensus is already reached or forced, by the time this task is
called, this task will return immediately.
A consensus may be broken later (if the simulation is still running) by
any voter opposing the end of test, or a voter forcing the consensus
deciding to consent normally or oppose normally.
Example
Example A-52
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
vote.wait_for_consensus();
end
endprogram
vmm_consensus::wait_for_no_consensus()
Waits until a consensus is no longer reached.
SystemVerilog
task wait_for_no_consensus();
OpenVera
task wait_for_no_consensus_t();
Description
Waits until a consensus is broken by no longer being forced and any
one participant opposing. If a consensus is not reached, nor forced
by the time this task is called, then this task will return immediately.
Example
Example A-53
program test_consensus;
vmm_consensus vote = new("Vote", "Main");
initial begin
...
vote.wait_for_no_consensus();
...
end
endprogram
vmm_consensus::yeas()
Returns a description of the consenting participants.
SystemVerilog
function void yeas(ref string who[],
ref string why[]);
OpenVera
task yeas(var string who[*],
var string why[*]);
Description
Returns a description of the testbench elements currently consenting
to the end of test, and their respective reasons.
Example
Example A-54
program test_consensus;
string who[];
string why[];
vmm_consensus vote = new("Vote", "Main");
initial begin
...
vote.yeas(who,why);
for(int i=0; i<who.size; i++)
$display(" %s ------ %s",who[i],why[i]);
...
end
endprogram
vmm_data
Models transactions efficiently.
SystemVerilog
int vmm_data::lineno = 0
string vmm_data::filename = ""
Description
The lineno and filename properties should be automatically set
by the create_instance() method, and the predefined
generators. Their content must be copied in the
vmm_data::copy_data() method. If set to non-default values,
their content should be displayed in the vmm_data::psdisplay()
method.
Data modeling can be done more quickly due to unified data
encapsulation, and by the presence of predefined methods for
allocating, copying, comparing, displaying, and byte packing or
unpacking of objects
This base class is to be used as the basis for all transaction
descriptors and data models. It provides a standard set of methods
expected to be found in all descriptors. It also creates a common
class (similar to void type in C language) that can be used to create
generic components.
The vmm_data class comes with shorthand macros that greatly
facilitate data member declaration, and provide a quick way to
implement the content of predefined methods. Implementing these
methods provides an environment for other classes, such as
vmm_channel, vmm_mss, vmm_scoreboard, and so on.
VMM User Guide
A- 147
Shorthand Macro:
do_is_valid()
is_valid()
do_allocate()
allocate()
do_copy()
copy()
do_compare()
compare()
do_byte_size()
byte_size()
do_max_byte_size()
max_byte_size()
do_byte_pack()
byte_pack()
do_byte_unpack()
byte_unpack()
Summary
vmm_data::byte_size() ............................
vmm_data::byte_unpack() ..........................
vmm_data::do_byte_pack() .........................
vmm_data::do_byte_pack() .........................
vmm_data::do_byte_size() .........................
vmm_data::do_byte_unpack() .......................
vmm_data::do_compare() ...........................
vmm_data::do_copy() ..............................
vmm_data::do_how_e ...............................
vmm_data::do_is_valid() ..........................
vmm_data::do_max_byte_size() .....................
vmm_data::do_psdisplay() .........................
vmm_data::do_what_e ..............................
vmm_data::is_valid() .............................
vmm_data::load() .................................
vmm_data::set_log() ..............................
vmm_data::max_byte_size() ........................
vmm_data::new() ..................................
vmm_data::notify .................................
vmm_data::psdisplay() ............................
vmm_data::save() .................................
vmm_data::scenario_id ............................
vmm_data::stream_id ..............................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-177
A-178
A-180
A-180
A-182
A-184
A-186
A-188
A-190
A-192
A-194
A-195
A-196
A-197
A-198
A-199
A-200
A-201
A-202
A-203
A-204
A-205
A-206
vmm_data_byte_size()
The shorthand implementation packing size methods.
SystemVerilog
vmm_data_byte_size(max-expr, size-expr)
OpenVera
Not supported.
Description
Provides a default implementation of the byte_size() and
max_byte_size() methods. The first and second expressions
specify the value returned by the max_byte_size() and
byte_size() methods respectively. The expression must be a
valid SystemVerilog expression in the content of the class.
The shorthand implementation must be located immediately before
the vmm_data_member_begin() .
Example
Example A-55
class eth_frame extends vmm_data;
...
vmm_data_byte_size(1500, this.len_typ+16)
vmm_data_member_begin(eth_frame)
...
vmm_data_member_end(eth_frame)
...
endclass
vmm_data_member_begin()
Starts the shorthand section.
SystemVerilog
vmm_data_member_begin(class-name)
OpenVera
Not supported.
Description
Starts the shorthand section providing a default implementation for
the psdisplay(), is_valid(), allocate(), copy(),
compare(), byte_pack, and byte_unpack() methods. A
default implementation for the constructor is also provided, unless
the vmm_data_new() method is previously specified.
In addition, a default implementation for byte_size() and
max_byte_size()is also provided, unless the
vmm_data_byte_size() method is previously specified.
The specified class-name must be the name of the vmm_data
extension class that is being implemented.
The shorthand section can only contain shorthand macros, and must
be terminated by the vmm_data_member_end() method.
Example
Example A-56
class eth_frame extends vmm_data;
VMM User Guide
A-152
...
vmm_data_member_begin(eth_frame)
vmm_data_member_end(eth_frame)
endclass
vmm_data_member_end()
Terminates the shorthand section.
SystemVerilog
vmm_data_member_end(class-name)
OpenVera
Not supported.
Description
Terminates the shorthand section providing a default implementation
for the psdisplay(), is_valid(), allocate(), copy(),
compare(), byte_size(), max_byte_size(), byte_pack,
and byte_unpack() methods.
The class-name specified must be the name of the vmm_data
extension class that is being implemented.
The shorthand section must have been started by the
vmm_data_member_begin() method.
Example
Example A-57
class eth_frame extends vmm_data;
...
vmm_data_member_begin(eth_frame)
...
vmm_data_member_end(eth_frame)
...
endclass
vmm_data_member_enum*()
The shorthand implementation for an enumerated data member.
SystemVerilog
vmm_data_member_enum(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_enum_array(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_enum_da(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_enum_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_enum_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified enum-type, fixed array of enums, dynamic array
of enums, scalar-indexed associative array of enums, or stringindexed associative array of enums data member to the default
implementation of the methods, specified by the do_what
argument.
The shorthand implementation must be located in a section started
by vmm_data_member_begin() .
Example
Example A-58
typedef enum bit[1:0] {NORMAL, VLAN, JUMBO } packet_type;
class eth_frame extends vmm_data;
rand packet_type packet_type_var;
...
`vmm_data_member_begin(eth_frame)
`vmm_data_member_enum (packet_type_var, DO_ALL)
...
`vmm_data_member_end(eth_frame)
...
endclass
vmm_data_member_handle*()
The shorthand implementation for a class handle data member.
SystemVerilog
vmm_data_member_handle(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_handle_array(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_handle_da(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_handle_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_handle_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified handle-type fixed array of handles, dynamic array
of handles, scalar-indexed associative array of handles, or stringindexed associative array of handles data member to the default
implementation of the methods specified by the do_what argument.
The shorthand implementation must be located in a section started
by vmm_data_member_begin().
Example
Example A-59
class vlan_frame;
...
endclass
class eth_frame extends vmm_data;
vlan_frame vlan_fr_var ;
...
`vmm_data_member_begin(eth_frame)
`vmm_data_member_handle(vlan_fr_var, DO_ALL)
...
`vmm_data_member_end(eth_frame)
...
endclass
vmm_data_new()
Starts the explicit constructor implementation.
SystemVerilog
vmm_data_new(class-name)
OpenVera
Not supported.
Description
Specifies that an explicit user-defined constructor is used instead of
the default constructor provided by the shorthand macros. Also,
declares a vmm_log instance that can be passed to the base
class constructor. Use this macro when data members must be
explicitly initialized in the constructor.
The class-name specified must be the name of the vmm_data
extension class that is being implemented.
This macro should be followed by the constructor declaration and
must precede the shorthand data member section i.e., be located
before the vmm_data_member_begin() macro.
Example
Example A-60
class eth_frame extends vmm_data;
...
vmm_data_new(eth_frame)
function new();
super.new(this.log)
VMM User Guide
A- 159
...
endfunction
vmm_data_member_begin(eth_frame)
...
vmm_data_member_end(eth_frame)
...
endclass
vmm_data_member_scalar*()
The shorthand implementation for a scalar data member.
SystemVerilog
vmm_data_member_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_scalar_array(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_scalar_da(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_scalar_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_scalar_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified scalar-type, fixed array of scalars, dynamic array
of scalars, scalar-indexed associative array of scalars, or stringindexed associative array of scalars data member to the default
implementation of the methods specified by the do_what argument.
A scalar is an integral type, such as bit, bit vector, and packed
unions.
The shorthand implementation must be located in a section started
by vmm_data_member_begin() .
Example
Example A-61
class eth_frame extends vmm_data;
rand bit [47:0] da;
...
vmm_data_member_begin(eth_frame)
vmm_data_member_scalar(da, DO_ALL);
...
vmm_data_member_end(eth_frame)
...
endclass
vmm_data_member_string*()
The shorthand implementation for a string data member.
SystemVerilog
vmm_data_member_string(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_string_array(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_string_da(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_string_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_data_member_string_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified string-type, fixed array of strings, dynamic array
of strings, scalar-indexed associative array of strings, or stringindexed associative array of strings data member to the default
implementation of the methods specified by the do_what argument.
The shorthand implementation must be located in a section started
by vmm_data_member_begin() .
Example
Example A-62
class eth_frame extends vmm_data;
string frame_name;
...
`vmm_data_member_begin(eth_frame)
`vmm_data_member_string(frame_name, DO_ALL)
...
`vmm_data_member_end(eth_frame)
...
endclass
vmm_data_member_user_defined()
User-defined shorthand implementation data member.
SystemVerilog
vmm_data_member_user_defined(member-name)
OpenVera
Not supported.
Description
Adds the specified user-defined default implementation of the
member.
The shorthand implementation must be located in a section started
by vmm_data_member_begin() .
Example
Example A-63
class eth_frame extends vmm_data;
rand bit [47:0] da;
`vmm_data_member_begin(eth_frame)
`vmm_data_member_user_defined(da)
`vmm_data_member_end(eth_frame)
function bit do_da ( input vmm_data::do_what_e do_what)
do_da = 1;
case (do_what)
endcase
endfunction
endclass
vmm_data_member_vmm_data*()
The shorthand implementation for a vmm_data-based data member.
SystemVerilog
vmm_data_member_vmm_data(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_data_member_vmm_data_array(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_data_member_vmm_data_da(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_data_member_vmm_data_aa_scalar(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_data_member_vmm_data_aa_string(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e
do_how)
OpenVera
Not supported.
Description
Adds the specified vmm_data-type, fixed array of vmm_datas,
dynamic array of vmm_datas, scalar-indexed associative array of
vmm_datas, or string-indexed associative array of vmm_datas data
member to the default implementation of the methods specified by
the do_what argument. The do_how argument specifies whether
the vmm_data values must be processed deeply or shallowly.
Example
Example A-64
class vlan_frame extends vmm_data;
...
endclass
class eth_frame extends vmm_data;
vlan_frame vlan_fr_var ;
...
`vmm_data_member_begin(eth_frame)
`vmm_data_member_vmm_data(vlan_fr_var, DO_ALL, DO_DEEP)
...
`vmm_data_member_end(eth_frame)
...
endclass
vmm_data::allocate()
Allocates a new instance.
SystemVerilog
virtual function vmm_data allocate();
OpenVera
Not supported.
Description
Allocates a new instance of the same type as the object instance.
Returns a reference to the new instance. Useful to implement class
factories to create instances of user-defined derived class in generic
code written using the base class type.
vmm_data::compare()
Compares the current object instance with the specified object
instance.
SystemVerilog
virtual function bit compare(input vmm_data to,
output string diff,
input int kind = -1);
OpenVera
Not supported.
Description
Compares the current value of the object instance with the current
value of the specified object instance, according to the specified
kind. Returns TRUE (non-zero) if the value is identical. Returns
FALSE, if the value is different, and a descriptive text of the first
difference found is returned in the specified string variable. The
kind argument may be used to implement different comparison
functions (for example, full compare, comparison of rand properties
only, comparison of all properties physically implemented in a
protocol, and so on.)
Example
Example A-65
function bit check(eth_frame actual)
sb_where_to_find_frame where;
eth_frame
q[$];
eth_frame
expect;
check = 0;
if (!index_tbl[hash(actual)].exists()) return;
where = index_tbl[hash(actual)];
q = sb.port[where.port_no].queue[where.queue_no];
expect = q.pop_front();
if (actual.compare(expect)) check = 1;
endfunction: check
vmm_data::copy()
Copies the current value of the object instance.
SystemVerilog
virtual function vmm_data copy(vmm_data to = null);
OpenVera
Not supported.
Description
Copies the current value of the object instance to the specified object
instance. If no target object instance is specified, a new instance is
allocated. Returns a reference to the target instance.
Example
Example A-66
The following trivial implementation does not work. Constructor
copying is a shallow copy. The objects instantiated in the object
(such as those referenced by the log and notify properties) are not
copied, and both copies will share references to the same service
interfaces. Moreover, it does not properly handle the case when the
to argument is not null.
Invalid implementation of the vmm_data::copy() method:
function vmm_data atm_cell::copy(vmm_data to = null) copy =
new(this);
endfunction
vmm_data::copy_data()
Copies the current value of all base class data properties.
SystemVerilog
virtual protected function void copy_data(vmm_data to);
OpenVera
Not supported.
Description
Copies the current value of all base class data properties in the
current data object, into the specified data object instance. This
method should be called by the implementation of the
vmm_data::copy() method, in classes immediately derived from
this base class.
vmm_data::data_id
Unique identifier for a data model or transaction descriptor instance.
SystemVerilog
int data_id;
OpenVera
Not supported.
Description
Specifies the offset of the descriptor within a sequence, and the
sequence offset within a stream. This property must be set by the
transactor that instantiates the descriptor. It is set by the predefined
generator, before randomization, so that it can be used to specify
conditional constraints to express instance-specific or streamspecific constraints.
vmm_data::display()
Displays the current value of the transaction or data.
SystemVerilog
function void display(string prefix = "");
OpenVera
Not supported.
Description
Displays the current value of the transaction or data described by
this instance, in a human-readable format on the standard output.
Each line of the output will be prefixed with the specified prefix. This
method prints the value returned by the psdisplay() method.
vmm_data::byte_pack()
Packs the content of the transaction or data into a dynamic array of
bytes.
SystemVerilog
virtual function int unsigned byte_pack(
ref logic [7:0] bytes[],
input int unsigned offset = 0,
input int kind = -1);
OpenVera
Not supported.
Description
Packs the content of the transaction or data into the specified
dynamic array of bytes, starting at the specified offset in the array.
The array is resized appropriately. Returns the number of bytes
added to the array.
If the data can be interpreted or packed in different ways, the kind
argument can be used to specify which interpretation or packing to
use.
vmm_data::byte_size()
Returns the number of bytes required to pack the content of this
descriptor.
SystemVerilog
virtual function int unsigned byte_size(int kind = -1);
OpenVera
Not supported.
Description
Returns the number of bytes required to pack the content of this
descriptor. This method will be more efficient than the
vmm_data::byte_pack() method, for knowing how many bytes
are required by the descriptor, because no packing is actually done.
If the data can be interpreted or packed in different ways, the kind
argument can be used to specify which interpretation or packing to
use.
vmm_data::byte_unpack()
Unpacks the specified number of bytes of data.
SystemVerilog
virtual function int unsigned byte_unpack(
const ref logic [7:0] bytes[],
input int unsigned offset = 0,
input int len = -1,
input int kind = -1);
OpenVera
Not supported.
Description
Unpacks the specified number of bytes of data from the specified
offset, in the specified dynamic array into this descriptor. If the
number of bytes to unpack is specified as -1, the maximum number
of bytes will be unpacked. Returns the number of bytes unpacked. If
there is not enough data in the dynamic array to completely fill the
descriptor, the remaining properties are set to unknown and a
warning is generated.
If the data can be interpreted or unpacked in different ways, the kind
argument can be used to specify which interpretation or packing to
use.
Example
Example A-67
class eth_frame extends vmm_data;
...
vmm_data::do_byte_pack()
Overrides the shorthand byte_pack() method.
SystemVerilog
virtual int function do_byte_pack(ref logic [7:0] bytes[],
input int unsigned offset = 0,
input int kind = -1);
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::byte_pack() method that is created by the
vmm_data shorthand macros. If defined, this method is used instead
of the default implementation.
The default implementation of this method in the vmm_data base
class must not be called (for example, do not call
super.do_byte_pack()).
The specified argument bytes is the dynamic array in which
transaction contents are packed, starting at the specified offset
value. The specified argument kind can be used to specify which
interpretation or packing to use.
Example
Example A-68
class eth_frame extends vmm_data;
...
virtual int function do_byte_pack(ref logic [7:0]
bytes[],input int unsigned offset = 0,
input int kind = -1);
int i;
...
`ifdef ETH_USE_COMPOSITION
{bytes[i], bytes[i+1]} = {this.vlan.user_priority,
this.vlan.cfi, this.vlan.id};
`else
{bytes[i], bytes[i+1]} = {this.user_priority,
this.cfi, this.vlan_id};
`endif
...
endfunction
endclass
vmm_data::do_byte_size()
Overrides the shorthand byte_size() method.
SystemVerilog
virtual int function do_byte_size(int kind
= -1);
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::byte_size() method that is created by the
vmm_data shorthand macros. If defined, this method is used instead
of the default implementation.
The default implementation of this method in the vmm_data base
class must not be called (for example, do not call
super.do_byte_size()).
The returned value is the number of bytes required to pack the
content of this descriptor. The specified kind argument can be used
to specify which interpretation or packing to use.
Example
Example A-69
class eth_frame extends vmm_data;
virtual int function do_byte_size(int kind = -1);
`ifdef TAGGED
do_byte_size = 14 + data.size();
`else
do_byte_size = 14 + data.size() + 4;
`endif
endfunction
endclass
vmm_data::do_byte_unpack()
Overrides the shorthand byte_unpack() method.
SystemVerilog
virtual int function do_byte_unpack(
const ref logic [7:0] bytes[],
input int unsigned offset = 0,
input int len = -1,
input int kind = -1);
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::byte_unpack() method that is created by the
vmm_data shorthand macros. If defined, this method is used instead
of the default implementation.
The default implementation of this method in the vmm_data base
class must not be called (for example, do not call
super.do_byte_unpack()).
The specified argument len is the number of data bytes to unpack,
starting at specified offset value. The unpacked data is stored in
the specified bytes dynamic array.
If the number of bytes to unpack is specified as -1, the maximum
number of bytes will be unpacked. This method returns the number
of bytes unpacked.
Example
Example A-70
class eth_frame extends vmm_data;
...
virtual int function do_byte_unpack(const ref logic [7:0]
bytes[],input int unsigned offset = 0,
input int len = -1,input int kind = -1);
...
`ifdef ETH_USE_COMPOSITION
{this.vlan.user_priority, this.vlan.cfi,
this.vlan.id} = {bytes[i], bytes[i+1]};
`else
{this.user_priority, this.cfi, this.vlan_id} =
{bytes[i], bytes[i+1]};
`endif
...
endfunction
...
endclass
vmm_data::do_compare()
Overrides the shorthand compare() method.
SystemVerilog
virtual bit function do_compare(input vmm_data to,
output string diff,
input int kind=-1);
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::compare() method that is created by the vmm_data
shorthand macros. If defined, this method is used instead of the
default implementation.
The default implementation of this method in the vmm_data base
class must not be called (for example, do not call
super.do_compare()).
The specified argument to is transaction instance with which current
transaction is compared, returns TRUE if the value is identical. If the
value is different, FALSE is returned and a descriptive text of the first
difference found is returned in the specified string variable diff.
The kind argument may be used to implement different comparison
functions (for example, full compare, comparison of rand properties
only, comparison of all properties physically implemented in a
protocol and so on.)
Example
Example A-71
class eth_frame extends vmm_data;
...
virtual bit function do_compare(input vmm_data to =
null,output string diff, input int kind = -1);
eth_frame fr;
do_compare = 1;
...
`ifdef ETH_USE_COMPOSITION
if (fr.vlan == null) begin
diff = "No vlan data";
do_compare = 0;
end
if (fr.vlan.user_priority !==
this.vlan.user_priority) begin
$sformat(diff, "user_priority (3'd%0d !== 3'd%0d)",
this.vlan.user_priority,
fr.vlan.user_priority);
do_compare = 0;
end
...
`else
if (fr.user_priority !== this.user_priority) begin
$sformat(diff, "user_priority (3'd%0d !== 3'd%0d)",
this.user_priority, fr.user_priority);
do_compare = 0;
end
...
`endif
...
endfunction
endclass
vmm_data::do_copy()
Overrides the shorthand copy() method.
SystemVerilog
virtual vmm_data function copy(vmm_data to = null);
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::copy() method that is created by the vmm_data
shorthand macros. If defined, this method is used instead of the
default implementation.
The default implementation of this method in the vmm_data base
class must not be called (for example, do not call
super.do_copy()).
The optional to argument specifies the transaction on which copy
needs to be performed.
Example
Example A-72
class eth_frame extends vmm_data;
...
virtual vmm_data function do_copy(vmm_data to = null);
eth_frame cpy;
if (to != null) begin
vmm_data::do_how_e
Specifies how vmm_data references are interpreted by a shorthand
implementation.
SystemVerilog
enum {
DO_NOCOPY
='h001,
DO_REFCOPY
='h002,
DO_DEEPCOPY
='h004,
HOW_TO_COPY
='h007,
DO_NOCOMPARE
='h008,
DO_REFCOMPARE ='h010,
DO_DEEPCOMPARE ='h020,
HOW_TO_COMPARE ='h038,
DO_NONE
='h009,
DO_REF
='h012,
DO_DEEP
='h024,
_DO_DUMMY} do_how_e;
OpenVera
Not supported.
Description
This method specifies how the copy and compare methods deal with
a reference to a vmm_data instance, in their default implementation.
Multiple mechanisms can be specified by using an add or an or, in
the individual symbolic values. Following are the meanings of the
DO_NONE, DO_REF, and DO_DEEP symbols:
Example
Example A-73
vmm_data_member_vmm_data(parent, DO_ALL, DO_REF);
vmm_data::do_is_valid()
Overrides the shorthand is_valid() method.
SystemVerilog
virtual bit function do_is_valid(bit silent = 1,
int kind = -1);
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::is_valid() method that is created by the vmm_data
shorthand macros. If defined, this method is used instead of the
default implementation. The default implementation of this method in
the vmm_data base class must not be called (for example, do not
call super.do_is_valid()).
If specified argument silent equals 1, no error or warning
messages are issued if the content is invalid. If silent is FALSE,
warning or error messages may be issued if the content is invalid.
The meaning and use of the argument kind argument is descriptorspecific and defined by the user extension of this method.
Example
Example A-74
class eth_frame extends vmm_data;
virtual bit function do_is_valid(bit silent = 1,
int kind = -1);
do_is_valid = 1;
if (!do_is_valid && !silent) begin
`vmm_error(this.log, "Ethernet Frame is not valid");
end
endfunction
endclass
vmm_data::do_max_byte_size()
Overrides the shorthand max_byte_size() method.
SystemVerilog
virtual int function do_max_byte_size(int kind
= -1);
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::max_byte_size() method that is created by the
vmm_data shorthand macros. If defined, this method is used
instead of the default implementation.
The default implementation of this method in the vmm_data base
class must not be called (for example, do not call
super.do_max_byte_size()).
Example
Example A-75
class eth_frame extends vmm_data;
virtual int function do_max_byte_size(int kind = -1);
`ifdef JUMBO_PACKET
do_max_byte_size = 9000;
`else
do_max_byte_size = 1500;
`endif
endfunction
endclass
vmm_data::do_psdisplay()
Overrides the shorthand psdisplay() method.
SystemVerilog
virtual function string do_psdisplay(string prefix = "")
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_data::psdisplay() method that is created by the
vmm_data shorthand macros. If defined, this method is used instead
of the default implementation.
The default implementation of this method in the vmm_data base
class must not be called (for example, do not call
super.do_psdisplay()).
Example
Example A-76
class eth_frame extends vmm_data;
...
virtual function string do_psdisplay(string prefix = "")
$sformat(psdisplay, "%sEthernet Frame #%0d.%0d.%0d:\n",
prefix, this.stream_id, this.scenario_id,
this.data_id);
...
endfunction
endclass
vmm_data::do_what_e
Specifies which methods are to be provided by a shorthand
implementation.
SystemVerilog
enum {DO_PRINT, DO_COPY, DO_COMPARE,
DO_PACK, DO_UNPACK, DO_ALL} do_what_e;
OpenVera
Not supported.
Description
This method specifies which methods are to include the specified
data members in their default implementation. Multiple methods can
be specified by using an add or an or, in the individual symbolic
values. All methods are specified by using the DO_ALL symbol.
Example
Example A-77
vmm_data_member_scalar(len,
DO_PRINT + DO_COPY + DO_COMPARE);
vmm_data::is_valid()
Checks the current value of the transaction or data.
SystemVerilog
virtual function bit is_valid(bit silent = 1,
int kind = -1);
OpenVera
Not supported.
Description
Checks whether the current value of the transaction or data
described by this instance is valid and error free, according to the
optionally specified kind or format. Returns TRUE (non-zero), if the
content of the object is valid. Otherwise, it returns FALSE. The
meaning (and use) of the kind argument is descriptor-specific, and
defined by the user extension of this method.
If silent is TRUE (non-zero), and if the content is invalid, then no
error or warning messages are generated. If silent is FALSE, and
if the content is invalid, then warning or error messages may be
generated.
vmm_data::load()
Sets the content of this descriptor.
SystemVerilog
virtual function bit load(int file);
OpenVera
Not supported.
Description
Sets the content of this descriptor from the data, in the specified file.
The format is user defined, and may be binary. By default, interprets
a complete line as binary byte data and unpacks it.
Should return FALSE (zero), if the loading operation was not
successful.
vmm_data::set_log()
Replaces the message service interface for this instance of a data
model or transaction descriptor.
SystemVerilog
function vmm_log set_log(vmm_log log);
OpenVera
Not supported.
Description
Replaces the message service interface for this instance of a data
model or transaction descriptor, with the specified message service
interface. Also, it returns a reference to the previous message
service interface. This method can be used to associate a descriptor
with the message service interface of a transactor currently
processing the transaction, or to set the service when it was not
available during initial construction.
vmm_data::max_byte_size()
Returns the maximum number of bytes required to pack the content
of this descriptor.
SystemVerilog
virtual function int unsigned max_byte_size(
int kind = -1);
OpenVera
Not supported.
Description
Returns the maximum number of bytes, which are required to pack
the content of any instance of this descriptor. A value of 0 indicates
an unknown maximum size. Thsi method can be used to allocate
memory buffers in the DUT or verification environment of suitable
sizes.
If the data can be interpreted or packed in different ways, the kind
argument can be used to specify which interpretation or packing to
use.
vmm_data::new()
Creates a new instance of this data model or transaction descriptor.
SystemVerilog
function new(vmm_log log= null, vmm_object parent = null,
string name ="");
OpenVera
Not supported.
Description
Creates a new instance of this data model or transaction descriptor,
with the specified message service interface. The specified
message service interface is used when constructing the
vmm_data::notify property.
Example
Example A-78
Because of the potentially large number of instances of data objects,
a class-static message service interface should be used to
minimize memory usage and to control class-generic messages:
class eth_frame extends vmm_data {
static vmm_log log = new(eth_frame, class);
function new();
super.new(this.log);
...
endfunction
endclass: eth_frame
vmm_data::notify
A notification service interface with three pre-configured events.
SystemVerilog
vmm_notify notify;
enum
{EXECUTE=999_999,
STARTED=999_998,
ENDED=999_997
}notifications_e;
OpenVera
Not supported.
Description
The EXECUTE notification is ON or OFF, and indicated by default. It
can be used to prevent the execution of a transaction or the transfer
of data, if reset. The STARTED and ENDED notifications are ON or
OFF events, and indicated by the transactor at the start and end of
the transaction execution or data transfer. The meaning and timing
of notifications is specific to the transactor, which is executing the
transaction described by this instance.
vmm_data::psdisplay()
Returns an image of the current value of the transaction or data.
SystemVerilog
virtual function string psdisplay(string prefix = "");
OpenVera
Not supported.
Description
Returns an image of the current value of the transaction or data
described by this instance, in a human-readable format as a string.
The string may contain newline characters to split the image across
multiple lines. Each line of the output must be prefixed with the
specified prefix.
vmm_data::save()
Appends the content of this descriptor to the specified file.
SystemVerilog
virtual function void save(int file);
OpenVera
Not supported.
Description
Appends the content of this descriptor to the specified file. The
format is user defined, and may be binary. By default, packs the
descriptor and saves the value of the bytes, in sequence, as binary
values and terminated by a newline.
vmm_data::scenario_id
Unique identifier for a data model or transaction descriptor instance.
SystemVerilog
int scenario_id;
OpenVera
Not supported.
Description
Specifies the offset of the descriptor within a sequence, and the
sequence offset within a stream. This property must be set by the
transactor that instantiates the descriptor. It is set by the predefined
generator before randomization, so it can be used to specify
conditional constraints to express instance-specific or streamspecific constraints.
vmm_data::stream_id
Unique identifier for a data model or transaction descriptor instance.
SystemVerilog
int stream_id;
OpenVera
Not supported.
Description
Specifies the offset of the descriptor within a sequence, and the
sequence offset within a stream. This property must be set by the
transactor that instantiates the descriptor. It is set by the predefined
generator before randomization, so it can be used to specify
conditional constraints to express instance-specific or streamspecific constraints.
vmm_env
A base class used to implement verification environments.
Summary
vmm_env::build() .................................
vmm_env::cfg_dut() ...............................
vmm_env::cleanup() ...............................
vmm_env::do_psdisplay() ..........................
vmm_env::do_start() ..............................
vmm_env::do_stop() ...............................
vmm_env::do_vote() ...............................
vmm_env::do_what_e ...............................
vmm_env::end_test ................................
vmm_env::end_vote ................................
vmm_env::gen_cfg() ...............................
vmm_env::log .....................................
vmm_env::new() ...................................
vmm_env::notify ..................................
vmm_env::report() ................................
vmm_env::reset_dut() .............................
vmm_env::run() ...................................
vmm_env::start() .................................
vmm_env::stop() ..................................
vmm_env::wait_for_end() ..........................
vmm_env_member_begin() ..........................
vmm_env_member_channel*() .......................
vmm_env_member_end() ............................
vmm_env_member_enum*() ..........................
vmm_env_member_scalar*() ........................
vmm_env_member_string*() ........................
vmm_env_member_subenv*() ........................
vmm_env_member_user_defined() ...................
vmm_env_member_vmm_data*() ......................
vmm_env_member_xactor*() ........................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-208
A-209
A-210
A-211
A-212
A-213
A-214
A-215
A-216
A-217
A-218
A-219
A-220
A-221
A-222
A-223
A-224
A-225
A-226
A-227
A-228
A-229
A-231
A-232
A-234
A-236
A-238
A-240
A-241
A-243
vmm_env::build()
Builds the verification environment.
SystemVerilog
virtual function void build();
OpenVera
Not supported.
Description
Builds the verification environment, according to the value of the test
configuration descriptor. If this method is not explicitly invoked in the
test program, it will be implicitly invoked by the
vmm_env::reset_dut() method.
Example
Example A-79
class my_test extends vmm_test;
...
virtual task run(vmm_env env);
tb_env my_env;
$cast(my_env, env);
my_env.build();
my_env.gen[0].start_xactor();
my_env.run();
endtask
endclass
vmm_env::cfg_dut()
Configures the DUT.
SystemVerilog
virtual task cfg_dut();
OpenVera
Not supported.
Description
Configures the DUT, according to the value of the test configuration
descriptor. If this method is not explicitly invoked in the test program,
it will be implicitly invoked by the vmm_env::start() method.
vmm_env::cleanup()
Performs clean-up operations.
SystemVerilog
virtual task cleanup();
OpenVera
Not supported.
Description
Performs clean-up operations to terminate the simulation, gracefully.
Clean-up operations may include, letting the DUT drain off all
buffered data, reading statistics registers in the DUT, and sweeping
the scoreboard for leftover expected responses. If this method is not
explicitly invoked in the test program, it will be implicitly invoked by
the vmm_env::run() method.
vmm_env::do_psdisplay()
Overrides the shorthand psdisplay() method.
SystemVerilog
protected virtual function string do_psdisplay(string prefix
= "");
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_env::psdisplay() method that is created by the vmm_env
shorthand macros. If defined, this method is used instead of the
default implementation.
Example
Example A-80
class my_vmm_env extends vmm_env;
...
virtual function string do_psdisplay(string prefix = "");
$sformat(do_psdisplay,"%s Printing environment members",
prefix);
...
endfunction
...
endclass
vmm_env::do_start()
Overrides the shorthand start() method.
SystemVerilog
protected virtual task do_start()
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_env::start() method that is created by the vmm_env
shorthand macros. If defined, this method is used instead of the
default implementation.
Example
Example A-81
class my_vmm_env extends vmm_env;
...
protected virtual task do_start();
//vmm_env::start() operations
...
endtask
...
endclass
vmm_env::do_stop()
Overrides the shorthand stop() method.
SystemVerilog
protected virtual task do_stop()
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_env::stop() method that is created by the vmm_env
shorthand macros. If defined, this method is used instead of the
default implementation.
Example
Example A-82
class my_vmm_env extends vmm_env;
...
protected virtual task do_stop();
//vmm_env::stop() operations
...
endtask
...
endclass
vmm_env::do_vote()
Overrides the shorthand voter registration.
SystemVerilog
protected virtual task do_vote()
OpenVera
Not supported.
Description
This method overrides the default implementation of the voter
registration that is created by the vmm_env shorthand macros. If
defined, this method is used instead of the default implementation.
Example
Example A-83
class my_vmm_env extends vmm_env;
...
protected virtual task do_vote();
//Register with this.end_vote
...
endtask
...
endclass
vmm_env::do_what_e
Specifies which methods should be provided by a shorthand
implementation.
SystemVerilog
enum {DO_PRINT, DO_START, DO_STOP, DO_RESET, DO_VOTE,
DO_ALL} do_what_e;
OpenVera
Not supported.
Description
Specifies which methods should include the specified data members
in their default implementation. "DO_PRINT" includes the member
in the default implementation of the psdisplay() method.
"DO_START" includes the member in the default implementation of
the start() method, if applicable. "DO_STOP" includes the
member in the default implementation of the stop() method, if
applicable. "DO_VOTE" automatically registers the member with the
vmm_env::end_vote consensus instance, if applicable.
Multiple methods can be specified by adding or using an or in the
individual symbolic values. All methods are specified by using the
"DO_ALL" symbol.
Example
Example A-84
vmm_env_member_subenv(tcpip_stack, DO_ALL - DO_STOP);
vmm_env::end_test
Causes the vmm_env::wait_for_end() method to return.
SystemVerilog
event end_test;
OpenVera
Not supported.
Description
Causes the vmm_env::wait_for_end() method to return, when
you trigger an event. It is up to the user-defined implementation of
the vmm_env::wait_for_end() method to detect that this event
is triggered and returned.
vmm_env::end_vote
End-of-test consensus object.
SystemVerilog
vmm_consensus end_vote;
OpenVera
vmm_consensus end_vote;
Description
Predefined end-of-test consensus instance that can be used in the
extension of the vmm_env::wait_for_end() method, to
determine that the simulation is reached its logical end. The name of
the consensus is the name of the environment specified in the
vmm_env constructor. The instance name of the consensus is "Endof-test Consensus".
Triggering the vmm_env::end_test event does not force the
consensus. A consensus does not trigger the end_test event. This
class property and the end_test event are not functionally related
in the base class.
Example
Example A-85
initial begin
apb_env env;
vmm_voter test_voter = env.end_vote.register_voter("Test
case Stimulus");
...
end
vmm_env::gen_cfg()
Randomizes the test configuration descriptor.
SystemVerilog
virtual function void gen_cfg();
OpenVera
Not supported.
Description
If this method is not explicitly invoked in the test program, it will be
implicitly invoked by the vmm_env::build() method.
vmm_env::log
Message service interface for the verification environment.
SystemVerilog
vmm_log log;
OpenVera
Not supported.
Description
This property is set by the constructor, using the specified
environment name, and may be modified at run time.
vmm_env::new()
Creates an instance of the verification environment.
SystemVerilog
function new(string name = Verif Env);
OpenVera
Not supported.
Description
Creates an instance of the verification environment, with the
specified name. The name is used as the name of the message
service interface.
vmm_env::notify
Notification service interface and predefined notifications.
SystemVerilog
vmm_notify notify;
enum{GEN_CFG = 1,
BUILD,
RESET_DUT,
CFG_DUT,
START,
RESTART,
WAIT_FOR_END,
STOP,
CLEANUP,
REPORT,
RESTARTED} notifications_e;
OpenVera
Not supported.
Description
Notification service interface and predefined notifications used to
indicate the progression of the verification environment. The
predefined notifications are used to signal the start of the
corresponding predefined virtual methods. All notifications are either
ON or OFF.
vmm_env::report()
Reports success or failure of the test, and closes all files.
SystemVerilog
virtual task report();
OpenVera
Not supported.
Description
Reports final success or failure of the test, and closes all files. If this
method is not explicitly invoked in the test program, it will be implicitly
invoked by the vmm_env::run() method.
vmm_env::reset_dut()
Resets the DUT to make it ready for configuration.
SystemVerilog
virtual task reset_dut();
OpenVera
Not supported.
Description
Physically resets the DUT to make it ready for configuration. If this
method is not explicitly invoked in the test program, it will be implicitly
invoked by the vmm_env::cfg_dut() method.
vmm_env::run()
Run the simulation.
SystemVerilog
task run()
OpenVera
Not supported.
Description
Runs all remaining steps of the simulation, including
vmm_env::stop(), vmm_env::cleanup(), and
vmm_env::report(). This method must be explicitly invoked in
the test programs.
vmm_env::start()
Starts the test.
SystemVerilog
virtual task start();
OpenVera
Not supported.
Description
Starts all the components of the verification environment to start the
actual test. If this method is not explicitly invoked in the test program,
it will be implictly invoked by the vmm_env::wait_for_end()
method.
vmm_env::stop()
Terminates the simulation, cleanly.
SystemVerilog
virtual task stop();
OpenVera
Not supported.
Description
Terminates all components of the verification environment to
terminate the simulation, cleanly. If this method is not explicitly
invoked in the test program, it will be implicitly invoked by the
vmm_env::cleanup() method.
vmm_env::wait_for_end()
Waits for an indication that the test is reached completion.
SystemVerilog
virtual task wait_for_end();
OpenVera
Not supported.
Description
Waits for an indication that the test is reached completion, or its
objective. When this task returns, it signals that the end of simulation
condition is detected. If this method is not explicitly invoked in the
test program, it will be implicitly invoked by the vmm_env::stop()
method.
Example
Example A-86
class tb_env extends vmm_env;
...
virtual task wait_for_end();
super.wait_for_end();
...
wait (this.cfg.run_for_n_tx_frames == 0 &&
this.cfg.run_for_n_tx_frames == 0);
...
endtask: wait_for_end
...
endclass: tb_env
vmm_env_member_begin()
Start the shorthand section.
SystemVerilog
vmm_env_member_begin(class-name)
OpenVera
Not supported.
Description
Start the shorthand section, providing a default implementation for
the psdisplay(), start() and stop() methods.
The class-name specified must be the name of the vmm_env
extension class that is being implemented.
The shorthand section can only contain shorthand macros, and must
be terminated by the vmm_env_member_end() method.
Example
Example A-87
class tb_env extends vmm_env;
...
vmm_env_member_begin(tb_env)
...
vmm_env_member_end(tb_env)
...
endclass
vmm_env_member_channel*()
Shorthand implementation for a channel data member.
SystemVerilog
vmm_env_member_channel(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_channel_array(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_channel_aa_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_channel_aa_string(member-name,
vmm_env::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified channel-type, array of channels, dynamic array of
channels, scalar-indexed associative array of channels, or stringindexed associative array of channels data member to the default
implementation of the methods, specified by the do_what
argument.
The shorthand implementation must be located in a section, which is
started by the vmm_env_member_begin() method.
Example
Example A-88
class my_vmm_env extends vmm_env;
my_data_channel my_channel;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_channel(my_channel,DO_ALL);
...
`vmm_env_member_end(my_vmm_env)
...
endclass
vmm_env_member_end()
Terminates the shorthand section.
SystemVerilog
vmm_env_member_end(class-name)
OpenVera
Not supported.
Description
Terminate the shorthand section, providing a default implementation
for the psdisplay(), start(), and stop() methods.
The class-name specified must be the name of the vmm_env
extension class that is being implemented.
The shorthand section must have been started by the
vmm_env_member_begin() method.
Example
Example A-89
class my_env extends vmm_env;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_end(my_vmm_env)
...
endclass
vmm_env_member_enum*()
Shorthand implementation for an enumerated data member.
SystemVerilog
vmm_env_member_enum(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_enum_array(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_enum_aa_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_enum_aa_string(member-name,
vmm_env::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified enum-type, array of enums, scalar-indexed
associative array of enums, or string-indexed associative array of
enums data member to the default implementation of the methods,
specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_env_member_begin() method.
Example
Example A-90
typedef enum {blue,green,red,black} my_colors;
vmm_env_member_scalar*()
Shorthand implementation for a scalar data member.
SystemVerilog
vmm_env_member_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_scalar_array(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_scalar_aa_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_scalar_aa_string(member-name,
vmm_env::do_what_e do_what)
OpenVera
Not supported.
Description
Add the specified scalar-type, array of scalars, scalar-indexed
associative array of scalars or string-indexed associative array of
scalars data member to the default implementation of the methods
specified by the do_what argument.
A scalar is an integral type, such as bit, bit vector, and packed
unions.
The shorthand implementation must be located in a section started
by the vmm_env_member_begin() method.
Example
Example A-91
class my_vmm_env extends vmm_env;
bit [31:0] address;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_scalar(address,DO_ALL)
...
`vmm_env_member_end(my_vmm_env)
...
endclass
vmm_env_member_string*()
Shorthand implementation for a string data member.
SystemVerilog
vmm_env_member_string(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_string_array(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_string_aa_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_string_aa_string(member-name,
vmm_env::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified string-type, array of strings, scalar-indexed
associative array of strings, or string-indexed associative array of
strings data member to the default implementation of the methods,
specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_env_member_begin() method.
Example
Example A-92
class my_vmm_env extends vmm_env;
string name;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_string(name,DO_PRINT)
...
`vmm_env_member_end(my_vmm_env)
...
endclass
vmm_env_member_subenv*()
Shorthand implementation for a transactor data member.
SystemVerilog
vmm_env_member_subenv(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_subenv_array(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_subenv_aa_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_subenv_aa_string(member-name,
vmm_env::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified sub-environment-type, array of subenvironments, dynamic array of sub-environments, scalar-indexed
associative array of sub-environments, or string-indexed associative
array of sub-environments data member to the default
implementation of the methods, specified by the do_what
argument.
The shorthand implementation must be located in a section started
by the vmm_env_member_begin() method.
Example
Example A-93
class my_subenv extends vmm_subenv
...
endclass
class my_vmm_env extends vmm_env;
my_subenv subenv ;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_subenv(sub_env,DO_ALL);
...
`vmm_env_member_end(my_vmm_env)
endclass
vmm_env_member_user_defined()
User-defined shorthand implementation data member.
SystemVerilog
vmm_env_member_user_defined(member-name)
OpenVera
Not supported.
Description
Adds the specified user-defined default implementation of the
methods, specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_env_member_begin() method.
Example
Example A-94
class my_vmm_env extends vmm_env;
bit [7:0] env_id;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_user_defined(env_id);
...
`vmm_env_member_end(my_vmm_env)
function bit do_env_id(vmm_env::do_what_e do_what)
do_env_id = 1;
case(do_what)
endfunction
endclass
vmm_env_member_vmm_data*()
Shorthand implementation for a vmm_data-based data member.
SystemVerilog
vmm_env_member_vmm_data(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_vmm_data_array(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_vmm_data_aa_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_vmm_data_aa_string(member-name,
vmm_env::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified vmm_data-type, array of vmm_datas, scalarindexed associative array of vmm_datas, or string-indexed
associative array of vmm_datas data member to the default
implementation of the methods, specified by the do_what
argument.
The shorthand implementation must be located in a section started
by the vmm_env_member_begin() method.
Example
Example A-95
class my_data extends vmm_data;
...
endclass : my_data
class my_vmm_env extends vmm_env;
my_data
data;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_vmm_data(data,DO_PRINT)
...
`vmm_env_member_end(my_vmm_env)
...
endclass
vmm_env_member_xactor*()
Shorthand implementation for a transactor data member.
SystemVerilog
vmm_env_member_xactor(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_xactor_array(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_xactor_aa_scalar(member-name,
vmm_env::do_what_e do_what)
vmm_env_member_xactor_aa_string(member-name,
vmm_env::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified transactor-type, array of transactors, dynamic
array of transactors, scalar-indexed associative array of transactors,
or string-indexed associative array of transactors data member to
the default implementation of the methods, specified by the
do_what argument.
The shorthand implementation must be located in a section started
by the vmm_env_member_begin() method.
Example
Example A-96
class my_data_gen extends vmm_xactor;
...
endclass
class my_vmm_env extends vmm_env;
my_data_gen my_xactor;
...
`vmm_env_member_begin(my_vmm_env)
`vmm_env_member_xactor(my_xactor,DO_ALL);
...
`vmm_env_member_end(my_vmm_env)
...
endclass
vmm_group
Class to create structural elements.
SystemVerilog
virtual class vmm_group extends vmm_unit;
Description
This class is used as the base composition class for building
structural elements composed of transactors or other groups.
This class can be a leaf or a non-leaf component.
Example
class vip1 extends vmm_group;
endclass
Summary
vmm_group::new()
Acts as a constructor for vmm_group.
SystemVerilog
function vmm_group::new(string name =, string inst =,
vmm_object parent = null);
Description
Constructs an instance of this class with the specified name,
instance name, and an optional parent.
The specified name is used as the name of the embedded vmm_log.
The specified instance name is used as the name of the underlying
vmm_object.
Example
class vip1 extends vmm_group;
function new (string name, string inst);
super.new (this,inst);
endfunction
endclass
vmm_group_callbacks
Facade class for callback methods provided by the vmm_group.
Example
class group_callbacks extends vmm_group_callbacks;
virtual function void my_f1();
endfunction
virtual function void my_f2();
endfunction
endclass
Summary
vmm_group::append_callback()
Appends the specified callback.
SystemVerilog
function void vmm_group::append_callback(
vmm_group_callbacks cb)
Description
Appends the specified callback extension cb to the callback registry
for this group.
Example
class group_callbacks extends vmm_group_callbacks;
virtual function void my_f1();
endfunction
endclass
class groupExtension extends vmm_group;
function new (string name, string inst,
vmm_unit parent=null);
super.new(name,inst,parent);
endfunction
function void build_ph();
`vmm_callback(group_callbacks,my_f1());
endfunction:build_ph
...
endclass
class groupExtension_callbacks extends group_callbacks;
int my_f1_counter++;
virtual function void my_f1();
my_f1_counter++;
endfunction
endclass
initial begin
groupExtension g1 = new ("my_group", "g1");
vmm_group::prepend_callback()
Prepends the specified callback.
SystemVerilog
function void vmm_group::prepend_callback(
vmm_group_callbacks cb)
Description
Prepends the specified callback extension cb to the callback
registry, for this group.
Example
class group_callbacks extends vmm_group_callbacks;
virtual function void my_f1();
endfunction
endclass
class groupExtension extends vmm_group;
function new (string name, string inst,
vmm_unit parent=null);
super.new(name,inst,parent);
endfunction
function void build_ph();
`vmm_callback(group_callbacks,my_f1());
endfunction:build_ph
...
endclass
class groupExtension_callbacks extends group_callbacks;
int my_f1_counter++;
virtual function void my_f1();
my_f1_counter++;
endfunction
endclass
initial begin
groupExtension g1 = new ("my_group", "g1");
groupExtension_callbacks cb1 = new();
groupExtension_callbacks cb2 = new();
g1.append_callback(cb1);
g1.prepend_callback(cb2);
...
end
vmm_group::unregister_callback()
Unregisters a callback.
SystemVerilog
function void vmm_group::unregister_callback(
vmm_group_callbacks cb);
Description
Removes the specified callback extension cb to the callback
registry, for this group.
Example
class group_callbacks extends vmm_group_callbacks;
virtual function void my_f1();
endfunction
endclass
class groupExtension extends vmm_group;
function new (string name, string inst,
vmm_unit parent=null);
super.new(name,inst,parent);
endfunction
function void build_ph();
`vmm_callback(group_callbacks,my_f1());
endfunction:build_ph
...
endclass
class groupExtension_callbacks extends group_callbacks;
int my_f1_counter++;
virtual function void my_f1();
my_f1_counter++;
endfunction
endclass
initial begin
groupExtension g1 = new ("my_group", "g1");
vmm_log
The vmm_log class implements an interface to the message
service.
Several methods apply to multiple message service interfaces, not
just the one where the method is invoked. All message service
interfaces that match the specified name and instance name are
affected by these methods. If the name or instance name is enclosed
between slashes (for example, /.../), then they are interpreted as
sed-style regular expressions. If a value of is specified, then the
name or instance name of the current message service interface is
specified. If the recurse parameter is TRUE (non-zero), then all
interfaces that are logically under the matching message service
interfaces are also specified.
Summary
vmm_log::add_watchpoint() ........................
vmm_log::append_callback() .......................
vmm_log::catch() .................................
vmm_log::copy() ..................................
vmm_log::create_watchpoint() .....................
vmm_log::disable_types() .........................
vmm_log::enable_types() ..........................
vmm_log::end_msg() ...............................
vmm_log::enum(message-severity) ..................
vmm_log::enum(message-type) ......................
vmm_log::enum(simulation-handling-value) .........
vmm_log::for_each() ..............................
vmm_log::get_instance() ..........................
vmm_log::get_message_count() .....................
vmm_log::get_name() ..............................
vmm_log::get_verbosity() .........................
vmm_log::is_above ................................
vmm_log::kill() ..................................
vmm_log::list() ..................................
vmm_log::log_start() .............................
vmm_log::log_stop() ..............................
vmm_log::modify() ................................
vmm_log::new() ...................................
vmm_log::prepend_callback() ......................
vmm_log::remove_watchpoint() .....................
vmm_log::report() ................................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-256
A-257
A-258
A-260
A-261
A-262
A-264
A-266
A-267
A-268
A-270
A-272
A-273
A-274
A-275
A-276
A-277
A-278
A-279
A-280
A-281
A-282
A-283
A-284
A-285
A-286
vmm_log::reset() .................................
vmm_log::set_instance() ..........................
vmm_log::set_name() ..............................
vmm_log::set_typ_image() .........................
vmm_log::set_sev_image() .........................
vmm_log::set_verbosity() .........................
vmm_log::start_msg() .............................
vmm_log::stop_after_n_errors() ...................
vmm_log::text() ..................................
vmm_log::uncatch() ...............................
vmm_log::uncatch_all() ...........................
vmm_log::unmodify() ..............................
vmm_log::unregister_callback() ...................
vmm_log::use_hier_inst_name() ....................
vmm_log::use_orig_inst_name() ....................
vmm_log::uses_hier_inst_name() ...................
vmm_log::set_format() ............................
vmm_log::wait_for_msg() ..........................
vmm_log::wait_for_watchpoint() ...................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-287
A-288
A-289
A-290
A-291
A-293
A-294
A-296
A-297
A-299
A-300
A-301
A-302
A-303
A-305
A-306
A-307
A-308
A-309
vmm_log::add_watchpoint()
Adds the specified watchpoint to the specified message service
interfaces.
SystemVerilog
virtual function void
add_watchpoint(int watchpoint_id,
string name = "",
string inst = "",
bit recurse = 0);
OpenVera
Not supported.
Description
Adds watchpoint as specified by watchpoint_id to the message
interface specified by name and inst arguments. If a message
matching the watchpoint specification is issued by one of the
specified message service interfaces associated with the
watchpoint, the watchpoint will be triggered. If the specified
argument recurse is set, then this method also applies to all the
message interfaces logically under the matching message service
interfaces.
vmm_log::append_callback()
Appends a callback faade instance with the message service.
SystemVerilog
virtual function void
append_callback(vmm_log_callbacks cb);
OpenVera
Not supported.
Description
Globally appends the specified callback faade instance with the
message service. Callback methods are invoked in the order in
which they were registered.
A warning is generated, if the same callback faade instance is
registered more than once. Callback faade instances can be
unregistered and re-registered dynamically.
Example
Example A-97
class tb_env extends vmm_env;
virtual function void build();
...
begin
sb_mac_cbs cb = new;
this.mac.append_callback(cb);
end
endfunction: build
endclass: tb_env
vmm_log::catch()
Adds a user-defined message handler.
SystemVerilog
function int catch(
vmm_log_catcher catcher,
string name = "",
string inst = "",
bit recurse = 0,
int typs = ALL_TYPS,
int severity = ALL_SEVS,
string text = "");
OpenVera
Not supported.
Description
Installs the specified message handler to catch any message of the
specified type and severity, issued by the specified message service
interface instances specified by name and instance arguments,
which contains the specified text. By default, this method catches all
messages issued by this message service interface instance. A
unique message handler identifier is returned that can be used later
to uninstall the message handler using the vmm_log::uncatch()
method.
Messages are considered caught by the first found user-defined
handler that can handle the message. User-defined message
handlers are considered in reverse order of installation. This means
that the last handler installed will be considered first. Once caught,
messages are handed-off to the vmm_log_catcher::caught()
Example
Example A-98
class err_catcher extends vmm_log_catcher;
...
endclass
alu_env env;
err_catcher ctcher;
initial begin
...
ctcher = new(10);
...
env.build();
env.sb.log.catch(ctcher,"","", ,vmm_log::ERROR_SEV,
"/Mismatch/");
end
vmm_log::copy()
Copies the configuration of this message service interface to the
specified message service interface.
SystemVerilog
virtual function vmm_log copy(vmm_log to = null);
OpenVera
Not supported.
Description
Copies the configuration of this message service interface to the
specified message service interface (or a new interface, if none is
specified), and returns a reference to the interface copy. The current
configuration of the message service interface is copied, except the
hierarchical relationship information, which is not modified.
vmm_log::create_watchpoint()
Creates a watchpoint descriptor.
SystemVerilog
virtual function int
create_watchpoint(int types = ALL_TYPS,
int severity = ALL_SEVS,
string text = "",
logic issued = 1'bx);
OpenVera
Not supported.
Description
Creates a watchpoint descriptor that will be triggered when the
specified message is used. The message can be specified by type,
severity, or by text pattern. By default, messages of all types,
severities, and text are specified. A message must match all
specified criteria to trigger the watchpoint. The issued parameter
specifies if the watchpoint is triggered when the message is
physically issued (1'b1), physically not issued (filtered out (1'b0)), or
regardless if the message is physically issued or not (1'bx).
A watchpoint will be repeatedly triggered, every time a message
matching the watchpoint specification is generated by a message
service interface associated with the watchpoint.
vmm_log::disable_types()
Specifies the message types to be disabled by the specified
message service interfaces.
SystemVerilog
virtual function void disable_types(int typs,
string name = "",
string inst = "",
bit recursive = 0);
OpenVera
Not supported.
Description
Specifies the message types to be disabled by the specified
message service interfaces. Message service interfaces are
specified by a value or regular expression, for both the name and
instance name. If no name and no instance are explicitly specified,
then this message service interface is implicitly specified.
If the name or instance named are specified between / characters,
then the specification is interpreted as a regular expression that must
be matched against all known names and instance names,
respectively. Both names must match to consider a message service
interface as specified. If the recursive argument is TRUE, then all
message service interfaces that are hierarchically below the
specified message service interfaces, are included in the
specification, whether their name and instance name matches or
not. A message service interface must exist to be specified.
vmm_log::enable_types()
Specifies the message types to be displayed by the specified
message service interfaces.
SystemVerilog
virtual function void enable_types(int typs,
string name = "",
string inst = "",
bit recursive = 0);
OpenVera
Not supported.
Description
Specifies the message types to be displayed by the specified
message service interfaces. Message service interfaces are
specified by a value or regular expression for both the name and
instance name. If no name and no instance are explicitly specified,
then this message service interface is implicitly specified.
If the name or instance named are specified between / characters,
then the specification is interpreted as a regular expression that must
be matched against all known names and instance names,
respectively. Both names must match to consider a message service
interface, as specified. If the recursive argument is TRUE, all
message service interfaces that are hierarchically below the
specified message service interfaces are included in the
specification, whether their name and instance name matches or
not. A message service interface to be specified, must exist.
vmm_log::end_msg()
Flushes and terminates the current message.
SystemVerilog
virtual function void end_msg();
OpenVera
Not supported.
Description
Flushes and terminates the current message, and triggers the
message display and the simulation handling. A message can be
flushed multiple times using the vmm_log::text("") method, but
the simulation handling and notification will only take effect on
message termination.
vmm_log::enum(message-severity)
Enumerated type defining symbolic values for message severities.
SystemVerilog
enum int {FATAL_SEV
= 'h0001,
ERROR_SEV
= 'h0002,
WARNING_SEV = 'h0004,
NORMAL_SEV = 'h0008,
TRACE_SEV
= 'h0010,
DEBUG_SEV
= 'h0020,
VERBOSE_SEV = 'h0040,
HIDDEN_SEV = 'h0080,
IGNORE_SEV = 'h0100,
DEFAULT_SEV = -1,
ALL_SEVS
= 'hFFFF
} severities_e;
OpenVera
Not supported.
Description
Enumerated type defining symbolic values for message severities
used, when specifying a message severity in properties or method
arguments. The vmm_log::DEFAULT_SEV and
vmm_log::ALL_SEVS are special symbolic values usable only with
some control methods, and are not used to issue actual messages.
Multiple message severities can be specified to some control
methods by combining the value of the required severities using the
bitwise-or or addition operator.
vmm_log::enum(message-type)
Enumerated type defining symbolic values for message types.
SystemVerilog
enum int {FAILURE_TYP
NOTE_TYP
DEBUG_TYP
REPORT_TYP
NOTIFY_TYP
TIMING_TYP
XHANDLING_TYP
PROTOCOL_TYP
TRANSACTION_TYP
COMMAND_TYP
CYCLE_TYP
USER_TYP_0
USER_TYP_1
USER_TYP_2
INTERNAL_TYP
DEFAULT_TYP
ALL_TYPS
} types_e;
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
'h0001,
'h0002,
'h0004,
'h0008,
'h0010,
'h0020,
'h0040,
'h0080,
'h0100,
'h0200,
'h0400,
'h0800,
'h1000,
'h2000,
'h4000,
-1,
'hFFFF
OpenVera
Not supported.
Description
Enumerated type defining symbolic values for message types used,
when specifying a message type in properties or method arguments.
The vmm_log::DEFAULT_TYP and vmm_log::ALL_TYPS are
special symbolic values usable only with some control methods, and
are not used to issue actual messages. Multiple message types can
be specified to some control methods by combining the value of the
required types, using the bitwise-or or addition operator.
vmm_log::enum(simulation-handling-value)
Symbolic values for simulation handling.
SystemVerilog
enum int {CONTINUE
COUNT_ERROR
DEBUGGER
DUMP_STACK
STOP_PROMPT
ABORT_SIM
IGNORE
DEFAULT_HANDLING
} handling_e;
=
=
=
=
=
=
=
=
'h0001,
'h0002,
'h0004,
'h0008,
'h0010,
'h0020,
'h0040,
-1
OpenVera
Not supported.
Description
Enumerated type defining symbolic values for simulation handling
used, when specifying a new simulation handling when promoting or
demoting a message using the vmm_log::modify() method.
Unless this method is specified, message types are assigned the
default severity and simulation handling, as shown in Table A-8.
Table A-8
Table A-9
Message Type
Default Severity
Default Handling
FAILURE_TYP
ERROR_SEV
COUNT_ERROR
NOTE_TYP
NORMAL_SEV
CONTINUE
DEBUG_TYP
DEBUG_SEV
CONTINUE
TIMING_TYP XHANDLING_TYP
WARNING_SEV
CONTINUE
TRANSACTION_TYP COMMAND_TYP
TRACE_SEV
CONTINUE
REPORT_TYP PROTOCOL_TYP
DEBUG_SEV
CONTINUE
CYCLE_TYP
VERBOSE_SEV
CONTINUE
Any type
FATAL_SEV
ABORT_SIM
vmm_log::for_each()
Iterates over message service instances.
SystemVerilog
function vmm_log for_each();
OpenVera
function rvm_log for_each();
Description
Returns a reference to the next known message service interface
that matches the iterator specification, specified in the last invocation
of vmm_log::reset() method. Returns NULL, if no more
instances match.
There is one iterator per message service instance.
Example
Example A-99
env.log.reset();
for (vmm_log log = env.log.for_each();
log != null;
log = env.log.for_each()) begin
...
end
vmm_log::get_instance()
Returns the instance name of the message service interface.
SystemVerilog
virtual function string get_instance();
OpenVera
Not supported.
Description
This method returns the instance name of the message service
interface.
vmm_log::get_message_count()
Returns the total number of messages of the specified severities.
SystemVerilog
virtual function int
get_message_count(int severity = ALL_SEVS,
string name = "",
string instance = "",
bit recurse = 0);
OpenVera
Not supported.
Description
Returns the total number of messages of the specified severities that
are issued from the specified message service interfaces. Message
severities can be specified as a sum of individual message severities
to specify more than one severity.
vmm_log::get_name()
Returns the nam of the message service interface.
SystemVerilog
virtual function string get_name();
OpenVera
Not supported.
Description
This method returns the name of the message service interface.
vmm_log::get_verbosity()
Returns the minimum message severity to be displayed.
SystemVerilog
virtual function int get_verbosity();
OpenVera
Not supported.
Description
Returns the minimum message severity to be displayed, when
sourced by this message service interface.
vmm_log::is_above
Specifies that this message service instance is hierarchically above
the specified message service interface.
SystemVerilog
virtual function void is_above(vmm_log log);
OpenVera
Not supported.
Description
This method is the corollary of the under argument of the
constructor, and need not be used if the specified message service
interface has already been constructed as being under this message
service interface.
vmm_log::kill()
Removes internal references to the message service interface.
SystemVerilog
virtual function void kill();
OpenVera
Not supported.
Description
Removes any internal reference to this message service interface,
so that it may be reclaimed by the garbage collection, once all use
references are also removed. Once this method is invoked, it is no
longer possible to control this message service interface by name.
vmm_log::list()
Lists message service interfaces that match a specified name and
instance name.
SystemVerilog
virtual function void list(string name = /./,
string instance = /./,
bit recurse = 0);
OpenVera
Not supported.
Description
Lists all message service interfaces that match the specified name
and instance name. If the recurse parameter is TRUE (non-zero),
then all interfaces that are logically under the matching message
service interface are also listed.
vmm_log::log_start()
Appends all messages produced by the specified message service
interfaces.
SystemVerilog
virtual function void log_start(int file,
string name = "",
string instance = "",
bit recurse = 0)
OpenVera
Not supported.
Description
Appends all messages produced by the specified message service
interfaces to the specified file. The file argument must be a file
descriptor, as returned by the $fopen() system task. By default, all
message service interfaces append their messages to the standard
output. Specifying a new output file does not stop messages from
being appended to previously specified files.
vmm_log::log_stop()
Stops logging messages from a specified message service interface.
SystemVerilog
virtual function void log_stop(int file,
string name = "",
string instance = "",
bit recurse = 0);
OpenVera
Not supported.
Description
Messages issued by the specified message service interfaces are no
longer appended to the specified file. The file argument must be a
file descriptor, as returned by the $fopen() system task. If the
specified file argument is 0, then messages are no longer sent to
the standard simulation output and transcript. If the file argument
is specified as 1, then appending to all files, except the standard
output, is stopped.
vmm_log::modify()
Modifies the specified type, severity, or simulation handling for a
message source.
SystemVerilog
virtual function int
modify(string name = "",
string inst = "",
bit recursive = 0,
int typs = ALL_TYPS,
int severity = ALL_SEVS,
string text = "",
int new_typ = UNCHANGED,
int new_severity = UNCHANGED,
int handling = UNCHANGED);
OpenVera
Not supported.
Description
Modifies the specified message source by any of the specified
message service interfaces, with the new specified type, severity, or
simulation handling. The message can be specified by type, severity,
numeric ID, or by text pattern. By default, messages of any type,
severity, ID, or text is specified. A message must match all specified
criteria.
This method returns a unique message modifier identifier that can be
used to remove it using the vmm_log::unmodify() method. All
message modifiers are applied in the same order they were defined,
before a message is generated.
vmm_log::new()
Creates a new instance of a message service interface.
SystemVerilog
function new(string name,
string inst,
vmm_log under = null);
OpenVera
Not supported.
Description
Creates a new instance of a message service interface, with the
specified interface name and instance name. Moreover, a message
service interface can optionally be specified as hierarchically below
another message service instance, to create a logical hierarchy of
message service interfaces.
vmm_log::prepend_callback()
Prepends a callback faade instance with the message service.
SystemVerilog
virtual function void
prepend_callback(vmm_log_callbacks cb);
OpenVera
Not supported.
Description
Globally prepends the specified callback faade instance with the
message service. Callback methods will be invoked in the order in
which they were registered.
A warning is generated if the same callback faade instance is
registered more than once. Callback faade instances can be
unregistered and re-registered dynamically.
Example
Example A-100
env.build();
begin
gen_rx_errs cb = new;
env.phy.prepend_callback(cb);
end
vmm_log::remove_watchpoint()
Removes the specified watchpoint from the specified message
service interfaces.
SystemVerilog
virtual function void remove_watchpoint(
int watchpoint_id=-1,
string name = "",
string inst = "",
bit recurse = 0);
OpenVera
Not supported.
Description
Removes the specified watchpoint watchpoint_id from the
message interface specified by name and instance arguments. If
a message matching the watchpoint specification is issued by one of
the specified message service interfaces associated with the
watchpoint, the watchpoint will be triggered. If the specified
argument recurse is set, then this method also applies to all the
message interfaces logically under the matching message service
interfaces.
vmm_log::report()
Reports a failure, if a message service interface issued an error or
fatal message.
SystemVerilog
virtual task report(
OpenVera
Not supported.
Description
Reports a failure if any of the specified message service interfaces,
matched by name and inst arguments, have issued any error or
fatal messages. Reports a success otherwise. The text of the pass
or fail message is specified using the
vmm_log_format::pass_or_fail() method. If the specified
argument recurse is set, then this method also applies to all the
message interfaces logically under the matching message service
interfaces.
vmm_log::reset()
Initializes the message service instance iterator.
SystemVerilog
function void reset(string name
string inst
= "/./",
bit
recurse = 0);
= "/./",
OpenVera
task reset(string name
= "/./",
string inst
= "/./",
bit
recurse = 0);
Description
Resets the message service instance iterator for this instance of the
message service, and initialize it to iterator using the specified name,
instance name, and optional recursion.
It is then possible to iterate over all known instances of the message
service interface that match the specified pattern, using the
vmm_log::for_each() method.
There is one iterator per message service instance.
Example
Example A-101
env.log.reset();
for (vmm_log log = env.log.for_each();
log != null;
log = env.log.for_each()) begin
end
vmm_log::set_instance()
Sets the instance name of the message service interface.
SystemVerilog
virtual function void set_instance(string inst);
OpenVera
Not supported.
Description
This method sets the instance name of the message service
interface.
vmm_log::set_name()
Sets the name of the message service interface.
SystemVerilog
virtual function void set_name(string name);
OpenVera
Not supported.
Description
This method sets the name of the message service interface.
vmm_log::set_typ_image()
Replaces the image, which is used to display the specified message.
SystemVerilog
virtual function string set_typ_image(int typ,
string image);
OpenVera
Not supported.
Description
Globally replaces the image, which is used to display the specified
message type with the specified image. The previous image is
returned. Default images are provided.
Default colors for fatal, error, and warning messages can be
automatically selected by using +define+VMM_LOG_ANSI_COLOR.
Messages can be custom color coded by specifying the ANSI
escape characters with the set_sev_image() or
set_typ_image() methods.
For example,
log.set_sev_image( vmm_log::FATAL_SEV,
"\033[41m*FATAL*\033[0m");
vmm_log::set_sev_image()
Replaces the image, which is used to display the specified message
severity.
SystemVerilog
virtual function string set_sev_image(int severity,
string image);
OpenVera
Not supported.
Description
Globally replaces the image, which is used to display the specified
message severity with the specified image. The previous image is
returned. Default images are provided.
Default colors for fatal, error, and warning messages can be
automatically selected by using +define+VMM_LOG_ANSI_COLOR.
Messages can be custom color coded by specifying the ANSI
escape characters with the set_sev_image() or
set_typ_image() methods.
For example,
log.set_sev_image( vmm_log::FATAL_SEV,
"\033[41m*FATAL*\033[0m");
Example
Example A-102
Following is an example for colorizing the severity display on ANSI
terminals.
log.set_sev_image(vmm_log::WARNING,
"\033[33mWARNING\033[0m");
log.set_sev_image(vmm_log::ERROR_SEV,
"\033[31mERROR\033[0m");
log.set_sev_image(vmm_log::FATAL_SEV,
"\033[41m*FATAL*\033[0m");
vmm_log::set_verbosity()
Specifies the minimum message severity to be displayed.
SystemVerilog
virtual function void set_verbosity(int severity,
string name = "",
string inst = "",
bit recursive = 0);
OpenVera
Not supported.
Description
Specifies the minimum message severity to be displayed, when
sourced by the specified message service interfaces. For ore
information, see the documentation for the enable_types()
method for the interpretation of the name, inst, and recursive
arguments, and how they are used to specify message service
interfaces.
The default minimum severity can be changed by using the
+vmm_log_default=sev runtime command-line option, where
sev is the desired minimum severity and is one of the levels such as
error, warning, normal, trace, debug, or verbose. The
default verbosity level can be later modified using this method.
The minimum severity level can be globally forced by using the
+vmm_force_verbosity=sev runtime command-line option. The
specified verbosity overrides the verbosity level specified, using this
method.
vmm_log::start_msg()
Prepares to generate a message.
SystemVerilog
virtual function bit start_msg( int typ, int severity =
DEFAULT_SEV);
With +define VMM_LOG_FORMAT_FILE_LINE
virtual function bit start_msg( int typ,
int severity = DEFAULT_SEV,
string fname = "",
int
line = -1);
OpenVera
virtual function bit (integer type,
integer severity = DEFAULT_TYP,
integer msg_id = -1);
Description
Prepares to generate a message of the specified type and severity.
If the message service interface instance is configured ignore
messages of the specified type or severity, then the function returns
FALSE.
When using SystemVerilog, the current filename and line number,
using fname and line arguments, where the message is created
can be supplied by using the __FILE__ and __LINE__ symbols.
For backward compatibility, the VMM_LOG_FORMAT_FILE_LINE
symbol must be defined to enable the inclusion of the filename, and
line number to the message formatter.
Example
Example A-103
program test
...
initial begin
...
env.log.text.start_msg(vmm_log::NOTE_TYP,
vmm_log::DEFAULT_SEV,
`__FILE__,__LINE__);
env.log.text("Starting Test My_Test");
env.log.text();
...
end
vmm_log::stop_after_n_errors()
Aborts the simulation, after a specified number of messages are
generated.
SystemVerilog
virtual function void stop_after_n_errors(int n);
OpenVera
Not supported.
Description
Aborts the simulation, after the specified number of messages with
a simulation handling of COUNT_ERROR is generated. This value is
global, and all messages from any message service interface count
toward this limit. A zero or negative value specifies no maximum.
The default value is 10. The message specified by the
vmm_log_format::abort_on_error() is displayed, before the
simulation is aborted.
vmm_log::text()
Adds the specified text to the message being constructed.
SystemVerilog
virtual function bit text(string msg = "");
OpenVera
Not supported.
Description
Adds the specified text to the message being constructed. This
method specifies a single line of message text. A newline character
is automatically appended when the message is issued. Additional
lines of messages can be produced by calling this method multiple
times, once per line. If an empty string is specified as message text,
all previously specified lines of text are flushed to the output, but the
message is not terminated. This method may return FALSE, if the
message is filtered out based on the text.
A message must be flushed and terminated by calling the
vmm_log::end_msg() method, to trigger the message display and
the simulation handling. A message can be flushed multiple times by
calling the vmm_log::text("") method, but the simulation
handling and notification will take effect on the message termination.
If additional lines are produced using the $display() system task
or other display mechanisms, they will not be considered by the
filters, nor included in explicit log files. They may also be displayed
out of order, if they are produced before the previous lines of the
message are flushed.
VMM User Guide
A- 297
Message
Type
Message
Severity
Failure
Fatal
Failure
Error
Failure
Warning
Note
Default
Debug
Trace
Debug
Debug
Debug
Verbose
Report
Default
Command
Default
Transaction
Default
Protocol
Default
Cycle
Default
vmm_log::uncatch()
Removes a user-defined message handler.
SystemVerilog
function bit uncatch(int catcher_id);
OpenVera
Not supported.
Description
Uninstalls the specified user-defined message handler. The
message handler is identified by the unique identifier that was
returned by the vmm_log::catch() method, when it was originally
installed.
Returns TRUE, if the specified message handler was successfully
uninstalled. Otherwise, it returns FALSE.
Example
Example A-104
class err_catcher extends vmm_log_catcher;
endclass
alu_env env;
err_catcher ctcher;
initial begin
env.build();
ctcher_id = env.sb.log.catch(ctcher, , , ,
vmm_log::ERROR_SEV,"/Mismatch/");
env.sb.log.uncatch(ctcher_id);
end
vmm_log::uncatch_all()
Removes all user-defined message handlers.
SystemVerilog
function void uncatch_all();
OpenVera
Not supported.
Description
Uninstalls all user-defined message handlers. All message handlers,
even those that were registered with or through a different message
service interface, are uninstalled.
Example
Example A-105
class err_catcher extends vmm_log_catcher;
endclass
alu_env env;
err_catcher ctcher1, ctcher2;
initial begin
env.build();
ctcher_id1 = env.log.catch(ctcher1, , , ,
vmm_log::ERROR_SEV,"/MON_ERROR_008/");
ctcher_id2 = env.log.catch(ctcher2, , , ,
vmm_log::ERROR_SEV,"/MON_ERROR_010/");
if(env.mon.error_cnt >10)
env.log.uncatch_all();
end
vmm_log::unmodify()
Removes a message modification from the message service
interfaces.
SystemVerilog
virtual function void unmodify(int modification_id = -1,
string name = "",
string instance = "",
bit recursive = 0);
OpenVera
Not supported.
Description
Removes the specified message modification_id from the
specified message service interfaces. By default, all message
modifications are removed. If the specified argument recursive is
set, then this method also applies to all the message interfaces
logically under the matching message service interfaces.
vmm_log::unregister_callback()
Unregisters the specified callback faade instance.
SystemVerilog
virtual function void unregister_callback(
vmm_log_callbacks cb);
OpenVera
Not supported.
Description
Globally unregisters the specified callback faade instance with the
message service. A warning is generated, if the specified faade
instance is not currently registered with the service. Callback faade
instances can later be re-registered.
vmm_log::use_hier_inst_name()
Switches to hierarchical instance names.
SystemVerilog
function void use_hier_inst_name();
OpenVera
Not supported.
Description
Rewrites the instance name of all message service interface
instances into a dot-separated hierarchical form. The original
instance names can later be restored using the
vmm_log::use_orig_inst_name() method.
An instance name is made hierarchical, if the message service
instance is specified as being under another message service
interface. Message service interface hierarchies can be built by
specifying the under argument to the constructor, or by using the
vmm_log::is_above() method.
For example, the code in Example A-106 results in instance names
such as top, top.m1, top.c1, and s1. The instance name for s1
is not modified, because it is not specified as being under another
message service interface, and thus creates a new hierarchical root.
Example
Example A-106
function tb_env::new();
super.new("top");
endfunction
function void tb_env::build();
super.build();
this.chan = new("Master to slave", "c1");
this.master = new("m1", this.chan);
this.slave = new("s1", this.chan);
this.log.is_above(this.master.log);
this.log.is_above(this.chan);
this.log.use_hier_inst_name();
endfunction
vmm_log::use_orig_inst_name()
Switches to original, flat instance names.
SystemVerilog
function void use_orig_inst_name();
OpenVera
Not supported.
Description
Rewrites the instance name of all message service interface
instances into the original and flat form specified, when the message
service instance was constructed.
Example
Example A-107
env.build();
if (env.log.uses_hier_inst_name())
env.log.use_orig_inst_name();
vmm_log::uses_hier_inst_name()
Checks if hierarchical instance names are in use.
SystemVerilog
function bit uses_hier_inst_name();
OpenVera
Not supported.
Description
Returns TRUE, if the message service interface instances use
hierarchical instance name, as defined by calling the
vmm_log::use_hier_inst_name() method. Returns
FALSE, if the original and flat instance names are used, as defined
by calling the vmm_log::use_orig_inst_name() method.
Example
Example A-108
env.build();
if (!env.log.uses_hier_inst_name())
env.log.use_hier_inst_name();
vmm_log::set_format()
Sets the message formatter to the specified message formatter
instance.
SystemVerilog
virtual function vmm_log_format
set_format(vmm_log_format fmt);
OpenVera
Not supported.
Description
Globally sets the message formatter to the specified message
formatter instance. A reference to the previously used message
formatter instance is returned. A default global message formatter is
provided.
vmm_log::wait_for_msg()
Waits for a one-time watchpoint for a specified message.
SystemVerilog
virtual task wait_for_msg(string name = "",
string inst = "",
bit recurse = 0,
int typs = ALL_TYPS,
int severity = ALL_SEVS,
string text = "",
logic issued = 1'bx,
ref vmm_log_msg msg);
OpenVera
Not supported.
Description
Sets up and waits for a one-time watchpoint for the specified
message (described by severity, message type typs, and string
text) on the specified message service interface (specified by inst
and name). The watchpoint is triggered only once and removed after
being triggered. If the specified argument recurse is set, then this
method also applies to all the message interfaces logically under the
matching message service interfaces.
A descriptor of the message that triggered the watchpoint will be
updated to the reference argument msg. Argument issued keeps
track whether the message is issued or not
vmm_log::wait_for_watchpoint()
Waits for the specified watchpoint to be triggered by a message.
SystemVerilog
virtual task wait_for_watchpoint(int watchpoint_id,
ref vmm_log_msg msg);
OpenVera
Not supported.
Description
Waits for the specified watchpoint to be triggered by a message
issued by one of the message service interfaces attached to the
watchpoint. A descriptor of the message that triggered the
watchpoint will be updated to the reference argument msg.
vmm_log_msg
This class describes a message issued by a message service
interface that caused a watchpoint to be triggered. It is returned by
the vmm_log::wait_for_watchpoint() and
vmm_log::wait_for_msg() method.
Summary
vmm_log_msg::effective_severity ..................
vmm_log_msg::effective_typ .......................
vmm_log_msg::handling ............................
vmm_log_msg::issued ..............................
vmm_log_msg::log .................................
vmm_log_msg::original_severity ...................
vmm_log_msg::original_typ ........................
vmm_log_msg::text[] ..............................
vmm_log_msg::timestamp ...........................
page
page
page
page
page
page
page
page
page
A-311
A-312
A-313
A-314
A-315
A-316
A-317
A-318
A-319
vmm_log_msg::effective_severity
Effective message severity as potentially modified by the
vmm_log::modify() method.
SystemVerilog
int effective_severity;
OpenVera
Not supported.
vmm_log_msg::effective_typ
Effective message type as potentially modified by the
vmm_log::modify() method.
SystemVerilog
int effective_typ;
OpenVera
Not supported.
vmm_log_msg::handling
The simulation handling after the message is physically generated.
SystemVerilog
int handling;
OpenVera
Not supported.
vmm_log_msg::issued
Indicates if the message is physically generated or not.
SystemVerilog
logic issued;
OpenVera
Not supported.
Description
If non-zero, then the message is generated.
vmm_log_msg::log
A reference to the message reporting interface that has generated
the message.
SystemVerilog
vmm_log log;
OpenVera
Not supported.
vmm_log_msg::original_severity
Original message severity, as specified in the code creating the
message.
SystemVerilog
int original_severity;
OpenVera
Not supported.
vmm_log_msg::original_typ
Original message type, as specified in the code creating the
message.
SystemVerilog
int original_typ;
OpenVera
Not supported.
vmm_log_msg::text[]
Formatted text of the message.
SystemVerilog
string text[$];
OpenVera
Not supported.
Description
Each element of the array contains one line of text, as built by
individual calls to the vmm_log::text() method.
vmm_log_msg::timestamp
The simulation time when the message was generated.
SystemVerilog
time timestamp;
OpenVera
Not supported.
vmm_log_callback
This class provides a facade for the callback methods provided by
the message service. Callbacks are associated with the message
service itself, but not a particular message service interface instance.
Summary
vmm_log_callback::pre_abort() ....................
vmm_log_callback::pre_debug() ....................
vmm_log_callback::pre_finish() ...................
vmm_log_callback::pre_stop() .....................
page
page
page
page
A-321
A-322
A-323
A-325
vmm_log_callback::pre_abort()
Aborts the condition callback.
SystemVerilog
virtual function void pre_abort(vmm_log log);
OpenVera
virtual function pre_abort(rvm_log log);
Description
This callback method is invoked by the message service when a
message was generated with an ABORT simulation handling, or the
maximum number of message with a COUNT_ERROR handling is
generated. This callback method is invoked before the
vmm_log_callback::pre_finish() callback method.
The message service interface provided as an argument may be
used to generate further messages.
vmm_log_callback::pre_debug()
Debugs condition callback.
SystemVerilog
virtual function void pre_debug(vmm_log log);
OpenVera
virtual function pre_debug(rvm_log log);
Description
This callback method is invoked by the message service when a
message was generated with a DEBUGGER simulation handling.
The message service interface provided as an argument may be
used to generate further messages.
vmm_log_callback::pre_finish()
Terminates the simulation callback.
SystemVerilog
virtual function void pre_finish(vmm_log log,
ref bit finished);
OpenVera
Not supported.
Description
This callback method is invoked by the message service, after the
vmm_log_callback::pre_abort() callback method, and immediately
before the $finish() method is invoked to terminate the
simulation.
The value of the finished parameter is 0 by default. If its value is
returned as 1, by the sequence of callback methods, it indicates that
the callback method is taken the responsibility of terminating the
simulation. Therefore, the final report and the $finish() method
will not be called.
Use this callback method, if you wish to delay the termination of the
simulation, after an abort condition is detected.
Example
Example A-109
fork
begin
#100;
log.report();
$finish();
end
join_none
finished = 1;
endfunction
vmm_log_callback::pre_stop()
Stops the condition callback.
SystemVerilog
virtual function void pre_stop(vmm_log log);
OpenVera
virtual function pre_stop(rvm_log log);
Description
This callback method is invoked by the message service when a
message was issued with a STOP simulation handling.
The message service interface provided as an argument may be
used to issue further messages.
vmm_log_catcher
VMM provides a mechanism to execute user-specific code, if a
certain message is generated from the testbench environment, using
the vmm_log_catcher class.
The vmm_log_catcher class is based on regexp to specify
matching vmm_log messages.
If a message with the specified regexp is generated during
simulation, the user-specified code is executed.
The vmm_log_catcher::caught() method can be used to
modify the caught message, change its type and severity. You can
choose to ignore the message, in which case it is not displayed. The
message can be displayed as is, after executing user-specified
code. The updated message can be displayed by calling the
vmm_log_catcher::issue() method, in the caught method.
The caught message, modified or unmodified, can be passed to
other catchers that are registered, using the
vmm_log_catcher::throw function.
The messages to be caught are registered with the vmm_log class
using the vmm_log::catch() method.
class error_catcher extends vmm_log_catcher;
virtual function void caught(vmm_log_msg msg);
msg.text[0] = {" Acceptable Error" , msg.text[0]};
msg.effective_severity = vmm_log::WARNING_SEV;
issue(msg);
endfunction
endclass
Summary
vmm_log_catcher::caught()
Handles a caught message.
SystemVerilog
virtual function void caught(vmm_log_msg msg);
OpenVera
Not supported.
Description
This method specifies how to handle a caught message. Unless regenerated using the vmm_log_catcher::issue() method, or
thrown back to the message service using the
vmm_log_catcher::throw() method, this message will not be
generated.
It is up to you to decide how a message, once caught, is to be
handled. Handling a message is defined by whatever behavior is
specified in the extension of this method. If left empty, the message
will be ignored.
This method must be overloaded.
Example
Example A-110
virtual function void caught(vmm_log_msg msg);
if (num_errors < max_errors) begin
msg.text[0] = {"ACCEPTABLE ERROR: ", msg.text[0]};
msg.effective_severity = vmm_log::WARNING_SEV;
...
end
else
. .
endfunction
vmm_log_catcher::issue()
Generates a caught message.
SystemVerilog
protected function void issue(vmm_log_msg msg);
OpenVera
Not supported.
Description
Immediately generates the specified message. The message is not
subject to being caught any further by this or another user-defined
message handler.
The message described by the vmm_log_msg descriptor may be
modified before being generated.
Example
Example A-111
virtual function void caught(vmm_log_msg msg);
if (num_errors > max_errors) begin
issue(msg);
end
...
endfunction
vmm_log_catcher::throw()
Throws back a caught message.
SystemVerilog
protected function void throw(vmm_log_msg msg);
OpenVera
Not supported.
Description
Throws the specified message back to the message service. The
message will be subject to being caught another user-defined
message handler, but not by this one.
The message described by the vmm_log_msg descriptor may be
modified before being thrown back.
Example
Example A-112
virtual function void caught(vmm_log_msg msg);
if (num_errors < max_errors)
throw(msg);
endfunction
vmm_log_format
This class is used to specify how messages are formatted, before
being displayed or logged to files. The default implementation of
these methods produces the default message format.
Summary
vmm_log_format::abort_on_error() .................
vmm_log_format::continue_msg() ...................
vmm_log_format::format_msg() .....................
vmm_log_format::pass_or_fail() ...................
page
page
page
page
A-334
A-335
A-337
A-339
vmm_log_format::abort_on_error()
Called when the total number of COUNT_ERROR messages exceeds
the error message threshold.
SystemVerilog
virtual function string abort_on_error(int count,
int limit);
OpenVera
Not supported.
Description
The string returned by the method describes the cause of the
simulation aborting. If null is returned, then no explanation is
displayed.
This method is called and the returned string is displayed, before the
vmm_log_callbacks::pre_abort() callback methods are
invoked.
vmm_log_format::continue_msg()
Formats the continuation of a message.
SystemVerilog
virtual function string continue_msg(
string name,
string instance,
string msg_typ,
string severity,
ref string lines[$]);
OpenVera
virtual function string continue_msg(string name,
string instance,
string msg_typ,
string severity,
string lines[$]);
Description
This method is called by all message service interfaces to format the
continuation of a message, and subsequent calls to the
vmm_log::end_msg() method or empty vmm_log::text("")
Example
Example A-113
...
string line[$];
string str;
super.build();
str = "Continue Msg string";
for(int idx = 0; idx < 5 ; idx++)
line.push_back(str);
`vmm_note(log,$psprintf("%0s",this.format.continue_msg
("msg","log","","DEBUG_SEV",line)));
...
vmm_log_format::format_msg()
Formats a message.
SystemVerilog
virtual function string format_msg(
string name,
string instance,
string msg_typ,
string severity,
ref string lines[$]);
With +define VMM_LOG_FORMAT_FILE_LINE
virtual function string format_msg(string name,
string inst,
string msg_typ,
string severity,
string fname,
int
line,
ref string lines[$]);
OpenVera
virtual function string format_msg(string name,
string instance,
string msg_typ,
string severity,
string lines[$]);
Description
Returns a fully formatted image of the message, as specified by the
arguments. The lines parameter contains one line of message text
for each non-empty call to the vmm_log::text() method. A line
may contain newline characters.
VMM User Guide
A- 337
Example
Example A-114
class env_log_fmt extends vmm_log_format;
function string format_msg(string name = "", string
instance = "",
string msg_type, string severity,
ref string lines[$]);
for(int i=0;i<lines.size;i++)
$sformat(format_msg,
"%0t, (%s) (%s) [%0s:%0s] \n \t \t %s ",
$time, name, instance, msg_type, severity, lines[i]);
endfunction
endclass
class my_env extends vmm_env;
...
env_log_fmt env_fmt = new();
function new();
this.log.set_format(env_fmt);
`vmm_note(log,"Inside New");
endfunction
endclass
vmm_log_format::pass_or_fail()
Formats the final pass or fail message at the end of simulation.
SystemVerilog
virtual function string pass_or_fail(bit pass,
string name,
string inst,
int fatals,
int errors,
int warnings,
int dem_errs,
int dem_warns);
OpenVera
Not supported.
Description
This method is called by the vmm_log::report() method to
format the final pass or fail message, at the end of simulation.
The pass argument, if true, indicates that the simulation was
successful.
The name and instance arguments are the specified name and
instance names specified to the vmm_log::report() method.
The fatals argument is the total number of
vmm_log::FATAL_SEV messages that were generated.
The errors argument is the total number of
vmm_log::ERROR_SEV messages that were generated.
vmm_ms_scenario
This is a base class for all user-defined multi-stream scenario
descriptors. This class extends from vmm_scenario.
Summary
vmm_ms_scenario::execute() .......................
vmm_ms_scenario::get_channel() ...................
vmm_ms_scenario::get_context_gen() ...............
vmm_ms_scenario::get_ms_scenario() ...............
vmm_ms_scenario::new() ...........................
page
page
page
page
page
A-342
A-344
A-346
A-348
A-350
vmm_ms_scenario::execute()
Executes a multi-stream scenario.
SystemVerilog
virtual task execute(ref int n)
OpenVera
Not supported.
Description
Execute the scenario. Increments the argument "n" by the total
number of transactions that were executed in this scenario.
This method must be overloaded to procedurally define a multistream scenario.
Example
Example A-115
class my_scenario extends vmm_ms_scenario;
my_atm_cell_scenario atm_scenario;
my_cpu_scenario cpu_scenario;
...
function new;
super.new(null);
atm_scenario = new;
cpu_scenario = new;
endfunction: new
task execute(ref int n);
fork
begin
atm_cell_channel out_chan;
int unsigned nn = 0;
$cast(out_chan, this.get_channel(
"ATM_SCENARIO_CHANNEL"));
atm_scenario.randomize with {length == 1;};
atm_scenario.apply(out_chan, nn);
n += nn;
end
begin
cpu_channel out_chan;
int unsigned nn = 0;
$cast(out_chan,this.get_channel(
"CPU_SCENARIO_CHANNEL"));
cpu_scenario.randomize with {length == 1;};
cpu_scenario.apply(out_chan, nn);
n += nn;
end
join
endtask: execute
...
endclass: my_scenario
vmm_ms_scenario::get_channel()
Returns a registered output channel.
SystemVerilog
function vmm_channel get_channel(string name)
OpenVera
Not supported.
Description
Returns the output channel, which is registered under the specified
logical name in the multi-stream generator where the multi-stream
scenario generator is registered. Returns NULL, if no such channel
exists.
Example
Example A-116
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm trans")
program test_ms_scenario;
vmm_ms_scenario_gen atm_ms_gen =
new("Atm Scenario Gen", 12);
atm_cell_channel my_chan=new("MY_CHANNEL", "EXAMPLE");
atm_cell_channel buffer_channel = new("MY_BUFFER",
"EXAMPLE");
...
initial begin
...
buffer_channel = atm_ms_gen.get_channel("MY_CHANNEL");
if(buffer_channel != null)
vmm_ms_scenario::get_context_gen()
Returns the multi-stream scenario generator that is executing this
scenario.
SystemVerilog
function vmm_ms_scenario_gen get_context_gen()
OpenVera
Not supported.
Description
Returns a reference to the multi-stream scenario generator that is
providing the context for the execution of this multi-stream scenario
descriptor. Returns NULL, if this multi-stream scenario descriptor is
not registered with a multi-stream scenario generator.
Example
Example A-117
`vmm_scenario_gen(atm_cell, "atm trans")
program test_ms_scenario;
vmm_ms_scenario_gen atm_ms_gen =
new("Atm Scenario Gen", 12);
vmm_ms_scenario ms_scen = new;
...
initial begin
atm_ms_gen.register_ms_scenario(
"FIRST SCEN",first_ms_scen);
...
if(my_scen.get_context_gen())
vmm_ms_scenario::get_ms_scenario()
Returns a registered multi-stream scenario descriptor.
SystemVerilog
function vmm_ms_scenario get_ms_scenario(string scenario,
string gen = "")
OpenVera
Not supported.
Description
Returns a copy of the multi-stream scenario that is registered under
the specified scenario name, in the multi-stream generator that is
registered under the specified generator name. Returns NULL, if no
such scenario exists. Therefore, vmm_ms_scenario::copy()
should be overloaded for multistream scenarios to return the copy of
the scenario.
If no generator name is specified, searches the scenario registry of
the generator that is executing this scenario.
The scenario can then be executed within the context of the
generator where it is registered by calling its
vmm_ms_scenario::execute() method.
Example
Example A-118
`vmm_scenario_gen(atm_cell, "atm trans")
program test_ms_scenario;
vmm_ms_scenario_gen atm_ms_gen =
new("Atm Scenario Gen", 12);
vmm_ms_scenario first_ms_scen = new;
vmm_ms_scenario buffer_ms_scen = new;
...
initial begin
atm_ms_gen.register_ms_scenario("FIRST
SCEN",first_ms_scen);
...
buffer_ms_scen = atm_ms_gen.get_ms_scenario("FIRST
SCEN");
if(buffer_ms_scen != null)
vmm_log(log,"Returned scenario \n");
...
else
vmm_log(log,"Returned null, scenario doesn't
exists\n");
...
end
endprogram
vmm_ms_scenario::new()
Instantiates a multi-stream scenario descriptor.
SystemVerilog
function new(vmm_scenario parent = null)
OpenVera
Not supported.
Description
Creates a new instance of a multi-stream scenario descriptor.
If a parent scenario descriptor is specified, then this instance of a
multi-stream scenario descriptor is assumed to be instantiated inside
the specified scenario descriptor, creating a hierarchical multistream scenario descriptor.
If no parent scenario descriptor is specified, then it is assumed to be
a top-level scenario descriptor.
Example
Example A-119
class my_scenario extends vmm_ms_scenario;
function new;
super.new(null);
endfunction: new
endclass
program test;
my_scenario sc0 = new;
endprogram
vmm_ms_scenario_gen
This class is a pre-defined multi-stream scenario generator.
VMM provides this class to model general purpose scenarios. It is
possible to generate heterogeneous scenarios, and have them
controlled by a unique transactor.
The multi-stream scenario generation mechanism provides an
efficient way of generating and synchronizing stimulus to various
BFMs. This helps you to reuse block level scenarios in subsystem
and system levels, and controlling or synchronizing the execution of
those scenarios of same or different streams. Single stream
scenarios can also be reused in multi-stream scenarios.
vmm_ms_scenario and vmm_ms_scenario_gen are the base
classes provided by VMM for this functionality. This section
describes the various usages of multi-stream scenario generation
with these base classes.
Generated scenarios can be transferred to any number of channels
of various types, anytime during simulation, making this solution very
scalable, dynamic and completely controllable. Moreoverer, it is
possible to model sub-scenarios that can be attached and controlled
by an overall scenario, in a hierarchical way. You can determine the
number of scenarios or the number of transactions to be generated,
either on a MSS basis or on a given scenario generator, making this
use model scalable from block to system level.
It is also possible to add or remove scenarios as simulation
advances, facilitating detection of corner cases or address other
constraints on the fly. If multiple scenario generators should access
a common channel, then it is possible to give the channel access to
Summary
416
vmm_ms_scenario_gen::channel_exists()
Checks if a channel is registered under a specified name.
SystemVerilog
virtual function bit channel_exists(string name)
OpenVera
Not supported.
Description
Returns TRUE, if there is an output channel registered under the
specified name. Otherwise, it returns FALSE.
Use the vmm_ms_scenario_gen::get_channel() method to
retrieve a channel under a specified name.
Example
Example A-120
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen =
new("MS Scenario Gen", 11);
atm_cell_channel ms_chan_1 =
new("MS-CHANNEL-1", "MY_CHANNEL");
...
initial begin
vmm_log(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL-1",ms_chan_1);
...
if(my_ms_gen.channel_exists("MS_CHANNEL-1"))
vmm_log(log,"Channel exists\n");
else
vmm_log(log,"Channel not yet registered\n");
...
end
endprogram
vmm_ms_scenario_gen::DONE
Notifiies the completed generation.
SystemVerilog
typedef enum int {DONE} symbols_e
OpenVera
Not supported.
Description
Notification in vmm_xactor::notify that is indicated when the
generation process is completed, as specified by the
vmm_ms_scenario_gen::stop_after_n_scenarios and
vmm_ms_scenario_gen::stop_after_n_insts class
properties.
Example
Example A-121
program test_scen;
...
vmm_ms_scenario_gen my_ms_gen = new(
"MY MS SCENARIO",10);
initial begin
...
`vmm_note(log,"Waiting for notification : DONE \n");
my_ms_gen.notify.wait_for(
vmm_ms_scenario_gen::DONE);
...
end
end
vmm_ms_scenario_gen::GENERATED
Notifies the newly generated scenario.
SystemVerilog
typedef enum int {GENERATED} symbols_e
OpenVera
Not supported.
Description
Notification in vmm_xactor::notify that is indicated, every time
a new multi-stream scenario is generated and about to be executed.
Example
Example A-122
program test_scen;
...
vmm_ms_scenario_gen my_ms_gen= new("MY MS SCENARIO",10);
...
initial begin
...
`vmm_note(
log,"Waiting for notification : GENERATED \n");
my_ms_gen.notify.wait_for(
vmm_ms_scenario_gen::GENERATED);
...
end
end
vmm_ms_scenario_gen::get_all_channel_names()
Returns all names in the channel registry.
SystemVerilog
virtual function void get_all_channel_names(
ref string name[$])
OpenVera
Not supported.
Description
Appends the names under which an output channel is registered.
Returns the number of names that were added to the array.
Example
Example A-123
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen",
11);
atm_cell_channel ms_chan_1=new("MS-CHANNEL-1",
"MY_CHANNEL");
string channel_name_array[$];
...
initial begin
`vmm_note(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL-1",ms_chan_1);
my_ms_gen.get_all_channel_names(channel_name_array);
end
endprogram
VMM User Guide
A- 357
vmm_ms_scenario_gen::get_all_ms_scenario_names()
Returns all names in the scenario registry.
SystemVerilog
virtual function void get_all_ms_scenario_names(
ref string name[$])
OpenVera
Not supported.
Description
Appends the names under which a multi-stream scenario descriptor
is registered. Returns the number of names that were added to the
array.
Example
Example A-124
class my_ms_scen extends vmm_ms_scenario;
endclass
program test_scenario;
string scen_name_arr[$];
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
initial begin
`vmm_note(log,"Registering MS scenario \n");
my_ms_gen.register_ms_scenario("MS-SCEN-1",ms_scen);
my_ms_gen.register_ms_scenario("MS-SCEN-2",ms_scen);
my_ms_gen.get_all_ms_scenario_names(scen_name_arr);
end
endprogram
vmm_ms_scenario_gen::get_all_ms_scenario_gen_names()
Returns all names in the generator registry.
SystemVerilog
virtual function void get_all_ms_scenario_gen_names(
ref string name[$])
OpenVera
Not supported.
Description
Appends the names under which a sub-generator is registered.
Returns the number of names that were added to the array.
Example
Example A-125
program test_scenario;
string ms_gen_names_arr[$];
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen =
new("Child-MS-Scen-Gen", 6);
...
initial begin
`vmm_note(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Scen-Gen",child_ms_gen);
parent_ms_gen.get_all_ms_scenario_gen_names(
ms_gen_names_arr);
end
endprogram
vmm_ms_scenario_gen::get_channel()
Returns the channel that is registered under a specified name.
SystemVerilog
virtual function vmm_channel get_channel(
string name)
OpenVera
Not supported.
Description
Returns the output channel registered under the specified name.
Generates a warning message and returns NULL, if there are no
channels registered under that name.
Example
Example A-126
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen",
11);
atm_cell_channel ms_chan_1=new("MS-CHANNEL-1",
"MY_CHANNEL");
atm_cell_channel buffer_chan = new("BUFFER","MY_BC");
...
initial begin
vmm_log(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL1",ms_chan_1);
...
buffer_chan = my_ms_gen.get_channel("MS-CHANNEL1");
...
end
endprogram
vmm_ms_scenario_gen::get_channel_name()
Returns a name under which a channel is registered.
SystemVerilog
virtual function string get_channel_name(vmm_channel chan)
OpenVera
Not supported.
Description
Return a name under which the specified channel is registered.
Returns "", if the channel is not registered.
Example
Example A-127
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen",
11);
atm_cell_channel ms_chan_1=new("MS-CHANNEL-1",
"MY_CHANNEL");
string buffer_chan_name;
initial begin
vmm_log(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL-1",ms_chan_1);
buffer_chan_name =
my_ms_gen.get_channel_name(ms_chan_1);
end
endprogram
vmm_ms_scenario_gen::get_ms_scenario_index()
Returns the index of the specified scenario.
SystemVerilog
virtual function int get_ms_scenario_index(
vmm_ms_scenario scenario)
OpenVera
Not supported.
Description
Returns the index of the specified scenario descriptor in the
vmm_ms_scenario_gen::scenario_set[$] array. A warning
message is generated and returns -1, if the scenario descriptor is not
found in the scenario set.
Example
Example A-128
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
int buffer_index;
initial begin
...
vmm_log(log,"Registering MS scenario \n");
my_ms_gen.register_ms_scenario("MS-SCEN-1",ms_scen);
...
buffer_index =
my_ms_gen.get_ms_scenario_index(ms_scen);
vmm_note(log,`vmm_sformatf(
"Index for ms_scen is : %d\n",buffer_index));
...
end
endprogram
vmm_ms_scenario_gen::get_ms_scenario()
Returns the scenario that is registered under a specified name.
SystemVerilog
virtual function vmm_ms_scenario get_ms_scenario(
string name)
OpenVera
Not supported.
Description
Returns a copy of the multi-stream scenario descriptor that is
registered under the specified name. Generates a warning message
and returns NULL, if there are no scenarios registered under that
name.
Example
Example A-129
class my_ms_scen extends vmm_ms_scenario;
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
my_ms_scen buffer_scen = new;
initial begin
vmm_log(log,"Registering MS scenario \n");
my_ms_gen.register_ms_scenario("MS-SCEN-1",ms_scen);
buffer_scen = my_ms_gen.get_ms_scenario("MY-SCEN_1");
end
endprogram
vmm_ms_scenario_gen::get_ms_scenario_gen()
Returns the sub-generator that is registered under a specified name.
SystemVerilog
virtual function vmm_ms_scenario_gen get_ms_scenario_gen(
string name)
OpenVera
Not supported.
Description
Returns the sub-generator that is registered under the specified
name. Generates a warning message and returns NULL, if there are
no generators registered under that name.
Example
Example A-130
program test_scenario;
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen =
new("Child-MS-Scen-Gen", 6);
vmm_ms_scenario_gen buffer_ms_gen =
new("Buffer-MS-Scen-Gen", 6);
...
initial begin
vmm_log(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Scen-Gen", child_ms_gen);
...
buffer_ms_gen = parent_ms_gen.get_ms_scenario_gen(
"Child-MS-Scen-Gen");
...
end
endprogram
vmm_ms_scenario_gen::get_ms_scenario_gen_name()
Returns a name under which a generator is registered.
SystemVerilog
virtual function string get_ms_scenario_gen_name(
vmm_ms_scenario_gen scenario_gen)
OpenVera
Not supported.
Description
Returns a name under which the specified sub-generator is
registered. Returns "", if the generator is not registered.
Example
Example A-131
program test_scenario;
string buffer_ms_gen_name;
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen =
new("Child-MS-Scen-Gen", 6);
initial begin
vmm_log(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Scen-Gen",child_ms_gen);
buffer_ms_gen_name =
parent_ms_gen.get_ms_scenario_gen_name(
child_ms_gen);
end
endprogram
vmm_ms_scenario_gen::get_ms_scenario_name()
Returns a name under which a scenario is registered.
SystemVerilog
virtual function string get_ms_scenario_name(
vmm_ms_scenario scenario)
OpenVera
Not supported.
Description
Returns a name under which the specified multi-stream scenario
descriptor is registered. Returns "", if the scenario is not registered.
Example
Example A-132
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
string buffer_name;
initial begin
...
vmm_log(log,"Registering MS scenario \n");
my_ms_gen.register_ms_scenario("MS-SCEN-1",ms_scen);
...
buffer_name = my_ms_gen.get_ms_scenario_name(ms_scen);
vmm_note(log,
`vmm_sformatf(
"Registered name for ms_scen is: %s\n",
buffer_name));
...
end
endprogram
vmm_ms_scenario_gen::get_n_insts()
Returns the number of transaction descriptors generated so far.
SystemVerilog
function int unsigned get_n_insts()
OpenVera
Not supported.
Description
Returns the current value of the
vmm_ms_scenario_gen::inst_count property.
Example
Example A-133
class my_ms_scen extends vmm_ms_scenario_gen;
...
function void print_ms_gen_fields();
...
`vmm_note(log,$psprintf(
"Present instance count is %d\n",
this.get_n_insts()));
endfunction
endclass
program test_scen;
my_ms_scen my_gen= new("MY MS SCENARIO",10);
initial begin
my_gen.print_ms_gen_fields();
end
end
vmm_ms_scenario_gen::get_n_scenarios()
Returns the number of multi-stream scenarios generated so far.
SystemVerilog
function int unsigned get_n_scenarios()
OpenVera
Not supported.
Description
Returns the current value of the
vmm_ms_scenario_gen::scenario_count property.
Example
Example A-134
class my_ms_scen extends vmm_ms_scenario_gen;
...
function void print_ms_gen_fields();
...
`vmm_note(log,$psprintf(
"Present scenario count is %d\n",
this.get_n_scenarios()));
endfunction
endclass
program test_scen;
my_ms_scen my_gen= new("MY MS SCENARIO",10);
initial begin
my_gen.print_ms_gen_fields();
end
end
vmm_ms_scenario_gen::get_names_by_channel()
Returns the names under which a channel is registered.
SystemVerilog
virtual function void get_names_by_channel(
vmm_channel chan,
ref string
name[$])
OpenVera
Not supported.
Description
Appends the names under which the specified output channel is
registered. Returns the number of names that were added to the
array.
Example
Example A-135
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen",
11);
atm_cell_channel ms_chan_1=new("MS-CHANNEL-1",
"MY_CHANNEL");
string channel_name_array[$];
...
initial begin
`vmm_note(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL-1",ms_chan_1);
...
my_ms_gen.get_names_by_channel(ms_chan_1,channel_name_arra
y);
...
end
endprogram
vmm_ms_scenario_gen::get_names_by_ms_scenario()
Returns the names under which a scenario is registered.
SystemVerilog
virtual function void get_names_by_ms_scenario(
vmm_ms_scenario scenario,
ref string
name[$])
OpenVera
Not supported.
Description
Appends the names under which the specified multi-stream scenario
descriptor is registered. Returns the number of names that were
added to the array.
Example
Example A-136
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
string scen_name_arr[$];
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
...
initial begin
...
`vmm_note(log,"Registering MS scenario \n");
my_ms_gen.register_ms_scenario("MS-SCEN-1",ms_scen);
my_ms_gen.register_ms_scenario("MS-SCEN-2",ms_scen);
...
my_ms_gen.get_names_by_ms_scenario(
ms_scen,scen_name_arr);
...
end
endprogram
vmm_ms_scenario_gen::get_names_by_ms_scenario_gen()
Returns the names under which a generator is registered.
SystemVerilog
virtual function void
get_names_by_ms_scenario_gen(vmm_ms_scenario_gen
scenario_gen, ref string name[$])
OpenVera
Not supported.
Description
Appends the names under which the specified sub-generator is
registered. Returns the number of names that were added to the
array.
Example
Example A-137
program test_scenario;
string ms_gen_names_arr[$];
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen =
new("Child-MS-Scen-Gen", 6);
...
initial begin
`vmm_note(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Scen-Gen", child_ms_gen);
...
parent_ms_gen.get_names_by_ms_scenario_gen(child_ms_gen,
ms_gen_names_arr);
...
end
endprogram
vmm_ms_scenario_gen::inst_count
Returns the number of transaction descriptor generated so far.
SystemVerilog
protected int inst_count;
OpenVera
Not supported.
Description
Returns the current count of the number of individual transaction
descriptor instances generated by the multi-stream scenario
generator. When it reaches or surpasses the value in
vmm_ms_scenario_gen::stop_after_n_insts, the generator
stops.
The number of transaction descriptor instances generated by the
execution of a multi-stream scenario is the number of transactions
reported by the vmm_ms_scenario::execute() method, when it
returns.
Example
Example A-138
class my_ms_scen extends vmm_ms_scenario_gen;
...
function void print_ms_gen_fields();
...
`vmm_note(log,$psprintf(
"Present instance count is %d\n", this.inst_count));
endfunction
...
endclass
program test_scen;
...
my_ms_scen my_gen= new("MY MS SCENARIO",10);
...
initial begin
...
my_gen.print_ms_gen_fields();
...
end
end
vmm_ms_scenario_gen::ms_scenario_exists()
Checks if a scenario is registered under a specified name.
SystemVerilog
virtual function bit ms_scenario_exists(string name)
OpenVera
Not supported.
Description
Returns TRUE, if there is a multi-stream scenario registered under
the specified name. Otherwise, it returns FALSE.
Use the vmm_ms_scenario_gen::get_ms_scenario()
method to retrieve a scenario under a specified name.
Example
Example A-139
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
...
initial begin
...
vmm_log(log,"Registering MS scenario \n");
my_ms_gen.register_ms_scenario("MS SCEN-1",ms_scen);
...
if(my_ms_gen.ms_scenario_exists("MS-SCEN-1"))
`vmm_note(log, "Scenario MS-SCEN-1 is registered");
else
`vmm_note(log,
"Scenario MS-SCEN-1 is not yet registered");
...
end
endprogram
vmm_ms_scenario_gen::ms_scenario_gen_exists()
Checks if a generator is registered under a specified name.
SystemVerilog
virtual function bit ms_scenario_gen_exists(string name)
OpenVera
Not supported.
Description
Returns TRUE, if there is a sub-generator registered under the
specified name. Otherwise, it returns FALSE.
Use the vmm_ms_scenario_gen::get_ms_scenario_gen() to
retrieve a sub-generator under a specified name.
Example
Example A-140
program test_scen;
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen =
new(" Child-MS-Scen-Gen", 6);
...
initial begin
vmm_log(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Scen-Gen",child_ms_gen);
...
if(parent_ms_gen.ms_scenario_gen_exists(
"Child-MS-Scen-Gen"))
vmm_ms_scenario_gen::register_channel()
Registers an output channel.
SystemVerilog
virtual function void register_channel(string name,
vmm_channel chan)
OpenVera
Not supported.
Description
Registers the specified output channel under the specified logical
name. The same channel may be registered multiple times under
different names, thus creating an alias to the same channel.
Once registered, the output channel is available under the specified
logical name to multi-stream scenarios through the
vmm_ms_scenario::get_channel() method.
It is an error to register a channel under a name that already exists.
Use the vmm_ms_scenario_gen::replace_channel() to
replace a registered scenario.
Example
Example A-141
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen =
new("MS Scenario Gen", 11);
atm_cell_channel ms_chan_1 =
new("MS-CHANNEL-1", "MY_CHANNEL");
...
initial begin
...
vmm_log(log,"Registering channel \n");
my_ms_gen.register_channel("MS-channel-1",ms_chan_1);
...
end
endprogram
vmm_ms_scenario_gen::register_ms_scenario()
Registers a multi-stream scenario descriptor
SystemVerilog
virtual function void register_ms_scenario(string name,
vmm_ms_scenario scenario)
OpenVera
Not supported.
Description
Registers the specified multi-stream scenario under the specified
name. The same scenario may be registered multiple times under
different names, thus creating an alias to the same scenario.
Registering a scenario implicitly appends it to the scenario set, if it is
not already in the vmm_ms_scenario_gen::scenario_set[$]
array.
It is an error to register a scenario under a name that already exists.
Use the vmm_ms_scenario_gen::replace_ms_scenario() to
replace a registered scenario.
Example
Example A-142
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
...
initial begin
...
vmm_log(log,"Registering MS scenario \n");
my_ms_gen.register_ms_scenario("MS SCEN-1",ms_scen);
...
end
endprogram
vmm_ms_scenario_gen::register_ms_scenario_gen()
Registers a sub-generator
SystemVerilog
virtual function void register_ms_scenario_gen(string name,
vmm_ms_scenario_gen scenario_gen)
OpenVera
Not supported.
Description
Registers the specified sub-generator under the specified logical
name. The same generator may be registered multiple times under
different names, therefore creating an alias to the same generator.
Once registered, the multi-stream generator becomes available
under the specified logical name to multi-stream scenarios via the
vmm_ms_scenario::get_ms_scenario() method to create
hierarchical multi-stream scenarios.
It is an error to register a generator under a name that already exists.
Use the
vmm_ms_scenario_gen::replace_ms_scenario_gen()
method to replace a registered generator.
Example
Example A-143
program test_scen;
vmm_ms_scenario_gen parent_ms_gen = new("Parent-MS-
Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen = new(" Child-MS-ScenGen", 6);
...
initial begin
vmm_log(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen("Child-MSScen-
Gen",child_ms_gen);
...
end
endprogram
vmm_ms_scenario_gen::replace_channel()
Replaces an output channel.
SystemVerilog
virtual function void replace_channel(string name,
vmm_channel chan)
OpenVera
Not supported.
Description
Registers the specified output channel under the specified name,
replacing the channel that is previously registered under that name
(if any). The same channel may be registered multiple times under
different names, thus creating an alias to the same output channel.
Example
Example A-144
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen",
11);
atm_cell_channel ms_chan_1=new("MS-CHANNEL-1",
"MY_CHANNEL");
...
initial begin
vmm_log(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL1",ms_chan_1);
my_ms_gen.register_channel("MS-CHANNEL2",ms_chan_1);
...
vmm_log(log,"Replacing the channel \n");
my_ms_gen.replace_channel("MS-CHANNEl1",ms_chan_1);
...
end
endprogram
vmm_ms_scenario_gen::replace_ms_scenario()
Replaces a scenario descriptor.
SystemVerilog
virtual function void replace_ms_scenario(string name,
vmm_ms_scenario scenario)
OpenVera
Not supported.
Description
Registers the specified multi-stream scenario under the specified
name, replacing the scenario that is previously registered under that
name (if any). The same scenario may be registered multiple times,
under different names, thus creating an alias to the same scenario.
Registering a scenario implicitly appends it to the scenario set, if it is
not already in the vmm_ms_scenario_gen::scenario_set[$]
array. The replaced scenario is removed from the
vmm_ms_scenario_gen::scenario_set[$] array, if it is not
also registered under another name.
Example
Example A-145
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
VMM User Guide
A- 393
vmm_ms_scenario_gen::replace_ms_scenario_gen()
Replaces a sub-generator.
SystemVerilog
virtual function void replace_ms_scenario_gen(string name,
vmm_ms_scenario_gen scenario_gen)
OpenVera
Not supported.
Description
Registers the specified sub-generator under the specified name,
replacing the generator that is previously registered under that name
(if any). The same generator may be registered multiple times under
different names, thus creating an alias to the same sub-generator.
vmm_ms_scenario_gen::scenario_count
Returns the number of multi-stream scenarios generated so far.
SystemVerilog
protected int scenario_count;
OpenVera
Not supported.
Description
Returns the current count of the number of top-level multi-stream
scenarios generated the multi-stream scenario generator. When it
reaches or surpasses the value in
vmm_ms_scenario_gen::stop_after_n_scenarios, the
generator stops.
Only the multi-stream scenarios that are explicitly executed by this
instance of the multi-stream scenario generator are counted. Subscenarios executed as part of a higher-level multi-stream scenario
are not counted.
Example
Example A-146
class my_ms_scen extends vmm_ms_scenario_gen;
...
function void print_ms_gen_fields();
...
`vmm_note(log,$psprintf(
"Present scenario count is %d\n",
this.scenario_count));
endfunction
...
endclass
program test_scen;
...
my_ms_scen my_gen= new("MY MS SCENARIO",10);
...
initial begin
fork
begin
@event;
my_gen.print_ms_gen_fields();
end
...
join
...
end
end
vmm_ms_scenario_gen::scenario_set[$]
Multi-stream scenarios available for execution.
SystemVerilog
vmm_ms_scenario scenatio_set[$]
OpenVera
Not supported.
Description
Multi-stream scenarios available for execution by this generator. The
scenario executed next, is selected by randomizing the
vmm_ms_scenario_gen::select_scenario class property.
Multi-stream scenario instances in this array should be managed
through the
vmm_ms_scenario_gen::register_ms_scenario(),
vmm_ms_scenario_gen::replace_ms_scenario() and
vmm_ms_scenario_gen::unregister_ms_scenario()
methods.
Example
Example A-147
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
my_ms_scen ms_scen_1 = new;
my_ms_scen ms_scen_2 = new;
...
initial begin
parent_ms_gen.register_ms_scenario(
"MS-Scen-1",ms_scen_1);
parent_ms_gen.register_ms_scenario(
"MS-Scen-2",ms_scen_2);
...
buffer_ms_gen =
parent_ms_gen.unregister_ms_scenario(ms_scen_1);
current_size = parent_ms_gen.scenario_set.size();
`vmm_note(log, `vmm_sformatf(
"Current size of scenario set is %d\n",current_size);
end
endprogram
vmm_ms_scenario_gen::select_scenario
Selects the scenario factory.
SystemVerilog
vmm_ms_scenario_election select_scenario
OpenVera
Not supported.
Description
Randomly selects the next multi-stream scenario, to execute from
the vmm_ms_scenario_gen::scenario_set[$] array. The
selection is performed by calling the randomize() method on this
class property, and then executing the multi-stream scenario found
in the vmm_ms_scenario_gen::scenario_set[$] array at the
index specified by the vmm_ms_scenario_election::select
class property.
The default election instance may be replaced by a user-defined
extension to modify the scenario election policy.
Example
Example A-148
program test_scenario;
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
my_ms_scen ms_scen_1 = new;
...
initial begin
parent_ms_gen.register_ms_scenario(
"MS-Scen-1",ms_scen_1);
...
parent_ms_gen.select_scenario.round_robin.constraint_
mode(0);
...
end
endprogram
vmm_ms_scenario_gen::stop_after_n_insts
Returns the number of transaction descriptor to generate.
SystemVerilog
int unsigned stop_after_n_insts
OpenVera
Not supported.
Description
Automatically stops the multi-stream scenario generator, when the
number of generated transaction descriptors reaches or surpasses
the specified value. A value of zero indicates an infinite number of
transaction descriptors.
The number of transaction descriptor instances generated by the
execution of a multi-stream scenario is the number of transactions
reported by the vmm_ms_scenario::execute() method, when it
returns. Entire scenarios are executed before the generator is
stopped, so that the actual number of transaction descriptors
generated may be greater than the specified value.
Example
Example A-149
`vmm_scenario_gen(atm_cell, "atm trans")
class my_ms_scenario extends vmm_ms_scenario;
...
endclass
program test_ms_scenario;
...
vmm_ms_scenario_gen ms_gen = new("MS Scenario Gen", 10);
my_ms_scenario ms_scen = new;
...
initial begin
...
ms_gen.stop_after_n_instances = 100;
...
end
endprogram
vmm_ms_scenario_gen::stop_after_n_scenarios
Returns the number of multi-stream scenarios to generate.
SystemVerilog
int unsigned stop_after_n_scenarios
OpenVera
Not supported.
Description
Automatically stops the multi-stream scenario generator, when the
number of generated multi-streams scenarios reaches or surpasses
the specified value. A value of zero specifies an infinite number of
multi-stream scenarios.
Only the multi-stream scenarios explicitly executed by this instance
of the multi-stream scenario generator are counted. Sub-scenarios
executed as part of a higher-level multi-stream scenario are not
counted.
Example
Example A-150
`vmm_scenario_gen(atm_cell, "atm trans")
class my_ms_scenario extends vmm_ms_scenario;
...
endclass
program test_ms_scenario;
...
vmm_ms_scenario_gen ms_gen = new("MS Scenario Gen", 10);
vmm_ms_scenario_gen::unregister_channel()
Unregisters an output channel.
SystemVerilog
virtual function bit unregister_channel(
vmm_channel chan)
OpenVera
Not supported.
Description
Completely unregisters the specified output channel and returns
TRUE, if it exists in the registry.
Example
Example A-151
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen",
11);
atm_cell_channel ms_chan_1=new("MS-CHANNEL-1",
"MY_CHANNEL");
...
initial begin
vmm_log(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL1",ms_chan_1);
...
if(my_ms_gen.unregister_channel(ms_chan_1)
vmm_log(log,"Channel has been
unregistered\n");
...
end
endprogram
vmm_ms_scenario_gen::unregister_channel_by_name()
Unregisters an output channel
SystemVerilog
virtual function vmm_channel unregister_channel_by_name(
string name)
OpenVera
Not supported.
Description
Unregisters the output channel under the specified name, and
returns the unregistered channel. Returns NULL, if there is no
channel registered under the specified name.
Example
Example A-152
`vmm_channel(atm_cell)
`vmm_scenario_gen(atm_cell, "atm_trans")
program test_scen;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen",
11);
atm_cell_channel ms_chan_1=new("MS-CHANNEL-1",
"MY_CHANNEL");
atm_cell_channel buffer_chan = new("BUFFER","MY_BC");
...
initial begin
vmm_log(log,"Registering channel \n");
my_ms_gen.register_channel("MS-CHANNEL1",ms_chan_1);
...
vmm_log(log,"Unregistered channel by name \n");
buffer_chan =
my_ms_gen.unregister_channel_by_name("MS-CHANNEL-
1");
...
end
endprogram
vmm_ms_scenario_gen::unregister_ms_scenario()
Unregisters a scenario descriptor.
SystemVerilog
virtual function bit unregister_ms_scenario(
vmm_ms_scenario scenario)
OpenVera
Not supported.
Description
Completely unregisters the specified multi-stream scenario
descriptor and returns TRUE, if it exists in the registry. The
unregistered scenario is also removed from the
vmm_ms_scenario_gen::scenario_set[$] array.
Example
Example A-153
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
...
initial begin
my_ms_gen.register_ms_scenario("MS SCEN-1",ms_scen);
...
if(my_ms_gen.unregister_ms_scenario(ms_scen)
vmm_log(log,"Scenario unregistered \n");
else
vmm_log(log,"Unable to unregister
...
end
endprogram
\n");
vmm_ms_scenario_gen::unregister_ms_scenario_by_name()
Unregisters a scenario descriptor.
SystemVerilog
virtual function vmm_ms_scenario
unregister_ms_scenario_by_name(
string name)
OpenVera
Not supported.
Description
Unregisters the multi-stream scenario under the specified name, and
returns the unregistered scenario descriptor. Returns NULL, if there
is no scenario registered under the specified name.
The unregistered scenario descriptor is removed from the
vmm_ms_scenario_gen::scenario_set[$] array, if it is not
also registered under another name.
Example
Example A-154
class my_ms_scen extends vmm_ms_scenario;
...
endclass
program test_scenario;
vmm_ms_scenario_gen my_ms_gen = new("MS Scenario Gen", 9);
my_ms_scen ms_scen = new;
my_ms_scen buffer_scen =new;
...
initial begin
my_ms_gen.register_ms_scenario("MS SCEN-1",ms_scen);
...
buffer_scen =
my_ms_gen.unregister_ms_scenario_by_name(
"MY-SCEN-1",ms_scen);
if(buffer_scen == null)
vmm_log(log,"Returned null value \n");
...
end
endprogram
vmm_ms_scenario_gen::unregister_ms_scenario_gen()
Unregisters a sub-generator
SystemVerilog
virtual function bit
unregister_ms_scenario_gen(vmm_ms_scenario_gen
scenario_gen)
OpenVera
Not supported.
Description
Completely unregisters the specified sub-generator and returns
TRUE, if it exists in the registry.
Example
Example A-155
program test_scenario;
string buffer_ms_gen_name;
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen =
new("Child-MS-Scen-Gen", 6);
...
initial begin
vmm_log(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Gen-1",child_ms_gen);
...
if(parent_ms_gen.unregister_ms_scenario_gen(
child_ms_gen))
vmm_ms_scenario_gen::unregister_ms_scenario_gen_by_n
ame()
Unregisters a sub-generator.
SystemVerilog
virtual function vmm_ms_scenario_gen
unregister_ms_scenario_gen_by_name(
string name)
OpenVera
Not supported.
Description
Unregisters the generator under the specified name, and returns the
unregistered generator. Returns NULL, if there is no generator
registered under the specified name.
Example
Example A-156
program test_scenario;
vmm_ms_scenario_gen parent_ms_gen =
new("Parent-MS-Scen-Gen", 11);
vmm_ms_scenario_gen child_ms_gen =
new("Child-MS-Scen-Gen", 6);
vmm_ms_scenario_gen buffer_ms_gen =
new("Buffer-MS-Scen-Gen", 6);
...
initial begin
vmm_log(log,"Registering sub MS generator \n");
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Gen-1",child_ms_gen);
parent_ms_gen.register_ms_scenario_gen(
"Child-MS-Gen-2",child_ms_gen);
...
buffer_ms_gen =
parent_ms_gen.unregister_ms_scenario_gen_by_name(
"Child-MS-Gen-1");
end
endprogram
vmm_notification
This class is used to describe a notification that can be
autonomously indicated or reset based on a user-defined behavior,
such as the composition of other notifications or external events.
Notification descriptors are attached to notifications, using the
vmm_notify::set_notification() method.
Summary
vmm_notification::indicate()
Define a method that causes the notification attached to the
descriptor to be indicated.
SystemVerilog
virtual task indicate(ref vmm_data status);
OpenVera
Not supported.
Description
Defines a method that, when it returns, causes the notification
attached to the descriptor to be indicated. The value of the status
argument is used as the indicated notification status descriptor. This
method is automatically invoked by the notification service interface
when a notification descriptor is attached to a notification, using the
vmm_notify::set_notification() method.
This method must be overloaded in a user-defined class extensions.
It can be used to implement arbitrary notification mechanisms, such
as notifications based on a complex composition of other indications
(for example, notification expressions) or external events.
Example
Example A-157
class bus_mon extends vmm_xactor;
static int OBSERVED;
my_trans tr;
function new(...);
super.new(...);
this.notify.configure(OBSERVED,vmm_notify::ON_OFF);
endfunction
...
virtual task main();
...
forever begin
tr=new();
...
this.notify.indicate(OBSERVED,tr);
...
end
endtask: main
endclass: bus_mon
vmm_notification::reset()
Defines a method that causes the ON or OFF notification, which is
attached to the notification descriptor to be reset.
SystemVerilog
virtual task reset();
OpenVera
Not supported.
Description
Defines a method that, when it returns, causes the ON or OFF
notification, which is attached to the notification descriptor to be
reset. This method is automatically invoked by the notification
service interface, when a notification definition is attached to a
vmm_notify::ON_OFF notification.
This method must be overloaded in user-defined class extensions.
Example
Example A-158
Example of notification indicated when two other notifications are
indicated:
class bus_mon extends vmm_xactor;
static int OBSERVED;
my_trans tr;
function new(...);
super.new(...);
this.notify.configure(OBSERVED,vmm_notify::ON_OFF);
endfunction
...
virtual task main();
...
forever begin
tr=new();
...
this.notify.indicate(OBSERVED,tr);
...
this.notify.reset();
end
endtask: main
endclass: bus_mon
vmm_notify
The vmm_notify class implements an interface to the notification
service. The notification service provides a synchronization
mechanism for concurrent threads or transactors. Unlike event
variables, the operation of the notification is defined at configuration
time. Moreover, notification can include status and timestamp
information attached to their indication.
Summary
vmm_notify::append_callback() ....................
vmm_notify::configure() ..........................
vmm_notify::copy() ...............................
vmm_notify::get_notification() ...................
vmm_notify::indicate() ...........................
vmm_notify::is_configured() ......................
vmm_notify::is_on() ..............................
vmm_notify::is_waited_for() ......................
vmm_notify::new() ................................
vmm_notify::register_vmm_sb_ds() .................
vmm_notify::reset() ..............................
vmm_notify::set_notification() ...................
vmm_notify::status() .............................
vmm_notify::terminated() .........................
vmm_notify::timestamp() ..........................
vmm_notify::unregister_callback() ................
vmm_notify::unregister_vmm_sb_ds() ...............
vmm_notify::wait_for() ...........................
vmm_notify::wait_for_off() .......................
vmm_notify_callbacks::indicated() ................
`vmm_notify_observer .............................
vmm_notify_observer::new() .......................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-424
A-426
A-428
A-429
A-430
A-431
A-432
A-433
A-435
A-436
A-437
A-439
A-440
A-441
A-442
A-443
A-445
A-446
A-447
A-449
A-453
A-454
vmm_notify::append_callback()
Registers a callback extension.
SystemVerilog
function void append_callback(int
notification_id,
vmm_notify_callbacks cbs);
OpenVera
task append_callback(integer event_id,
rvm_notify_callbacks cbs);
Description
Appends the specified callback extension to the list of registered
callbacks, for the specified notification. All registered callback
extensions are invoked, when the specified notification is indicated.
Example
Example A-159
class my_callbacks extends vmm_notify_callbacks;
virtual function void indicated(vmm_data status);
...
endfunction
endclass
program vmm_notify_test;
initial begin
int EVENT_A = 1;
vmm_log log = new("Notify event", "vmm_notify_test");
vmm_notify notify = new(log);
my_callbacks my_callbacks_inst = new;
void'(notify.configure(EVENT_A));
...
`vmm_note(log, "Appending vmm notify call back");
notify.append_callback(EVENT_A,my_callbacks_inst);
...
end
endprogram
vmm_notify::configure()
Defines a new notification.
SystemVerilog
virtual function int
configure(int notification_id = -1,
sync_e sync = ONE_SHOT);
OpenVera
Not supported.
Description
Defines a new notification associated with the specified unique
identifier. If a negative identifier value is specified, a new, unique
identifier greater than 1,000,000 is returned. The thread
synchronization mode of a notification is defined when the
notification is configured, and not when it is triggered or waited upon,
using one of the vmm_notify::ONE_SHOT,
vmm_notify::BLAST, or vmm_notify::ON_OFF synchronization
types. This definition timing prevents a notification from being
misused by the triggering or waiting threads.
Table A-12
Table A-13
Enumerated Value
Broadcasting Operation
vmm_notify::ONE_SHOT
vmm_notify::BLAST
vmm_notify::ON_OFF
vmm_notify::copy()
Copies the current configuration of this notification service interface.
SystemVerilog
virtual function vmm_notify copy(vmm_notify to = null);
OpenVera
Not supported.
Description
Copies the current configuration of this notification service interface
to the specified instance. If no instance is specified, a new instance
is allocated using the same message service interface as the original
one. A reference to the copied target instance is returned.
Only the notification configuration information is copied and merged
with any pre-configured notification in the destination instance.
Copied notification configuration replaces any pre-existing
configuration for the same notification identifier. Status and
timestamp information is not copied.
vmm_notify::get_notification()
Gets the notification descriptor associated with the notification.
SystemVerilog
virtual function vmm_notification
get_notification(int notification_id);
OpenVera
Not supported.
Description
Gets the notification descriptor associated with the specified
notification, if any. If no notification descriptor is associated with the
specified notification, then it returns null.
vmm_notify::indicate()
Indicates the specified notification with the optional status descriptor.
SystemVerilog
virtual function void indicate(int notification_id,
vmm_data status = null);
OpenVera
Not supported.
Example
Example A-160
class consumer extends vmm_xactor;
...
virtual task main();
...
forever begin
...
this.in_chan.get(tr);
tr.notify.indicate(vmm_data::STARTED);
...
end
endtask: main
endclass: consumer
vmm_notify::is_configured()
Checks whether the specified notification is configured or not.
SystemVerilog
virtual function int is_configured(int notification_id);
OpenVera
Not supported.
Description
Checks whether the specified notification is currently configured or
not. If this method returns 0, then the notification is not configured.
Otherwise, it returns an integer value corresponding to the current
vmm_notify::ONE_SHOT, vmm_notify::BLAST, or
vmm_notify::ON_OFF configuration.
vmm_notify::is_on()
Check whether the specified vmm_notify::ON_OFF notification is
currently in the notify state or not.
SystemVerilog
virtual function bit is_on(int notification_id);
OpenVera
Not supported.
Description
If this method returns TRUE, then the notification is in the notify
state, and any call to the vmm_notify::wait_for() method will
not block. A warning is generated, if this method is called on any
other types of notifications.
vmm_notify::is_waited_for()
Checks whether a thread is currently waiting for the specified
notification or not.
SystemVerilog
virtual function bit is_waited_for(int notification_id);
OpenVera
Not supported.
Description
Checks whether a thread is currently waiting for the specified
notification or not, including waiting for an ON or OFF notification to
be reset. It is an error to specify an unconfigured notification. The
function returns TRUE, if there is a thread known to be waiting for the
specified notification.
Note that the knowledge about the number of threads waiting for a
particular notification is not definitive, and may be out of date. As
threads call the vmm_notify::wait_for() method, the fact that
they are waiting for the notification is recorded. Once the notification
is indicated and each thread returns from the method call, the fact
that they are no longer waiting is also recorded. However, if the
threads are externally terminated through the disable statement or
a timeout, the fact that they are no longer waiting cannot be
recorded. In this case, it is up to the terminated threads to report that
they are no longer waiting, by calling the
vmm_notify::terminated() method.
vmm_notify::new()
Creates a new instance of this class.
SystemVerilog
function new(vmm_log log);
OpenVera
Not supported.
Description
Creates a new instance of this class, using the specified message
service interface to generate an error and debug messages.
vmm_notify::register_vmm_sb_ds()
For more information on this class, refer to the VMM Scoreboard
User Guide.
vmm_notify::reset()
Resets the specified notification.
SystemVerilog
virtual function void reset(int notification_id = -1,
reset_e rst_typ = SOFT);
OpenVera
Not supported.
Description
A vmm_notify::SOFT reset clears the specified ON_OFF
notification, and restarts the vmm_notification::indicate()
and vmm_notification::reset() methods on any attached
notification descriptor. A vmm_notify::HARD reset clears all
status information and attached notification descriptor on the
specified event, and further assumes that no threads are waiting for
that notification. If no notification is specified, all notifications are
reset.
Example
Example A-161
The following example shows definitions of three user-defined
notifications:
class bus_mon
static int
static int
static int
extends
EVENT_A
EVENT_B
EVENT_C
vmm_xactor;
= 0;
= 1;
= 2;
function new(...);
super.new(...);
super.notify.configure(this.EVENT_A);
super.notify.configure(this.EVENT_B,
vmm_notify::ON_OFF);
super.notify.configure(this.EVENT_C,
vmm_notify::BLAST);
endfunction
...
virtual task main();
...
forever begin
...
super.notify.indicate(this.EVENT_A);
...
super.notify.reset(this.EVENT_A);
...
end
endtask: main
endclass: bus_mon
vmm_notify::set_notification()
Defines the notification, using the notification descriptor.
SystemVerilog
virtual function void
set_notification(int notification_id,
vmm_notification ntfy = null);
OpenVera
Not supported.
Description
Defines the specified notification, using the specified notification
descriptor. If the descriptor is null, then the notification is undefined
and can only be indicated using the vmm_notify::indicate()
method. If a notification is already defined, the new definition
replaces the previous definition.
vmm_notify::status()
Returns the status descriptor that is associated with the notification.
SystemVerilog
virtual function vmm_data status(int notification_id);
OpenVera
Not supported.
Description
Returns the status descriptor that is associated with the specified
notification, when it was last indicated. It is an error to specify an
unconfigured notification.
vmm_notify::terminated()
Indicates that a thread waiting for the specified notification is
disabled.
SystemVerilog
virtual function void terminated(int notification_id);
OpenVera
Not supported.
Description
Indicates to the notification service interface that a thread waiting for
the specified notification is disabled, and is no longer waiting.
vmm_notify::timestamp()
Returns the simulation time when the notification was last indicated.
SystemVerilog
virtual function time timestamp(int notification_id);
OpenVera
Not supported.
Description
Returns the simulation time when the specified notification was last
indicated. It is an error to specify an unconfigured notification.
vmm_notify::unregister_callback()
Unregisters a callback extension.
SystemVerilog
function void unregister_callback(
int
notification_id,
vmm_notify_callbacks sb);
OpenVera
task unregister_callback(integer
rvm_notify_callbacks sb);
event_id,
Description
Unregisters the specified callback extension from the notification
service interface, for the specified notification. An error is generated,
if the specified callback extension was not previously registered with
the specified notification.
Example
Example A-162
class my_callbacks extends vmm_notify_callbacks;
virtual function void indicated(vmm_data status);
...
endfunction
endclass
program vmm_notify_test;
initial begin
int EVENT_A = 1;
vmm_log log = new("Notify event", "vmm_notify_test");
vmm_notify notify = new(log);
vmm_notify::unregister_vmm_sb_ds()
For more information on this class, refer to the VMM Scoreboard
User Guide.
vmm_notify::wait_for()
Suspends the execution thread, until the specified notification is
notified.
SystemVerilog
virtual task wait_for(int notification_id);
OpenVera
Not supported.
Description
It is an error to specify an unconfigured notification. Use the
vmm_notify::status() function to retrieve any status descriptor
attached to the indicated notification.
Example
Example A-163
class consumer extends vmm_xactor;
...
virtual task main();
...
while (1) begin
...
this.in_chan.peek(tr);
tr.notify.wait_for(vmm_data::ENDED);
this.in_chan.get(tr);
...
end
endtask: main
endclass: consumer
vmm_notify::wait_for_off()
Suspends the execution thread, until the specified
vmm_notify::ON_OFF notification is reset.
SystemVerilog
virtual task wait_for_off(int notification_id);
OpenVera
Not supported.
Description
It is an error to specify an unconfigured or a non-ON or OFF
notification. The status returned by subsequent calls to the
vmm_notify::status() function is undefined.
vmm_notify_callbacks
Facade class for callback methods provided by the notification
service. User-defined extensions of this class must be registered
with specific instances of the notification service interface and for
specific notifications, using the
vmm_notify::append_callback() method.
This class is a virtual class and cannot be instantiated on its own.
Summary
vmm_notify_callbacks::indicated()
Reports that a notification is indicated.
SystemVerilog
virtual function void indicated(vmm_data status);
OpenVera
virtual task indicated(rvm_data status);
Description
This method is invoked whenever the notification corresponding to
the callback extension is indicated. The status is a reference to the
status descriptor, which is specified to the
vmm_notify::indicate() method that caused the notification to
be indicated.
The purpose of this callback is similar to the
vmm_notify::wait_for() method. However, unlike the
vmm_notify:;wait_for() method, it reliably reports multiple
indications of the same notification during the same timestep.
Example
class my_callbacks extends vmm_notify_callbacks;
virtual function void indicated(vmm_data status);
...
endfunction
endclass
vmm_notify_observer#(T,D)
Simplifies subscription to a notification callback method.
SystemVerilog
class vmm_notify_observer #(type T, type D = vmm_data)
extends vmm_notify_callbacks
Description
The vmm_notify_observer class is a parameterized extension of
vmm_notify_callbacks. Any subscriber (scoreboard, coverage
model, and so on) can get the transaction status whenever a
notification event is indicated. The `vmm_notify_observer
macro is provided to specify the observer and its method name to be
called.
Example
class scoreboard;
virtual function void observe_trans(ahb_trans tr);
...
endfunction
endclass
`vmm_notify_observer(scoreboard, observe_trans)
Summary
`vmm_notify_observer
Defines a parameterized class in the style of the
vmm_notify_observer class.
SystemVerilog
`define vmm_notify_observer(classname, methodname)
Description
Defines a parameterized class in the style of the
vmm_notify_observer class, with the specified name, and
calling the specified T::methodname(D.status) method. Useful
for defining a subscription class for an observer with a different
observation method.
Example
class scoreboard;
virtual function void observe_trans(ahb_trans tr);
...
endfunction
endclass
`vmm_notify_observer(scoreboard, observe_trans)
vmm_notify_observer::new()
Appends a callback method to invoke the
T::observe(D.status) method in the specified instance.
SystemVerilog
function vmm_notify_observer::new(T observer,
vmm_notify ntfy, int notification_id)
Description
Appends a callback method to invoke the T::observe(D) method
in the specified instance, whenever the specified indication is notified
on the specified Notification Service Interface.
Example
vmm_notify_observer#(scoreboard, ahb_trans)
observe_start = new(sb, mon.notify, mon.TRANS_START);
vmm_object
The vmm_object class is a virtual class that is used as the common
base class for all VMM related classes. This helps to provide parent
or child relationships for class instances. Additionally, it provides
local, relative, and absolute hierarchical naming.
Summary
vmm_object::create_namespace() ...................
vmm_object::display() ............................
vmm_object::find_child_by_name() .................
vmm_object::find_object_by_name() ................
vmm_object::get_hier_inst_name() .................
vmm_object::get_log() ............................
vmm_object::get_namespaces() .....................
vmm_object::get_num_children() ...................
vmm_object::get_num_roots() ......................
vmm_object::get_nth_child() ......................
vmm_object::get_nth_root() .......................
vmm_object::get_object_hiername() ................
vmm_object::get_object_name() ....................
vmm_object::get_parent() .........................
vmm_object::get_parent_object() ..................
vmm_object::get_root_object() ....................
vmm_object::get_type() ...........................
vmm_object::get_typename() .......................
vmm_object::implicit_phasing() ...................
vmm_object::is_implicitly_phased() ...............
vmm_object::is_parent_of() .......................
vmm_object::kill_object() ........................
vmm_object::new() ................................
vmm_object::print_hierarchy() ....................
vmm_object::psdisplay() ..........................
vmm_object::set_object_name() ....................
vmm_object::set_parent() .........................
vmm_object::set_parent_object() ..................
vmm_object::type_e ...............................
`foreach_vmm_object() ............................
`foreach_vmm_object_in_namespace() ...............
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-456
A-457
A-458
A-459
A-460
A-461
A-462
A-463
A-464
A-465
A-466
A-467
A-468
A-469
A-470
A-471
A-472
A-473
A-474
A-475
A-476
A-477
A-478
A-479
A-481
A-482
A-483
A-485
A-486
A-488
A-489
vmm_object::create_namespace()
Defines a namespace with specified default object inclusion policy.
SystemVerilog
function bit create_namespace(string name, namespace_typ_e
typ = OUT_BY_DEFAULT);
Description
Defines a namespace with the specified default object inclusion
policy. A namespace must be previously created using this method,
before it can be used or referenced. Returns true, if the namespace
was successfully created. The empty name space ("") is reserved
and cannot be defined.
Example
class A extends vmm_object;
function new (string name, vmm_object parent=null);
super.new (parent, name);
vmm_object::create_namesapce("NS1",
vmm_object::IN_BY_DEFAULT);
endfunction
endclass
vmm_object::display()
Displays a description of the object to the standard output.
SystemVerilog
virtual function void display(string prefix = "");
OpenVera
Not supported.
Description
Displays the image returned by vmm_object::type_e to the
standard output. Each line of the output will be prefixed with the
specified argument prefix.
If this method conflicts with a previously declared method in a class,
which is now based on the vmm_object class, it can be removed
by defining the VMM_OBJECT_NO_DISPLAY symbol at compiletime.
Example
Example A-164
class trans_data extends vmm_data;
byte data;
...
endclass
initial begin
trans_data trans;
trans.display("Test Trans: ");
end
vmm_object::find_child_by_name()
Finds the named object relative to this object.
SystemVerilog
function vmm_object vmm_object::find_child_by_name(
string name, string space = "");
Description
Finds the named object, interpreting the name as a hierarchical
name relative to this object in the specified namespace. If the name
is a match pattern or regular expression, the first object matching the
name is returned. Returns null, if no child was found under the
specified name.
Example
class D extends vmm_object;
...
endclass
class E extends vmm_object;
D d1;
function new(string name, vmm_object parent=null);
...
d1 = new ("d1",this);
endfunction
endclass
...
initial begin
vmm_object obj;
E e1= new ("e1");
...
obj = e1.find_child_by_name ("d1");
...
end
vmm_object::find_object_by_name()
Finds the named object in the specified namespace.
SystemVerilog
static function vmm_object
vmm_object::find_object_by_name(string name,
string space = "");
Description
Finds the named object, interpreting the name as an absolute name
in the specified namespace. If the name is a match pattern or regular
expression, the first object matching the name is returned.
Returns null, if no object was found under the specified name.
Example
class D extends vmm_object;
...
endclass
class E extends vmm_object;
D d1;
function new(string name, vmm_object parent=null);
...
d1 = new ("d1");
endfunction
endclass
...
initial begin
vmm_object obj;
...
obj = E :: find_object_by_name ("d1");
...
end
vmm_object::get_hier_inst_name()
Returns the hierarchical instance name of the object.
SystemVerilog
function string get_hier_inst_name();
OpenVera
Not supported.
Description
Returns the hierarchical instance name of the object. The instance
name is composed of the dot-separated instance names of the
message service interface of all the parents of the object.
The hierarchical name is returned, whether or not the message
services interfaces are using hierarchical or flat names.
Example
Example A-165
class tb_env extends vmm_env;
tr_scenario_gen gen1;
...
endclass
initial begin
string str;
tb_env env;
...
str = env.s1.gen1.get_hier_inst_name();
`vmm_note(log, str);
end
vmm_object::get_log()
Returns the vmm_log instance of this object.
SystemVerilog
virtual function vmm_log vmm_object::get_log();
Description
Returns the vmm_log instance of this object, or the nearest
enclosing object. If no vmm_log instance is available in the object
genealogy, a default global vmm_log instance is returned.
Example
class ABC extends vmm_object;
vmm_log log = new("ABC", "class");
...
function vmm_log get_log();
return this.log;
endfunction
...
endclass
vmm_log test_log;
ABC abc_inst = new("test_abc");
initial begin
test_log = abc_inst.get_log();
...
end
vmm_object::get_namespaces()
Returns all namespaces created by the create_namespace()
method.
SystemVerilog
function void get_namespaces(output string names[]);
Description
This method returns all namespaces created by the
create_namespace() method that belong to a dynamic array of
strings as specified by names[].
Example
initial begin
string ns_array[];
...
vmm_object::get_namespaces(ns_array);
...
end
vmm_object::get_num_children()
Gets the total number of children for this object.
SystemVerilog
function int vmm_object::get_num_children();
Description
Gets the total number of children object for this object.
Example
class C extends vmm_object;
...
endclass
class D extends vmm_object;
...
endclass
class E extends vmm_object;
C c1;
D d1;
D d2;
function new(string name, vmm_object parent=null);
...
c1 = new ("c1",this);
d1 = new ("d1");
d2 = new ("d2",this);
endfunction
endclass
int num_children;
initial begin
E e1 = new ("e1");
...
num_children = e1.get_num_children;
...
end
vmm_object::get_num_roots()
Gets the total number of root objects in the specified namespace.
SystemVerilog
static function int vmm_object::get_num_roots(
string space = "");
Description
Gets the total number of root objects in the specified namespace.
Example
class D extends vmm_object;
...
endclass
class E extends vmm_object;
D d1;
D d2;
function new(string name, vmm_object parent=null);
...
d1 = new ("d1");
d2 = new ("d2");
endfunction
endclass
...
int num_roots;
initial begin
E e1 = new ("e1");
...
num_roots = E :: get_num_roots(); //Returns 2
...
end
vmm_object::get_nth_child()
Returns the nth child of this object.
SystemVerilog
function vmm_object vmm_object::get_nth_child(int n);
Description
Returns the nth child of this object. Returns null, if there is no child.
Example
class C extends vmm_object;
...
endclass
class D extends vmm_object;
...
endclass
class E extends vmm_object;
C c1;
D d1;
D d2;
function new(string name, vmm_object parent=null);
c1 = new ("c1",this);
d1 = new ("d1");
d2 = new ("d2",this);
endfunction
endclass
initial begin
vmm_object obj;
string name;
E e1 = new ("e1");
obj = e1.get_nth_child(0);
name = obj.get_object_name(); //Returns c1
...
end
vmm_object::get_nth_root()
Returns the nth root object in the specified namespace.
SystemVerilog
static function vmm_object vmm_object::get_nth_root(int n,
string space = "");
Description
Returns the nth root object in the specified namespace. Returns null,
if there is no such root.
Example
class D extends vmm_object;
...
endclass
class E extends vmm_object;
D d1;
D d2;
function new(string name, vmm_object parent=null);
...
d1 = new ("d1");
d2 = new ("d2");
endfunction
endclass
...
int num_roots;
initial begin
vmm_object root;
E e1 = new ("e1");
...
root= E :: get_nth_root(0); //Returns d1
...
end
vmm_object::get_object_hiername()
Gets the complete hierarchical name of this object.
SystemVerilog
function string vmm_object::get_object_hiername(
vmm_object root = null, string space = "");
Description
Gets the complete hierarchical name of this object in the specified
namespace, relative to the specified root object. If no root object is
specified, returns the complete hierarchical name of the object. The
instance name is composed of the period-separated instance names
of the message service interface of all the parents of the object.
Example
class D extends vmm_object;
...
endclass
class E extends vmm_object;
D d1;
function new(string name, vmm_object parent=null);
...
d1 = new ("d1",this);
endfunction
endclass
...
initial begin
string hier_name;
E e1 = new ("e1");
...
hier_name = e1.d1.get_object_hiername();
...
end
vmm_object::get_object_name()
Gets the local name of this object
SystemVerilog
function string vmm_object::get_object_name(
string space = "");
Description
Gets the local name of this object, in the specified namespace. If no
namespace is specified, then returns the actual name of the object.
Example
class C extends vmm_object;
function new(string name, vmm_object parent=null);
super.new (parent,name);
endfunction
endclass
...
initial begin
string obj_name;
C c1 = new ("c1");
...
obj_name = c1.get_object_name(); //Returns c1
...
end
vmm_object::get_parent()
Returns a parent object.
SystemVerilog
function vmm_object get_parent(
vmm_object::type_e typ = VMM_OBJECT);
OpenVera
Not supported.
Description
Returns the parent object of the specified type, if any. Returns NULL,
if no such parent is found. Specifying VMM_OBJECT returns the
immediate parent of any type.
Example
Example A-166
class tb_env extends vmm_env;
tr_scenario_gen gen1;
function new(string inst, vmm_consensus end_vote);
gen1.set_parent_object(this);
endfunction
endclass
initial begin
tb_env env;
if (env.gen1.randomized_obj.get_parent() != env.gen1)
begin
`vmm_error(log, "Factory instance in atomic_gen returns
wrong parent");
end
end
vmm_object::get_parent_object()
Returns the parent of this object.
SystemVerilog
function vmm_object vmm_object::get_parent_object(string
space = "");
Description
Returns the parent object of this object for specified namespace, if
any. Returns null, if no parent is found. A root object contains no
parent.
Example
class C extends vmm_object;
...
endclass
class D extends vmm_object;
C c1;
function new(string name, vmm_object parent=null);
c1 = new ("c1",this);
endfunction
endclass
initial begin
vmm_object parent;
D d1 = new ("d1");
parent = d1.c1.get_parent_object;
end
vmm_object::get_root_object()
Gets the root parent of this object.
SystemVerilog
function vmm_object vmm_object::get_root_object(
string space = "");
Description
Gets the root parent of this object, for the specified namespace.
Example
class C extends vmm_object;
...
endclass
class D extends vmm_object;
C c1;
function new(string name, vmm_object parent=null);
c1 = new ("c1",this);
endfunction
endclass
class E extends vmm_object;
D d1;
function new(string name, vmm_object parent=null);
...
d1 = new ("d1",this);
endfunction
endclass
...
initial begin
vmm_object root;
E e1 = new ("e1");
root = e1.d1.c1.get_root_object;
...
end
vmm_object::get_type()
Returns the type of the object.
SystemVerilog
function vmm_object::type_e get_type();
OpenVera
Not supported.
Description
Returns the type of this vmm_object extension.
Returns the VMM_OBJECT, if it is not one of the known VMM class
extensions. VMM_UNKNOWN is purely an internal value, and is never
returned.
Example
Example A-167
class tb_env extends vmm_env;
tr_scenario_gen gen1;
gen1.set_parent_object(this);
endclass
initial begin
tb_env env;
if (env.get_type() != vmm_object::VMM_ENV)
begin
`vmm_error(log, "Wrong type returned from vmm_env
instance");
end
end
vmm_object::get_typename()
Returns the name of the actual type of this object.
SystemVerilog
pure virtual function string vmm_object::get_typename();
Description
This function is implemented in the `vmm_typename(string
name) macro. It returns the type of this vmm_object extension.
However, it will not return an appropriate vmm_object if
`vmm_typename(name) is not used in the corresponding class.
Example
class ahb_gen extends vmm_group;
`vmm_typename (ahb_gen)
function new (string name);
super.new (get_typename(), name);
endfunction
endclass
vmm_object::implicit_phasing()
If the is_on argument is false, inhibits the implicit phasing for this
object and all of its children objects.
SystemVerilog
virtual function void vmm_object::implicit_phasing(
bit is_on);
Description
If the is_on argument is false, inhibits the implicit phasing for this
object and all of its children objects. Used to prevent a large object
hierarchy that does not require phasing from being needlessly
walked by the implicit phaser (for example, a RAL model). By default,
implicit phasing is enabled.
Example
class subsys_env extends vmm_subenv;
...
endclass
class sys_env extends vmm_subenv;
subsys_env subenv1;
...
function void build();
...
subenv1 = new ("subenv1", "subenv1");
subenv1.set_parent_object(this);
subenv1.implicit_phasing(0);
...
endfunction
...
endclass
vmm_object::is_implicitly_phased()
Returns true, if the implicit phasing is enabled for this object.
SystemVerilog
virtual function bit vmm_object::is_implicitly_phased();
Description
Returns true, if the implicit phasing is enabled for this object.
Example
class subsys_env extends vmm_subenv;
...
endclass
class sys_env extends vmm_env;
subsys_env subenv1;
...
function void build();
...
subenv1 = new ("subenv1", "subenv1");
subenv1.set_parent_object(this);
subenv1.implicit_phasing(0);
if(subenv1.is_implicitly_phased)
`vmm_error(log, "Implict Phasing for subenv1 not
disabled");
...
endfunction
...
endclass
vmm_object::is_parent_of()
Returns true, if the specified object is a parent of this object.
SystemVerilog
function bit vmm_object::is_parent_of(vmm_object obj,
string space ="");
Description
Returns true, if the specified object is a parent of this object under
specified argument space namespace.
Example
class sub extends vmm_subenv;
...
endclass
class tb_env extends vmm_env;
sub s1 ;
...
virtual function void build();
super.build();
s1 = new ("s1");
s1.set_parent_object(this);
if (!this.is_parent_of(s1))
`vmm_error(log, "Unable to set parent for s1");
...
endfunction
endclass
vmm_object::kill_object()
Clears cross-references to this object and its children.
SystemVerilog
Virtual function void vmm_object::kill_object();
Description
Clears cross-references to this object and all its children, so that the
entire object hierarchy rooted at the object can be garbage collected.
Killing the root object enables the garbage collection of the entire
object hierarchy underneath it, unless there are other references to
an object within that hierarchy. Any external reference to any object
in a hierarchy, prevents the garbage collection of that object.
Example
class C extends vmm_object;
function new(string name, vmm_object parent=null);
super.new (parent,name);
endfunction
endclass
class D extends vmm_object;
C c1;
function new(string name, vmm_object parent=null);
super.new (parent,name);
c1 = new ("c1",this);
endfunction
endclass
initial begin
D d1 = new ("d1");
d1.kill_object;
end
vmm_object::new()
Constructs a new instance of this object.
SystemVerilog
function void vmm_object::new(vmm_object parent = null,
string name = "[Anonymous]", bit disable_hier_insert = 0);
Description
Constructs a new instance of this object, optionally specifying
another object as its parent. The specified name cannot contain any
colons (:). Specified argument disable_hier_insert indicates
whether hierarchical insertion needs to be enabled or not.
To add an object to the parent-child hierarchical structure, set
disable_hier_insert argument to 1.
Example
class A extends vmm_object;
function new (string name, vmm_object parent=null);
super.new (parent, name);
endfunction
endclass
vmm_object::print_hierarchy()
Prints the object hierarchy.
SystemVerilog
function void print_hierarchy( vmm_object root = null, bit
verbose=0);
Description
Prints the object hierarchy that is rooted at the specified object.
Prints the hierarchy for all roots, if no root is specified.
This method shows the desired object hierarchy, when you ensure
that the parent-child relationship is created across different
components, either at instantiation time or through
vmm_object::set_parent_object. verbose could be passed
as 1 to enabled the verbose option while displaying.
Example
class D extends vmm_object;
...
endclass
class E extends vmm_object;
D d1;
function new(string name, vmm_object parent=null);
...
d1 = new ("d1",this);
endfunction
endclass
initial begin
E e1 = new ("e1");
...
E :: print_hierarchy();
...
end
vmm_object::psdisplay()
Creates a description of the object.
SystemVerilog
virtual function string vmm_object::psdisplay(
string prefix = "");
Description
Creates a human-readable description of the content of this object.
Each line of the image is prefixed with the specified prefix.
Example
class D extends vmm_object;
...
function string psdisplay(string prefix = "");
...
endfuntion
endclass
...
vmm_log log = new ("Test", "main");
initial begin
D d1 = new ("d1");
...
`vmm_note (log, d1.psdisplay);
...
end
vmm_object::set_object_name()
Sets or replaces the name of this object in the specified namespace.
SystemVerilog
function void vmm_object::set_object_name(string name,
string space = "");
Description
This method is used to set or replace the name of this object in the
specified namespace. If no namespace is specified, the name of the
object is replaced. If a name is not specified for a namespace, it
defaults to the object name. Names in a named namespace may
contain colons (:) to create additional levels of hierarchy, or may be
empty to skip a level of hierarchy. A name starting with a caret (^)
indicates that it is a root in the specified namespace. However, this
does not apply to the object name where parentless objects create
roots in the default namespace.
Example
class E extends vmm_object;
...
endclass
initial begin
vmm_object obj;
E e1 = new ("e1");
vmm_object::create_namespace("NS1",
vmm_object::IN_BY_DEFAULT);
...
obj = e1;
obj.set_object_name ("new_e1","NS1");
...
end
vmm_object::set_parent()
Specifies a parent object.
SystemVerilog
function void set_parent(vmm_object parent);
OpenVera
Not supported.
Description
Specifies a new parent object to this object. Specifying a NULL
parent breaks any current parent or child relationship. An object may
contain only one parent, but the identity of a parent can be changed
dynamically.
If this object and the parent object are known to contain their own
instance of the message service interface, then the vmm_log
instance in the parent is specified as being above the vmm_log
instance in the child by calling parent.is_above(this). The
instance names of the message service interfaces can then be
subsequently made hierarchical by using the
vmm_log::use_hier_inst_name() method.
The presence of the vmm_object base class being optional, it is
not possible to call this method in code designed to be reusable with
and without this base class. To that effect, the
VMM_OBJECT_SET_PARENT(_parent, _child) macro should
be used instead. This macro calls this method, if the vmm_object
base class is present, but do nothing if not.
Examples
Example A-168
this.notify = new(this.log);
this.notify.set_parent_object(this);
Example A-169
this.notify = new(this.log);
VMM_OBJECT_SET_PARENT(this.notify, this)
vmm_object::set_parent_object()
Sets or replaces the parent of this object.
SystemVerilog
function void vmm_object::set_parent_object(
vmm_object parent);
Description
Specifies a new parent object to this object. Specifying a null parent,
breaks any current parent or child relationship. An object may
contain only one parent, but the identity of a parent can be changed
dynamically.
Example
class C extends vmm_object;
function new(string name, vmm_object parent=null);
super.new (parent,name);
endfunction
endclass
class D extends vmm_object;
C c1;
function new(string name, vmm_object parent=null);
super.new (parent,name);
c1 = new ("c1",this);
endfunction
endclass
initial begin
D d1 = new ("d1");
D d2 = new ("d2");
d1.c1.set_parent_object (d2);
end
vmm_object::type_e
Returns the type of this object.
SystemVerilog
typedef enum {
VMM_UNKNOWN, VMM_OBJECT, VMM_DATA, VMM_SCENARIO,
VMM_MS_SCENARIO, VMM_CHANNEL, VMM_NOTIFY, VMM_XACTOR,
VMM_SUBENV, VMM_ENV, VMM_CONSENSUS, VMM_TEST
} type_e
OpenVera
Not supported.
Description
Value returned by the vmm_object::type_e method to identify
the type of this vmm_object extension. Once the type is known, a
reference to a vmm_object can be cast into the corresponding
class type.
The VMM_UNKNOWN type is an internal value, and never returned by
the vmm_object::type_e method.
The VMM_OBJECT is returned when the type of the object cannot
be determined, or to specify any object type to the
vmm_object::type_e method.
Example
Example A-170
program test;
class tb_env extends vmm_env;
type_e env_c_type;
function new();
super.new("tb_env");
end_vote.set_parent_object(this);
env_c_type = get_type();
endfunction
endclass
initial
begin
string disp_str;
...
$sformat(disp_str,"Type of env class is :
%s",env.env_c_type.name());
`vmm_note(log,disp_str);
end
endprogram
`foreach_vmm_object()
Shorthand macro to iterate over all objects.
SystemVerilog
`foreach_vmm_object(classtype, string name, vmm_root root);
Description
This is a shorthand macro to iterate over all objects of a specified
type and name, under a specified root.
Example
class E extends vmm_object;
...
endclass
...
initial begin
E e11 = new ("e11");
vmm_object_iter my_iter;
...
`foreach_vmm_object(vmm_object, "@%*", e11)
begin
...
end
end
`foreach_vmm_object_in_namespace()
Shorthand macro to iterate over all objects of a specified type and
name, within a specified namespace.
SystemVerilog
`foreach_vmm_object_in_namespace(classtype, string name,
string space, vmm_root root);
Description
Shorthand macro to iterate over all objects of a specified type with
the specified name, in the specified namespace under a specified
root.
Example
class C extends vmm_object;
function new(string name, vmm_object parent=null);
super.new(parent, name);
...
vmm_object::create_namespace("NS1",
vmm_object::IN_BY_DEFAULT);
...
endfunction
endclass
C c1 = new("c1");
int I;
initial begin
`foreach_vmm_object_in_namespace(vmm_object, "@%*",
"NS1", c1)
begin
end
end
vmm_object_iter
This is the vmm_object hierarchy traversal iterator class.
The vmm_object_iter class traverses the hierarchy rooted at the
specified object, looking for objects whose relative hierarchical name
matches the specified name. Beginning at a specific object, you can
traverse through the hierarchy through the different methods like the
first() and next() methods.
Example
class E extends vmm_object;
...
endclass
...
initial begin
E e11 = new ("e1");
vmm_object obj;
vmm_object_iter iter = new (e11, "/a1/");
...
obj = iter.first();
while (obj != null)
begin
...
obj = iter.next;
end
...
end
Summary
vmm_object_iter::first()
Resets the state of the iterator to the first object.
SystemVerilog
function vmm_object vmm_object_iter::first();
Description
Resets the state of the iterator to the first object in the vmm_object
hierarchy. Returns null, if the specified hierarchy contains no child
objects.
Example
class E extends vmm_object;
...
endclass
...
initial begin
E e11 = new ("e1");
vmm_object obj;
vmm_object_iter iter = new (e11, "/a1/");
...
obj = iter.first();
...
end
vmm_object_iter::new()
Instantiates an vmm_object iterator that traverses the hierarchy
rooted at the specified root object.
SystemVerilog
function new( vmm_object root = null, string
string space = "");
name = "",
Description
Traverses the hierarchy rooted at the specified root object, looking
for objects whose relative hierarchical name in the specified
namespace matches the specified name. The object name is relative
to the specified root object. If no object is specified, traverses all
hierarchies and the hierarchical name is absolute. The specified root
(if any) is not included in the iteration.
Example
/ Match pattern - /a1/, with root object e11 vmm_object_iter
iter = new (e11, "/a1/" );
vmm_object_iter::next()
SystemVerilog
function vmm_object vmm_object_iter::next();
Description
Returns the next object in the vmm_object hierarchy. Returns null,
if there are no more child objects. Objects are traversed depth first.
Example
class E extends vmm_object;
...
endclass
...
initial begin
E e11 = new ("e1");
vmm_object obj;
vmm_object_iter iter = new(e11, "/a1/");
...
obj = iter.first();
while (obj != null)
begin
...
obj = iter.next;
end
...
end
vmm_opts
Utility class that provides the facility to pass values from the
command line during runtime, or from the source code, across
hierarchies.
Summary
vmm_opts::get_bit() ..............................
vmm_opts::get_help() .............................
vmm_opts::get_int() ..............................
vmm_opts::get_obj() ..............................
vmm_opts::get_object_bit() .......................
vmm_opts::get_object_int() .......................
vmm_opts::get_object_obj() .......................
vmm_opts::get_object_range() .....................
vmm_opts::get_object_string() ....................
vmm_opts::get_range() ............................
vmm_opts::get_string() ...........................
vmm_opts::set_bit() ..............................
vmm_opts::set_int() ..............................
vmm_opts::set_object() ...........................
vmm_opts::set_range() ............................
vmm_opts::set_string() ...........................
vmm_unit_config* ................................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
A-495
A-496
A-497
A-498
A-499
A-500
A-502
A-504
A-506
A-508
A-510
A-511
A-513
A-515
A-517
A-519
A-521
vmm_opts::get_bit()
Returns true, if specified option is set using the command-line.
Otherwise, it returns false.
SystemVerilog
static function bit vmm_opts::get_bit(string name,
string doc = "", int verbosity = 0, string fname = "",
int lineno = 0);
Description
Returns true, if the argument name is specified on the commandline. Otherwise, it returns false. The option is specified using the
command-line +vmm_name or +vmm_opts+name. You can specify a
description of the option using doc, and the verbosity level of the
option using verbosity. A verbosity value must be within the range
0 to 10. The fname and lineno arguments are used to track the
file name and the line number, where the option is specified. These
optional arguments are used for providing information to the user
through vmm_opts::get_help().
Example
bit b;
b = vmm_opts::get_bit(
"FOO", "Value set for 'b' from command line");
Command line:
simv +vmm_FOO or simv +vmm_opts+FOO
vmm_opts::get_help()
Displays the list of available or specified VMM runtime options.
SystemVerilog
static function void vmm_opts::get_help(
vmm_object root = null,
int verbosity = 0);
Description
Displays the known options used by the verification environment with
the specified vmm_object hierarchy, with verbosity lower than or
equal to the absolute value of the specified verbosity. If no
vmm_unit root is specified, the options used by all object
hierarchies are displayed. A verbosity value must be within the range
-10 to 10. If the specified verbosity value is negative, the hierarchical
name of each vmm_unit instance that uses an option is also
displayed.
Example
vmm_opts::get_help(this_object);
vmm_opts::get_int()
Returns an integer value, if specified using the command-line.
Otherwise, it returns the default value.
SystemVerilog
static function int vmm_opts::get_int(string name,
int dflt = 0, string doc = "", int verbosity = 0,
string fname = "", int lineno = 0);
Description
Returns an integer value, if the argument name and its integer value
are specified on the command line. Otherwise, returns the default
value specified in the dflt argument. The option is specified using
the command line +vmm_name=value or
+vmm_opts+name=value. You can specify a description of the
option using doc, and the verbosity level of the option using
verbosity. A verbosity value must be within the range 0 to 10. The
fname and lineno arguments are used to track the file name and
the line number, where the option is specified. These optional
arguments are used to provide information through the
vmm_opts::get_help() method.
Example
int i;
i = vmm_opts::get_int ("FOO", 0,
"Value set for 'i' from command line");
Command line:
simv +vmm_FOO=100 or simv +vmm_opts+FOO=100
vmm_opts::get_obj()
Returns the vmm_object instance, if specified through the
vmm_opts::set_object() method.
SystemVerilog
static function vmm_object vmm_opts::get_obj(
output bit is_set,
input string name,
input vmm_object dflt = null,
input string fname = "",
input int lineno = 0);
Description
If an explicit value is specified, returns the globally named object
type option and sets the is_set argument to true. If no object
matches the expression specified by name, returns the default
object specified by argument dflt.Object type options can only be
set using the vmm_opts::set_object() method. The fname
and lineno arguments can be used to track the file name and the
line number where the get_obj is invoked from.
Example
class A extends vmm_object;
endclass
initial begin
A a = new ("a");
vmm_object obj;
bit is_set;
obj = vmm_opts :: get_obj(is_set, "OBJ", a);
end
vmm_opts::get_object_bit()
Returns true, if the named option is set for the hierarchy. Otherwise,
it returns false.
SystemVerilog
static function bit vmm_opts::get_object_bit(output bit
is_set, input vmm_object obj, string name, string doc =
"", int verbosity = 0, string fname = "", int lineno = 0);
Description
If an explicit value is specified, returns the named boolean type
option for the specified object instance, and sets the is_set
argument to true. You can specify a description of the option using
doc, and the verbosity level of the option using verbosity. The
verbosity value must be within the range 0 to 10, with 10 being the
highest. The fname and lineno arguments are used to track the
file name and the line number, where the option is specified. These
optional arguments are used to provide information to the user
through the vmm_opts::get_help() method.
Example
class B extends vmm_object;
bit foo, is_set;
function new(string name, vmm_object parent=null);
foo = vmm_opts::get_object_bit(is_set, this, "FOO",
"SET foo value", 0);
endfunction
endclass
Command line:
simv +vmm_FOO@A:%:b
vmm_opts::get_object_int()
Returns an integer value, if the named integer option is set for the
hierarchy. Otherwise, it returns the default value.
SystemVerilog
static function int vmm_opts::get_object_int(
output bit is_set,
input vmm_object obj,
input string name,
input int dflt = 0,
input string doc = "",
input int verbosity = 0,
input string fname = "",
input int lineno = 0);
Description
If an explicit value is specified, returns the named integer type option
for the specified object instance and sets the is_set argument to
true. You can specify a description of the option using doc, and the
verbosity level of the option using verbosity. The verbosity value
must be within the range 0 to 10. The fname and lineno arguments
are used to track the file name and the line number, where the option
is specified. These optional arguments are used to provide
information through the vmm_opts::get_help() method.
Example
class B extends vmm_object;
int foo;
function new(string name, vmm_object parent=null);
bit is_set;
super.new(parent,name);
foo = vmm_opts::get_object_int(is_set, this, "FOO",
Command line:
simv +vmm_FOO=25@%:X:b
vmm_opts::get_object_obj()
Returns the vmm_object instance for the specified hierarchical
name.
SystemVerilog
static function vmm_object get_object_obj(
output bit is_set,
input vmm_object obj,
input string name,
input vmm_object dflt = null,
input string
doc = "",
input int
verbosity = 0,
input string
fname = "",
input int
lineno = 0);
Description
Iif an explicit value is specified, returns the named object type option
for the specified object instance and set the is_set argument to
true. If no object matches the expression specified by name, returns
the default object specified by argument dflt. You can specify a
description of the option using doc, and the verbosity level of the
option using verbosity. Object type options can only be set using
the vmm_opts::set_object() method. The fname and lineno
arguments can be used to track the file name and the line number
where the get_object_obj is invoked from.
Example
class A extends vmm_object;
int foo = 11;
function new( vmm_object parent=null, string name);
super.new(parent, name);
endfunction
endclass
class B extends vmm_object;
A a1, a2;
function new(vmm_object parent=null, string name);
bit is_set;
super.new(parent, name);
a1 = new(null, "a1");
a2 = new(null, "a2");
a2.foo = 22;
$cast(a1, vmm_opts::get_object_obj(is_set, this,
"OBJ_F1",a2,"SET OBJ", 0));
endfunction
endclass
vmm_opts::get_object_range()
Returns the integer range for the specified hierarchy.
SystemVerilog
static function void vmm_opts::get_object_range(
output bit is_set,
input vmm_object obj,
input string name,
output int min,max,
input int dflt_min, dflt_max,
input string doc = "", int verbosity = 0,
input string fname = "",
int lineno = 0);
Description
If an explicit range is specified, sets the min and max parameters to
the values of the named integer-range-type option for the specified
object instance, and sets the is_set argument to true. A range
option is specified using the syntax +vmm_name=[min:max]. You
can specify a description of the option using doc, and the verbosity
level of the option using verbosity. A verbosity value must be
within the range 0 to 10. The fname and lineno arguments are
used to track the file name and the line number, where the option is
specified. These optional arguments are used to provide information
through the vmm_opts::get_help() method.
If no explicit values are provided for integer range of the specified
hierarchy, sets the default range values to specified arguments
dflt_min & dflt_max to the min and max arguments respectively.
The fname and lineno arguments are used to track the file name and
the line number where the get_object_range is invoked.
Example
class B extends vmm_object;
int min_val = -1;
int max_val = -1;
function new(string name, vmm_object parent=null);
bit is_set;
super.new(parent,name);
vmm_opts::get_object_range(is_set, this,
"FOO", min_val, max_val,-1,-1, "SET foo value", 0);
endfunction
endclass
Command line:
simv +vmm_FOO=[5:10]@%:X:b
vmm_opts::get_object_string()
Returns a string value, if the named string option is set for the
hierarchy. Otherwise, it returns the default value.
SystemVerilog
static function string get_object_string(output bit is_set,
input vmm_object obj, string name, string dflt, string doc
= "", int verbosity = 0, string fname = "", int lineno = 0);
Description
If an explicit value is specified, returns the named string type option
for the specified object instance, and sets the is_set argument to
true. If no explicit value is specified, specified default string name
dftl is assigned to string name. You can specify a description of the
option using doc, and the verbosity level of the option using
verbosity. The verbosity value must be within the range 0 to 10.
The fname and lineno arguments are used to track the file name
and the line number, where the option is specified. These optional
arguments are used to provide information through the
vmm_opts::get_help() method. The fname and lineno
arguments are used to track the file name and the line number where
the get_object_string is invoked.
Example
class B extends vmm_object;
string foo="ZERO";
function new(string name, vmm_object parent=null);
bit is_set;
super.new(parent,name);
foo = vmm_opts::get_object_string(is_set, this,
"FOO", "DEF_VAL", "SET foo value", 0);
endfunction
endclass
Command line:
simv +vmm_FOO=HELLO@%:X:b
vmm_opts::get_range()
Returns an integer range, if specified using the command-line.
Otherwise, it returns the default range.
SystemVerilog
static function void vmm_opts::get_range(string name,
output int min,max, input int dflt_min, dflt_max,
string doc = "", int verbosity = 0, string fname = "",
int lineno = 0);
Description
Returns the named integer range option. A range option is specified
using the syntax +vmm_name=[min:max] or
+vmm_opts+name=[min:max]. You can specify a description of
the option using doc, and the verbosity level of the option using
verbosity. A verbosity value must be within the range 0 to 10. The
fname and lineno arguments are used to track the file name and
the line number, where the option is specified. These optional
arguments are used to provide information through the
vmm_opts::get_help() method.
If no explicit values are provided for integer range of the specified
hierarchy, sets the default range values to specified arguments
dflt_min & dflt_max to the min and max arguments respectively.
The fname and lineno arguments are used to track the file name and
the line number where the get_object_range is invoked.
Example
int min_val;
int max_val;
Command line:
simv +vmm_FOO=[5:10] or simv +vmm_opts+FOO=[5:10]
vmm_opts::get_string()
Returns the string value, if specified using the command-line.
Otherwise, it returns the default value.
SystemVerilog
static function string vmm_opts::get_string(string name,
string dflt, string doc = "", int verbosity = 0,
string fname = "", int lineno = 0);
Description
Returns string value, if the argument name and its string value are
specified on the command-line. Otherwise, it returns the default
value specified in the dflt argument. The option is specified using
the command line +vmm_name=value or
+vmm_opts+name=value. You can specify a description of the
option using doc, and the verbosity level of the option using
verbosity. A verbosity value must be within the range 0 to 10. The
fname and lineno arguments are used to track the file name and
the line number, where the option is specified. These optional
arguments are used to providing information through the
vmm_opts::get_help() method.
Example
string str;
str = vmm_opts :: get_string ("FOO", "DEF",
"str value from command line");
Command line:
simv +vmm_FOO=HELLO or simv +vmm_opts+FOO=HELLO
vmm_opts::set_bit()
Sets the hierarchically named boolean type option.
SystemVerilog
static function void
vmm_opts::set_bit(string name,
bit val,
vmm_unit root = null,
string fname = "",
int lineno = 0);
vmm_opts::set_bit(string name,
bit val,
string fname = "",
int lineno = 0);
Description
Sets the hierarchically named boolean type option for the specified
vmm_object instances as specified by val. If no vmm_unit root is
specified, the hierarchical option name is assumed to be absolute.
The argument name can be a pattern. When
vmm_opts::get_object_bit() is called in any object whose
hierarchical name matches the pattern, the option is set for that
boolean variable. The fname and lineno arguments are used to
track the file name and the line number, where the option is specified
from.
Example
class B extends vmm_object;
bit foo;
function new(string name, vmm_object parent=null);
bit is_set;
super.new(parent,name);
foo = vmm_opts::get_object_bit(is_set, this, "FOO",
"SET foo value", 0);
endfunction
endclass
B b2;
initial begin
vmm_opts::set_bit("b2:FOO",null);
b2 = new("b2", null);
end
vmm_opts::set_int()
Sets the hierarchically named integer type option.
SystemVerilog
static function void vmm_opts::set_int(string name,
int val,
vmm_unit root = null,
string fname = "",
int lineno = 0);
With +define NO_VMM12
static function void vmm_opts::set_int(string name,
int val,
string fname = "",
int lineno = 0);
Description
Sets the hierarchically named integer type option for the specified
vmm_object instances as specified by val. If no vmm_unit root is
specified, the hierarchical option name is assumed to be absolute.
The argument name can be a pattern. When
vmm_opts::get_object_bit() is called in any object whose
hierarchical name matches the pattern, the option is set for that
integer variable. The fname and lineno arguments are used to
track the file name and the line number, where the option is specified
from.
Example
class A extends vmm_object;
int a_foo;
function new(vmm_object parent=null, string name);
bit is_set;
super.new(parent, name);
a_foo = vmm_opts::get_object_int(is_set, this,
"A_FOO", 2 , "SET a_foo value", 0);
endfunction
endclass
class D extends vmm_object;
A a1;
...
endclass
initial begin
D d2;
vmm_opts::set_int("d2:a1:A_FOO", 99,null);
d2 = new (null, "d2");
end
vmm_opts::set_object()
Sets the hierarchically named vmm_object type option.
SystemVerilog
static function void
vmm_opts::set_object(string name,
vmm_object obj,
vmm_unit root = null,
string fname = "",
int lineno = 0);
vmm_opts::set_object(string name,
vmm_object obj,
string fname = "",
int lineno = 0);
Description
Sets the hierarchically named type-specific option for the specified
vmm_object instances. If no vmm_unit root is specified, the
hierarchical option name is assumed to be absolute. When called
from the vmm_unit::configure_ph() method, the root unit must
always be specified as this, because vmm_unit instances can
only configure lower-level instances during the configure phase.
The hierarchical option name is specified by prefixing the option
name with a hierarchical vmm_unit name and a colon (:).
The hierarchical option name may be specified using a match
pattern or a regular expression, except for the last part of the
hierarchical name (the name of the option itself). The hierarchical
option name may specify a namespace. An error is reported, if the
option value is not eventually used.
The fname and lineno arguments are used to track the file name
and the line number, where the option is specified from.
Example
class A extends vmm_object;
int foo = 11;
function new( vmm_object parent=null, string name);
bit is_set;
super.new(parent, name);
endfunction
endclass
class B extends vmm_object;
A a1;
A a2;
function new(vmm_object parent=null, string name);
bit is_set;
super.new(parent, name);
a1 = new(null, "a1");
a2 = new(null, "a2");
a2.foo = 22;
$cast(a1, vmm_opts::get_object_obj(is_set, this,
"OBJ_F1",a2,"SET OBJ", 0));
endfunction
endclass
B b2;
A a3;
initial begin
a3 = new(null, "a3");
a3.foo = 99;
vmm_opts::set_object("b2:OBJ_F1", a3,null,,);
b2 = new(null, "b2");
end
vmm_opts::set_range()
Sets the hierarchically named integer range type option.
SystemVerilog
static function void vmm_opts::set_range(string name,
int min, max,
vmm_unit root = null,
string fname = "",
int lineno = 0);
With +define NO_VMM12
static function void vmm_opts::set_range(string name,
int min, max,
string fname = "",
int lineno = 0);
Description
Sets the hierarchically named integer range type option, for the
specified vmm_object instances. If no vmm_unit root is specified,
then the hierarchical option name is assumed to be absolute. The
name argument can be a pattern. When
vmm_opts::get_object_range() is called in an object whose
hierarchical name matches the pattern, then min and max are
returned.
The fname and lineno arguments are used to track the file name
and the line number, where the range is specified from.
Example
class B extends vmm_object;
vmm_opts::set_string()
Sets the hierarchical named string type option.
SystemVerilog
static function void vmm_opts::set_string(string name,
string val,
vmm_unit root = null,
string fname = "",
int lineno = 0);
With +define NO_VMM12
static function void vmm_opts::set_string(string name,
string val,
string fname = "",
int lineno = 0);
Description
Sets the hierarchically named string type option, for the specified
vmm_object instances as specified by name. If no vmm_unit root
is specified, then the hierarchical option name is assumed to be
absolute. The argument name can be a pattern. When the
vmm_opts::get_object_string() method is called in any
object whose hierarchical name matches the pattern, then val is
returned for that string variable.
The fname and lineno arguments are used to track the file name
and the line number, where the option is specified from.
Example
class B extends vmm_object;
string foo="ZERO";
function new(string name, vmm_object parent=null);
bit is_set;
super.new(parent,name);
foo = vmm_opts::get_object_string(is_set, this,
"FOO","DEF_VAL", "SET foo value", 0);
endfunction
endclass
initial begin
B b2;
vmm_opts::set_string("b2:FOO", "NEW_VAL", null);
b2 = new("b2", null);
end
vmm_unit_config*
This section describes the following macros:
`vmm_unit_config_begin( <classname> )
`vmm_unit_config_end( <classname> )
`vmm_unit_config_begin( <classname> )
Macro, which indicates the beginning of the structural configuration
parameters setting in the vmm_unit::configure_ph() phase.
`vmm_unit_config_boolean(name, descr, verbosity, attribute)
Macro for setting Boolean value to the variable, with the name
specified in the argument.
It internally calls vmm_opts::get_object_bit, which uses
description and verbosity arguments as well.
It also sets the rand_mode of the variable to 0, so that the value set
through configuration will not change due to randomization.
The attribute argument is for future enhancements.
`vmm_unit_config_rand_int(name, dflt, descr, verbosity,
attribute)
Macro for setting integer value to the variable, with the name
specified in the argument.
It internally calls vmm_opts::get_object_int, which uses
default value, description, and verbosity arguments as well.
It also sets the rand_mode of the variable to 0, so that the value set
through configuration will not change due to randomization.
The attribute argument is for future enhancements.
`vmm_unit_config_rand_obj(name, dflt, descr, verbosity,
attribute)
Macro for setting object value to the variable, with the name
specified in the argument.
It internally calls vmm_opts::get_object_obj, which uses
default value and verbosity arguments as well.
It also sets the rand_mode of the variable to 0, so that the value set
through configuration will not change due to randomization.
The description and attribute arguments are for future
enhancements.
B
Standard Library Classes (Part 2)
Note:
Each method, explained in this appendix, uses the SystemVerilog
name in the heading to introduce it. Additionally, there are a few
instances where a _t suffix is appended to indicate that it may be
a blocking method.
vmm_phase
vmm_phase_def
vmm_rtl_config_DW_format
vmm_rtl_config
vmm_rtl_config_file_format
vmm_scenario
vmm_scenario_gen#(T, text)
<class-name>_scenario
<class-name>_atomic_scenario
<class-name>_scenario_election
<class-name>_scenario_gen_callbacks
vmm_scheduler
vmm_scheduler_election
vmm_ss_scenario#(T)
vmm_simulation
vmm_subenv
vmm_test
vmm_test_registry
vmm_timeline
vmm_timeline_callbacks
vmm_tlm
vmm_tlm_generic_payload
vmm_tlm_analysis_port#(I,D)
vmm_tlm_analysis_export#(T,D)
vmm_tlm_analysis_export(SUFFIX)
vmm_tlm_b_transport_export#(T,D)
vmm_tlm_b_transport_port #(I,D)
vmm_tlm_export_base #(D,P)
vmm_tlm_nb_transport_bw_export#(T,D,P)
vmm_tlm_nb_transport_bw_port#(I,D,P)
vmm_tlm_nb_transport_export#(T,D,P)
vmm_tlm_nb_transport_fw_export#(T,D,P)
vmm_tlm_nb_transport_fw_port#(I,D,P)
vmm_tlm_nb_transport_port#(I,D,P)
vmm_tlm_port_base#(D,P)
vmm_tlm_initiator_socket#(I,D,P)
vmm_tlm_target_socket#(T,D,P)
vmm_unit
vmm_version
vmm_voter
vmm_xactor
vmm_xactor_callbacks
vmm_xactor_iter
vmm_phase
The vmm_phase class is used as a container for phase descriptors,
and their associated statistical information.
Summary
vmm_phase::completed ...............................
vmm_phase::started .................................
vmm_phase::get_name() ..............................
vmm_phase::get_timeline() ..........................
vmm_phase::is_aborted() ...........................
vmm_phase::is_done() ..............................
vmm_phase::is_running() ...........................
vmm_phase::is_skipped() ...........................
vmm_phase::next_phase() ...........................
vmm_phase::previous_phase() .......................
page B-6
page B-7
page B-8
page B-9
page B-10
page B-12
page B-13
page B-14
page B-16
page B-17
vmm_phase::completed
Phase execution completion event.
Description
This event is triggered when the execution of this phase is
completed.
Example
vmm_timeline top;
vmm_phase ph;
initial begin
top = new("top", "top");
ph = top.get_phase("connect");
@(ph.completed);
`vmm_log (log, "Completed execution of phase connect");
...
end
vmm_phase::started
Phase execution start event.
Description
This event is triggered when the execution of this phase starts.
Example
vmm_timeline top;
vmm_phase ph;
initial begin
top = new("top", "top");
ph = top.get_phase("connect");
...
@(ph.started);
`vmm_note(log," connect phase execution started");
...
end
vmm_phase::get_name()
Method to get the phase descriptor name.
SystemVerilog
function string vmm_phase::get_name()
Description
Returns the name of the phase descriptor.
Example
vmm_timeline top;
vmm_phase ph;
string ph_name;
initial begin
top = new("top", "top");
ph = top.get_phase("connect");
...
ph_name = ph.get_name(); //returns string "connect"
...
end
vmm_phase::get_timeline()
Method to get the enclosing timeline.
SystemVerilog
function vmm_timeline vmm_phase::get_timeline()
Description
Returns the timeline, which contains this phase.
Example
vmm_timeline top;
vmm_phase ph;
initial begin
vmm_timeline t;
top = new("top", "top");
ph = top.get_phase("connect");
...
t = ph.get_timeline;
...
end
vmm_phase::is_aborted()
Method to check aborted status of the phase.
SystemVerilog
function int vmm_phase::is_aborted()
Description
Returns the number of times that the phase is aborted.
Example
class myTest extends vmm_timeline;
function new(string name, string inst,
vmm_object parent = null);
super.new(name, inst, parent);
endfunction
task reset_ph;
$display("%t:Starting Reset", $time);
#5;
$display("%t:Finishing Reset", $time);
endtask
task training_ph;
#5;
endtask
task run_ph;
#5;
endtask
endclass
vmm_log log = new("test", "main");
myTest top;
initial begin
vmm_phase ph_reset;
top = new("top", "top");
ph_reset = top.get_phase("reset");
fork
top.run_phase();
join_none
#7 top.abort_phase("training"); //aborting training
#1 top.reset_to_phase("reset"); //aborting run
#1 top.jump_to_phase("run"); //aborting reset,
// skipping training-start_of_test
#10;
if(ph_reset.is_aborted() != 2)
`vmm_error(log,`vmm_sformatf(
$psprintf("Expected reset to abort 2 times,
is_aborted returns %d",ph_reset.is_aborted))
);
vmm_phase::is_done()
Method to check completion status of the phase.
SystemVerilog
function int vmm_phase::is_done()
Description
Returns the number of times that the phase is completed.
vmm_phase::is_running()
Method to get execution status of the phase.
SystemVerilog
function bit vmm_phase::is_running()
Description
Returns true, if the phase is currently being executed. Always returns
false for function phases, unless called from within the phase
implementation function itself.
Example
vmm_timeline top;
vmm_phase ph;
initial
begin
top = new("top", "top");
ph = top.get_phase("connect");
...
wait(ph.is_running == 0);
...
end
vmm_phase::is_skipped()
Returns the number of times that the phase is skipped.
SystemVerilog
function int vmm_phase::is_skipped()
Description
Returns the number of times that the phase is skipped.
Example
class myTest extends vmm_timeline;
function new(string name, string inst,
vmm_object parent = null);
super.new(name, inst, parent);
endfunction
task reset_ph;
$display("%t:Starting Reset", $time);
#5;
$display("%t:Finishing Reset", $time);
endtask
task training_ph;
#5;
endtask
task run_ph;
#5;
endtask
endclass
vmm_log log = new("test", "main");
myTest top;
initial begin
vmm_phase ph_training;
top = new("top", "top");
ph_training = top.get_phase("training");
fork
top.run_phase();
join_none
#9 top.jump_to_phase("run"); //aborting reset,
//skipping training-start_of_test
#10;
if(ph_training.is_skipped() != 1)
`vmm_error(log,`vmm_sformatf(
$psprintf("Expected training to abort 1 times,
is_skipped returns %d",ph_training.is_skipped))
);
vmm_phase::next_phase()
Method to get the following phase descriptor.
SystemVerilog
function vmm_phase vmm_phase::next_phase()
Description
Returns the following phase in the timeline containing this phase.
Returns null, if this is the last phase in the timeline.
Example
vmm_timeline top;
vmm_phase ph;
initial begin
vmm_phase nx_ph;
top = new("top", "top");
ph = top.get_phase("connect");
...
nx_ph = ph.next_phase(); //returns phase configure_test
`vmm_note(log,`vmm_sformatf("
%s will execute after connect",nx_ph.get_name());
...
end
vmm_phase::previous_phase()
Method to get the preceding phase descriptor.
SystemVerilog
function vmm_phase vmm_phase::previous_phase()
Description
Returns the preceding phase in the timeline containing this phase.
Returns null, if this is the first phase in the timeline.
Example
vmm_timeline top;
vmm_phase ph;
initial begin
vmm_phase prv_ph;
top = new("top", "top");
ph = top.get_phase("connect");
...
prv_ph = ph.previous_phase(); //returns phase configure
`vmm_note(log,`vmm_sformatf(
"connect will execute after %s ",prv_ph.get_name());
...
end
vmm_phase_def
The vmm_phase_def virtual class is extended to create a userdefined phase.
Summary
vmm_bottomup_function_phase_def
Predefined bottom-up phase definition.
SystemVerilog
class vmm_bottomup_function_phase_def #(type T)
extends vmm_function_phase_def
Description
Implements the vmm_phase_def::run_function_phase(). To
call the
vmm_bottomup_function_phase_def::do_function_phas
e() method on any object of specified type, within the vmm_object
hierarchy under the specified root, in a bottom-up order.
vmm_bottomup_function_phase_def::do_function_phase()
Method to execute an object for particular phase execution.
SystemVerilog
virtual function void
vmm_bottomup_function_phase_def::do_function_phase(T obj)
Description
Implementation of the function phase on an object of the specified
type. You can choose to execute some non-delay processes of a
specified object in this method, of a new phase definition class
extended from this class.
Example
class udf_phase_def extends
vmm_bottomup_function_phase_def;
function void do_function_phase(vmm_unit un1);
un1.my_method();
endfunction
endclass
vmm_fork_task_phase_def#(T)
Predefined task based phase definition.
class vmm_fork_task_phase_def #(type T) extends
vmm_task_phase_def
SystemVerilog
Description
Implements the vmm_phase_def::run_task_phase(). To make
a call to the vmm_fork_task_phase_def::do_task_phase()
method on any object of a specified type, within the vmm_object
hierarchy, under the specified root in a top-down order.
vmm_fork_task_phase_def::do_task_phase()
Method to execute on object for particular phase execution.
SystemVerilog
virtual task vmm_fork_task_phase_def::do_task_phase(T obj)
Description
Implementation of the task phase on an object of the specified type.
You can choose to execute time-consuming processes in this
method, of a new phase definition class extended from this class.
Example
class udf_phase_def extends vmm_fork_task _phase_def;
task do_task_phase(vmm_unit un1);
un1.my_method();
endtask
endclass
vmm_null_phase_def
Predefined null phase definition.
SystemVerilog
class vmm_null_phase_def extends vmm_phase_def
Description
Implements empty vmm_phase_def::run_function_phase()
and vmm_phase_def::run_task_phase(). Typically used to
override a predefined phase to skip its predefined implementation for
a specific vmm_unit instance.
Example
class myphase_def extends
vmm_null_phase_def #(groupExtension);
endclass : myphase_def
myphase_def null_ph = new();
group_extension m1 = new("groupExtension","m1");
`void(m1.override_phase("configure",null_ph ));
//nothing to de done for this component in configure phase
vmm_phase_def::is_function_phase()
Method to check the type of phase definition (check if it is a function).
SystemVerilog
virtual function bit vmm_phase_def::is_function_phase()
Description
Returns true, if this phase is executed by calling the
vmm_phase_def::run_function_phase() method. Otherwise,
it returns false.
Example
virtual class user_function_phase_def #(
user_function_phase_def) extends
vmm_topdown_function_phase_def;
function bit is_function_phase();
return 1;
endfunction:is_function_phase
endclass
vmm_phase_def::is_task_phase()
Method to check type of phase definition (check if it is a task).
SystemVerilog
virtual function bit vmm_phase_def::is_task_phase()
Description
Returns true, if this phase is executed by calling the
vmm_phase_def::run_task_phase() method. Otherwise, it
returns false.
Example
virtual class user_task_phase_def #( user_task_phase_def)
extends vmm_fork_task_phase_def;
function bit is_task_phase();
return 1;
endfunction:is_task_phase
endclass
vmm_phase_def::run_function_phase()
Method to execute phase definition, used by timeline.
SystemVerilog
virtual function void run_function_phase(string
name,
vmm_object obj,
vmm_log log);
Description
Executes the function phase, under the specified name on the
specified object. This method must be overridden, if the
vmm_phase_def::is_function_phase() method returns true.
The argument log is the message interface instance to be used by
the phase for reporting information.
Example
virtual class user_function_phase_def #(
user_function_phase_def)
extends vmm_topdown_function_phase_def;
function bit is_function_phase();
return 1;
endfunction:is_function_phase
function run_function_phase(string name,
vmm_object root, vmm_log log);
`vmm_note(log,`vmm_sformatf(
"Executing phase %s for %s", name,
root.get_object_name());
endfuction
endclass
vmm_phase_def::run_task_phase()
Method to execute phase definition, used by timeline.
SystemVerilog
virtual task run_task_phase(string name,
vmm_object obj,
vmm_log log);
Description
Executes the task phase, under the specified name on the specified
root object. This method must be overridden if the
vmm_phase_def::is_task_phase() method returns true.
The argument log is the message interface instance to be used by
the phase for reporting information.
Example
virtual class user_task_phase_def #( user_task_phase_def)
extends vmm_fork_task_phase_def;
function bit is_task_phase();
return 1;
endfunction:is_task_phase
task run_task_phase(string name, vmm_object root,
vmm_log log);
`vmm_note(log,`vmm_sformatf(
"Executing phase %s for %s", name,
root.get_object_name());
endtask
endclass
vmm_reset_xactor_phase_def
Predefined vmm_reset_xactor phase definition class.
SystemVerilog
class vmm_reset_xactor_phase_def extends
vmm_xactor_phase_def;
Description
Implements the
vmm_reset_xactor_phase_def::do_function_phase().
This function calls the reset_xactor() function, on a specified
object of type vmm_xactor.
Example
class consumer extends vmm_xactor ;
packet_channel in_chan;
function new(string inst, packet_channel in_chan);
super.new("consumer", inst);
this.in_chan = in_chan;
endfunction
...
...
class consumer_timeline #(string phase = "reset") extends
vmm_timeline;
`vmm_typename(consumer_timeline)
consumer xactor;
packet_channel
chan;
function new (string inst, packet_channel chan,
vmm_unit parent = null);
super.new(get_typename(),inst, parent);
this.chan = chan;
endfunction
function void build_ph;
xactor = new("xactor", chan);
xactor.set_parent_object(this);
endfunction
function void connect_ph;
vmm_reset_xactor_phase_def reset = new(
"consumer","xactor");
void(this.insert_phase(phase,phase, reset));
endfunction
...
...
endclass
consumer_timeline
vmm_start_xactor_phase_def
Predefined vmm_start_xactor phase definition class.
SystemVerilog
class vmm_start_xactor_phase_def extends
vmm_xactor_phase_def;
Description
Implements the
vmm_start_xactor_phase_def::do_function_phase().
This function calls the start_xactor() function, on specified
object of type vmm_xactor.
Example
class consumer extends vmm_xactor ;
packet_channel
in_chan;
function new(string inst, packet_channel in_chan);
super.new("consumer", inst);
this.in_chan = in_chan;
endfunction
...
...
class consumer_timeline #(string phase = "start") extends
vmm_timeline;
`vmm_typename(consumer_timeline)
consumer xactor;
packet_channel chan;
function new (string inst, packet_channel chan,
vmm_unit parent = null);
super.new(get_typename(),inst, parent);
this.chan = chan;
endfunction
function void build_ph;
xactor = new("xactor", chan);
xactor.set_parent_object(this);
endfunction
function void connect_ph;
vmm_start_xactor_phase_def start = new(
"consumer","xactor");
void(this.insert_phase(phase, phase, start));
enfunction
...
...
endclass
consumer_timeline
vmm_stop_xactor_phase_def
Predefined vmm_stop_xactor phase definition class.
SystemVerilog
class vmm_stop_xactor_phase_def extends
vmm_xactor_phase_def;
Description
Implements the
vmm_stop_xactor_phase_def::do_function_phase().
This function calls the stop_xactor() function on a specified
object of type vmm_xactor.
Example
class consumer extends vmm_xactor ;
packet_channel
in_chan;
function new(string inst, packet_channel in_chan);
super.new("consumer", inst);
this.in_chan = in_chan;
endfunction
...
...
class consumer_timeline #(string phase = "stop") extends
vmm_timeline;
`vmm_typename(consumer_timeline)
consumer xactor;
packet_channel chan;
function new (string inst, packet_channel chan,
vmm_unit parent = null);
super.new(get_typename(),inst, parent);
this.chan = chan;
endfunction
function void build_ph;
xactor = new("xactor", chan);
xactor.set_parent_object(this);
endfunction
function void connect_ph;
vmm_stop_xactor_phase_def stop = new(
"consumer","xactor");
void(this.insert_phase(phase,phase, stop));
endfunction
...
...
endclass
consumer_timeline
vmm_topdown_function_phase_def
Predefined top-down phase definition.
SystemVerilog
class vmm_topdown_function_phase_def #(type T=vmm_object)
extends vmm_phase_def;
Description
Implements the vmm_phase_def::run_function_phase(). To
call the
vmm_topdown_function_phase_def::do_function_phase
() method on any object of specified type within the vmm_object
hierarchy under the specified root in a top-down order.
vmm_topdown_function_phase_def::do_function_phase()
Method to execute an object for particular phase execution.
SystemVerilog
virtual function void
vmm_topdown_function_phase_def::do_function_phase(T obj)
Description
Implementation of the function phase on an object of the specified
type.
You can choose to execute some non-delay processes of the
specified object in this method, of a new phase definition class
extended from this class.
Example
class udf_phase_def extends vmm_topdown_function_phase_def;
function void do_function_phase(vmm_unit un1);
un1.my_method();
endfunction
endclass
vmm_xactor_phase_def
Predefined vmm_xactor phase definition class.
SystemVerilog
class vmm_xactor_phase_def #(type T=vmm_xactor) extends
vmm_phase_def;
Description
Implements the
vmm_xactor_phase_def::run_function_phase(), to call
the vmm_xactor_phase_def::do_function_phase() method
on any object of specified type within the vmm_object hierarchy,
with specified name or instance.
vmm_rtl_config_DW_format
Predefined implementation for an RTL configuration parameter,
using the DesignWare Implementation IP file format.
SystemVerilog
class vmm_rtl_config_DW_format extends
vmm_rtl_config_file_format
vmm_rtl_config
This is the base class for RTL configuration and extends
vmm_object. This class is for specifying RTL configuration
parameters. A different class from other parameters that use the
vmm_opts class is used, because these parameters must be
defined at compile time and may not be modified at runtime.
Example
class ahb_master_config extends vmm_rtl_config;
rand int addr_width;
rand bit mst_enable;
string
kind = "MSTR";
constraint cst_mst {
addr_width == 64;
mst_enable == 1;
}
`vmm_rtl_config_begin(ahb_master_config)
`vmm_rtl_config_int(addr_width, mst_width)
`vmm_rtl_config_boolean(mst_enable, mst_enable)
`vmm_rtl_config_string(kind, kind)
`vmm_rtl_config_end(ahb_master_config)
function new(string name = "", vmm_rtl_config parent =
null);
super.new(name, parent);
endfunction
endclass
Summary
vmm_rtl_config::build_config_ph() .................
vmm_rtl_config::default_file_fmt ..................
vmm_rtl_config::file_fmt ..........................
vmm_rtl_config::get_config() ......................
vmm_rtl_config::get_config_ph() ...................
vmm_rtl_config_* .................................
vmm_rtl_config::map_to_name() .....................
page
page
page
page
page
page
page
B-40
B-41
B-42
B-43
B-44
B-45
B-46
vmm_rtl_config::build_config_ph()
Builds RTL configuration parameters.
SystemVerilog
virtual function void vmm_rtl_config::build_config_ph()
Description
Builds the structure of RTL configuration parameters for hierarchical
RTL designs.
Example
class env_config extends vmm_rtl_config;
rand ahb_master_config mst_cfg;
rand ahb_slave_config slv_cfg;
...
function void build_config_ph();
mst_cfg = new("mst_cfg", this);
slv_cfg = new("slv_cfg", this);
endfunction
...
endclass
vmm_rtl_config::default_file_fmt
Default RTL configuration file format.
SystemVerilog
static vmm_rtl_config_file_format
vmm_rtl_config::default_file_fmt
Description
Default RTL configuration file format writer or parser. Used if the
vmm_rtl_config::file_fmt is null.
Example
class def_rtl_config_file_format extends
vmm_rtl_config_file_format;
endclass
intial begin
def_rtl_config_file_format dflt_fmt = new();
vmm_rtl_config::default_file_fmt = dflt_fmt;
end
vmm_rtl_config::file_fmt
RTL configuration file format.
SystemVerilog
protected vmm_rtl_config_file_format
vmm_rtl_config::file_fmt
Description
The RTL configuration file format writer or parser for this instance.
Example
//protected vmm_rtl_config_file_format vmm_rtl_config ::
file_fmt
class ahb_rtl_config_file_format extends
vmm_rtl_config_file_format;
endclass
class env_config extends vmm_rtl_config;
rand ahb_master_config mst_cfg;
ahb_rtl_config_file_format ahb_file_fmt;
function void build_config_ph();
mst_cfg = new("mst_cfg", this);
ahb_file_fmt = new;
mst_cfg.file_fmt = ahb_file_format;
endfunction
endclass
vmm_rtl_config::get_config()
Returns a vmm_rtl_config object for the specified vmm_object.
SystemVerilog
static function vmm_rtl_config::get_config(vmm_object obj,
string fname = "", int lineno = 0)
Description
Gets the instance of the specified class extended from the
vmm_rtl_config class, whose hierarchical name in the VMM RTL
Config namespace is identical to the hierarchical name of the
specified object. This allows a component to retrieve its instanceconfiguration, without having to know where it is located in the
testbench hierarchy.
The fname and lineno arguments are used to track the file name
and the line number where get_config is invoked from.
Example
class ahb_master extends vmm_group;
ahb_master_config cfg;
function void configure_ph();
$cast(cfg, vmm_rtl_config::get_config(this,
`__FILE__, `__LINE__));
endfunction
endclass
vmm_rtl_config::get_config_ph()
Sets the RTL configuration parameters.
SystemVerilog
virtual function void vmm_rtl_config::get_config_ph()
Description
Reas a configuration file and sets the current value of members to
the corresponding RTL configuration parameters. The filename may
be computed using the value of the +vmm_rtl_config option,
using the vmm_opts::get_string("rtl_config") method
and the hierarchical name of this vmm_object instance.
A default implementation of this method is created, if the
`vmm_rtl_config_*() shorthand macros are used.
vmm_rtl_config_*
`vmm_rtl_config_begin(classname)
`vmm_rtl_config_boolean(name, fname)
`vmm_rtl_config_int(name, fname)
`vmm_rtl_config_string(name, fname)
`vmm_rtl_config_obj(name)
`vmm_rtl_config_end(classname)
Description
Type-specific, shorthand macros providing a default implementation
for setting, randomizing, and saving RTL parameter members. The
name is the name of the member in the class. The fname is the
name of the RTL configuration parameter in the RTL configuration
file.
Example
class ahb_master_config extends vmm_rtl_config;
rand int addr_width;
rand bit mst_enable;
string kind = "MSTR";
`vmm_rtl_config_begin(ahb_master_config)
`vmm_rtl_config_int(addr_width, mst_width)
`vmm_rtl_config_boolean(mst_enable, mst_enable)
`vmm_rtl_config_string(kind, kind)
`vmm_rtl_config_end(ahb_master_config)
endclass
vmm_rtl_config::map_to_name()
Maps the specified name to the object name.
SystemVerilog
function void vmm_rtl_config::map_to_name(string name)
Description
Use the specified name for this instance of the configuration
descriptor, instead of the object name, when looking for relevant
vmm_rtl_config instances in the RTL configuration hierarchy.
The specified name is used as the object name in the VMM RTL
Config namespace. When argument name is passed as caret (^) for
any particular configuration descriptor, that configuration descriptor
becomes a root object under "VMM RTL Config".
Example
class ahb_master_config extends vmm_rtl_config;
function new(string name = "", vmm_rtl_config parent =
null);
super.new(name, parent);
endfunction
endclass
class env_config extends vmm_rtl_config;
rand ahb_master_config mst_cfg;
function void build_config_ph();
mst_cfg = new("mst_cfg", this);
endfunction
endclass
initial begin
env_config env_cfg = new("env_cfg");
env_cfg.mst_cfg.map_to_name("env:mst");
end
vmm_rtl_config::save_config_ph()
Saves the RTL configuration parameters in a file.
SystemVerilog
virtual function void vmm_rtl_config::save_config_ph()
Description
Creates a configuration file that specifies the RTL configuration
parameters corresponding to the current value of the class
members. The filename may be computed using the value of the
+vmm_rtl_config option, using the
vmm_opts::get_string("rtl_config") method and the
hierarchical name of this vmm_object instance.
A default implementation of this method is created, if the
`vmm_rtl_config_*() shorthand macros are used.
vmm_rtl_config_file_format
Base class for RTL configuration file format.
SystemVerilog
virtual class vmm_rtl_config_file_format
Description
This is the base class for RTL configuration file writer or parser. May
be used to simplify the task of implementing the
vmm_rtl_config::get_config_ph() and
vmm_rtl_config::save_config_ph() methods.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
virtual function bit fopen(vmm_rtl_config cfg,
string mode,string fname = "",int lineno = 0);
string filename = {cfg.prefix, ":",
cfg.get_object_hiername(), ".rtl_conf"};
vmm_rtl_config::file_ptr = $fopen(filename, mode);
if (vmm_rtl_config::file_ptr == 0) return 0;
else return 1;
endfunction
function string get_val(string str);
if (`vmm_str_match(str, "
: ")) begin
string fname = `vmm_str_prematch(str);
string fval = `vmm_str_postmatch(str);
if (`vmm_str_match(fval, ";")) begin
fval = `vmm_str_prematch(fval);
end
return fval;
end
endfunction
virtual function bit read_int(string name,
output int value);
int r;
string str;
$display("Calling read_int for %s", name);
r = $freadstr(str, vmm_rtl_config::file_ptr);
str = get_val(str);
value = str.atoi();
$display("Got %0d for %s", value, name);
return (r != 0);
endfunction
virtual function bit write_int(string name, int value);
$fwrite(vmm_rtl_config::file_ptr, "%s : %0d;\n",
name, value);
return 1;
endfunction
virtual function void fclose();
$fclose(vmm_rtl_config::file_ptr);
endfunction
endclass
Summary
page
page
page
page
page
page
page
page
page
page
B-51
B-52
B-53
B-54
B-55
B-56
B-57
B-58
B-59
B-60
vmm_rtl_config_file_format ::fclose()
Closes the RTL configuration file.
SystemVerilog
pure virtual function void vmm_rtl_config_file_format
::fclose()
Description
Closes the configuration file that was previously opened. An
implementation may choose to internally cache the information
written to the file using the write_*() methods, and physically
write the file just before closing it.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
...
virtual function void fclose();
$fclose(vmm_rtl_config::Xfile_ptrX);
endfunction
...
endclass
vmm_rtl_config_file_format::fname()
Computes the filename that contains the RTL configuration
parameter for the specified instance of the RTL configuration
descriptor.
SystemVerilog
virtual protected function string
vmm_rtl_config_file_format::fname(vmm_rtl_config cfg)
Description
Computes the filename that contains the RTL configuration
parameter for the specified instance of the RTL configuration
descriptor. By default, concatenates the value of the
+vmm_rtl_config option and the hierarchical name of the
specified RTL configuration descriptor, separating the two parts with
a slash (/) and appending a .cfg suffix.
vmm_rtl_config_file_format::fopen()
Opens an RTL config file.
SystemVerilog
pure virtual function bit vmm_rtl_config_file_format ::
fopen(vmm_rtl_config cfg, string mode,
string fname = "", int lineno = 0)
Description
Opens the configuration file corresponding to the specified RTL
configuration descriptor in the specified mode (r or w). The filename
may be computed using the value of the +vmm_rtl_config option,
using the vmm_opts::get_string("rtl_config") method
and the name of specified RTL configuration descriptor. Returns
true, if the file was successfully opened. If the file is open for read, it
may be immediately parsed and its content internally cached. The
fname and lineno arguments are used to track the file name and
the line number where get_config is invoked from.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
virtual function bit fopen(vmm_rtl_config cfg,
string mode,string fname = "", int lineno = 0);
string filename = {cfg.prefix, ":",
cfg.get_object_hiername(), ".rtl_conf"};
vmm_rtl_config::Xfile_ptrX = $fopen(filename, mode);
if (vmm_rtl_config::file_ptr == 0) return 0;
else return 1;
endfunction
...
endclass
vmm_rtl_config_file_format::get_fname()
Returns the name of the configuration file, which is currently opened.
Returns "", if the file is not opened.
SystemVerilog
pure virtual function string vmm_rtl_config_file_format
::get_fname()
Description
Returns the name of the configuration file, which is currently opened.
Return "", if the file is not opened.
vmm_rtl_config_file_format::read_bit()
Reads a boolean variable from the RTL configuration file.
SystemVerilog
pure virtual function bit vmm_rtl_config_file_format
::read_bit(string name, output bit value)
Description
Returns a boolean value with the specified name, from the RTL
configuration file.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
...
virtual function bit read_bit(string name,
output bit value);
int r;
string str;
r = $freadstr(str, vmm_rtl_config::Xfile_ptrX);
str = get_val(str);
value = str.atoi();
$display("Got %b for %s", value, name);
return (r != 0);
endfunction
...
endclass
vmm_rtl_config_file_format::read_int()
Reads an integer variable from the RTL configuration file.
SystemVerilog
pure virtual function bit vmm_rtl_config_file_format
::read_int(string name, output int value)
Description
Returns an integer value with the specified name, from the RTL
configuration file.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
...
virtual function bit read_int(string name,
output int value);
int r;
string str;
$display("Calling read_int for %s", name);
r = $freadstr(str, vmm_rtl_config::Xfile_ptrX);
str = get_val(str);
value = str.atoi();
$display("Got %0d for %s", value, name);
return (r != 0);
endfunction
...
endclass
vmm_rtl_config_file_format::read_string()
Returns a string value with the specified name, from the RTL
configuration file.
SystemVerilog
pure virtual function bit vmm_rtl_config_file_format
::read_string(string name, output string value)
Description
Sets the value argument to the value of the named RTL
configuration parameter, as specified in the file. Returns true, if a
value for the parameter was found in the file. Otherwise, it returns
false. An implementation may require that the parameters be read in
the same order, as they are found in the file.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
...
virtual function bit read_string(string name,
output string value);
int r;
string str;
$display("Calling read_string for %s", name);
r = $freadstr(str, vmm_rtl_config::Xfile_ptrX);
value = get_val(str);
$display("Got %s for %s", value, name);
return (r != 0);
endfunction
...
endclass
vmm_rtl_config_file_format::write_bit()
Writes a boolean name and value to the RTL config file.
SystemVerilog
pure virtual function bit vmm_rtl_config_file_format
::write_bit(string name, bit value)
Description
Writes a name and boolean value to the RTL configuration file.
Returns true, if the parameter was not previously written. Otherwise,
it returns false. An implementation may physically write the
parameter values in the file in a different order, than if they were
written using these methods.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
...
virtual function bit write_bit(string name, bit value);
$fwrite(vmm_rtl_config::Xfile_ptrX, "%s : %b;\n",
name, value);
return 1;
endfunction
...
endclass
vmm_rtl_config_file_format::write_int()
Writes an integer name and value to the RTL config file.
SystemVerilog
pure virtual function bit vmm_rtl_config_file_format
::write_int(string name, int value)
Description
Writes the name and integer value in the RTL configuration file.
Returns true, if the parameter was not previously written. Otherwise,
it returns false. An implementation may physically write the
parameter values in the file in a different order, than if they were
written using these methods.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
...
virtual function bit write_int(string name, int value);
$fwrite(vmm_rtl_config::Xfile_ptrX, "%s : %0d;\n",
name, value);
return 1;
endfunction
...
endclass
vmm_rtl_config_file_format::write_string()
Writes the specified value for the named RTL configuration
parameter.
SystemVerilog
pure virtual function bit vmm_rtl_config_file_format
::write_string(string name, string value)
Description
Writes the specified value for the named RTL configuration
parameter. Returns true, if the parameter was not previously written.
Otherwise, it returns false. An implementation may physically write
the parameter values in the file in a different order, than if they were
written using these methods.
Example
class rtl_config_file_format extends
vmm_rtl_config_file_format;
...
virtual function bit write_string(string name,
string value);
$fwrite(vmm_rtl_config::Xfile_ptrX, "%s : %s;\n",
name, value);
return 1;
endfunction
...
endclass
vmm_scenario
Base class for all user-defined scenarios. This class extends from
vmm_data.
Summary
vmm_scenario::get_parent_scenario() ...............
vmm_scenario::define_scenario() ...................
vmm_scenario::length ..............................
vmm_scenario::psdisplay() .........................
vmm_scenario::redefine_scenario() .................
vmm_scenario::repeat_thresh .......................
vmm_scenario::repeated ............................
vmm_scenario::repetition ..........................
vmm_scenario::scenario_id .........................
vmm_scenario::scenario_kind .......................
vmm_scenario::scenario_name() .....................
vmm_scenario::set_parent_scenario() ...............
vmm_scenario::stream_id ...........................
vmm_scenario_new() ...............................
vmm_scenario_member_begin() ......................
vmm_scenario_member_end() ........................
vmm_scenario_member_enum*() ......................
vmm_scenario_member_handle*() ....................
vmm_scenario_member_scalar*() ....................
vmm_scenario_member_string*() ....................
vmm_scenario_member_vmm_data*() ..................
vmm_scenario_member_user_defined() ...............
vmm_scenario_member_vmm_scenario() ...............
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
B-62
B-64
B-66
B-67
B-68
B-69
B-70
B-72
B-73
B-74
B-75
B-76
B-77
B-78
B-80
B-82
B-83
B-85
B-87
B-89
B-91
B-93
B-94
vmm_scenario::get_parent_scenario()
Returns the higher-level hierarchical scenario.
SystemVerilog
function vmm_scenario get_parent_scenario()
OpenVera
Not supported.
Description
Returns the single stream or multiple-stream scenario that was
specified as the parent of this scenario. A scenario with no parent is
a top-level scenario.
Example
Example B-1
class atm_cell extends vmm_data;
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
...
atm_cell_scenario parent_scen = new;
atm_cell_scenario child_scen = new;
...
initial begin
...
vmm_log(log,"Setting parent to a child scenarion \n");
child.scen.set_parent_scenario(parent_scen);
...
if(child_scen.get_parent_scenario() == parent_scen)
vmm_log(log,"Child scenario has proper parent \n");
...
else
vmm_log(log,"Child scenario has improper parent \n");
...
end
endprogram
vmm_scenario::define_scenario()
Defines a new scenario kind.
SystemVerilog
function int unsigned define_scenario(string name,
int unsigned max_len=0);
OpenVera
Not supported.
Description
Defines a new scenario kind that is included in this scenario
descriptor, and returns a unique scenario kind identifier. The
vmm_scenario::scenario_kind data member randomly
selects one of the defined scenario kinds. The new scenario kind
may contain up to the specified number of random transactions.
The scenario kind identifier should be stored in a state variable that
can then be subsequently used to specify the kind-specific
constraints.
Example
Example B-2
`vmm_scenario_gen(atm_cell, "atm trans")
class my_scenario extends atm_cell_scenario;
int unsigned START_UP_SEQ;
int unsigned RESET_SEQ;
...
function new()
START_UP_SEQ = define_scenario("START_UP_SEQ",5);
RESET_SEQ = define_scenario("RESET_SEQ",11);
...
endfunction
...
endclass
vmm_scenario::length
Length of the scenario.
SystemVerilog
rand int unsigned length
OpenVera
Not supported.
Description
Random number of transaction descriptor in this random scenario.
Constrained to be less than or equal to the maximum number of
transactions in the selected scenario kind.
Example
Example B-3
`vmm_scenario_gen(atm_cell, "atm trans")
class my_scenario extends atm_cell_scenario;
...
constraint scen_length {
if (scenario_kind == START_UP_SEQ)
{ length == 2 } ;
... }
endclass
vmm_scenario::psdisplay()
Creates an image of the scenario descriptor.
SystemVerilog
virtual function string psdisplay(string prefix = "")
OpenVera
Not supported.
Description
Creates human-readable image of the content of the scenario
descriptor.
Example
Example B-4
class my_scenario extends atm_cell_scenario;
int unsigned START_UP_SEQ;
function new()
redefine_scenario(this.START_UP_SEQ,"WAKE_UP_SEQ",5);
...
endfunction
...
endclass
initial begin
...
my_scenario scen_inst = new();
...
$display("Data of the redefined scenario is %s \n",
scen_inst.psdisplay());
...
end
vmm_scenario::redefine_scenario()
Redefines an existing scenario kind.
SystemVerilog
function void redefine_scenario(int unsigned scenario_kind,
string name, int unsigned max_len=0);
OpenVera
Not supported.
Description
Redefines an existing scenario kind, which is included in this
scenario descriptor. The scenario kind may be redefined with a
different name, or maximum number of random transactions.
Use this method to modify, refine, or replace an existing scenario
kind, in a pre-defined scenario descriptor.
Example
Example B-5
class my_scenario extends atm_cell_scenario;
int unsigned START_UP_SEQ;
...
function new()
redefine_scenario(this.START_UP_SEQ,"WAKE_UP_SEQ",5);
...
endfunction
...
endclass
vmm_scenario::repeat_thresh
Repetition warning threshold.
SystemVerilog
static int unsigned repeat_thresh
OpenVera
Not supported.
Description
Specifies a threshold value that triggers a warning about possibly
unconstrained vmm_scenario::repeated data member.
Defaults to 100.
Example
Example B-6
`vmm_scenario_gen(atm_cell, "atm trans")
class my_scenario extends atm_cell_scenario;
...
constraint scen_rep_thresh
{
if (scenario_kind == START_UP_SEQ)
{ //Note: Default constraint is 100 for repeat_thresh.
repeat_thresh < 120 } ;
...
}
endclass
vmm_scenario::repeated
Scenario identifier of the randomizing generator.
SystemVerilog
rand int unsigned repeated
OpenVera
Not supported.
Description
The number of time the entire scenario is repeated. A repetition
value of zero specifies that the scenario will not be repeated, and will
be applied only once.
Constrained to zero, by default, by the
vmm_scenario::repetition constraint block.
Note:It is best to repeat the same transaction, instead of creating a
scenario of many transactions constrained to be identical.
Example
Example B-7
`vmm_scenario_gen(atm_cell, "atm trans")
class my_scenario extends atm_cell_scenario;
...
constraint scen_repetitions
{
if (scenario_kind == START_UP_SEQ)
{ //Note: Default constraint is 0 for repeated.
repeated < 4 } ;
...
}
endclass
vmm_scenario::repetition
Constraint preventing the scenario, from being repeated.
SystemVerilog
constraint repetition {
repeated == 0;
}
OpenVera
Not supported.
Description
The vmm_scenario::repeated data member specifies the
number of times a scenario is repeated. It is not often used, but if left
unconstrained, can cause stimulus to be erroneously repeatedly
applied over two billion times on an average.
This constraint block constrains this data member to prevent
repetition, by default. To have a scenario be repeated a random
number of times, override this constraint block.
Example
Example B-8
class many_atomic_scenario
extends eth_frame_atomic_scenario;
constraint repetition {repeated < 10;}
endclass
vmm_scenario::scenario_id
Scenario identifier of the randomizing generator.
SystemVerilog
int scenario_id
OpenVera
Not supported.
Description
This data member is set by the scenario generator, before
randomization to the current scenario counter value of the generator.
This state variable can be used to specifiy scenario-specific
constraints, or to identify the order of different scenarios within a
stream.
Example
Example B-9
class atm_cell extends vmm_data;
rand int payload[3];
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
class atm_cell_ext extends atm_cell;
...
constraint test {
payload[1] == scenario_id;
...
}
endclass
vmm_scenario::scenario_kind
Scenario kind identified.
SystemVerilog
rand int unsigned scenario_kind
OpenVera
Not supported.
Description
Used to randomly select one of the scenario kinds, which is defined
in this random scenario descriptor.
Example
Example B-10
`vmm_scenario_gen(atm_cell, "atm trans")
class my_scenario extends atm_cell_scenario;
...
constraint start_up_const {
(trans_type == 0 ) -> {scenario_kind inside
{RESET_SEQ,START_UP_SEQ}};
...
}
endclass
vmm_scenario::scenario_name()
Returns the name of a scenario kind.
SystemVerilog
function string scenario_name(int unsigned scenario_kind);
OpenVera
Not supported.
Description
Returns the name of the specified scenario kind, as defined by the
vmm_scenario::define_scenario() or
vmm_scenario::redefine_scenario() methods.
Example
Example B-11
class my_scenario extends atm_cell_scenario;
int unsigned START_UP_SEQ;
...
function new()
redefine_scenario(this.START_UP_SEQ,"WAKE_UP_SEQ",5);
...
endfunction
...
function post_randomize();
$display("Name of the redefined scenario is %s \n",
scenario_name(scenario_kind));
...
endfunction
endclass
vmm_scenario::set_parent_scenario()
Defines higher-level hierarchical scenario.
SystemVerilog
function void set_parent_scenario(
vmm_scenario parent)
OpenVera
Not supported.
Description
Specifies the single stream or multiple-stream scenario that is the
parent of this scenario. This allows this scenario to grab a channel
that is already grabbed by the parent scenario.
Example
Example B-12
class atm_cell extends vmm_data;
rand int payload[3];
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario parent_scen = new;
atm_cell_scenario child_scen = new;
initial begin
vmm_log(log,"Setting parent to a child scenarion \n");
child.scen.set_parent_scenario(parent_scen);
end
endprogram
vmm_scenario::stream_id
Stream identifier of the randomizing generator.
SystemVerilog
int stream_id
OpenVera
Not supported.
Description
This data member is set by the scenario generator, before
randomization to the stream identifier of generator. This state
variable can be used to specific stream-specific constraints, or to
differentiate stimulus from different streams in a scoreboard.
Example
Example B-13
class atm_cell extends vmm_data;
rand int payload[3];
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
class atm_cell_ext extends atm_cell;
...
constraint test {
payload[0] == stream_id;
...}
endclass
vmm_scenario_new()
Start of explicit constructor implementation.
SystemVerilog
vmm_scenario_new(class-name)
OpenVera
Not supported.
Description
Specifies that an explicit user-defined constructor is used, instead of
the default constructor provided by the shorthand macros. Also,
declares a vmm_log instance that can be passed to the base
class constructor. Use this macro when data members must be
explicitly initialized in the constructor.
The class-name specified must be the name of the vmm_scenario
extension class that is being implemented.
This macro should be followed by the constructor declaration, and
must precede the shorthand data member section. This means that
it should be located before the
vmm_scenario_member_begin() macro.
Example
Example B-14
class my_scenario extends vmm_ms_scenario;
...
vmm_scenario_new(my_scenario)
vmm_scenario_member_begin()
Start of shorthand section.
SystemVerilog
vmm_scenario_member_begin(class-name)
OpenVera
Not supported.
Description
Starts the shorthand section providing a default implementation for
the psdisplay(), is_valid(), allocate(), copy(), and
compare() methods. A default implementation for the constructor
is also provided unless the vmm_scenario_new() macro as
been previously specified.
The class-name specified must be the name of the vmm_scenario
extension class that is being implemented.
The shorthand section can only contain shorthand macros and must
be terminated by the vmm_scenario_member_end()
method.
Example
Example B-15
class my_scenario extends vmm_data;
...
vmm_scenario_member_begin(my_scenario)
...
vmm_scenario_member_end(my_scenario)
VMM User Guide
B-80
endclass
vmm_scenario_member_end()
End of shorthand section.
SystemVerilog
vmm_scenario_member_end(class-name)
OpenVera
Not supported.
Description
Terminates the shorthand section, by providing a default
implementation for the psdisplay(), is_valid(), allocate(),
copy(), and compare() methods.
The class-name specified must be the name of the vmm_scenario
extension class that is being implemented.
The shorthand section must be started by the
vmm_scenario_member_begin() method.
Example
Example B-16
class eth_scenario extends vmm_data;
...
vmm_scenario_member_begin(eth_scenario)
...
vmm_scenario_member_end(eth_scenario)
...
endclass
vmm_scenario_member_enum*()
The shorthand implementation for an enumerated data member.
SystemVerilog
vmm_scenario_member_enum(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_enum_array(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_enum_da(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_enum_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_enum_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified enum-type, fixed array of enums, dynamic array
of enums, scalar-indexed associative array of enums, or stringindexed associative array of enums data member to the default
implementation of the methods that are specified by the do_what
argument.
The shorthand implementation must be located in a section started
by vmm_scenario_member_begin() .
Example
Example B-17
typedef enum bit[1:0] {NORMAL, VLAN, JUMBO } frame_type;
class eth_scenario extends vmm_data;
rand frame_type frame_var;
...
`vmm_scenario_member_begin(eth_scenario)
`vmm_scenario_member_enum(frame_var, DO_ALL)
...
`vmm_scenario_member_end(eth_scenario)
...
endclass
vmm_scenario_member_handle*()
The shorthand implementation for a class handle data member.
SystemVerilog
vmm_scenario_member_handle(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_handle_array(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_handle_da(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_handle_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_handle_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified handle-type fixed array of handles, dynamic array
of handles, scalar-indexed associative array of handles, or stringindexed associative array of handles data member to the default
implementation of the methods that are specified by the do_what
argument.
The shorthand implementation must be located in a section started
by vmm_scenario_member_begin() .
Example
Example B-18
class vlan_frame;
...
endclass
class eth_scenario extends vmm_data;
vlan_frame vlan_fr_var ;
...
`vmm_scenario_member_begin(eth_scenario)
`vmm_scenario_member_vmm_handle(vlan_fr_var,
DO_ALL,DO_DEEP)
...
`vmm_scenario_member_end(eth_scenario)
...
endclass
vmm_scenario_member_scalar*()
The shorthand implementation for a scalar data member.
SystemVerilog
vmm_scenario_member_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_scalar_array(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_scalar_da(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_scalar_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_scalar_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified scalar-type, fixed array of scalars, dynamic array
of scalars, scalar-indexed associative array of scalars, or stringindexed associative array of scalars data member to the default
implementation of the methods that are specified by the do_what
argument.
A scalar is an integral type, such as bit, bit vector, and packed
unions.
Example
Example B-19
class eth_scenario extends vmm_data;
rand bit [47:0] da;
...
vmm_scenario_member_begin(eth_scenario)
vmm_scenario_member_scalar(da, DO_ALL);
...
vmm_scenario_member_end(eth_scenario)
...
endclass
vmm_scenario_member_string*()
The shorthand implementation for a string data member.
SystemVerilog
vmm_scenario_member_string(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_string_array(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_string_da(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_string_aa_scalar(member-name,
vmm_data::do_what_e do_what)
vmm_scenario_member_string_aa_string(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified string-type, fixed array of strings, dynamic array
of strings, scalar-indexed associative array of strings, or stringindexed associative array of strings data member to the default
implementation of the methods that are specified by the do_what
argument.
The shorthand implementation must be located in a section started
by vmm_scenario_member_begin() .
Example
Example B-20
class eth_scenario extends vmm_data;
string scen_name;
...
`vmm_scenario_member_begin(eth_scenario)
`vmm_scenario_member_string(scen_name, DO_ALL)
...
`vmm_scenario_member_end(eth_scenario)
...
endclass
vmm_scenario_member_vmm_data*()
The shorthand implementation for a vmm_data-based data member.
SystemVerilog
vmm_scenario_member_vmm_data(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_scenario_member_vmm_data_array(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_scenario_member_vmm_data_da(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_scenario_member_vmm_data_aa_scalar(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
vmm_scenario_member_vmm_data_aa_string(member-name,
vmm_data::do_what_e do_what,
vmm_data::do_how_e do_how)
OpenVera
Not supported.
Description
Adds the specified vmm_data-type, fixed array of vmm_datas,
dynamic array of vmm_datas, scalar-indexed associative array of
vmm_datas, or string-indexed associative array of vmm_datas data
member to the default implementation of the methods that are
Example
Example B-21
class vlan_frame extends vmm_data;
...
endclass
class eth_scenario extends vmm_data;
vlan_frame vlan_fr_var ;
...
`vmm_scenario_member_begin(eth_scenario)
`vmm_scenario_member_vmm_data(vlan_fr_var,
DO_ALL,DO_DEEP)
...
`vmm_scenario_member_end(eth_scenario)
...
endclass
vmm_scenario_member_user_defined()
User-defined shorthand implementation data member.
SystemVerilog
vmm_scenario_member_user_defined(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified user-defined default implementation of the
methods that are specified by the do_what argument.
The shorthand implementation must be located in a section started
by vmm_scenario_member_begin() .
Example
Example B-22
class eth_scenario extends vmm_data;
rand bit[47:0] da;
`vmm_scenario_member_begin(eth_scenario)
`vmm_scenario_member_user_defined(da, DO_ALL)
`vmm_scenario_member_end(eth_scenario)
function bit do_da ( input vmm_data::do_what_e do_what)
do_da = 1; // Success, abort by returning 0
case (do_what)
endcase
endfunction
endclass
vmm_scenario_member_vmm_scenario()
The shorthand implementation for a sub-scenario.
SystemVerilog
vmm_scenario_member_vmm_scenario(member-name,
vmm_data::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified vmm_scenario-type sub-scenario member to the
default implementation of the methods that are specified by the
do_what argument.
The shorthand implementation must be located in a section started
by vmm_scenario_member_begin() .
Example
Example B-23
class vlan_scenario extends vmm_data;
...
endclass
class eth_scenario extends vmm_data;
vlan_scenario vlan_scen ;
`vmm_scenario_member_begin(eth_scenario)
`vmm_scenario_member_vmm_scenario(vlan_scen,
DO_ALL)
`vmm_scenario_member_end(eth_scenario)
endclass
VMM User Guide
B-94
vmm_scenario_gen#(T, text)
Parameterized version of the VMM scenario generator.
SystemVerilog
class vmm_scenario_gen #(type T=vmm_data,string text= )
extends vmm_scenario_gen_base;
Description
The `vmm_scenario_generator macro creates a parameterized
scenario generator. This generator can generate non-vmm_data
transactions as well.
A macro is used to define a class-name_scenario_gen class,
for any user-specified class derived from vmm_data1, using a
process similar to the vmm_channel macro.
The scenario generator class is an extension of the vmm_xactor
class and as such, inherits all the public interface elements provided
in the base class.
Example
class ahb_trans extends vmm_data;
rand bit [31:0] addr;
rand bit [31:0] data;
endclass
`vmm_channel(ahb_trans)
`vmm_scenario_gen(ahb_trans, "AHB Scenario Gen")
1. With a constructor callable without any arguments.
Summary
vmm_scenario_gen::define_scenario() ...............
vmm_scenario_gen::enum {DONE} .....................
vmm_scenario_gen::enum {GENERATED} ...............
vmm_scenario_gen::get_all_scenario_names() .......
vmm_scenario_gen::get_n_insts() ..................
vmm_scenario_gen::get_n_scenarios() ..............
vmm_scenario_gen::get_names_by_scenario() ........
vmm_scenario_gen::get_scenario() .................
vmm_scenario_gen::get_scenario_index() ...........
vmm_scenario_gen::get_scenario_name() ............
vmm_scenario_gen::inject() .......................
vmm_scenario_gen::inject_obj() ...................
vmm_scenario_gen::inst_count .....................
vmm_scenario_gen::new() ..........................
vmm_scenario_gen::out_chan .......................
vmm_scenario_gen::replace_scenario() .............
vmm_scenario_gen::register_scenario() ............
vmm_scenario_gen::scenario_count .................
vmm_scenario_gen::scenario_exists() ..............
vmm_scenario_gen::scenario_set[$] ................
vmm_scenario_gen::select_scenario ................
vmm_scenario_gen::stop_after_n_insts .............
vmm_scenario_gen::stop_after_n_scenarios .........
vmm_scenario_gen::unregister_scenario() ..........
vmm_scenario_gen::unregister_scenario_by_name() ..
vmm_scenario_gen ................................
vmm_scenario_gen_using() ........................
page B-97
page B-98
page B-100
page B-102
page B-103
page B-104
page B-105
page B-106
page B-107
page B-109
page B-110
page B-112
page B-114
page B-115
page B-117
page B-118
page B-120
page B-122
page B-123
page B-125
page B-127
page B-129
page B-131
page B-133
page B-134
page B-136
page B-138
vmm_scenario_gen::define_scenario()
Defines a new scenario kind.
SystemVerilog
function int unsigned define_scenario(string name,
int unsigned max-len);
OpenVera
Not supported.
Description
Defines a new scenario kind that is included in this scenario
descriptor, and returns a unique scenario kind identifier. The
vmm_scenario::scenario_kind data member randomly
selects one of the defined scenario kinds. The new scenario kind
may contain up to the specified number of random transactions.
The scenario kind identifier should be stored in a state variable that
can then be subsequently used to the specified kind-specific
constraints.
vmm_scenario_gen::enum {DONE}
Notification identifier for the vmm_xactor::notify notification
service interface.
SystemVerilog
enum {DONE};
OpenVera
Not supported.
Description
Notification identifier for the vmm_xactor::notify notification
service interface provided by the vmm_xactor base class. It is
configured as a vmm_notify::ON_OFF notification, and is
indicated when the generator stops, because the specified number
of instances or scenarios are generated. No status information is
specified.
Example
Example B-24
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
...
initial
begin
...
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
...
atm_gen.notify.wait_for(atm_cell_scenario_gen::DONE);
$finish;
end
...
endprogram
vmm_scenario_gen::enum {GENERATED}
Notification identifier for the vmm_xactor::notify notification
service interface.
SystemVerilog
enum {GENERATED};
OpenVera
Not supported.
Description
Notification identifier for the vmm_xactor::notify notification
service interface provided by the vmm_xactor base class. It is
configured as a vmm_notify::ONE_SHOT notification, and is
indicated immediately before a scenario is applied to the output
channel. The randomized scenario is specified as the status of the
notification.
Example
Example B-25
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
...
initial
begin
...
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
...
atm_gen.notify.wait_for(
atm_cell_scenario_gen::GENERATED);
end
...
endprogram
vmm_scenario_gen::get_all_scenario_names()
Returns all names in the scenario registry.
SystemVerilog
virtual function void get_all_scenario_names(
ref string
name[$])
OpenVera
Not supported.
Description
Appends the names under which a scenario descriptor is registered.
Returns the number of names that were added to the array.
Example
Example B-26
class atm_cell extends vmm_data;
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
string scen_names_arr[$];
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario atm_scenario = new;
...
initial begin
...
atm_gen.get_all_scenario_names(scen_names_arr);
end
endprogram
vmm_scenario_gen::get_n_insts()
Returns the actual number of instances generated.
SystemVerilog
function int unsigned get_n_insts();
OpenVera
Not supported.
Description
The generator stops after the stop_after_n_insts limit on the
number of instances is reached, and only after entire scenarios are
applied. Hence, it can generate a few more instances than
configured. This method returns the actual number of instances that
were generated.
Example
Example B-27
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
initial
begin
atm_gen.stop_after_n_insts = 10;
atm_gen.start_xactor();
`vmm_note(log,$psprintf(
"Total Instances Generated: %0d",
atm_gen.get_n_insts()));
end
endprogram
vmm_scenario_gen::get_n_scenarios()
Returns the actual number of scenarios generated.
SystemVerilog
function int unsigned get_n_scenarios();
OpenVera
Not supported.
Description
The generator stops after the stop_after_n_scenarios limit on
the number of scenarios is reached, and only after entire scenarios
are applied. Hence, it can generate a few less scenarios than
configured. This method returns the actual number of scenarios that
were generated.
Example
Example B-28
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
initial
begin
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
`vmm_note(log,$psprintf("Total Scenarios Generated:
%0d", atm_gen.get_n_scenarios()));
end
...
endprogram
vmm_scenario_gen::get_names_by_scenario()
Returns the names under which a scenario is registered.
SystemVerilog
virtual function void get_names_by_scenario(
vmm_ss_scenario_base scenario,ref string name[$])
OpenVera
Not supported.
Description
Appends the names under which the specified scenario descriptor is
registered. Returns the number of names that were added to the
array.
Example
Example B-29
class atm_cell extends vmm_data;
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
string scen_names_arr[$];
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario atm_scenario = new;
initial begin
atm_gen.get_names_by_scenario(
atm_scenario,scen_names_arr);
end
endprogram
vmm_scenario_gen::get_scenario()
Returns the scenario registered under a specified name.
SystemVerilog
virtual function vmm_scenario get_scenario(string name)
OpenVera
Not supported.
Description
Returns the scenario descriptor registered under the specified
name. Generates a warning message and returns NULL, if there are
no scenarios registered under that name.
Example
Example B-30
class atm_cell extends vmm_data;
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario atm_scenario = new;
...
initial begin
if(atm_gen.get_scenario("PARENT SCEN") == atm_scenario)
vmm_log(log,"Scenario matching \n");
end
endprogram
vmm_scenario_gen::get_scenario_index()
Returns the index of the specified scenario.
SystemVerilog
virtual function int get_scenario_index(
vmm_ss_scenario_base scenario)
OpenVera
Not supported.
Description
Returns the index of the specified scenario descriptor, which is in the
scenario set array. A warning message is generated and returns -1,
if the scenario descriptor is not found in the scenario set.
Example
Example B-31
class atm_cell extends vmm_data;
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario atm_scenario = new;
...
initial begin
...
scen_index = atm_gen.get_scenario_index(atm_scenario);
if(scen_index == 5)
`vmm_note(log, `vmm_sformatf(
"INDEX MATCHED %0d", index));
else
`vmm_error(log,`vmm_sformatf(
"INDEX NOT MATCHING %0d", index));
...
end
endprogram
vmm_scenario_gen::get_scenario_name()
Returns the name of the specified scenario.
SystemVerilog
virtual function int get_scenario_name(vmm_scenario
scenario)
OpenVera
Not supported.
Description
Returns a name under which the specified scenario descriptor is
registered. Returns "", if the scenario is not registered.
Example
Example B-32
class atm_cell extends vmm_data;
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario atm_scenario = new;
initial begin
scenario_name =
atm_gen.get_scenario_name(atm_scenario);
vmm_note(log,`vmm_sformatf("Registered name for
atm_scenario is : %s\n",scenario_name));
end
endprogram
VMM User Guide
B- 109
vmm_scenario_gen::inject()
Injects the specified scenario descriptor in the output stream.
SystemVerilog
virtual task inject(vmm_ss_scenario#(T) scenario);
OpenVera
Not supported.
Description
Unlike injecting the descriptors directly in the output channel, it
counts toward the number of instances and scenarios generated by
this generator, and will be subjected to the callback methods. The
method returns once the scenario is consumed by the output
channel, or it is dropped by the callback methods.
This method can be used to inject directed stimulus while the
generator is running (with unpredictable timing), or when the
generated is stopped.
Example
Example B-33
class my_scenario extends atm_cell_scenario
...
virtual task apply(atm_cell_channel channel,
ref int unsigned n_insts);
...
this.randomize();
super.apply(channel, n_insts);
...
endtask
...
endclass
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
my_scenario scen;
...
initial
begin
...
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
...
atm_gen.inject(scen);
...
end
...
endprogram
vmm_scenario_gen::inject_obj()
Injects the specified descriptor in the output stream.
SystemVerilog
virtual task inject_obj(class-name obj);
OpenVera
Not supported.
Description
Unlike injecting the descriptor directly in the output channel, it counts
toward the number of instances and scenarios generated by this
generator, and will be subjected to the callback methods as an
atomic scenario. The method returns once the descriptor is
consumed by the output channel, or it is dropped by the callback
methods.
This method can be used to inject directed stimulus while the
generator is running (with unpredictable timing), or when the
generated is stopped.
Example
Example B-34
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12, genchan);
atm_cell tr = new();
...
initial
begin
...
tr.addr = 64'ha0;
tr.data = 64'h50;
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
...
atm_gen.inject_obj(tr);
...
end
...
endprogram
vmm_scenario_gen::inst_count
Returns the number of instances generated so far.
SystemVerilog
protected int inst_count;
OpenVera
protected integer inst_count;
Description
Returns the current count of the number of individual instances
generated by or injected through the scenario generator. When it
reaches or surpasses the value in
vmm_scenario_gen::stop_after_n_insts, the generator
stops.
Example
Example B-35
class generator_ext extends pkt_scenario_gen;
...
function void reset_xactor(reset_e rst_typ = SOFT_RST);
this.inst_count
= 0;
...
endfunction
endclass
vmm_scenario_gen::new()
Creates a new instance of a scenario generator transactor.
SystemVerilog
function new(string instance,
int stream_id = -1, class-name_channel out_chan =
null,vmm_object parent = null);
OpenVera
Not supported.
Description
Creates a new instance of a scenario generator transactor, with the
specified instance name and optional stream identifier. The
generator can be optionally connected to the specified output
channel. If no output channel is specified, one will be created
internally in the class-name_scenario_gen::out_chan
property.
The name of the transactor is defined as the user-defined class
description string, which is specified in the class implementation
macro appended with the Scenario Generator. Specified parent
argument indicates the parent of this generator.
Example
Example B-36
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
vmm_scenario_gen::out_chan
References the output channel for the instances generated by this
transactor.
SystemVerilog
class-name_channel out_chan;
OpenVera
Not supported.
Description
The output channel may be specified through the constructor. If no
output channel was specified, a new instance is automatically
created. The reference in this property may be dynamically replaced,
but the generator should be stopped during the replacement.
Example
Example B-37
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
initial
begin
atm_gen.stop_after_n_insts = 10;
atm_gen.start_xactor();
while (1) begin
atm_gen.out_chan.get(c);
end
end
endprogram
vmm_scenario_gen::replace_scenario()
Replaces a scenario descriptor.
SystemVerilog
virtual function void replace_scenario(string name,
<class-name>_scenario scenario);
OpenVera
Not supported.
Description
Registers the specified scenario under the specified name, replacing
the scenario that is previously registered under that name, if any.
The name under which a scenario is registered does not need to be
the same as the name of a kind of scenario, which is defined in the
scenario descriptor using the
vmm_scenario_gen::define_scenario() method. The same
scenario may be registered multiple times under different names,
therefore creating an alias to the same scenario.
Registering a scenario implicitly appends it to the scenario set, if it is
not already in the vmm_scenario_gen::scenario_set[$]
array. The replaced scenario is removed from the scenario set, if it is
not also registered under another name.
Example
Example B-38
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario parent_scen = new;
...
initial begin
...
atm_gen.register_scenario("MY SCENARIO", parent_scen);
atm_gen.register_scenario("PARENT SCEN", parent_scen);
...
if(atm_gen.scenario_exists("MY SCENARIO")
begin
atm_gen.replace_scenario(
"MY SCENARIO", parent_scen);
vmm_log(log,
"Scenario exists and has been replaced\n");
...
end
end
endprogram
vmm_scenario_gen::register_scenario()
Registers a scenario descriptor.
SystemVerilog
virtual function void register_scenario(string name,
vmm_ss_scenario_base scenario);
OpenVera
Not supported.
Description
Registers the specified scenario under the specified name. The
name under which a scenario is registered does not need to be the
same as the name of a kind of scenario, which is defined in the
scenario descriptor using the
vmm_scenario_gen::define_scenario() method. The same
scenario may be registered multiple times under different names,
therefore creating an alias to the same scenario.
Registering a scenario implicitly appends it to the scenario set, if it is
not already in the vmm_scenario_gen::scenario_set[$]
array.
It is an error to register a scenario under a name that already exists.
Use the vmm_scenario_gen::replace_scenario() method to
replace a registered scenario.
Example
Example B-39
class atm_cell extends vmm_data;
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario parent_scen = new;
...
initial begin
...
vmm_log(log,"Registering scenario \n");
atm_gen.register_scenario("PARENT SCEN", parent_scen);
...
end
endprogram
vmm_scenario_gen::scenario_count
Returns the number of scenarios generated so far.
SystemVerilog
protected int scenario_count;
OpenVera
protected integer scenario_count;
Description
Returns the current count of the number of scenarios generated by
or injected through the scenario generator. When it reaches or
surpasses the value in
vmm_scenario_gen::stop_after_n_scenarios, the
generator stops.
Example
Example B-40
class generator_ext extends pkt_scenario_gen;
...
virtual task inject(pkt_scenario scenario);
scenario.scenario_id = this.scenario_count;
...
endtask
endclass
vmm_scenario_gen::scenario_exists()
Checks whether a scenario is registered under a specified name or
not.
SystemVerilog
virtual function bit scenario_exists(string name)
OpenVera
Not supported.
Description
Returns TRUE, if there is a scenario registered under the specified
name. Otherwise, it returns FALSE.
Use the vmm_scenario_gen::get_scenario() method to
retrieve a scenario under a specified name.
Example
Example B-41
class atm_cell extends vmm_data;
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario parent_scen = new;
...
initial begin
...
vmm_log(log,"Registering scenario \n");
atm_gen.register_scenario("PARENT SCEN", parent_scen);
...
if(atm_gen.scenario_exists("PARENT SCEN") begin
vmm_log(log,"Scenario exists and you can use \n");
...
end
end
endprogram
vmm_scenario_gen::scenario_set[$]
Sets-of available scenario descriptors that may be repeatedly
randomized.
SystemVerilog
vmm_ss_scenario(T) scenario_set[$];
OpenVera
Not supported.
Description
Sets-of available scenario descriptors that may be repeatedly
randomized, to create the random content of the output stream. The
class-name_scenario_gen::select_scenario property is
used to determine which scenario descriptor, out of the available set
of descriptors, is randomized next. The individual instances of the
output stream are then created, by calling the classname_scenario::apply() method of the randomized scenario
descriptor.
By default, this property contains one instance of the atomic scenario
descriptor class-name_atomic_scenario. Out of the box, the
scenario generator generates individual random descriptors.
The vmm_data::stream_id property of the randomized instance
is assigned the value of the stream identifier of the generator, before
randomization. The vmm_data::scenario_id property of the
randomized instance is assigned a unique value, before
randomization. It will be reset to 0, when the generator is reset, and
after the specified number of instances or scenarios are generated.
VMM User Guide
B- 125
Example
Example B-42
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
my_scenario test_scen = new();
...
initial
begin
...
atm_gen.scenario_set.delete();
atm_gen.scenario_set.push_back(test_scen);
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
...
end
...
endprogram
vmm_scenario_gen::select_scenario
Determines which scenario descriptor will be randomized next.
SystemVerilog
vmm_scenario_election#(T,text) select_scenario;
OpenVera
Not supported.
Description
References the scenario descriptor selector that is repeatedly
randomized to determine which scenario descriptor, out of the
available set of scenario descriptors, will be randomized next.
By default, a round-robin selection process is used. The constraint
blocks or randomized properties in this instance can be turned-off, or
the instance can be replaced with a user-defined extension, to
modify the election rules.
Example
Example B-43
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
my_scenario scen;
...
initial
begin
atm_gen.scenario_set.push_back(scen);
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
...
if(atm_gen.select_scenario == null)
`vmm_note(log,"Failed to create select_scenario
instance for ATM Scenario Generator.");
end
...
endprogram
vmm_scenario_gen::stop_after_n_insts
Stops generation, after the specified number of transaction or data
descriptor instances are generated.
SystemVerilog
int unsigned stop_after_n_insts;
OpenVera
Not supported.
Description
The generator stops after the specified number of transaction or data
descriptor instances are generated, and consumed by the output
channel. The generator must be reset, before it can be restarted. If
the value of this property is 0, the generator does not stop on its own,
based on the number of generated instances (but may still stop,
based on the number of generated scenarios).
The default value of this property is 0.
Example
Example B-44
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
...
initial
begin
atm_gen.stop_after_n_insts = 10;
atm_gen.start_xactor();
...
end
...
endprogram
vmm_scenario_gen::stop_after_n_scenarios
Stops generation, after the specified number of scenarios are
generated.
SystemVerilog
int unsigned stop_after_n_scenarios;
OpenVera
Not supported.
Description
The generator stops after the specified number of scenarios are
generated, and entirely consumed by the output channel. The
generator must be reset, before it can be restarted. If the value of this
property is 0, the generator does not stop on its own, based on the
number of generated scenarios (but may still stop, based on the
number of generated instances).
The default value of this property is 0.
Example
Example B-45
program test_scenario;
...
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
...
initial
begin
atm_gen.stop_after_n_scenarios = 10;
atm_gen.start_xactor();
...
end
...
endprogram
vmm_scenario_gen::unregister_scenario()
Unregisters a scenario descriptor.
SystemVerilog
virtual function bit unregister_scenario(
vmm_ss_scenario_base scenario);
OpenVera
Not supported.
Description
Completely unregisters the specified scenario descriptor and returns
TRUE, if it exists in the registry. The unregistered scenario is also
removed from the scenario set.
Example
Example B-46
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario atm_scenario = new;
...
initial begin
if(atm_gen.unregister_scenario(atm_scenario))
vmm_log(log,"Scenario has been unregistered \n");
else
vmm_log(log,"Unable to unregister scenario\n");
end
endprogram
vmm_scenario_gen::unregister_scenario_by_name()
Unregisters a scenario descriptor.
SystemVerilog
virtual function vmm_scenario
unregister_scenario_by_name(string name)
OpenVera
Not supported.
Description
Unregisters the scenario under the specified name, and returns the
unregistered scenario descriptor. Returns NULL, if there is no
scenario registered under the specified name.
The unregistered scenario descriptor is removed from the scenario
set, if it is not also registered under another name.
Example
Example B-47
`vmm_scenario_gen(atm_cell, "atm trans")
program test_scenario;
atm_cell_scenario_gen atm_gen =
new("Atm Scenario Gen", 12);
atm_cell_scenario atm_scenario = new;
atm_cell_scenario buffer_scenario = new;
...
initial begin
...
buffer_scenario =
VMM User Guide
B-134
atm_gen.unregister_scenario_by_name("PARENT SCEN");
if(buffer_scenario != null)
vmm_log(log,"Scenario has been unregistered \n");
...
else
vmm_log(log,"Returned null value\n");
...
end
endprogram
vmm_scenario_gen
Macro to define a scenario generator class to generate sequences
of related instances.
SystemVerilog
vmm_scenario_gen(class_name, "Class Description")
OpenVera
Not supported.
Description
Defines a scenario generator class to generate sequences of related
instances of the specified class. The specified class must be derived
from the vmm_data class, and the class-name_channel class
must exist. It must also contain a constructor with no arguments, or
that contain default values for all of its arguments.
The macro defines classes named
class-name_scenario_gen
class-name_scenario
class-name_scenario_election
class-name_scenario_gen_callbacks
Example
Example B-48
class atm_cell extends vmm_data;
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
vmm_scenario_gen_using()
Defines a scenario generator class to generate sequences of related
instances.
SystemVerilog
vmm_scenario_gen_using( class-name , channel-type,
"Class Description")
OpenVera
Not supported.
Description
Defines a scenario generator class to generate sequences of related
instances of the specified class, using the specified classname_channel output channel. The generated class must be
compatible with the specified channel type, and both must exist.
This macro should be used only when generating instances of a
derived class that must be applied to a channel of the base class.
Example
Example B-49
class atm_cell extends vmm_data;
...
endclass
// `vmm_scenario_gen(atm_cell, "atm trans")
// You cannot use both `vmm_scenario_gen and
// `vmm_scenario_gen_using.
`vmm_scenario_gen_using(atm_cell,atm_cell_channel,
"atm_cell")
<class-name>_scenario
This class implements a base class for describing scenarios or
sequences of transaction descriptors. This class named classname_scenario is automatically declared and implemented for any
user-specified class named class-name by the scenario generator
macro, using a process similar to the vmm_channel macro.
Summary
<class-name>_scenario::allocate_scenario() .......
<class-name>_scenario::apply() ...................
<class-name>_scenario::define_scenario() .........
<class-name>_scenario::fill_scenario() ...........
<class-name>_scenario::items[] ...................
<class-name>_scenario::length ....................
<class-name>_scenario::log .......................
<class-name>_scenario::redefine_scenario() .......
<class-name>_scenario::repeat_thresh .............
<class-name>_scenario::repeated ..................
<class-name>_scenario::scenario_id ...............
<class-name>_scenario::scenario-kind .............
<class-name>_scenario::scenario_name() ...........
<class-name>_scenario::stream_id .................
<class-name>_scenario::using .....................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
B-140
B-142
B-143
B-144
B-145
B-147
B-148
B-149
B-151
B-152
B-153
B-154
B-155
B-156
B-157
<class-name>_scenario::allocate_scenario()
Allocates a new set of instances in the items property.
SystemVerilog
function void
allocate_scenario(class-name using = null);
OpenVera
Not supported.
Description
Allocates a new set of instances in the items property, up to the
maximum number of items that are in the maximum-length scenario.
Any instance previously located in the items array is replaced. If a
reference to an instance is specified in the using argument, the
array is filled by calling the vmm_data::copy() method on the
specified instance. Otherwise, the array is filled with new instance of
the class-name class.
Example
Example B-50
class my_scenario extends atm_cell_scenario;
...
rand write_scenario scen1;
...
constraint test {
if (scenario_kind == ATM) {
repeated == 4;
foreach(items[i]) {
...
items[i].kind == atm_cell::WRITE;
items[i].addr == 64'hfff;
...
}
}
}
...
virtual task apply(atm_cell_channel chan,
ref int unsigned n_insts);
super.apply(chan,n_insts);
this.allocate_scenario(tr);
scen1.apply(chan, n_insts);
...
endtask
...
endclass
<class-name>_scenario::apply()
Applies the items in the scenario descriptor to an output channel.
SystemVerilog
virtual task apply(class-name_channel channel,
ref int unsigned n-insts);
OpenVera
Not supported.
Description
Applies the items in the scenario descriptor to the specified output
channel, and returns when they are consumed by the channel. The
n-insts argument is set to the number of instances that were
consumed by the channel. By default, copies the values of the
items array using the vmm_data::copy() method.
This method may be overloaded to define procedural scenarios.
Example
Example B-51
class dut_ms_sequence;
rand eth_frame_sequence to_phy;
rand eth_frame_sequence to_mac;
rand wb_cycle_sequence to_host;
virtual task apply(eth_frame_channel to_phy_chan,
eth_frame_channel to_mac_chan,
wb_cycle_channel wb_chan);
endtask
endclass: dut_ms_sequence
<class-name>_scenario::define_scenario()
Defines a new scenario.
SystemVerilog
function int unsigned
define_scenario(string name,
int unsigned max-len = 0);
OpenVera
Not supported.
Description
Defines a new scenario with the specified name, and the specified
maximum number of transactions or data descriptors. Returns a
unique scenario identifier that should be assigned to an int
unsigned property.
Example
Example B-52
class my_scenario extends atm_cell_scenario;
...
function new();
...
this.ATM = define_scenario("ATM read write", 6);
...
endfunction
...
endclass
<class-name>_scenario::fill_scenario()
Allocates new instances in the items property.
SystemVerilog
function void fill_scenario(class-name using = null);
OpenVera
Not supported.
Description
Allocates new instances in the items property, up to the maximum
number of items in the maximum-length scenario, in any null
element of the array. Any instance, which is previously located in the
items array is left untouched. If a reference to an instance is
specified in the using argument, the array is filled by calling the
vmm_data::copy() method on the specified instance. Otherwise,
the array is filled with a new instance of the class-name class.
Example
Example B-53
class my_scenario extends atm_cell_scenario;
...
rand write_scenario scen1;
...
virtual task apply(atm_cell_channel chan,
ref int unsigned n_insts);
this.fill_scenario(tr);
scen1.apply(chan, n_insts);
endtask
endclass
<class-name>_scenario::items[]
Instances that are randomized to form the scenarios.
SystemVerilog
rand class-name items[];
OpenVera
Not supported.
Description
Instances of user-specified class-name that are randomized to
form the scenarios. Only elements from index 0 to classname_scenario::length-1 are part of the scenario.
The constraint blocks and rand attributes of the instances in the
randomized array may be turned ON or OFF to modify the constraints
on scenario items. They can also be replaced with extensions.
By default, the output stream is formed by copying the values of the
items in this array, onto the output channel.
Example
Example B-54
class my_scenario extends atm_cell_scenario;
...
constraint test {
if (scenario_kind == ATM) {
length == 4;
foreach(items[i]) {
...
items[i].kind == atm_cell::WRITE;
items[i].addr == 64'hfff;
...
}
}
}
...
endclass
<class-name>_scenario::length
Defines the randomized number of items in the scenario.
SystemVerilog
rand int unsigned length;
OpenVera
Not supported.
Description
Defines how many instances in the classname_scenario::items[] property are part of the scenario.
Example
Example B-55
class my_scenario extends atm_cell_scenario;
...
constraint test {
if (scenario_kind == ATM) {
...
length == 4;
...
}
}
`vmm_note(log,$psprintf("Scenario Length %0d.",length));
...
endclass
<class-name>_scenario::log
Message service interface to be used to issue generic messages.
SystemVerilog
static vmm_log log = new(class-name,class);
OpenVera
Not supported.
Description
Message service interface to be used to issue generic messages,
when the message service interface of the scenario generator is not
available or in scope.
Example
Example B-56
class atm_cell extends vmm_data;
...
endclass
`vmm_scenario_gen(atm_cell, "atm trans")
class my_scenario extends atm_cell_scenario;
...
function new();
`vmm_note(log,
"Display is coming from atm_cell_scenario class.");
...
endfunction
endclass
<class-name>_scenario::redefine_scenario()
Redefines the name and maximum number of descriptors in a
scenario.
SystemVerilog
function void
redefine_scenario(int unsigned scenario-kind,
string name,
int unsigned max-len);
OpenVera
Not supported.
Description
Redefines the name and maximum number of descriptors in a
previously defined scenario. Used to redefine an existing scenario
instead of creating a new one, and constrain the original scenario out
of existence.
Example
Example B-57
class my_scenario extends atm_cell_scenario;
...
function new();
...
this.ATM = define_scenario("ATM read write", 6);
...
endfunction
...
redefine_scenario(scenario_kind,"Redefined our scenario",
10);
...
`vmm_note(log,$psprintf({"After Redefining the
scenario=>\n Scenario Name:","
%0s and Max scenarios:
%0d"},scenario_name(scenario_kind),
get_max_length()));
...
endclass
<class-name>_scenario::repeat_thresh
Threshold for the number of times to repeat a scenario.
SystemVerilog
static int unsigned repeat_thresh;
OpenVera
Not supported.
Description
To avoid accidentally repeating a scenario many times, because the
repeated property was left unconstrained. A warning message is
generated, if the value of the repeated property is greater than the
value specified in this property. The default value is 100.
Example
Example B-58
class my_scenario extends atm_cell_scenario;
function new();
...
this.ATM = define_scenario("ATM read write", 6);
repeat_thresh = 2;
endfunction
constraint test {
repeated == 5;
}
// Here repeated > repeat_thresh so warning will be issued.
// Warning: A scenario will be repeated 5 times...
`vmm_note(log,$psprintf(
"repeat_thresh scenarios: %0d.",repeat_thresh));
endclass
<class-name>_scenario::repeated
Returns the number of times the items in the scenario are repeated.
SystemVerilog
rand int unsigned repeated;
OpenVera
Not supported.
Description
A value of 0 indicates that the scenario is not repeated, hence is
applied only once. The repeated instances in the scenario count
toward the total number of instances generated, but only one
scenario is considered generated, regardless of the number of times
it is repeated.
Example
Example B-59
class my_scenario extends atm_cell_scenario;
...
constraint test {
if (scenario_kind == ATM) {
repeated == 4;
}
}
`vmm_note(log,$psprintf(
"Repeated Scenarios %0d.",repeated));
...
endclass
<class-name>_scenario::scenario_id
Identifies the scenario.
SystemVerilog
int scenario_id;
OpenVera
Not supported.
Description
Identifies the scenario within the stream. It is set by the scenario
generator before the scenario descriptor is randomized, and
incremented after each randomization. Can be used to express
scenario-specific constraints. The scenario identifier is reset to 0
when the scenario generator is reset, or when the specified number
of scenarios are generated.
Example
Example B-60
class my_scenario extends atm_cell_scenario;
...
`vmm_note(log,$psprintf("Scenario ID for
atm_cell_scenario #%0d.",scenario_id));
...
endclass
<class-name>_scenario::scenario-kind
Selects the identifier of the scenario that is generated.
SystemVerilog
rand int unsigned scenario-kind;
OpenVera
Not supported.
Description
When randomized, selects the identifier of the scenario that is
generated. Constrained to the known scenario identifiers defined,
using the class-name_scenario::define_scenario()
method. Can be constrained to modify the distribution of generated
scenarios.
Example
Example B-61
class my_scenario extends atm_cell_scenario;
...
function new();
this.ATM = define_scenario("ATM read write", 6);
scenario_kind = this.ATM;
...
endfunction
...
`vmm_note(log,$psprintf(
"Scenario Kind: %0d.",scenario_kind));
...
endclass
<class-name>_scenario::scenario_name()
Returns the name associated with the specified scenario identifier.
SystemVerilog
function string
scenario_name(int unsigned scenario-kind);
OpenVera
Not supported.
Example
Example B-62
class my_scenario extends atm_cell_scenario;
...
function new();
...
this.ATM = define_scenario("ATM read write", 6);
scenario_kind = this.ATM;
...
endfunction
...
`vmm_note(log,$psprintf("Scenario Name:
%0s",scenario_name(scenario_kind)));
...
endclass
<class-name>_scenario::stream_id
Identifies the stream.
SystemVerilog
int stream_id;
OpenVera
Not supported.
Description
Identifies the stream. It is set by the scenario generator, before the
scenario descriptor is randomized. Can be used to express streamspecific constraints.
Example
Example B-63
class my_scenario extends atm_cell_scenario;
...
function new();
...
this.ATM = define_scenario("ATM read write", 6);
...
endfunction
...
`vmm_note(log,$psprintf(
"Stream ID for atm_cell_scenario #%0d.",stream_id));
...
endclass
<class-name>_scenario::using
Instance used in pre_randomize() when invoking the
fill_scenario() method.
SystemVerilog
class-name using;
OpenVera
Not supported.
Description
Instance used in the default implementation of the
pre_randomize() method, when invoking the
fill_scenario() method. Sets to null, by default. Can be
replaced by an instance of a derived class, to subject the items of the
scenario to different constraints or content.
Example
Example B-64
class my_scenario extends atm_cell_scenario;
function new(atm_cell tr);
...
this.ATM = define_scenario("ATM read write", 6);
this.using = tr;
...
endfunction
endclass
my_scenario atm;
// It will call the fill_scenario method with using object.
atm.pre_randomize();
<class-name>_atomic_scenario
This class implements a predefined atomic scenario descriptor. An
atomic scenario is composed of a single, unconstrained transaction
or data descriptor. The class-name_atomic_scenario class is
automatically implemented for any user-specified class, class-name,
by the scenario generator macro, using a process similar to the
vmm_channel macro.
Summary
<class-name>_atomic_scenario::ATOMIC
Identifier for the atomic scenario.
SystemVerilog
int unsigned ATOMIC;
OpenVera
Not supported.
Description
Symbolic scenario identifier for the atomic scenario, described by
this descriptor. The atomic scenario is a single, random,
unconstrained, and transaction descriptor (that is, an atomic
descriptor).
Example
Example B-65
class my_scenario extends atm_cell_atomic_scenario;
...
constraint repetition {
if (scenario_kind == ATOMIC) {
length == 2;
repeated < 122;
}
}
function new();
...
redefine_scenario(this.ATOMIC, "my_scenario", 2);
...
endfunction
endclass
<class-name>_atomic_scenario::atomic-scenario
Constraints of the atomic scenario.
SystemVerilog
constraint atomic_scenario;
OpenVera
Not supported.
Description
Specifies the constraints of the atomic scenario. By default, the
atomic scenario is a single, unrepeated, and unconstrained item.
This constraint block may be overridden to redefine the atomic
scenario.
Example
Example B-66
class my_scenario extends atm_cell_atomic_scenario;
constraint atomic_scenario {
if (scenario_kind == ATOMIC) {
length == 2;
repeated < 122;
}
}
// If you do not overwrite atomic_scenario constraint then
// Scenario Length = 1
// Repeated Scenario = 0
`vmm_note(log,$psprintf("
Scenario Length: %0d & Repeated Scenario: %0d",
length,repeated);
endclass
<class-name>_scenario_election
This class implements a random selection process for selecting the
next scenario descriptor, from a set of available descriptors, to be
randomized next. The class-name_scenario_election class
is automatically implemented for any user-specified class, classname, by the scenario generator macros, using a process similar to
the vmm_channel macro.
Summary
<class-name>_scenario_election::last_selected[$] .
<class-name>_scenario_election::n_scenarios ......
<class-name>_scenario_election::next_in_set ......
<class-name>_scenario_election::round_robin ......
<class-name>_scenario_election::scenario_id ......
<class-name>_scenario_election::scenario_set[$] ..
<class-name>_scenario_election::select ...........
<class-name>_scenario_election::stream_id ........
page
page
page
page
page
page
page
page
B-162
B-163
B-164
B-165
B-166
B-167
B-168
B-169
<class-name>_scenario_election::last_selected[$]
Returns the history of the last scenario selections.
SystemVerilog
int unsigned last_selected[$];
OpenVera
Not supported.
Description
Returns the history (maximum of 10) of last scenario selections. Can
be used to express constraints based on the historical distribution of
the selected scenarios (for example, Never select the same
scenario twice in a row.).
Example
Example B-67
class scen_election extends atm_cell_scenario_election;
...
endclass
program test_scenario;
scen_election elect;
...
initial
begin
elect.last_selected =
gen.select_scenario.last_selected;
end
...
endprogram
<class-name>_scenario_election::n_scenarios
Number of available scenario descriptors in the scenario set.
SystemVerilog
int unsigned n_scenarios;
OpenVera
Not supported.
Description
The final value of the select property must be in the
[0:n_scenarios-1] range.
Example
Example B-68
class scen_election extends atm_cell_scenario_election;
...
endclass
program test_scenario;
scen_election a_scen;
initial
begin
a_scen.n_scenarios = 5;
...
end
...
endprogram
<class-name>_scenario_election::next_in_set
The next scenario in a round-robin selection process.
SystemVerilog
int unsigned next_in_set;
OpenVera
Not supported.
Description
The next scenario descriptor index that would be selected in a roundrobin selection process. Used by the round_robin constraint
block.
Example
Example B-69
class scen_election extends atm_cell_scenario_election;
...
constraint round_robin {
select == next_in_set;
}
...
endclass
<class-name>_scenario_election::round_robin
Constrains the scenario selection process to a round-robin selection.
SystemVerilog
constraint round_robin;
OpenVera
Not supported.
Description
This constraint block may be turned-off to produce a random
scenario selection process, or allow a different constraint block to
define a different scenario selection process.
Example
Example B-70
class scen_election extends atm_cell_scenario_election;
...
constraint round_robin {
select == next_in_set;
}
...
endclass
<class-name>_scenario_election::scenario_id
Identifies the scenario within the stream.
SystemVerilog
int scenario_id;
OpenVera
Not supported.
Description
It is set by the scenario generator before the scenario selector is
randomized, and incremented after each randomization. Can be
used to express scenario-specific constraints. The scenario identifier
is reset to 0 when the scenario generator is reset, or when the
specified number of scenarios are generated.
Example
Example B-71
`vmm_scenario_gen(atm_cell, "ATM Cell")
class scen_election extends atm_cell_scenario_election;
constraint con_select {
if (this.scenario_id % 5 == 0)
begin
select dist {
0 := 3,
1 := 1
};
end
}
endclass
<class-name>_scenario_election::scenario_set[$]
The set of scenario descriptors.
SystemVerilog
class-name_scenario scenario_set[$];
OpenVera
Not supported.
Description
The available set of scenario descriptors. Can be used to
procedurally determine, which scenario to select or to express
constraints based on the scenario descriptors.
Example
Example B-72
class scen_election extends atm_cell_scenario_election;
...
endclass
program test_scenario;
...
initial
begin
scen_election elect;
atm_cell_scenario_gen gen = new("Scenario Gen");
gen.select_scenario.scenario_set =
elect.scenario_set;
...
end
endprogram
<class-name>_scenario_election::select
The index of the selected scenario to be randomized next.
SystemVerilog
rand int select;
OpenVera
Not supported.
Description
The index, within the scenario_set array, of the selected scenario
descriptor to be randomized next.
Example
Example B-73
class scen_election extends atm_cell_scenario_election;
...
constraint distribution{
select dist {0 := 3,
1 := 1
};
}
...
endclass
<class-name>_scenario_election::stream_id
Stream identifier.
SystemVerilog
int stream_id;
OpenVera
Not supported.
Description
It is set by the scenario generator to the value of the generator
stream identifier, before the scenario selector is randomized. Can be
used to express stream-specific constraints.
Example
Example B-74
`vmm_scenario_gen(atm_cell, "ATM Cell")
class scen_election extends atm_cell_scenario_election;
...
endclass
program test_scenario;
scen_election elect;
...
initial
begin
elect.stream_id =0;
...
end
endprogram
<class-name>_scenario_gen_callbacks
This class implements a faade for callback containments for the
scenario generator transactor. The classname_scenario_gen_callbacks class is automatically
implemented for any user-specified class, class-name, by the
scenario generator macro, using a process similar to the
vmm_channel macro.
Summary
<class-name>_scenario_gen_callbacks::post_scenario_gen() page B-
<class-name>_scenario_gen_callbacks::pre_scenario_randomize() page
171
B-173
<class-name>_scenario_gen_callbacks::post_scenario_gen()
Callback invoked by the generator, after a scenario is randomized.
SystemVerilog
virtual task post_scenario_gen(
class-name_scenario_gen gen,
class-name_scenario scenario,
ref bit dropped);
OpenVera
Not supported.
Description
Callback method invoked by the generator after a new scenario is
randomized, but before it is applied to the output channel. The gen
argument refers to the generator instance that is invoking the
callback method. The scenario argument refers to the newly
randomized scenario that can be modified. Note that any
modifications of the randomization state of the scenario descriptor,
such as turning constraint blocks ON or OFF, remains in effect the
next time the scenario descriptor is selected to be randomized. If the
value of the dropped argument is set to non-zero, then the
generated instance is not applied to the output channel.
Example
Example B-75
`vmm_scenario_gen(atm_cell, "ATM Cell")
class atm_scen_callbacks extends
atm_cell_scenario_gen_callbacks;
<classname>_scenario_gen_callbacks::pre_scenario_randomize()
Callback invoked by the generator after a scenario is selected.
SystemVerilog
virtual task pre_scenario_randomize(
class-name_scenario_gen gen,
ref class-name_scenario scenario);
OpenVera
Not supported.
Description
Callback method invoked by the generator after a new scenario is
selected, but before it is randomized. The gen argument refers to the
generator instance that is invoking the callback method. The
scenario argument refers to the newly selected scenario
descriptor, which can be modified. Note that any modifications of the
randomization state of the scenario descriptor, such as turning
constraint blocks ON or OFF, remains in effect the next time the
scenario descriptor is selected to be randomized. If the reference to
the scenario descriptor is set to null, then the scenario will not be
randomized and a new scenario will be selected.
To minimize memory allocation and collection, it is possible that the
elements of the scenarios may not be allocated. Use the classname_scenario::allocate_scenario() or the classname_scenario::fill_scenario() to allocate the elements of
the scenario, if necessary.
Example
Example B-76
`vmm_scenario_gen(atm_cell, "ATM Cell")
class atm_scen_callbacks extends
atm_cell_scenario_gen_callbacks;
virtual task pre_scenario_randomize(
atm_cell_scenario_gen gen,
ref atm_cell_scenario scenario);
...
endtask
...
endclass
vmm_scheduler
Channels are point-to-point transaction descriptor transfer
mechanisms. If multiple sources are adding descriptors to a single
channel, then the descriptors are interleaved with the descriptors
from the other sources, in a fair but uncontrollable way. If a multipoint-to-point mechanism is required to follow a specific scheduling
algorithm, a vmm_scheduler component can be used to identify
which source stream should next be forwarded to the output stream.
This class is based on the vmm_xactor class.
Summary
vmm_scheduler::log ...............................
vmm_scheduler::new() .............................
vmm_scheduler::new_source() ......................
vmm_scheduler::out_chan ..........................
vmm_scheduler::randomized_sched ..................
vmm_scheduler::reset_xactor() ....................
vmm_scheduler::sched_off() .......................
vmm_scheduler::sched_on ..........................
vmm_scheduler::schedule() ........................
vmm_scheduler::set_output() ......................
vmm_scheduler::start_xactor() ....................
vmm_scheduler::stop_xactor() .....................
page
page
page
page
page
page
page
page
page
page
page
page
B-178
B-179
B-180
B-181
B-182
B-183
B-184
B-185
B-186
B-188
B-189
B-190
vmm_scheduler::get_object()
Extracts the next scheduled transaction descriptor.
SystemVerilog
virtual protected task get_object(
output vmm_data obj,
input vmm_channel source,
input int unsigned input_id,
input int offset);
OpenVera
Not supported.
Description
This method is invoked by the default implementation of the
vmm_scheduler::schedule() method to extract the next
scheduled transaction descriptor from the specified input channel, at
the specified offset within the channel. Overloading this method
allows access to or replacement of the descriptor that is about to be
scheduled. User-defined extensions can be used to introduce errors
by modifying the object, interfere with the scheduling algorithm by
substituting a different object, or recording of the schedule into a
functional coverage model.
Any object that is returned by this method, through the obj
argument, must be either internally created or physically removed
from the input source using the vmm_channel::get() method. If
a reference to the object remains in the input channel (for example,
by using the vmm_channel::peek() or
Example
Example B-77
vmm_data data_obj;
int unsigned input_ids[$];
...
task start();
...
#1;
scheduler.start_xactor();
input_ids = {0,1};
scheduler.schedule(data_obj,sources,input_ids);
scheduler.get_object(data_obj,chan_2,1,0);
...
endtask
vmm_scheduler::log
Message service interface for this scheduler.
SystemVerilog
vmm_log log;
OpenVera
Not supported.
Description
Sets by the constructor, and uses the name and instance name
specified in the constructor.
Example
Example B-78
class atm_scheduler extends vmm_scheduler ;
vmm_log log;
function new(string name, string instance,
vmm_channel out_chan, int instance_id = -1);
super.new(name,instance,out_chan,instance_id);
log = new (name, instance);
...
endfunction
...
endclass
vmm_scheduler::new()
Creates an instance of a channel scheduler.
SystemVerilog
function new(string name,
string instance,
vmm_channel destination,
int instance_id = -1, vmm_object parent = null);
OpenVera
Not supported.
Description
Creates a new instance of a channel scheduler object with the
specified name, instance name, destination channel, and optional
instance identifier. The destination can be assigned to null and set
later by using vmm_scheduler::set_output() .
Example
Example B-79
class atm_subenv extends vmm_subenv;
atm_scheduler scheduler;
atm_cell_channel chan_2;
...
task sub_build();
chan_2 = new("chan_2", "gen");
scheduler = new("schedular","subenv",chan_2,1);
...
endtask
endclass
vmm_scheduler::new_source()
Adds the channel instance to the scheduler.
SystemVerilog
virtual function int new_source(vmm_channel chan);
OpenVera
Not supported.
Description
Adds the specified channel instance, as a new input channel to the
scheduler. This method returns an identifier for the input channel that
must be used to modify the configuration of the input channel or -1,
if an error occurred.
Any user extension of this method must call the
super.new_source() method.
Example
Example B-80
int int_id;
atm_cell_channel sources[$];
function build();
...
sources.push_back(chan_2);
sources.push_back(chan_3);
int_id = scheduler.new_source(chan_1);
int_id = scheduler.new_source(chan_2);
...
endfunction
vmm_scheduler::out_chan
Reference to the output channel.
SystemVerilog
protected vmm_channel out_chan;
OpenVera
Not supported.
Description
Set by the constructor.
Example
Example B-81
class atm_scheduler extends vmm_scheduler ;
function new(string name, string instance,
vmm_channel out_chan, int instance_id = -1);
...
this.out_chan = out_chan;
...
endfunction
...
endclass
vmm_scheduler::randomized_sched
Factory instance randomized by the default implementation of the
vmm_scheduler::schedule() method.
SystemVerilog
vmm_scheduler_election randomized_sched;
OpenVera
Not supported.
Description
Can be replaced with user-defined extensions, to modify the election
rules.
Example
Example B-82
class atm_scheduler extends vmm_scheduler ;
...
function new(string name, string instance,
vmm_channel out_chan, int instance_id = -1);
...
randomized_sched.id_history[instance_id] = instance_id;
...
endfunction
...
endclass
vmm_scheduler::reset_xactor()
Resets this vmm_scheduler instance.
SystemVerilog
virtual function void
reset_xactor(vmm_xactor::reset_e rst_typ = SOFT_RST);
OpenVera
Not supported.
Description
The output channel and all input channels are flushed. If a
HARD_RST reset type is specified, then the scheduler election
factory instance in the randomized_sched property is replaced
with a new default instance.
Example
Example B-83
class atm_env extends vmm_env;
...
task reset_dut();
scheduler.reset_xactor();
...
endtask
...
endclass
vmm_scheduler::sched_off()
Turns-off scheduling from the specified input channel.
SystemVerilog
virtual function void sched_off(int unsigned input-id);
OpenVera
Not supported.
Description
By default, scheduling from an input channel is on. When scheduling
is turned off, the input channel is not flushed and the scheduling of
new transaction descriptors from that source channel is inhibited.
The scheduling of descriptors from that source channel is resumed,
as soon as scheduling is turned on.
Any user extension of this method should call the
super.sched_off() method.
vmm_scheduler::sched_on
Turns-on scheduling from the specified input channel.
SystemVerilog
virtual function void sched_on(int unsigned input-id);
OpenVera
Not supported.
Description
By default, scheduling from an input channel is on. When scheduling
is turned off, the input channel is not flushed and the scheduling of
new transaction descriptors from that source channel is inhibited.
The scheduling of descriptors from that source channel is resumed,
as soon as scheduling is turned on.
Any user extension of this method should call the
super.sched_on() method.
vmm_scheduler::schedule()
Creates scheduling components with different rules.
SystemVerilog
virtual protected task
schedule(output vmm_data obj,
input vmm_channel sources[$],
int unsigned input_ids[$]);
OpenVera
Not supported.
Description
Overloading this method allows the creation of scheduling
components with different rules. It is invoked for each scheduling
cycle. The transaction descriptor returned by this method in the obj
argument is added to the output channel. If this method returns
null, no descriptor is added for this scheduling cycle. The input
channels provided in the sources argument are all the currently
non-empty ON input channels. Their corresponding input identifier is
found in the input_ids argument.
New scheduling cycles are attempted, whenever the output channel
is not full. If no transaction descriptor is scheduled from any of the
currently non-empty source channels, then the next scheduling cycle
will be delayed until an additional ON source channel becomes nonempty. Lock-up occurs, if there are no empty input channels and no
OFF channels.
Example
Example B-84
vmm_data data_obj;
int unsigned input_ids[$];
...
task start();
...
#1;
scheduler.start_xactor();
input_ids = {0,1};
scheduler.schedule(data_obj,sources,input_ids);
...
endtask
...
vmm_scheduler::set_output()
Specifies the channel as the destination if not set previously.
System Verilog
function void set_output(vmm_channel destination);
Open Vera
Not supported
Description
Identifies the channel as the destination of the scheduler if the
destination is not set previously. If destination is already set, then a
warning is issued stating that this particular call has been ignored.
Example
Example B-85
class atm_env extends vmm_group;
...
void function build_ph();
scheduler = new("schedular","subenv",null,1);
...
endfunction
...
void function connect_ph();
scheduler.set_output(out_chan);
...
endfunction
...
endclass
vmm_scheduler::start_xactor()
Starts this vmm_scheduler instance.
SystemVerilog
virtual function void start_xactor();
OpenVera
Not supported.
Description
The scheduler can be stopped. Any extension of this method must
call super.start_xactor().
Example
Example B-86
class atm_env extends vmm_env;
...
task start();
scheduler.start_xactor();
...
endtask
...
endclass
vmm_scheduler::stop_xactor()
Suspends this vmm_scheduler instance.
SystemVerilog
virtual function void stop_xactor();
OpenVera
Not supported.
Description
The scheduler can be restarted. Any extension of this method must
the call super.stop_xactor() method.
Example
Example B-87
class atm_env extends vmm_env;
...
task stop();
scheduler.stop_xactor();
...
endtask
...
endclass
vmm_scheduler_election
This class implements a round-robin election process by default. In
its current form, turning it into a random election process requires
that this class be extended. To simplify this process, you need to just
turn-off the default_round_robin constraint block.
The following class properties should be read or added:
vmm_scheduler_election::next_idx
vmm_scheduler_election::source_idx
vmm_scheduler_election::obj_offset
Summary
vmm_scheduler_election::default_round_robin ......
vmm_scheduler_election::election_id ..............
vmm_scheduler_election::id_history[$] ............
vmm_scheduler_election::ids[$] ...................
vmm_scheduler_election::instance_id ..............
vmm_scheduler_election::n_sources ................
vmm_scheduler_election::next_idx .................
vmm_scheduler_election::obj_history[$] ...........
vmm_scheduler_election::obj_offset ...............
vmm_scheduler_election::post_randomize() .........
vmm_scheduler_election::source_idx ...............
vmm_scheduler_election::sources[$] ...............
page
page
page
page
page
page
page
page
page
page
page
page
B-192
B-193
B-194
B-195
B-196
B-197
B-198
B-199
B-200
B-201
B-202
B-203
vmm_scheduler_election::default_round_robin
Constraints required by the default round-robin election process.
SystemVerilog
constraint default_round_robin;
OpenVera
Not supported.
Example
Example B-88
class atm_scheduler_election extends
vmm_scheduler_election;
...
constraint default_round_robin {
source_idx == next_idx;
}
constraint vmm_scheduler_election_valid {
obj_offset == 0;
source_idx >= 0;
source_idx < n_sources;
}
...
endclass
vmm_scheduler_election::election_id
Incremented by the vmm_scheduler instance.
SystemVerilog
int unsigned election_id;
OpenVera
Not supported.
Description
Incremented by the vmm_scheduler instance that is randomizing
this object instance before every election cycle. Can be used to
specified election-specific constraints.
Example
Example B-89
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf("election_id method
%0d ",randomized_sched.election_id));
endfunction
...
endclass
vmm_scheduler_election::id_history[$]
A queue of input identifiers.
SystemVerilog
int unsigned id_history[$];
OpenVera
Not supported.
Description
A queue of the (up to) 10 last input identifiers that were elected.
Example
Example B-90
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"id_history.size method %0d ",
randomized_sched.id_history.size));
foreach(randomized_sched.id_history[i])
`vmm_note(log,$psprintf("ids[%0d] = %0d ",i,
randomized_sched.id_history[i]));
endfunction
...
endclass
vmm_scheduler_election::ids[$]
Input identifiers corresponding to the source channels.
SystemVerilog
int unsigned ids[$];
OpenVera
Not supported.
Description
Unique input identifiers corresponding to the source channels, at the
same index, in the sources array.
Example
Example B-91
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"ids.size method %0d ",
randomized_sched.ids.size));
foreach(randomized_sched.ids[i])
`vmm_note(log,$psprintf(
"ids[%0d] = %0d ",i,
randomized_sched.ids[i]));
endfunction
...
endclass
vmm_scheduler_election::instance_id
Instance identifier of a vmm_scheduler class instance.
SystemVerilog
int instance_id;
OpenVera
Not supported.
Description
Instance identifier of the vmm_scheduler class instance that is
randomizing this object instance. Can be used to specify the
instance-specific constraints.
Example
Example B-92
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"instance_id method %0d ",
randomized_sched.instance_id));
endfunction
...
endclass
vmm_scheduler_election::n_sources
Number of sources.
SystemVerilog
int unsigned n_sources;
OpenVera
Not supported.
Description
Similar to the vmm_scheduler_election::sources.size()
method.
Example
Example B-93
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"n_sources method %0d ",
randomized_sched.n_sources));
endfunction
...
endclass
vmm_scheduler_election::next_idx
Assign to source_idx for a round-robin process.
SystemVerilog
int unsigned next_idx;
OpenVera
Not supported.
Description
This is the value to assign to source_idx, to implement a roundrobin election process.
Example
Example B-94
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"next_idx = %0d ",
randomized_sched.next_idx));
endfunction
...
endclass
vmm_scheduler_election::obj_history[$]
A list of transaction descriptors.
SystemVerilog
vmm_data obj_history[$];
OpenVera
Not supported.
Description
A list of the (up to) 10 last transaction descriptors that were elected.
Example
Example B-95
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"obj_history.size method %0d ",
randomized_sched.obj_history.size));
foreach(randomized_sched.obj_history[i])
`vmm_note(log,$psprintf(
"obj_history[%0d] = %0d ",i,
randomized_sched.obj_history[i]));
endfunction
...
endclass
vmm_scheduler_election::obj_offset
Offset of the elected transaction descriptor, within the elected source
channel.
SystemVerilog
rand int unsigned obj_offset;
OpenVera
Not supported.
Description
Offset, within the source channel indicated by the source_idx
property of the elected transaction descriptor, within the elected
source channel. This property is constrained to be 0 in the
vmm_scheduler_election_valid constraint block, to preserve
ordering of the input streams.
Example
Example B-96
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"obj_offset = %0d",randomized_sched.obj_offset));
endfunction
...
endclass
vmm_scheduler_election::post_randomize()
Performs the round-robin election.
SystemVerilog
function void post_randomize();
OpenVera
Not supported.
Description
The default implementation of this method helps to perform the
round-robin election.
Example
Example B-97
class atm_scheduler_election extends
vmm_scheduler_election;
function void pre_randomize();
default_round_robin.constraint_mode(0);
vmm_scheduler_election_valid.constraint_mode(0);
...
endfunction
endclass
class atm_scheduler extends vmm_scheduler ;
atm_scheduler_election randomized_sched;
...
function new(...)
randomized_sched = new();
endfunction
endclass
vmm_scheduler_election::source_idx
Index in the sources array of the elected source channel.
SystemVerilog
rand int unsigned source_idx;
OpenVera
Not supported.
Description
An index of 1 indicates no election. The
vmm_scheduler_election_valid constraint block constrains
this property to be in the 0 to sources.size()-1 range.
Example
Example B-98
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"source_idx = %0d",randomized_sched.source_idx));
endfunction
...
endclass
vmm_scheduler_election::sources[$]
Input source channels with transaction descriptors available to be
scheduled.
SystemVerilog
vmm_channel sources[$];
OpenVera
Not supported.
Example
Example B-99
class atm_scheduler extends vmm_scheduler ;
...
function void my_disp();
`vmm_note(log,$psprintf(
"sources.size method %0d ",
randomized_sched.sources.size));
endfunction
...
endclass
vmm_ss_scenario#(T)
Parameterized version of the VMM single stream scenario.
SystemVerilog
class vmm_ss_scenario #(type T) extends
vmm_ss_scenario_base;
Description
The parameterized single stream scenario is used by the
parameterized scenario generator. It extends the vmm_scenario.
You can extend this class to create a scenario.
Example
class ahb_trans extends vmm_data;
rand bit [31:0] addr;
rand bit [31:0] data;
endclass
`vmm_channel(ahb_trans)
`vmm_scenario_gen(ahb_trans, "AHB Scenario Gen")
class user_scenario extends ahb_trans_scenario;
endclass
vmm_simulation
The vmm_simulation class extending from vmm_unit is a toplevel singleton module that manages the end-to-end simulation
timelines. It includes pre-test and post-test timelines with predefined
pre-test and post-test phases. The predefined pre-test phases are
build, configure, and connect. The predefined post-test
phase is final.
Example
program tb_top;
class my_test extends vmm_test;
...
endclass
class my_env extends vmm_group;
...
endclass
initial begin
my test test1 = new("test1");
my_env env = new("env");
vmm_simulation my_sim;
my_sim = vmm_simulation :: get_sim();
...
end
endprogram
Summary
vmm_simulation::allow_new_phases() ...............
vmm_simulation::display_phases() .................
vmm_simulation::get_post_timeline() ..............
vmm_simulation::get_pre_timeline() ...............
vmm_simulation::get_sim() ........................
vmm_simulation::get_top_timeline() ...............
vmm_simulation::run_tests() ......................
page
page
page
page
page
page
page
B-206
B-207
B-208
B-209
B-210
B-211
B-212
vmm_simulation::allow_new_phases()
Enables the addition of user-defined phases in timelines.
SystemVerilog
static function void vmm_simulation::allow_new_phases(
bit allow = 1)
Description
Enables the addition of user-defined phases in timelines, if allow is
true. If the insertion of a user-defined phase is attempted, when new
phases are not allowed, an error message is issued.
By default, addition of user-defined phases are not allowed.
Example
program tb_top;
class my_test extends vmm_test;
...
endclass
class my_env extends vmm_group;
...
endclass
initial begin
my test test1 = new("test1");
my_env env = new("env");
...
vmm_simulation::allow_new_phases();
// insert new phases using
// vmm_timeline::insert_phase();
end
endprogram
vmm_simulation::display_phases()
Displays how various phases in the various timelines will be
executed.
SystemVerilog
static function void vmm_simulation::display_phases()
Description
Displays how various phases in the various timelines will be
executed (that is, in sequence or in parallel). Should be invoked after
the build phase.
Example
program tb_top;
class my_test extends vmm_test;
virtual function void start_of_sim_ph();
vmm_simulation::display_phases();
endfunction
endclass
class my_env extends vmm_group;
endclass
initial begin
my test test1 = new("test1");
my_env env = new("env");
...
vmm_simulation::run_tests();
end
endprogram
vmm_simulation::get_post_timeline()
Returns the post-test timeline.
SystemVerilog
static function vmm_timeline
vmm_simulation::get_post_timeline()
Description
Returns the post-test timeline.
vmm_simulation::get_pre_timeline()
Returns the pre-test timeline.
SystemVerilog
static function vmm_timeline
vmm_simulation::get_pre_timeline()
Description
Returns the pre-test timeline.
vmm_simulation::get_sim()
Returns the vmm_simulation singleton.
SystemVerilog
static function vmm_simulation vmm_simulation::get_sim()
Description
Returns the vmm_simulation singleton.
Example
program tb_top;
class my_test extends vmm_test;
...
endclass
class my_env extends vmm_group;
...
endclass
initial begin
my test test1 = new("test1");
my_env env = new("env");
vmm_simulation my_sim;
...
my_sim = vmm_simulation :: get_sim();
...
end
endprogram
vmm_simulation::get_top_timeline()
Returns the top-level test timeline.
SystemVerilog
static function vmm_timeline
vmm_simulation::get_top_timeline()
Description
Returns the top-level test timeline.
Example
program tb_top;
class my_test extends vmm_test;
...
endclass
class my_env extends vmm_group;
...
endclass
initial begin
my test test1 = new("test1");
my_env env = new("env");
vmm_timeline my_tl;
...
my_tl = vmm_simulation::get_top_timeline();
...
end
endprogram
vmm_simulation::run_tests()
Run tests specified at runtime.
SystemVerilog
task vmm_simulation::run_tests()
Description
Run tests specified at runtime using the +vmm_test or
+vmm_test_file, or runs default test
The following is the usage of +vmm_test_file and +vmm_test to
specify testcase at runtime:
+vmm_test_file+<file name>
- will run list of tests
specified in the file (if concatenation is allowed, otherwise
issues a fatal message)
+vmm_test=<testname>+<testname>+...
Run list of specified tests
+vmm_test=<test name>
- run specific test
+vmm_test=ALL_TESTS - run all the registered tests (if
concatenation is allowed, otherwise issues a fatal message)
Example
program tb_top;
class my_test extends vmm_test;
endclass
class my_env extends vmm_group;
endclass
initial begin
my test test1 = new("test1");
my_env env = new("env");
....
vmm_simulation::run_tests();
end
endprogram
vmm_subenv
This is a base class used to encapsulate a reusable subenvironment.
Summary
vmm_subenv::cleanup() ............................
vmm_subenv::configured() .........................
vmm_subenv::do_psdisplay() .......................
vmm_subenv::do_start() ...........................
vmm_subenv::do_stop() ............................
vmm_subenv::do_vote() ............................
vmm_subenv::do_what_e ............................
vmm_subenv::end_test .............................
vmm_subenv::log ..................................
vmm_subenv::new() ................................
vmm_subenv::report() .............................
vmm_subenv::start() ..............................
vmm_subenv::stop() ...............................
vmm_subenv_member_begin() .......................
vmm_subenv_member_channel*() ....................
vmm_subenv_member_end() .........................
vmm_subenv_member_enum*() .......................
vmm_subenv_member_scalar*() .....................
vmm_subenv_member_string*() .....................
vmm_subenv_member_subenv*() .....................
vmm_subenv_member_user_defined() ................
vmm_subenv_member_vmm_data*() ...................
vmm_subenv_member_xactor*() .....................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
B-215
B-216
B-217
B-218
B-219
B-220
B-221
B-222
B-223
B-224
B-226
B-227
B-228
B-229
B-230
B-232
B-233
B-235
B-237
B-239
B-241
B-242
B-244
vmm_subenv::cleanup()
Verifies end-of-test conditions.
SystemVerilog
virtual task cleanup();
OpenVera
virtual task cleanup_t();
Description
Stops the sub-environment (if not already stopped), and then verifies
any end-of-test conditions.
The base implementation must be called using the
super.cleanup(), by any extension of this method, in a userdefined extension of this base class.
Example
Example B-100
class my_vmm_subenv extends vmm_subenv;
...
virtual task cleanup()
super.cleanup();
...
endtask
...
endclass
vmm_subenv::configured()
Indicates that the DUT is configured.
SystemVerilog
protected function void configured();
OpenVera
protected task configured();
Description
Reports to the base class that the sub-environment and associated
DUT are configured appropriately, and that the sub-environment is
ready to be started.
This method must be called by a user-defined configured()
method in the extension of this base class.
Example
Example B-101
class my_vmm_subenv extends vmm_subenv;
...
protected function void configured(...);
// Configuration of sub environment and corresponding
// portion of DUT
...
super.configured();
endfunction
...
endclass
vmm_subenv::do_psdisplay()
Overrides the shorthand psdisplay() method.
SystemVerilog
virtual function string do_psdisplay(string prefix = "")
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_subenv::psdisplay() method, created by the
vmm_subenv shorthand macros. If defined, it will be used instead of
the default implementation.
Example
Example B-102
class my_vmm_subenv extends vmm_subenv;
...
`vmm_subenv_member_begin( my_vmm_subenv)
...
`vmm_subenv_member_end( my_vmm_subenv)
virtual function string do_psdisplay(string prefix = "");
$sformat(do_psdisplay,"%s Printing sub environment
members \n",prefix);
...
endfunction
...
endclass
vmm_subenv::do_start()
Overrides the shorthand start() method.
SystemVerilog
protected virtual task do_start()
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_subenv::start() method created by the vmm_subenv
shorthand macros. If defined, it will be used instead of the default
implementation.
Example
Example B-103
class my_vmm_subenv extends vmm_subenv;
...
`vmm_subenv_member_begin( my_vmm_subenv)
...
`vmm_subenv_member_end( my_vmm_subenv)
protected virtual task do_start();
//vmm_subenv::start() operations
...
endtask
...
endclass
vmm_subenv::do_stop()
Overrides the shorthand stop() method.
SystemVerilog
protected virtual task do_stop()
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_subenv::stop() method created by the vmm_subenv
shorthand macros. If defined, it will be used instead of the default
implementation.
Example
Example B-104
class my_vmm_subenv extends vmm_subenv;
...
`vmm_subenv_member_begin( my_vmm_subenv)
...
`vmm_subenv_member_end( my_vmm_subenv)
protected virtual task do_stop();
//vmm_subenv::stop() operations
...
endtask
...
endclass
vmm_subenv::do_vote()
Overrides the shorthand voter registration.
SystemVerilog
protected virtual task do_vote()
OpenVera
Not supported.
Description
This method overrides the default implementation of the voter
registration, created by the vmm_subenv shorthand macros. If
defined, it will be used instead of the default implementation.
Example
Example B-105
class my_vmm_subenv extends vmm_subenv;
...
`vmm_subenv_member_begin( my_vmm_subenv)
...
`vmm_subenv_member_end( my_vmm_subenv)
protected virtual task do_vote();
//Register with this.end_vote
...
endtask
...
endclass
vmm_subenv::do_what_e
Specifies which methods are to be provided by a shorthand
implementation.
SystemVerilog
enum {DO_PRINT, DO_START, DO_STOP,
DO_VOTE, DO_ALL} do_what_e;
OpenVera
Not supported.
Description
Used to specify which methods are to include the specified data
members in their default implementation. "DO_PRINT" includes the
member in the default implementation of the psdisplay() method.
"DO_START" includes the member in the default implementation of
the start() method, if applicable. "DO_STOP" includes the
member in the default implementation of the stop() method, if
applicable. "DO_VOTE" automatically registers the member with the
vmm_subenv::end_test consensus instance, if applicable.
Multiple methods can be specified by adding or using the or
symbolic values. All methods are specified by specifying the
"DO_ALL" symbol.
Example
Example B-106
vmm_subenv_member_subenv(idler, DO_ALL - DO_STOP);
vmm_subenv::end_test
End-of-test consensus interface.
SystemVerilog
protected vmm_consensus end_test;
OpenVera
protected vmm_consensus end_test;
Description
Local copy of the vmm_consensus reference supplied to the
constructor. It may be used to indicate if the sub-environment and its
components consent to or oppose the ending of the test.
Unless an objection is indicated, the sub-environment will consent by
default.
Example
Example B-107
class my_vmm_subenv extends vmm_subenv;
...
function new(string name,string inst,
vmm_consensus end_test);
super.new(name,inst,end_test);
...
endfunction
...
endclass
vmm_subenv::log
Message service interface for the sub-environment.
SystemVerilog
vmm_log log;
OpenVera
rvm_log log;
Description
This property is set by the constructor, using the specified name and
instance name. These names may be modified, afterward, using the
vmm_log::set_name() or vmm_log::set_instance()
methods.
Example
Example B-108
class my_vmm_subenv extends vmm_subenv;
vmm_log log;
...
function new(string name,string inst,
vmm_consensus end_test);
...
`vmm_debug(log,"Sub Environment new done");
endfunction
...
endclass
vmm_subenv::new()
Creates a new instance of this sub-environment base class.
SystemVerilog
function new(string name,
string inst,
vmm_consensus end_test,
vmm_object parent = null);
With +define NO_VMM12
function new(string name,
string inst,
vmm_consensus end_test);
OpenVera
task new(string name,
string inst,
vmm_consensus end_test);
Description
Creates a new instance of this base class with the specified name
and instance name. The specified name and instance names are
used as the name and instance names of the log class property.
The specified end-of-test consensus object is assigned to the
end_test class property, and may be used by the sub-environment
to indicate that it opposes or consents to the ending of the test.
Example
Example B-109
class my_vmm_subenv extends vmm_subenv;
...
function new(string name,string inst,
vmm_consensus end_test, vmm_object parent = null);
super.new(name,inst,end_test, parent);
endfunction
endclass
vmm_subenv::report()
Reports information collected by the sub-environment.
SystemVerilog
virtual function void report();
OpenVera
virtual task report();
Description
Reports status, coverage, or statistical information collected by the
sub-environment, but not pass or fail of the test or sub-environment.
This method needs to be extended. It may also be invoked multiple
times during the simulation.
Example
Example B-110
class my_vmm_subenv extends vmm_subenv;
...
virtual function void report()
super.report();
...
endfunction
...
endclass
vmm_subenv::start()
Starts the sub-environment.
SystemVerilog
virtual task start();
OpenVera
virtual task start_t();
Description
Starts the sub-environment. An error is reported, if this method is
called before the sub-environment and DUT is reported as
configured to the sub-environment base class, using the
vmm_consensus::unregister_voter() method.
A stopped sub-environment may be restarted.
The base implementation must be called using the super.start()
method, by any extension of this method in a user-defined
extension of this base class.
Example
Example B-111
class my_vmm_subenv extends vmm_subenv;
...
virtual task start()
super.start();
this.my_xactor.start_xactor();
endtask
endclass
vmm_subenv::stop()
Stops the sub-environment.
SystemVerilog
virtual task stop();
OpenVera
virtual task stop_t();
Description
Stops the sub-environment to terminate the test cleanly. An error is
generated, if the sub-environment is not previously started.
The base implementation must be called using the super.stop()
method, by any extension of this method in a user-defined extension
of this base class.
Example
Example B-112
class my_vmm_subenv extends vmm_subenv;
...
virtual task stop()
super.stop();
this.my_xactor.stop_xactor();
...
endtask
...
endclass
vmm_subenv_member_begin()
Starts of shorthand section.
SystemVerilog
vmm_subenv_member_begin(class-name)
OpenVera
Not supported.
Description
Starts the shorthand section providing a default implementation for
the psdisplay(), start() and stop() methods.
The class-name specified must be the name of the vmm_subenv
extension class that is being implemented.
The shorthand section can only contain shorthand macros, and must
be terminated by the vmm_subenv_member_end() method.
Example
Example B-113
class tcpip_stack extends vmm_subenv;
...
vmm_subenv_member_begin(tcpip_stack)
...
vmm_subenv_member_end(tcpip_stack)
...
endclass
vmm_subenv_member_channel*()
Shorthand implementation for a channel data member.
SystemVerilog
vmm_subenv_member_channel(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_channel_array(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_channel_aa_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_channel_aa_string(member-name,
vmm_subenv::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified channel-type, array of channels, dynamic array of
channels, scalar-indexed associative array of channels, or stringindexed associative array of channels data member to the default
implementation of the methods specified by the do_what
argument.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-114
class my_vmm_subenv extends vmm_subenv;
data_channel subenv_channel;
...
`vmm_subenv_member_begin(my_vmm_subenv)
`vmm_subenv_member_channel(subenv_channel,DO_ALL)
...
`vmm_subenv_member_end(my_vmm_subenv)
...
endclass
vmm_subenv_member_end()
End of shorthand section.
SystemVerilog
vmm_subenv_member_end(class-name)
OpenVera
Not supported.
Description
Terminates the shorthand section providing a default implementation
for the psdisplay(), start() and stop() methods.
The class-name specified must be the name of the vmm_subenv
extension class that is being implemented.
The shorthand section must be started by the
vmm_subenv_member_begin() method.
Example
Example B-115
class my_vmm_subenv extends vmm_subenv;
...
`vmm_subenv_member_begin(my_vmm_subenv)
...
`vmm_subenv_member_end(my_vmm_subenv)
...
endclass
vmm_subenv_member_enum*()
Shorthand implementation for an enumerated data member.
SystemVerilog
vmm_subenv_member_enum(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_enum_array(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_enum_aa_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_enum_aa_string(member-name,
vmm_subenv::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified enum-type, array of enums, scalar-indexed
associative array of enums, or string-indexed associative array of
enums data member to the default implementation of the methods
specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-116
typedef enum {blue,green,red,black} my_colors;
vmm_subenv_member_scalar*()
Shorthand implementation for a scalar data member.
SystemVerilog
vmm_subenv_member_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_scalar_array(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_scalar_aa_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_scalar_aa_string(member-name,
vmm_subenv::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified scalar-type, array of scalars, scalar-indexed
associative array of scalars or string-indexed associative array of
scalars data member to the default implementation of the methods
specified by the do_what argument.
A scalar is an integral type, such as bit, bit vector, and packed
unions.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-117
class my_vmm_subenv extends vmm_subenv;
bit [31:0] address;
...
`vmm_subenv_member_begin(my_vmm_subenv)
`vmm_subenv_member_scalar(address,DO_ALL)
...
`vmm_subenv_member_end(my_vmm_subenv)
...
endclass
vmm_subenv_member_string*()
Shorthand implementation for a string data member.
SystemVerilog
vmm_subenv_member_string(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_string_array(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_string_aa_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_string_aa_string(member-name,
vmm_subenv::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified string-type, array of strings, scalar-indexed
associative array of strings, or string-indexed associative array of
strings data member to the default implementation of the methods
specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-118
class my_vmm_subenv extends vmm_subenv;
string xactor_name;
...
`vmm_subenv_member_begin(my_vmm_subenv)
`vmm_subenv_member_string(xactor_name,DO_ALL)
...
`vmm_subenv_member_end(my_vmm_subenv)
...
endclass
vmm_subenv_member_subenv*()
Shorthand implementation for a transactor data member.
SystemVerilog
vmm_subenv_member_subenv(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_subenv_array(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_subenv_aa_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_subenv_aa_string(member-name,
vmm_subenv::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified sub-environment-type, array of subenvironments, dynamic array of sub-environments, scalar-indexed
associative array of sub-environments, or string-indexed associative
array of sub-environments data member to the default
implementation of the methods specified by the do_what
argument.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-119
class sub_subenv extends vmm_subenv;
function new(....);
super.new(...);
...
endfunction
endclass
class my_vmm_subenv extends vmm_subenv;
sub_subenv sub_subenv_inst;
...
`vmm_subenv_member_begin(my_vmm_subenv)
`vmm_subenv_member_subenv(sub_subenv_inst,DO_ALL)
...
`vmm_subenv_member_end(my_vmm_subenv)
...
endclass
vmm_subenv_member_user_defined()
User-defined shorthand implementation data member.
SystemVerilog
vmm_subenv_member_user_defined(member-name)
OpenVera
Not supported.
Description
Adds the specified user-defined default implementation of the
methods specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-120
class my_vmm_subenv extends vmm_subenv;
bit [7:0] subenv_id;
...
`vmm_env_member_begin(my_vmm_subenv)
`vmm_subenv_member_user_defined(subenv_id)
...
`vmm_env_member_end(my_vmm_subenv)
function bit do_subenv_id(vmm_subenv::do_what_e do_what)
do_subenv_id = 1;
case(do_what)
endfunction
endclass
vmm_subenv_member_vmm_data*()
Shorthand implementation for a vmm_data-based data member.
SystemVerilog
vmm_subenv_member_vmm_data(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_vmm_data_array(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_vmm_data_aa_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_vmm_data_aa_string(member-name,
vmm_subenv::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified vmm_data-type, array of vmm_datas, scalarindexed associative array of vmm_datas, or string-indexed
associative array of vmm_datas data member to the default
implementation of the methods specified by the do_what
argument.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-121
class my_data extends vmm_data;
...
endclass
class my_vmm_subenv extends vmm_subenv;
my_data
subenv_data;
...
`vmm_subenv_member_begin(my_vmm_subenv)
`vmm_subenv_member_vmm_data(subenv_data,DO_ALL)
...
`vmm_subenv_member_end(my_vmm_subenv)
...
endclass
vmm_subenv_member_xactor*()
Shorthand implementation for a transactor data member.
SystemVerilog
vmm_subenv_member_xactor(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_xactor_array(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_xactor_aa_scalar(member-name,
vmm_subenv::do_what_e do_what)
vmm_subenv_member_xactor_aa_string(member-name,
vmm_subenv::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified transactor-type, array of transactors, dynamic
array of transactors, scalar-indexed associative array of transactors,
or string-indexed associative array of transactors data member to
the default implementation of the methods specified by the
do_what argument.
The shorthand implementation must be located in a section started
by the vmm_subenv_member_begin() method.
Example
Example B-122
class my_vmm_subenv extends vmm_subenv;
data_gen subenv_xactor;
...
`vmm_subenv_member_begin(my_vmm_subenv)
`vmm_subenv_member_xactor(subenv_xactor,DO_ALL)
...
`vmm_subenv_member_end(my_vmm_subenv)
...
endclass
vmm_test
The vmm_test class is an extension of vmm_timeline, and
handles the test execution timeline with all of the default predefined
phases. This is used as the base class for all tests.
Instances of this class must be either root objects or children of
vmm_test objects.
Example
class my_test1 extends vmm_test;
`vmm_typename(my_test1)
function new(string name);
super.new(name);
endfunction
function void config_ph;
cfg cfg1 = new;
if (cfg1.randomize)
`vmm_note (log, "CFG randomized successfully" );
else
`vmm_error (log, "CFG randomization failed" );
endfunction
endclass
Summary
vmm_test::get_doc() ..............................
vmm_test::get_name() .............................
vmm_test::log ....................................
vmm_test::new() ..................................
vmm_test::run() ..................................
vmm_test::set_config() ...........................
vmm_test_begin() ................................
vmm_test_end() ..................................
page
page
page
page
page
page
page
page
B-247
B-248
B-249
B-251
B-252
B-253
B-254
B-256
vmm_test::get_doc()
Returns the description of a test.
SystemVerilog
virtual function string get_doc();
OpenVera
Not supported.
Description
Returns the short description of the test that was specified in the
constructor.
Example
Example B-123
class my_test extends vmm_test;
function new();
super.new("my_test");
endfunction
static my_test this_test = new();
virtual task run(vmm_env env);
vmm_note(this.log,
{"Running test ", this.get_doc()});
...
endtask
endclass
vmm_test::get_name()
Returns the name of a test.
SystemVerilog
virtual function string get_name();
OpenVera
Not supported.
Description
Returns the name of the test that was specified in the constructor.
Example
Example B-124
class my_test extends vmm_test;
function new();
super.new("my_test");
endfunction
static my_test this_test = new();
virtual task run(vmm_env env);
vmm_note(this.log,
{"Running test ", this.get_name()});
...
endtask
endclass
vmm_test::log
Message service interface for the testcase.
SystemVerilog
vmm_log log;
OpenVera
Not supported.
Description
Message service interface instance that can be used to generate
messages in the vmm_test::run() method.
The name of the message service interface is "Testcase", and the
instance name is the name specified to the vmm_test::new()
method.
Example
Example B-125
program test;
class test_100 extends vmm_test;
vmm_env env;
function new();
super.new("test_100", "Single Read");
endfunction
task run(vmm_env env1);
`vmm_note(log,"Test Started");
$cast(env, env1);
endtask
endclass
initial begin
test_100 T;
T = new;
T.run(T.env);
end
endprogram
vmm_test::new()
Creates an instance of the testcase.
SystemVerilog
function new(string name,
string doc = "",
vmm_object parent = null);
OpenVera
Not supported.
Description
Creates an instance of the testcase, its message service interface,
and registers it in the global testcase registry under the specified
name. A short description of the testcase may also be specified.
Example
Example B-126
class my_test extends vmm_test;
function new();
super.new("my_test");
endfunction
static my_test this_test = new();
virtual task run(vmm_env env);
...
endtask
endclass
vmm_test::run()
Runs a testcase.
SystemVerilog
virtual task run(vmm_env env);
OpenVera
Not supported.
Description
The test itself.
The default implementation of this method calls env.run(). If a
different test implementation is required, the default implementation
of this method must not be invoked using the super.run()
method.
This method should not call vmm_log::report().
Example
Example B-127
class my_test extends vmm_test;
virtual task run(vmm_env env);
tb_env my_env;
$cast(my_env, env);
my_env.start();
my_env.gen[0].start_xactor();
my_env.run();
endtask
endclass
vmm_test::set_config()
SystemVerilog
virtual function void vmm_test::set_config()
Description
This method may be used to set vmm_unit factory instances and
configuration parameters in vmm_unit instances outside of the
scope of the test module, using the
classname::override_with_*() and vmm_opts::set_*()
methods.
This method can only be used if tests are executed one per
simulation. When this method is used, tests cannot be concatenated.
Example
class my_ahb_trans extends vmm_object;
...
`vmm_class_factory(my_ahb_trans)
endclass
class my_test1 extends vmm_test;
`vmm_typename(my_test1)
function new(string name);
super.new(name);
endfunction
function set_config();
ahb_trans::override_with_new("@%*",
my_ahb_trans::this_type, log, `__FILE__,
`__LINE__);
endfunction
...
endclass
vmm_test_begin()
Shorthand macro to define a testcase class.
SystemVerilog
vmm_test_begin(testclassname, envclassname, doc)
OpenVera
Not supported.
Description
Shorthand macro that may be used to define a user-defined testcase
implemented using a class based on the vmm_test class. The first
argument is the name of the testcase class that will also be used as
the name of the testcase in the global testcase registry. The second
argument is the name of the environment class that will be used to
execute the testcase. A data member of that type named "env" will
be defined and assigned, ready to be used. The third argument is a
string, which is used to document the purpose of the test.
This macro can be used to create the testcase class up to and
including the declaration of the vmm_test::run() method. This
macro can then be followed by variable declarations and procedural
statements. The instance of the verification environment of the
specified type can be accessed as "this.env". It must be
preceded by any import statement required by the test
implementation.
Example
The following example shows how the testcase from Example B-126
and Example B-127 can be implemented, using shorthand macros.
Example B-128
import tb_env_pkg::*;
vmm_test_begin(my_test, tb_env, "Simple test")
this.env.build();
this.env.gen[0].stop_xactor();
this.env.run();
vmm_test_end(my_test)
vmm_test_end()
Shorthand macro to define a testcase class.
SystemVerilog
vmm_test_end(testclassname)
OpenVera
Not supported.
Description
Shorthand macro that may be used to define a user-defined testcase
implemented using a class, based on the vmm_test class. The first
argument must be the same name specified as the first argument of
the vmm_test_begin() macro.
This macro can be used to end the testcase class, including the
implementation of the vmm_test::run() method.
Example
The following example shows how the testcase from Example B-126
and Example B-127 can be implemented, using shorthand macros.
Example B-129
vmm_test_begin(my_test, tb_env, Simple test)
this.env.build();
this.env.gen[0].stop_xactor();
this.env.run();
vmm_test_end(my_test)
vmm_test_registry
Global test registry that can be optionally used to implement runtime
selection of tests.
No constructor is documented, because this class is implemented
using a singleton pattern. Its functionality is accessed strictly
through static members.
Summary
vmm_test_registry::list()
Lists all available tests.
SystemVerilog
static function void list();
OpenVera
Not supported.
Description
Lists the tests that are registered with the global test registry.
This method is invoked automatically by the
vmm_test_registry::run() method, followed by a call to
$finish(), if the +vmm_test_help option is specified.
Example
Example B-130
program test;
`include "test.lst"
i2c_env env;
initial begin
vmm_test_registry registry = new;
env = new;
registry.list();
registry.run(env);
end
endprogram
vmm_test_registry::run()
Runs a testcase.
SystemVerilog
static task run(vmm_env env);
OpenVera
Not supported.
Description
Runs a testcase on the specified verification environment. Using
SystemVerilog, this method must be invoked in a program thread to
satisfy Verification Methodology Manual rules.
If more than one testcase is registered, then the name of a testcase
must be specified using the "+vmm_test" runtime string option.
For more information, see the section,
vmm_opts::get_string() to know how to specify runtime string
options. If only one test is registered, then it is run by default without
having to specify its name at runtime.
A default testcase, named "Default" that simply invokes
env::run(), is automatically available if no testcase is previously
registered under that name.
Example
Example B-131
program top;
tb_env env = new();
initial vmm_test_registry::run(env);
endprogram
vmm_timeline
The vmm_timeline user-defined class coordinates simulation
through a user-defined timeline, with predefined test phases as
follows:
- build
- configure
- connect
- configure_test
- start_of_sim
- reset
- training
- config_dut
- start
- start_of_test
- run
- shutdown
- cleanup
- report
- final
Phases may be subsequently added or removed as needed.
Summary
vmm_timeline::abort_phase() ......................
vmm_timeline::append_callback() ..................
vmm_timeline::delete_phase() .....................
vmm_timeline::display_phases() ...................
vmm_timeline::get_current_phase_name() ...........
vmm_timeline::get_next_phase_name() ..............
vmm_timeline::get_phase() ........................
vmm_timeline::get_previous_phase_name() ..........
vmm_timeline::insert_phase() .....................
vmm_timeline::jump_to_phase() ....................
vmm_timeline::prepend_callback() .................
vmm_timeline::rename_phase() .....................
vmm_timeline::reset_to_phase() ...................
vmm_timeline::run_phase() ........................
vmm_timeline::step_function_phase() ..............
vmm_timeline::task_phase_timeout() ...............
vmm_timeline::unregister_callback() ..............
vmm_timeline_callbacks ...........................
vmm_timeline_callback::break_on_phase() ..........
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
B-263
B-264
B-267
B-268
B-269
B-270
B-271
B-272
B-273
B-275
B-276
B-278
B-279
B-280
B-281
B-282
B-283
B-285
B-286
vmm_timeline::abort_phase()
Aborts the specified phase, if currently executing.
SystemVerilog
function void abort_phase(string name, string fname = "",
int lineno = 0);
Description
Aborts the execution of the specified phase, if it is the currently
executing phase in the timeline. If another phase is executing, it
generates a warning message if the specified phase is already
executed to completion, and generates an error message if the
specified phase is not yet started. The fname and lineno
arguments are used to track the file name and the line number where
this method is invoked from.
Example
class test extends vmm_test;
vmm_timeline topLevelTimeline;
endclass
...
initial begin
test test1 = new ("test1", "test1");
...
fork
test1.topLevelTimeline.run_phase("reset");
#(reset_cycle) test1.topLevelTimeline.abort_phase (
"reset");
...
join_any
disable fork;
...
end
vmm_timeline::append_callback()
Appends the specified callback.
SystemVerilog
function void append_callback( vmm_timeline_callbacks cb);
Description
Appends the specified callback extension to the callback registry, for
this timeline. Returns true, if the registration was successful.
Example
class timeline_callbacks extends vmm_timeline_callbacks;
virtual function void my_f1();
endfunction
endclass
class timelineExtension extends vmm_timeline;
function new (string name, string inst,
vmm_unit parent=null);
super.new(name,inst,parent);
endfunction
function void build_ph();
`vmm_callback(timeline_callbacks,my_f1());
endfunction:build_ph
...
endclass
class timelineExtension_callbacks extends
timeline_callbacks;
int my_f1_counter++;
virtual function void my_f1();
my_f1_counter++;
endfunction
endclass
initial begin
timelineExtension tl = new ("my_timeline", "t1");
timelineExtension_callbacks cb1 = new();
tl.append_callback(cb1);
...
end
vmm_timeline::configure_test_ph()
Configures the environment from testcase.
SystemVerilog
function void configure_test_ph();
Description
The configure_test_ph is the method that gets executed at the
beginning of the test root timeline. The test-specific run-time
configuration should be put in configure_test_ph() (options,
callbacks, and so on). For multiple test concatenation, the default
rollback for the tests in sequence is this configure_test_ph.
Also, for multiple tests, the configure_test phase is run, even
if timeline is not reset before it, followed by the test root timeline from
reset point (set through `VMM_TEST_IS_CONCATENABLE macro)
to the end (start_of_sim, reset, training, config_dut, run, shutdown,
cleanup, and report) for the subsequent tests.
Example
class test_read_back2back extends vmm_test;
function new(string name);
super.new(name);
endfunction
virtual function void configure_test_ph();
test_read_back2back_test_trans tr = new();
tr.address = 'habcd_1234;
tr.address.rand_mode(0);
cpu_trans::override_with_copy("@%*", tr, log, `__FILE__,
`__LINE__);
vmm_opts::set_int("%*:num_scenarios", 50);
endfunction
endclass
vmm_timeline::delete_phase()
Deletes the specified phase from timeline.
SystemVerilog
function bit delete_phase(string phase_name,
string fname = "", int lineno = 0);
Description
Deletes the specified phase in this timeline. Returns false, if the
phase does not exist.
The fname and lineno arguments are used to track the file name
and the line number where this method is invoked from.
Example
class groupExtension extends vmm_group;
function void build_ph ();
vmm_timeline t = this.get_timeline();
...
t.delete_phase ("connect");
...
endfunction
endclass
vmm_timeline::display_phases()
Displays all phases left to be executed.
SystemVerilog
function void display_phases();
Description
Displays all phases left to be executed, for this timeline.
Example
class test extends vmm_test;
...
user_timeline topLevelTimeline;
...
endclass
...
initial begin
test test1 = new ("test1", "test1");
...
fork
begin
test1.topLevelTimeline.run_phase();
end
begin
#20 test1.topLevelTimeline.display_phases();
end
...
join
...
end
vmm_timeline::get_current_phase_name()
Displays the current executing phase of the timeline.
SystemVerilog
function string get_current_phase_name();
Description
Displays the current phase, where the timeline phase execution is at
a given point of time.
Example
class test extends vmm_test;
...
user_timeline topLevelTimeline;
...
endclass
...
initial begin
test test1 = new ("test1", "test1");
...
fork
begin
test1.topLevelTimeline.run_phase();
end
begin
#20 `vmm_note (log, psprintf("Current Simulation
Phase for test1 is : %s ",
test1.topLevelTimeline.get_current_phase_name())
);
end
...
join
...
end
vmm_timeline::get_next_phase_name()
Returns the name of the following phase.
SystemVerilog
function string get_next_phase_name(string name);
Description
Returns the name of the phase that follows the specified phase.
Returns $, if the specified phase is the last one. Returns ?, if the
specified phase is unknown.
Example
class groupExtension extends vmm_group;
...
function void build_ph ();
string nxt_ph;
vmm_timeline t = this.get_timeline();
...
nxt_ph = t.get_next_phase_name ("start_of_sim");
//returns "reset"
...
endfunction
endclass
vmm_timeline::get_phase()
Returns the phase descriptor for a specified phase.
SystemVerilog
function vmm_phase get_phase(string name);
Description
Returns the descriptor of the specified phase in this timeline. Returns
null if the specified phase is unknown.
Example
class groupExtension extends vmm_group;
...
function void build_ph();
vmm_phase ph;
vmm_timeline t = this.get_timeline();
...
ph = t.get_phase ("start_of_sim");
...
endfunction
endclass
vmm_timeline::get_previous_phase_name()
Returns the name of the preceding phase.
SystemVerilog
function string get_previous_phase_name(string name);
Description
Returns the name of the phase that precedes the specified phase.
Returns ^, if the specified phase is the first one. Returns ?, if the
specified phase is unknown.
Example
class groupExtension extends vmm_group;
...
function void build_ph ();
string prv_ph;
vmm_timeline t = this.get_timeline();
...
prv_ph = t.get_previous_phase_name ("start_of_sim");
//returns "configure_test"
...
endfunction
endclass
vmm_timeline::insert_phase()
Inserts a phase in timeline.
SystemVerilog
function bit insert_phase(string phase_name,
string before_name, vmm_phase_def def, string fname = "",
int lineno = 0);
Description
Creates the specified phase (phase_name) before the specified
phase (before_name) in this timeline, and issues a note that a new
user-defined phase is defined. The argument def specifies the
phase instance to be inserted. If the phase already exists, adds this
definition to the existing phase definition. If the before_name is
specified as a caret (^), then inserts the phase at the beginning of the
timeline. If it is specified as a dollar sign ($), then inserts the phase
at the end of the timeline. Returns true, if the phase insertion was
successful.
The fname and lineno arguments are used to track the file name
and the line number where this method is invoked from.
Example
typedef class groupExtension
class udf_start_def extends vmm_fork_task_phase_def
#(groupExtension);
...
endclass
class groupExtension extends vmm_group;
...
function void build_ph ();
vmm_timeline t = this.get_timeline();
vmm_timeline::jump_to_phase()
Aborts the execution of the timeline immediately and jump to the
beginning of the specified phase.
SystemVerilog
function void jump_to_phase(string name,string fname = "",
int lineno = 0);
Description
Aborts the execution of the timeline, and immediately jumps to the
beginning of the specified phase (but does not start executing it).
Generates a warning message, if the specified phase is already
started or completed.
Executing a phase without the intervening phases may cause severe
damage to the state of the executing testcase and verification
environment, and should be used with care. You should typically use
to abort a testcase or simulation, and jump to the report phase. The
fname and lineno arguments are used to track the file name and
the line number where this method is invoked from.
Example
class timelineExtension #(string jump_phase = "report",
int delay_in_jump = 10) extends vmm_timeline;
...
task reset_ph;
#delay_in_jump jump_to_phase(jump_phase);
endtask
...
endclass
vmm_timeline::prepend_callback()
Prepends the specified callback.
SystemVerilog
function void prepend_callback(vmm_timeline_callbacks cb);
Description
Prepends the specified callback extension to the callback registry,
for this timeline. Returns true, if the registration was successful.
Example
class timeline_callbacks extends vmm_timeline_callbacks;
virtual function void my_f1();
endfunction
endclass
class timelineExtension extends vmm_timeline;
function new (string name, string inst,
vmm_unit parent=null);
super.new(name,inst,parent);
endfunction
function void build_ph();
`vmm_callback(timeline_callbacks,my_f1());
endfunction:build_ph
...
endclass
class timelineExtension_callbacks extends
timeline_callbacks;
int my_f1_counter++;
virtual function void my_f1();
my_f1_counter++
endfunction
endclass
initial begin
timelineExtension tl = new ("my_timeline", "t1");
timelineExtension_callbacks cb1 = new();
timelineExtension_callbacks cb2 = new();
tl.append_callback(cb1);
tl.prepend_callback(cb2);
...
end
vmm_timeline::rename_phase()
Provides a new name to the specified phase.
SystemVerilog
function bit rename_phase(string old_name, string new_name,
string fname = "", int lineno = 0);
Description
Renames the specified phase old_name in this timeline, to the new
phase name new_name. Returns false, if the original named phase
does not exist, or if a phase already exists with the new name.
Generates a warning that a phase is renamed. Renaming timeline
default phases is not allowed. The fname and lineno arguments
are used to track the file name and the line number where this
method is invoked from.
Example
class groupExtension extends vmm_group;
...
function void build_ph ();
vmm_timeline t = this.get_timeline();
...
// Renaming predefined phase 'start_of_sim'
if(t.rename_phase("start_of_sim",
"renamed_start_of_sim") == 0)
`vmm_error(log, " ... ");
...
endfunction
endclass
vmm_timeline::reset_to_phase()
Resets timeline to the specified phase.
SystemVerilog
function void reset_to_phase(string name, string fname="",
int lineno=0);
Description
Resets this timeline to the specified phase name. Any task-based
phase, which is concurrently running is aborted. If the timeline is
reset to the configure phase or earlier, all of its vmm_unit subinstances are enabled, along with itself.
The fname and lineno arguments are used to track the file name
and the line number where this method is invoked from.
Example
class test extends vmm_test;
user_timeline topLevelTimeline;
endclass
...
initial begin
test test1 = new ("test1", "test1");
fork
test1.topLevelTimeline.run_phase();
//Assume topLevelTimeline is going to run more
//than #9 delay
#9 test1.topLevelTimeline.reset_to_phase ("build");
join
end
vmm_timeline::run_phase()
Runs a timeline, up to and including the specified phase.
SystemVerilog
task run_phase(string name = "$", string fname = "", int
lineno = 0);
Description
Executes the phases in this timeline, up to and including the
specified phase by argument name. For name $, run all phases.
The fname and lineno arguments are used to track the file name
and the line number where this method is invoked from.
Example
class test extends vmm_test;
...
vmm_timeline topLevelTimeline;
...
endclass
...
initial begin
test test1 = new ("test1", "test1");
test1.topLevelTimeline.run_phase ("build");
...
test1.topLevelTimeline.run_phase ();
end
vmm_timeline::step_function_phase()
Steps to the next executable phase.
SystemVerilog
function void step_function_phase(string name,
string fname = "", int lineno = 0);
Description
Executes the specified function phase in this timeline. Must be a
function phase, and must be the next executable phase. The fname
and lineno arguments are used to track the file name and the line
number where this method is invoked from.
Example
class test extends vmm_test;
...
vmm_timeline topLevelTimeline;
...
endclass
...
initial begin
test test1 = new ("test1", "test1");
...
test1.topLevelTimeline.run_phase ("configure");
test1.topLevelTimeline.step_function_phase ("connect");
test1.topLevelTimeline.step_function_phase (
"configure_test");
...
end
vmm_timeline::task_phase_timeout()
Sets the timeout value for any task phase.
SystemVerilog
function bit task_phase_timeout(string name,
int unsigned delta, vmm_log::severities_e
error_severity=vmm_log::ERROR_SEV, string fname = "",
int lineno = 0);
Description
Sets the timeout value - as specified by delta - for the completion
of the specified task phase. If the task phase does not complete
within the time specified in the timeout value, then an error message
is generated. Message severity, which is error by default, can be
overridden using the error_severity argument.Returns false, if
the specified phase does not exist or is not a task phase.
A timeout value of 0 specifies no timeout value. Calling this method,
while the phase is currently executing, causes the timer to be reset
to the specified value. By default, phases do not have timeouts. The
fname and lineno arguments are used to track the file name and
the line number where this method is invoked from.
Example
class groupExtension extends vmm_group;
function void build_ph ();
vmm_timeline t = this.get_timeline();
if(t.task_phase_timeout("reset",4) == 0)
`vmm_error (log, " ... ");
...
endfunction
endclass
vmm_timeline::unregister_callback()
Unregisters a callback.
SystemVerilog
function void unregister_callback(
vmm_timeline_callbacks cb);
Description
Removes the specified callback extension from the callback registry,
for this timeline. Returns true, if the unregistration was successful.
Example
class timeline_callbacks extends vmm_timeline_callbacks;
virtual function void my_f1();
endfunction
endclass
class timelineExtension extends vmm_timeline;
function new (string name, string inst, vmm_unit
parent=null);
super.new(name,inst,parent);
endfunction
function void build_ph();
`vmm_callback(timeline_callbacks,my_f1());
endfunction:build_ph
...
endclass
class
timelineExtension_callbacks extends
timeline_callbacks;
int my_f1_counter++;
virtual function void my_f1();
my_f1_counter++;
endfunction
endclass
initial begin
timelineExtension tl = new ("my_timeline", "t1");
timelineExtension_callbacks cb1 = new();
timelineExtension_callbacks cb2 = new();
tl.append_callback(cb1);
tl.append_callback(cb2);
...
tl.unregister_callback(cb2);
...
end
vmm_timeline_callbacks
Facade class for callback methods provided by a timeline.
Example
class timeline_callbacks extends vmm_timeline_callbacks;
virtual function void my_f1();
endfunction
virtual function void my_f2();
endfunction
endclass
Summary
vmm_timeline_callback::break_on_phase()
This method is called, if the +break_on_X_phase option is set for
this timeline instance.
SystemVerilog
function void vmm_timeline_callbacks::break_on_phase(
vmm_timeline t1, string name)
Description
This method is called, if the +break_on_X_phase option is set for
this timeline instance. The arguments are the instance of the timeline
and the name of the phase (X). If no callbacks are registered, $stop
is called instead of this method.
Example
class timeline_callbacks extends vmm_timeline_callbacks;
vmm_log log;
function new(vmm_log log);
this.log = log;
endfunction
function void break_on_phase(vmm_timeline tl,
string name);
if(name=="reset")
`vmm_note(log,
"user callback executing for reset phase");
endfunction
endclass
vmm_timeline tl;
initial begin
timeline_callbacks
cb1;
tl = new("my_timeline", "tl");
cb1 = new(tl.log);
tl.append_callback(cb1);
tl.run_phase();
end
vmm_tlm
This class contains the sync_e enumerated for various phases of
the transaction. All TLM port classes use this enumerated value as
the default template for defining the phases of the transaction.
SystemVerilog
class vmm_tlm;
typedef enum { TLM_REFUSED, TLM_ACCEPTED,
TLM_UPDATED, TLM_COMPLETED } sync_e;
typdef enum {BEGIN_REQ, END_REQ, BEGIN_RESP,
END_RESP} phase_e;
typedef enum { TLM_BLOCKING_PORT, TLM_BLOCKING_EXPORT,
TLM_NONBLOCKING_FW_PORT, TLM_NONBLOCKING_FW_EXPORT,
TLM_NONBLOCKING_PORT,TLM_NONBLOCKING_EXPORT,
TLM_ANALYSIS_PORT,TLM_ANALYSIS_EXPORT} intf_e;
sync_e sync;
endclass
Description
This class provides enumerated type sync_e, which is the
response status from a non-blocking transport function call, upon
receiving a transaction object.
The enumerated type phase_e contains various phases of a
transaction object. These phases can be updated by different
components that access the same transaction object.
The enumerated type intf_e is used to connect the
vmm_channel_typed to TLM transport ports, TLM transport
exports, and TLM analysis ports and exports.
The vmm_tlm class also provides static methods to print, check, and
report the bindings of all TLM ports and exports, under a specified
root.
Summary
vmm_tlm_extension_base
Generic payload extensions base class. This class must be
extended to define user extensions of the
vmm_tlm_generic_payload class.
SystemVerilog
class vmm_tlm_extension_base extends vmm_data;
Description
This class is used to define extensions of the
vmm_tlm_generic_payload class.
vmm_tlm_generic_payload
This data class contains attributes, as defined by the OSCI TLM2.0
tlm_generic_payload class. The class is extended from the
vmm_rw_access class, which is in turn extended from vmm_data
class. The SystemVerilog implementation uses the VMM data
shorthand macros, to implement all methods that are implemented
by the vmm_data class.
Generic payload class can be extended to have user defined
functionality by extending vmm_tlm_extension_base. The
vmm_tlm_generic_payload class has a dynamic array of
vmm_tlm_extension_base, which is used to store the user
extensions.
SystemVerilog
class vmm_tlm_generic_payload extend vmm_rw_access;
typedef enum {TLM_READ_COMMAND = 0,
TLM_WRITE_COMMAND = 1,
TLM_IGNORE_COMMAND = 2
}tlm_command;
typedef enum {TLM_OK_RESPONSE = 1,
TLM_INCOMPLETE_RESPONSE = 0,
TLM_GENERIC_ERROR_RESPONSE = -1,
TLM_ADDRESS_ERROR_RESPONSE = -2,
TLM_COMMAND_ERROR_RESPONSE = -3,
TLM_BURST_ERROR_RESPONSE = -4,
TLM_BYTE_ENABLE_ERROR_RESPONSE = -5
}tlm_response_status;
rand
rand
rand
rand
longint
tlm_command
byte
int unsigned
tlm_response_status
m_address;
m_command;
m_data[];
m_length;
m_response_status;
bit
rand byte
rand int unsigned
rand int unsigned
int unsigned
int unsigned
int unsigned
m_dmi_allowed = 0;
m_byte_enable[];
m_byte_enable_length;
m_streaming_width;
min_m_length;
max_m_length;
max_m_byte_enable_length;
constraint c_length_valid
{ m_data.size == m_length;
m_length>min_m_length;
}
constraint c_data_size_reasonable
{m_length<=max_m_length;
}
constraint c_byte_enable_valid
{ m_byte_enable.size == m_byte_enable_length;
}
constraint c_byte_enable_size_reasonable
{ m_byte_enable_length<=max_m_byte_enable_length;
}
endclass: vmm_tlm_generic_payload
Description
The class members are kept public to access methods to set and get
the members that are not provided. The DMI and Debug Interfaces
are not part of the VMM-TLM implementation, and therefore not
included in the vmm_tlm_generic_payload class.
The m_data and m_data_enable values are constrained to small
values of 16 and 256, respectively for better performance. If values
larger than these are required, then the constraint blocks such as
c_data_size_reasonable and
c_byte_enable_size_reasonable should be switched off and
applicable ranges can be provided.
Summary
vmm_tlm_generic_payload::set_extensions()
To add user-defined extension to vmm_tlm_extension_base
class array in the generic payload class.
SystemVerilog
function vmm_tlm_extension_base set_extension(int
index, vmm_tlm_extension_base ext);
Description
This function is used to assign the extension base to the dynamic
array in the generic payload class at the specified index, and returns
the old extension at that index.
vmm_tlm_generic_payload::get_extensions()
Returns the user-defined extension at the specified index from the
extensions array of the generic payload class.
SystemVerilog
function vmm_tlm_extension_base get_extension(int
index);
Description
This function is used to get the extension from the dynamic array in
the generic payload class in that index.
vmm_tlm_generic_payload::clear_extensions()
To clear the user-defined extension at the specified index from the
extensions array in the generic payload class.
SystemVerilog
function void clear_extension(int index);
Description
This function is used to clear the extension from the dynamic array
in the generic payload class in that index.
Example
class my_extensions extend vmm_tlm_extension_base;
rand int data32;
rand bit[7:0] data8;
end class
class producer extends vmm_xactor;
vmm_tlm_nb_transport_port#(producer) nb_port;
task run_ph();
my_data tr;
my_extensions tr_ex, temp_tr_ext;
while(1) begin
tr = new();
tr_ex = new();
tr.set_extensions(0,tr_ex);
temp_tr_ext = tr.get_extensions(0);
this.nb_port.nb_tranport_fw(tr,ph,delay);
tr.clear_extensions(0);
#5;
end
endtask
endclass
vmm_tlm::check_bindings()
Static method to check if minimum bindings exist for all TLM ports
and exports under the specified root.
SystemVerilog
static function check_bindings(vmm_object root= null);
Description
A warning is generated if a port is unbound ,or if an export contains
less than the minimum bindings specified for the export. Analysis
port bindings are reported with debug severity. If root is not specified,
then the binding checks are done for all TLM ports and exports in the
environment.
The check_bindings() method is also available with all TLM
ports and exportsm and can be invoked for the particular port object.
Example
class my_env extends vmm_group;
function void start_of_sim_ph();
...
vmm_tlm::check_bindings(this);
endfunction
endclass
vmm_tlm::print_bindings()
Static method used to print the bindings of all TLM ports and exports,
instantiated under a specified root.
SystemVerilog
static function print_bindings(vmm_object root = null);
Description
Prints the bindings of all TLM ports and exports, including transport
ports and exports, sockets and analysis ports, and exports
instantiated under the vmm_object, specified by the root
argument. If null is passed, then the bindings are printed for all TLM
ports and exports in the environment.
The print_bindings() method is also available with all TLM
ports and exports, and can be invoked for the particular port object.
Example
class my_env extends vmm_group;
function void start_of_sim_ph();
...
vmm_tlm::print_bindings(this);
endfunction
endclass
vmm_tlm::report_unbound()
Static method to report all unbound TLM ports and to export
instances available under a specified root.
SystemVerilog
static function report_bindings(vmm_object root = null);
Description
Reports all unbound TLM ports and exports, including transport ports
and exports, sockets and analysis ports, and exports instantiated
under the vmm_object, specified by the root argument. If null is
passed, then the bindings are printed for all TLM ports and exports
in the environment.
A warning is generated, if any TLM port or export under the specified
root is left unbound. For analysis ports, a message with debug
severity is generated.
The report_unbound() method is also available with all TLM
ports and exports, and can be invoked for the particular port object.
Example
class my_env extends vmm_group;
function void start_of_sim_ph();
...
vmm_tlm::report_unbound(this);
endfunction
endclass
vmm_tlm_analysis_port#(I,D)
Analysis ports are useful to broadcast transactions, to observers like
scoreboards and functional coverage models. Analysis ports can be
bound to any number of observers, through the observers analysis
export.
The analysis port calls the write method of all the observers bound
to it.
SystemVerilog
class vmm_tlm_analysis_port#(
type INITIATOR = vmm_tlm_xactor, type DATA = vmm_data,)
extends vmm_tlm_analysis_port_base#(DATA);
Description
The analysis port can be instantiated in any transactor class that
wishes to broadcast the transaction object to the connected
observers.
Any number of bindings are allowed for the analysis port. The
analysis port calls the write methods of the connected analysis
exports, which in turn execute the write methods of their respective
parent components.
The vmm_tlm_analysis_port_base provides all the access
methods that are provided by the vmm_tlm_port_base class. The
methods provided by the vmm_tlm_analysis_port_base class
are get_peers(), get_n_peers(), get_peer_id(),
get_peer(), tlm_bind(), tlm_unbind(), and
tlm_import(). For more information on these access methods,
refer to the description provided in the vmm_tlm_port_base class.
VMM User Guide
B-300
Example
class consumer extends vmm_xactor;
vmm_tlm_analysis_port#(consumer) analysis_port =
new(this,"consumer_analysis");
function b_transport(int id=-1,my_trans trans,
ref int delay);
this.analysis_port.write(trans);
endfunction
endclass
vmm_tlm_analysis_export#(T,D)
Analysis exports are used by observer components that implement
a write method to receive broadcast transactions from other
components that instantiate the vmm_tlm_analysis_port class.
Analysis exports can be bound to any number of analysis ports, as
specified in the constructor of the analysis export. The different
analysis ports connected to this export can be distinguished using
the peer identity of the analysis port.
The analysis export implements the write method, which is called by
the analysis ports that are bound to this export.
SystemVerilog
class vmm_tlm_analysis_export#(type T = vmm_tlm_xactor,
type D = vmm_data)
extends vmm_tlm_analysis_export_base#(D);
Description
The analysis export can be instantiated in a component class that
wishes to receive broadcast transaction objects from other
components.
The vmm_tlm_analysis_export_base provides all access
methods that are provided by the vmm_tlm_export_base class.
The methods provided by vmm_tlm_analysis_port_base are:
get_peers()
get_n_peers()
get_peer_id()
get_peer()
tlm_bind()
bind_peer()
tlm_unbind()
VMM User Guide
B-302
unbind_peer()
tlm_import()
print_bindings()
check_bindings()
report_unbound()
Example
class scoreboard extends vmm_group;
vmm_tlm_analysis_export#(scoreboard) analysis_export =
new(this,"scb_analysis");
function write(int id=-1, my_trans trans);
endfunction
endclass
vmm_tlm_analysis_export(SUFFIX)
Shorthand macro to create unique class names of the analysis
export. This is used if multiple vmm_tlm_analysis_export
instances are required in the same observer class, each having its
own implementation of the write method.
SystemVerilog
`vmm_tlm_analysis_export(SUFFIX)
Description
The use model is similar to the shorthand macros provided for the
unidirectional exports. For more information, refer to the macro
description of `vmm_tlm_nb_transport_fw_export.
Example
class scoreboard extends vmm_group;
`vmm_tlm_analysis_export(_1)
`vmm_tlm_analysis_export(_2)
vmm_tlm_analysis_export_1#(scoreboard) scb1;
vmm_tlm_analysis_export_2#(scoreboard) scb2;
function write_1 (int id=-1,my_trans trans);
`vmm_note(log, $psprintf("Received %s from %0d",
Trans.psdisplay(""), id);
endfunction
function write_2 (int id=-1,my_trans trans);
`vmm_note(log, $psprintf("Received %s from %0d",
Trans.psdisplay(""), id);
endfunction
endclass
vmm_tlm_b_transport_export#(T,D)
Blocking transport export class.
Any class instantiating this blocking transport export, must provide
an implementation of the b_transport() task.
SystemVerilog
class vmm_tlm_b_transport_export#(
type TARGET = vmm_tlm_xactor,
type DATA = vmm_data)
extends vmm_tlm_export_base#(DATA);
Description
Class providing the blocking transport export. The parameter type
TARGET is the class that instantiates the transport export. This
defaults to vmm_tlm_xactor. The parameter DATA is the data type
of the transaction the export services. The default is vmm_data.
The export can be bound to multiple ports, up to the maximum
bindings, specified in the constructor of this class.
Summary
`vmm_tlm_b_transport_export()
Shorthand macro to create unique blocking transport exports. This is
required if more than one export is bound in a target transactor.
SystemVerilog
`vmm_tlm_b_transport_export(SUFFIX)
Description
This macro creates a uniquified vmm_tlm_b_transport_export
class, with the SUFFIX appended to the class name
vmm_tlm_b_transport_export. The class with the name
vmm_tlm_b_transport_exportSUFFIX is created in the scope,
where the macro is called.
This macro is required if there are multiple instances of the
vmm_tlm_b_transport_export, and each requires a unique
implementation of the b_transport() task in the parent
transactor.
The b_transport() methods in the parent transactor must be
uniquified using the same SUFFIX to b_transport.
Alternatively, if multiple ports need to service the parent transactor,
then a single export with multiple bindings using unique ids can be
used in place of the macro. The single b_transport() method can
be programmed to serve the various ports depending on the id.
Example
class consumer extends vmm_xactor;
`vmm_tlm_b_transport_export(_1)
`vmm_tlm_b_transport_export(_2)
vmm_tlm_b_transport_export_1#(consumer) b_export1 =
new(this, "export1");
vmm_tlm_b_transport_export_2#(consumer) b_export2 =
new(this,"export2");
task b_transport_1(int id = -1, vmm_data trans,
ref int delay );
trans.display("From export1");
endtask
task b_transport_2(int id = -1, vmm_data trans,
ref int delay);
trans.display("From export2");
endtask
endclass
class producer extends vmm_xactor;
vmm_tlm_b_transport_port#(producer) b_port;
endclass
class my_env extends vmm_group;
producer p1,p2;
consumer c1;
function void connect_ph();
c1.b_export1.tlm_bind(p1.b_port);
c1.b_export2.tlm_bind(p2.b_port);
endfunction
endclass
vmm_tlm_b_transport_export::b_transport()
Blocking transport method of the export.
SystemVerilog
task b_transport(int id = -1, DATA trans, ref int delay );
Description
Blocking transport task of the transport export. This task is internally
called by the bound transport port. This task calls the
b_transport() method of the parent transactor in which it is
instantiated.
The specified trans argument is a handle of the transaction object,
id specifies the binding identifier of this export, delay argument is
the timing annotation.
Example
class consumer extends vmm_xactor;
vmm_tlm_b_transport_export#(consumer) b_export;
task b_transport(int id = -1, vmm_data trans,
ref int delay);
trans.display("From consumer");
endtask
endclass
vmm_tlm_b_transport_export::new()
Constructor of blocking transport export class.
SystemVerilog
function new(TARGET parent, string name, int max_binds = 1 ,
int min_binds = 0);
Description
Sets the parent and instance name of the blocking transport export.
Sets the maximum and minimum bindings allowed for this export.
The default value of maximum bindings is 1, and the minimum
binding is 0. An error is generated during tlm_bind(), if the
current binding exceeds the maximum allowed bindings for the
export. An error is generated during elaboration, if the export does
not contain the minimum number of specified bindings.
Example
class consumer extends vmm_xactor;
vmm_tlm_b_transport_export#(consumer) b_export;
function void build_ph();
this.b_export = new(this,"consumer export",5,1);
endfunction
endclass
vmm_tlm_b_transport_port #(I,D)
Base class for modeling a blocking transport port.
SystemVerilog
class vmm_tlm_b_transport_port #(
type INITIATOR = vmm_tlm_xactor, type DATA = vmm_data)
extends vmm_tlm_port_base#(DATA);
Description
Class providing the blocking transport port. The parameter type
INITIATOR is the class that instantiates the transport port. This
defaults to vmm_tlm_xactor. The parameter DATA is the data type
of the transaction port services. The default is vmm_data.
The port can be bound to one export. A warning is generated, if the
port is left unbound.
There is no backward path for the blocking transport.
Summary
vmm_tlm_b_transport_port::b_transport()
TLM task for blocking transport.
SystemVerilog
task b_transport(DATA trans, ref int delay);
Description
TLM task for blocking transport. Invokes the b_transport()
method of the bounded export. The index argument can be used
for associating the b_transport call with the caller, this can be
usefull for the target to identify which producers called this task. The
trans argument is a handle of the transaction object. The delay
argument is the timing annotation.
Example
class producer extends vmm_xactor;
vmm_tlm_b_transport_port#(producer) b_port;
task run_ph();
my_data tr;
while(1) begin
tr = new();
this.b_port.b_tranport(tr, delay);
$display("Transaction Completed");
end
endtask
endclass
vmm_tlm_b_transport_port::new()
Constructor for blocking transport port class.
SystemVerilog
function new(INITIATOR parent, string name);
Description
Sets the parent and instance name of the blocking transport port.
Example
class producer extends vmm_xactor;
vmm_tlm_b_transport_port#(producer) b_port;
function void build_ph();
this.b_port = new(this,"producer port");
endfunction
endclass
vmm_tlm_export_base #(D,P)
Abstract base class for all TLM2.0 transport exports. This class
contain the methods that are required by all TLM2.0 transport export
implementations. Any user-defined export must be extended from
this base class.
The parameter DATA is the type of the transaction object of the
export services. The default type is vmm_data. The parameter
PHASE is the type of the phasing class. The default value is
vmm_tlm::phase_e.
SystemVerilog
virtual class vmm_tlm_export_base #(type DATA = vmm_data,
type PHASE = vmm_tlm::phase_e) extends vmm_tlm_base;
Description
Sets the parent, if it is an extension of vmm_object. Sets the name
of the instance.
Summary
page
page
page
page
page
page
page
page
B-314
B-315
B-316
B-317
B-318
B-319
B-321
B-323
vmm_tlm_export_base::get_n_peers() Function
Returns the number of export bindings.
SystemVerilog
function int get_n_peers();
Description
Returns the number of port export bindings, as set with the
tlm_bind() method.
Example
class consumer extends vmm_xactor;
vmm_tlm_b_transport_export#(consumer) b_export;
function display_n_connections();
$display("Export has %d bindings",
this.b_export.get_n_peers());
endfunction
endclass
vmm_tlm_export_base::get_peer()
Returns the binding for the port.
SystemVerilog
function vmm_tlm_port_base#(DATA,PHASE) get_peer(int
id = -1);
Description
Returns the port bound to the current export, with the specified id.
Null is returned, if the port does not have a binding with the specified
id. If only one binding exists for the export, then the handle to be
binding is returned without considering the id value passed.
Example
class consumer extends vmm_xactor;
vmm_tlm_b_transport_export#(consumer) b_export;
function display_my_id();
vmm_tlm_export_base peer;
peer = this.b_export.get_peer(0);
$display("My id = %d",peer.get_peer_id();
endfunction
endclass
vmm_tlm_export_base::get_peer_id()
Returns the id of this port, for its binding.
SystemVerilog
function int get_peer_id(vmm_tlm_port_base#(DATA,PHASE)
peer);
Description
Returns the binding id of the specified port bound to this export. If
the specified port is not bound to this export, then -1 is returned.
Example
class my_env extends vmm_group;
producer p1,p2;
consumer c1;
function void connect_ph();
p1.b_port.tlm_bind(c1.b_export);
p2.b_port.tlm_bind(c1.b_export);
int p1_id = c1.b_export.get_peer_id(p1.b_port);
int p2_id = c1.b_export.get_peer_id(p2.b_port);
endfunction
endclass
vmm_tlm_export_base::get_peers()
Returns the list of all bindings of the export.
SystemVerilog
function void get_peers(vmm_tlm_port_base#(DATA,PHASE)
peers[$]);
Description
Returns the queue of bindings of the export in the specified queue.
Example
class consumer extends vmm_xactor;
vmm_tlm_b_transport_export#(consumer) b_export;
function display_connections();
vmm_tlm_port_base q[$];
b_export.get_peers(q);
foreach(q[i])
$display("Binding[%0d] %s",i,
q[i].get_object_name() );
endfunction
endclass
vmm_tlm_export_base::new()
Constructor of an export base class.
SystemVerilog
function new(vmm_object parent, string name,
int max_binds = 1, int min_binds = 0, vmm_log log);
Description
Sets the parent, if it is an extension of vmm_object. Sets the name
of the instance. Sets the maximum and minimum bindings allowed
for this export. log is the message interface instance to be used for
reporting messages.
vmm_tlm_export_base::tlm_bind()
Binds the TLM export to the TLM port passed as an argument.
SystemVerilog
function void tlm_bind(vmm_tlm_port_base#(DATA,PHASE)
peer,int id = -1, string fname = "", int lineno = 0);
Description
Binds the TLM export to the supplied port. Multiple bindings are
allowed for exports.
This method adds the supplied port descriptor to the bindings list of
the export. An error is generated, if the supplied port already
contains a binding.
The second argument, id, is used to distinguish between multiple
ports that bind to the same export. If a positive id is supplied, then
it must be unique for this export. It is an error, if a positive id already
used by the export is supplied. If no id or a negative id is provided,
then the lowest available positive id is automatically assigned. This
id is passed as an argument of the transport method, implemented
in the exports parent.
The fname and lineno arguments are used to track the file name
and the line number, where the tlm_bind is invoked from.
Example
class producer extends vmm_xactor;
vmm_tlm_b_transport_port#(producer)
b_port = new(this,"producer port");
endclass
vmm_tlm_export_base::tlm_import()
Imports an export from an inner level in the hierarchy, to an outer
level.
SystemVerilog
function void tlm_import(vmm_tlm_export_base#(DATA,PHASE)
peer, string fname = "", int lineno = 0);
Description
This is a special way of exporting bindings. It simplifies the binding
for hierarchical exports, by making the inner export visible to the
outer hierarchy. The binding resolves to a port-export binding. The
method allows only parent-child exports to be imported. An error is
generated, if the exports do not share a parent-child relationship. It
is an error to import an export that is already imported. It is an error
to import an export that is already bound. The method can be called
for both parent-to-child bindings and child-to-parent bindings. For
this, the parent transactors must be derivatives of vmm_object. If
the parent is a vmm_xactor extension, then the vmm_xactor base
class should be underpinned. If the vmm_xactor is not
underpinned, or the parent is not a derivative of vmm_object, then
only child.export.tlm_import(parent.export) is allowed.
The error checks are not executed, and you must ensure legal
connections.
The fname and lineno arguments are used to track the file name
and the line number, where the tlm_import is invoked from.
Example
class target_child extends vmm_xactor;
vmm_tlm_b_transport_export#(target_child) b_export;
endclass
class target_parent extends vmm_group;
vmm_tlm_b_transport_export#(target_parent) b_export;
target_child target;
function void connect_ph();
target.b_export.tlm_import(this.b_export);
endfunction
endclass
vmm_tlm_export_base::tlm_unbind()
Removes an existing binding of the export.
SystemVerilog
function void tlm_unbind(vmm_tlm_port_base#(D,P)
peer = null, int id = -1, string fname = "", int lineno = 0);
Description
Removes the binding supplied as a peer or id from the list of
bindings, for this export. Also, removes the binding of this export with
the connected port.
If the supplied peer is not null, then the binding of the peer is
removed. An error is generated, if the supplied peer is not bound to
this export.
If the supplied peer is null and the supplied id is a positive number,
then the binding to the port with the supplied id is removed. An error
is generated, if there is no binding with the supplied positive id.
If the supplied peer is null and the supplied id negative, then all
bindings for this export are removed.
On unbinding, the id of the unbound port becomes available for
reuse.
The fname and lineno arguments are used to track the file name
and the line number, where the tlm_unbind is invoked from.
Example
class my_env extends vmm_group;
producer p1;
consumer c1, c2;
function void connect_ph()
p1.b_port.tlm_bind(c1.b_export);
endfunction
class test2 extends vmm_test;
function void configure_test_ph();
env.p1.b_port.tlm_unbind();
env.p1.b_port.tlm_bind(c2.b_export);
endfunction
endclass
vmm_tlm_nb_transport_bw_export#(T,D,P)
Non-blocking backward transport export class.
SystemVerilog
class vmm_tlm_nb_transport_bw_export#(
type TARGET = vmm_tlm_xactor, type DATA = vmm_data,
type PHASE = vmm_tlm::phase_e)
extends vmm_tlm_export_base#(DATA,PHASE);
Description
Class providing the non-blocking backward transport export. This
class should be instantiated in the initiator transactor, which
instantiates a non-blocking forward port. The transactions sent from
this transactor, on the forward path, can be received by the
transactor on the backward path through this backward export.
The parameter type TARGET is the class instantiating the transport
export. This defaults to vmm_tlm_xactor. The parameter DATA is
the data type of the transaction in the export services. The default is
vmm_data. The parameter type, PHASE, is the phase class for this
export. The default type is vmm_tlm::phase_e.
The export can be bound to multiple ports, up to the max bindings
specified in the constructor of this class.
Summary
`vmm_tlm_nb_transport_bw_export()
Shorthand macro to create unique instances of non-blocking,
backward transport export. This is useful if multiple exports are
required in the same initiator transactor.
SystemVerilog
`vmm_tlm_nb_transport_bw_export(SUFFIX)
Description
This macro creates a uniquified
vmm_tlm_nb_transport_bw_export class, with the SUFFIX
appended to the class name
vmm_tlm_nb_transport_bw_export. The class with the name
vmm_tlm_nb_transport_bw_exportSUFFIX is created in the
scope, where the macro is called.
This macro is required if there are multiple instances of the
vmm_tlm_nb_transport_bw_export class, and each requires a
unique implementation of the nb_transport_bw() task, in the
parent transactor.
The nb_transport_bw() methods in the parent transactor must
be uniquified, using the same SUFFIX to nb_transport_bw.
Alternatively, if multiple ports need to service the parent transactor,
then a single export with multiple bindings using unique ids can be
used in place of the macro. The single nb_transport_bw()
method can be programmed to serve various ports, depending on
the id.
Example
class producer extends vmm_xactor;
`vmm_tlm_nb_transport_bw_export(_1)
`vmm_tlm_nb_transport_bw_export(_2)
vmm_tlm_nb_transport__bw_export_1#(producer)
nb_export1 = new(this, "export1");
vmm_tlm_nb_transport_bw_export_2#(producer)
nb_export2 = new(this, "export2");
function nb_transport_bw_1(int id = -1, vmm_data trans,
ref vmm_tlm::phase_e ph, ref int delay);
trans.display("From export1");
endfunction
function nb_transport_bw_2(int id = -1,vmm_data trans,
ref vmm_tlm::phase_e ph, ref int delay);
trans.display("From export2");
endfunction
endclass
class consumer extends vmm_xactor;
vmm_tlm_nb_transport_bw_port#(producer) nb_port;
endclass
class my_env extends vmm_group;
producer p1;
consumer c1,c2;
function void connect_ph();
p1.nb_export1.tlm_bind(c1.nb_port);
p1.nb_export2.tlm_bind(c2.nb_port);
endfunction
endclass
vmm_tlm_nb_transport_bw_export::nb_transport_bw()
Non-blocking transport method of the export.
SystemVerilog
function vmm_tlm::sync_e nb_transport_bw(int id,
DATA trans, ref PHASE ph, ref int delay );
Description
Non-blocking transport function of the transport export. This function
is internally called by the bound transport port. This function calls the
nb_transport_bw() method of parent transactor it is instantiated
in.The argument id specifies the binding id of this export. If the
export is bound to multiple ports then the peer can be distinguished
using the id passed to the nb_transport_bw().The trans
argument is a handle of the transaction object, ph is the handle of
phase class to specify the phase of a transaction trans, the delay
argument is the timing annotation.
Example
class producer extends vmm_xactor;
vmm_tlm_nb_transport_fw_export#(producer) nb_export;
function vmm_tlm::sync_e nb_transport_bw(int id = -1,
vmm_data trans,ref vmm_tlm::phase_e ph, ref int delay
);
trans.display("From producer on backward path.");
endfunction
endclass
vmm_tlm_nb_transport_bw_export::new()
Constructor of non-blocking backward transport export class. Any
class instantiating this non-blocking export must provide an
implementation of the nb_transport_bw() function.
SystemVerilog
function new(TARGET parent, string name, int max_binds = 1 ,
int min_binds = 0);
Description
Sets the parent and instance name of the blocking transport export.
Sets the maximum and minimum bindings allowed for this export.
The default value of maximum bindings is 1 and minimum bindings
is 0. An error is generated during tlm_bind(), if the current
binding exceeds the maximum allowed bindings for the export. An
error is generated during elaboration, if the export does not contain
the minimum number of specified bindings.
Example
class producer extends vmm_xactor;
vmm_tlm_nb_transport_bw_export#(producer) nb_export;
vmm_tlm_nb_transport_fw_port#(producer)nb_port;
function void build_ph();
this.nb_export = new(this,"consumer export",5,1);
endfunction
endclass
vmm_tlm_nb_transport_bw_port#(I,D,P)
Non-blocking transport port for the backward path.
SystemVerilog
class vmm_tlm_nb_transport_bw_port #(
type INITIATOR = vmm_tlm_xactor, type DATA = vmm_data,
type PHASE = vmm_tlm::phase_e)
extends vmm_tlm_port_base#(DATA,PHASE);
Description
Class providing the non-blocking backward transport port.
Transactions received from the producer, on the forward path, are
sent back to the producer on the backward path using this nonblocking transport port. The parameter type INITIATOR is the class
instantiating the transport port. This defaults to vmm_tlm_xactor.
The parameter DATA is the data type of the transaction the port
services. The default is vmm_data. The parameter type PHASE is the
phase class for this port. The default type is vmm_tlm::phase_e.
The port can be bound to one export. A warning is generated if the
port is left unbound.
Summary
vmm_tlm_nb_transport_bw_port::nb_transport_bw()
Non-blocking backward transport function. The target transactor
instantiating this transport port should call the
nb_transport_bw() method of the transport port.
SystemVerilog
function vmm_tlm::sync_e nb_transport_bw(DATA trans,
ref PHASE ph, ref int delay );
Description
Non-blocking transport function of the port. Calls the
nb_transport_bw() method of the bound export. The argument
trans is a handle of the transaction object, ph is a handle of the
phase class, and delay is the timing annotation.
Example
class consumer extends vmm_xactor;
vmm_tlm_nb_transport_bw_port#(consumer) nb_port;
my_trans current_trans ;
task run_ph();
while(1) begin
this.nb_port.nb_tranport_bw(current_trans,ph,
delay);
#5;
end
endtask
endclass
vmm_tlm_nb_transport_bw_port::new()
Constructor of non-blocking backward transport port class.
SystemVerilog
function new(INITIATOR parent, string name);
Description
Sets the parent and instance name of the non-blocking backward
transport port.
Example
class consumer extends vmm_xactor;
vmm_tlm_nb_transport_fw_export#(consumer) nb_export;
vmm_tlm_nb_transport_bw_port#(consumer)nb_port ;
function void build_ph();
this.nb_port = new(this,"consumer port");
endfunction
endclass
vmm_tlm_nb_transport_export#(T,D,P)
Bidirectional non-blocking export.
SystemVerilog
class vmm_tlm_nb_transport_export#(
type TARGET = vmm_tlm_xactor, type DATA = vmm_data,
type FW_PHASE = vmm_tlm, type BW_PHASE = FW_PHASE)
extends vmm_tlm_socket_base#(DATA,BW_PHASE);
Description
Bidirectional export providing non-blocking transport export for the
forward path, and non-blocking transport port for the backward path
in a single transport export.
Only one-to-one binding is allowed for this bidirectional non-blocking
export. The vmm_tlm_nb_transport_export can only be bound
to the vmm_tlm_nb_transport_port.
The vmm_tlm_socket_base provides all the access methods that
are provided by the vmm_tlm_export_base class. The methods
available with this class are tlm_bind(), tlm_unbind(),
tlm_import(), and get_peer(). For more information on the
descriptions of those methods, see the vmm_tlm_port_exbase
class description.
This class provides non-blocking transport methods for both the
forward path, nb_transport_fw and the backward path,
nb_transport_bw.
Example
class consumer extends vmm_xactor;
vmm_tlm_nb_transport_export#(consumer) nb_export =
new(this,"consumer_bi");
function vmm_tlm::sync_e nb_transport_fw(int id=-1,
my_trans trans, ref vmm_tlm ph, ref int delay);
endfunction
virtual task run_ph();
my_trans tr;
while(1) begin
this.tr.notify.wait_for(vmm_data::ENDED);
this.nb_port.nb_transport_bw(tr,ph,delay);
#5;
end
endtask
endclass
Summary
`vmm_tlm_nb_transport_export()
Shorthand macro to create unique classes of the bidirectional export.
This is useful if multiple vmm_tlm_nb_transport_export
instances are required in the same initiator transactor, each having
its own implementation of the nb_transport_fw() method.
SystemVerilog
`vmm_tlm_nb_transport_export(SUFFIX)
Description
The use model is similar to the shorthand macros provided for the
unidirectional non-blocking exports. For more information, see the
description of `vmm_tlm_nb_transport_fw_export macro.
Example
class consumer extends vmm_xactor;
`vmm_tlm_nb_transport_export(_1)
`vmm_tlm_nb_transport_export(_2)
vmm_tlm_nb_transport_export_1#(producer) nb_exp1;
vmm_tlm_nb_transport_export_2#(producer) nb_exp2;
function vmm_tlm::sync_e nb_transport_fw_1(int id=-1,
my_trans trans,ref vmm_tlm ph, ref int delay);
endfunction
function vmm_tlm::sync_e nb_transport_fw_2(int id=-1,
my_trans trans,ref vmm_tlm ph, ref int delay);
endfunction
endclass
vmm_tlm_nb_transport_fw_export#(T,D,P)
Non-blocking forward transport export class.
SystemVerilog
class vmm_tlm_nb_transport_fw_export#(
type TARGET = vmm_tlm_xactor, type DATA = vmm_data,
type PHASE = vmm_tlm::phase_e)
extends vmm_tlm_export_base#(DATA,PHASE);
Description
Class providing the non-blocking forward transport export. The
parameter type TARGET is the class instantiating the transport
export. This defaults to vmm_tlm_xactor. The parameter DATA is
the data type of the transaction the export services. The default is
vmm_data. The parameter type PHASE is the phase class for this
export. The default type is vmm_tlm::phase_e.
The export can be bound to multiple ports up to the max bindings
specified in the constructor of this class.
Summary
`vmm_tlm_nb_transport_fw_export()
Shorthand macro to create unique instances of non-blocking forward
transport export. This is useful if multiple exports are required in the
same target transactor.
SystemVerilog
`vmm_tlm_nb_transport_fw_export(SUFFIX)
Description
This macro creates a uniquified
vmm_tlm_nb_transport_fw_export class, with SUFFIX
appended to the vmm_tlm_nb_transport_fw_export class
name. The class with the name
vmm_tlm_nb_transport_fw_exportSUFFIX is created in the
scope, where the macro is called.
This macro is required if there are multiple instances of the
vmm_tlm_nb_transport_fw_export class, and each requires a
unique implementation of the nb_transport_fw() task in the
parent transactor.
The nb_transport_fw() methods in the parent transactor must
be uniquified using the same SUFFIX to nb_transport_fw.
Alternatively, if multiple ports need to service the parent transactor,
then a single export with multiple bindings using unique ids can be
used in place of the macro. The single nb_transport_fw()
method can be programmed to serve the various ports depending on
the id.
Example
class consumer extends vmm_xactor;
`vmm_tlm_nb_transport_fw_export(_1)
`vmm_tlm_nb_transport_fw_export(_2)
vmm_tlm_nb_transport__fw_export_1#(consumer)
nb_export1 = new(this, "export1");
vmm_tlm_nb_transport_fw_export_2#(consumer)
nb_export2 = new(this, "export2");
function nb_transport_fw_1(int id = -1, vmm_data trans,
ref vmm_tlm::phase_e ph, ref int delay );
trans.display("From export1");
endfunction
task nb_transport_fw_2(int id = -1, vmm_data trans,
ref vmm_tlm::phase_e ph, ref int delay);
trans.display("From export2");
endtask
endclass
class producer extends vmm_xactor;
vmm_tlm_nb_transport_fw_port#(producer) nb_port;
endclass
class my_env extends vmm_group;
producer p1,p2;
consumer c1;
function void connect_ph();
c1.nb_export1.tlm_bind(p1.nb_port);
c1.nb_export2.tlm_bind(p2.nb_port);
endfunction
endclass
vmm_tlm_nb_transport_fw_export::nb_transport_fw()
Non-blocking transport method of the export.
SystemVerilog
function vmm_tlm::sync_e nb_transport_fw(int id = -1,
DATA trans, ref PHASE ph, ref int delay);
Description
Non-blocking transport function of the transport export. This function
is internally called by the bound transport port. This function calls the
nb_transport_fw() method of the parent transactor in which it is
instantiated. If the export is bound to multiple ports then the peer can
be distinguished using the id field passed to the
nb_transport_fw() method.
The trans argument is a handle of the transaction object, ph is the
handle of phase class to specify the phase of a transaction trans,
and the delay argument is the timing annotation.
Example
class consumer extends vmm_xactor;
vmm_tlm_nb_transport_fw_export#(consumer) nb_export;
function vmm_tlm::sync_e nb_transport_fw(int id = -1,
vmm_data trans,ref vmm_tlm::phase_e ph,
ref int delay );
trans.display("From consumer");
return vmm_tlm::TLM_COMPLETED;
endfunction
endclass
vmm_tlm_nb_transport_fw_export::new()
Constructor of non-blocking forward transport export class. Any
class instantiating this non-blocking export must provide an
implementation of the nb_transport_fw() function.
SystemVerilog
function new(TARGET parent, string name, int max_binds = 1,
int min_binds = 0);
Description
Set the parent and instance name of the blocking transport export.
Sets the maximum and minimum bindings allowed for this export.
The default value of maximum bindings is 1 and minimum binding is
0. An error is issued during tlm_bind() if the current binding
exceeds the maximum allowed bindings for the export. An error is
issued during elaboration if the export does not have the minimum
number of specified bindings.
Example
class consumer extends vmm_xactor;
vmm_tlm_nb_transport_fw_export#(consumer) nb_export;
function void build_ph();
this.nb_export = new(this,"consumer export",5,1);
endfunction
endclass
vmm_tlm_nb_transport_fw_port#(I,D,P)
Non-blocking transport port for the forward path.
SystemVerilog
class vmm_tlm_nb_transport_fw_port #(
type INITIATOR=vmm_tlm_xactor,
type DATA = vmm_data, type PHASE = vmm_tlm::phase_e)
extends vmm_tlm_port_base#(DATA,PHASE);
Description
Class providing the non-blocking forward transport port.
Transactions originating from the producer are sent on the forward
path, using this non-blocking transport port. The parameter type,
INITIATOR is the class that instantiates the transport port. This
defaults to vmm_tlm_xactor. The parameter DATA is the data type
of the transaction the port services. The default is vmm_data. The
parameter type PHASE is the phase class for this port. The default
type is vmm_tlm::phase_e.
The port can be bound to one export. A warning is generated if the
port is left unbound.
Summary
vmm_tlm_nb_transport_fw_port::nb_transport_fw()
Non-blocking forward transport function. The initiator transactor
initiating this transport port should call the nb_transport_fw()
method of the transport port.
SystemVerilog
function vmm_tlm::sync_e nb_transport_fw(DATA trans,
ref PHASE ph, ref int delay);
Description
Call the nb_transport_fw() method of the bound export. The
argument, trans is a handle of the transaction object, ph is a handle
of the phase class, and delay is the timing annotation.
You must ensure that delay is provided in the loop, where this nonblocking function is being called.
Example
class producer extends vmm_xactor;
vmm_tlm_nb_transport_port#(producer) nb_port;
task run_ph();
my_data tr;
while(1) begin
tr = new();
this.nb_port.nb_tranport_fw(tr,ph,delay);
#5;
end
endtask
endclass
vmm_tlm_nb_transport_fw_port::new()
Constructor of non-blocking forward transport port class.
SystemVerilog
function new(TARGET parent, string name);
Description
Sets the parent and instance name of the non-blocking forward
transport port.
Example
class producer extends vmm_xactor;
vmm_tlm_nb_transport_fw_port#(producer) nb_port;
function void build_ph();
this.nb_port = new(this,"producer port");
endfunction
endclass
vmm_tlm_nb_transport_port#(I,D,P)
Bidirectional non-blocking port.
SystemVerilog
class vmm_tlm_nb_transport_port#(
type INITIATOR = vmm_tlm_xactor, type DATA = vmm_data,
type FW_PHASE = vmm_tlm::phase_e,
type BW_PHASE = FW_PHASE)
extends vmm_tlm_socket_base#(DATA,FW_PHASE);
Description
Bidirectional port providing a non-blocking transport port for the
forward path, and a non-blocking transport export for the backward
path, in a single transport port.
Only one-to-one binding is allowed for this bidirectional, nonblocking port. The vmm_tlm_nb_transport_port can only be
bound to the vmm_tlm_nb_transport_export.
The vmm_tlm_socket_base provides all the access methods that
are provided by the vmm_tlm_port_base class. The methods
available with this class are tlm_bind(), tlm_unbind(),
tlm_import(), and get_peer(). For more information on those
methods, see the vmm_tlm_port_base class.
This class provides non-blocking transport methods for both, the
forward path, nb_transport_fw and the backward path,
nb_transport_bw.
Example
class producer extends vmm_xactor;
vmm_tlm_nb_transport_port#(producer) nb_port =
new(this,"producer_bi");
function vmm_tlm::sync_e nb_transport_bw(int id=-1,
my_trans trans, ref vmm_tlm::phase_e ph,
ref int delay);
endfunction
virtual task run_ph();
my_trans tr;
while(1) begin
tr = new();
tr.randomize();
this.nb_port.nb_transport_fw(tr,ph,delay);
#5;
end
endtask
endclass
Summary
`vmm_tlm_nb_transport_port()
Shorthand macro to create unique classes of the bidirectional port.
This is useful if multiple vmm_tlm_nb_transport_port instances
are required in the same initiator transactor, each having its own
implementation of the nb_transport_bw() method.
SystemVerilog
`vmm_tlm_nb_transport_port(SUFFIX)
Description
The use model is similar to the shorthand macros provided for the
unidirectional non-blocking ports. For more information, see the
description of the `vmm_tlm_nb_transport_fw_export macro.
Example
class producer extends vmm_xactor;
`vmm_tlm_nb_transport_port(_1)
`vmm_tlm_nb_transport_port(_2)
vmm_tlm_nb_transport_port_1#(producer) nb_port1;
vmm_tlm_nb_transport_port_2#(producer)
nb_port2;
function vmm_tlm::sync_e nb_transport_bw_1
(int id=-1,my_trans trans,ref vmm_tlm::phase_e ph,
ref int delay);
endfunction
function vmm_tlm::sync_e nb_transport_bw_2
(int id=-1,my_trans trans,ref vmm_tlm::phase_e ph,
ref int delay);
endfunction
endclass
vmm_tlm_port_base#(D,P)
Abstract base class for all TLM2.0 transport ports
SystemVerilog
virtual class vmm_tlm_port_base#(type DATA=vmm_data,
type PHASE = vmm_tlm::phase_e) extends vmm_tlm_base;
Description
This is an abstract base class for all TLM2.0 transport ports. This
class contain the methods that are required by all TLM2.0 transport
port implementations. Any user-defined port must be extended from
this base class.
The DATA parameter is the type of the transaction object the port
services. The default type is vmm_data. The PHASE parameter is the
type of the phasing class. The default value is vmm_tlm::phase_e.
Summary
vmm_tlm_port_base::get_peer() ....................
vmm_tlm_port_base::get_peer_id() .................
vmm_tlm_port_base::new() .........................
vmm_tlm_port_base::tlm_bind() ....................
vmm_tlm_port_base::tlm_import() ..................
vmm_tlm_port_base::tlm_unbind() ..................
page
page
page
page
page
page
B-348
B-349
B-350
B-351
B-353
B-355
vmm_tlm_port_base::get_peer()
Returns the binding for the port.
SystemVerilog
function vmm_tlm_export_base#(DATA,PHASE) get_peer();
Description
Returns the export bound to the current port. Returns Null, if the port
does not contain a binding.
Example
class producer extends vmm_xactor;
vmm_tlm_b_transport_port#(producer) b_port;
function display_my_id();
vmm_tlm_export_base peer;
peer = this.b_port.get_peer();
$display("My id = %d",peer.get_peer_id(this);
endfunction
endclass
vmm_tlm_port_base::get_peer_id()
Returns the id of this port for its binding
SystemVerilog
function int get_peer_id();
Description
Returns the id of this port, with respect to its export binding. If port
is not bound, -1 is returned.
Example
class my_env extends vmm_group;
producer p1,p2;
consumer c1;
function connect_ph();
p1.b_port.tlm_bind(c1.b_export);
p2.b_port.tlm_bind(c1.b_export);
int p1_id = p1.b_port.get_peer_id(); //returns 0
int p2_id = p2.b_port.get_peer_id(); //returns 1
endfunction
endclass
vmm_tlm_port_base::new()
Constructor of the port base class.
SystemVerilog
function new(vmm_object parent, string name, vmm_log log);
Description
Sets the parent, if the base class extends vmm_object. Sets the
name of the instance. log is the message interface instance to be
used for reporting messages.
vmm_tlm_port_base::tlm_bind()
Binds the TLM port to the TLM export passed as an argument.
SystemVerilog
function void tlm_bind(vmm_tlm_export_base#(DATA,PHASE)
peer,int id = -1, , string fname = "", int lineno = 0);
Description
Binds the TLM port to the TLM export. A port can contain only one
binding, though multiple bindings are allowed for exports. It is an
error to bind a port that already contains a binding.
This method adds the current port descriptor to the bindings list of
peer. Calling port.tlm_bind(export,id) is equivalent to
export.tlm_bind(port,id), and the binding can be done
either way. It is an error if both calls are made, since the port allows
only one binding.
The second argument, id, is used to distinguish between multiple
ports that bind to the same export. The id field is used by the export.
If a positive id is supplied, then it must be unique for that export. It
is an error if a positive id already used by the export is supplied. If
no id or a negative id is supplied, then the lowest available unique
positive id is automatically assigned. This id is passed as an
argument of the transport method implemented in the exports
parent. The fname and lineno arguments are used to track the file
name and the line number, where tlm_bind is invoked from.
Example
class producer extends vmm_xactor;
vmm_tlm_b_transport_port#(producer)
b_port = new(this,"producer port");
endclass
class consumer extends vmm_xactor;
vmm_tlm_b_transport_export#(consumer)
b_export = new(this,"consumer export");
endclass
class my_env extends vmm_group;
producer p[4];
consumer c;
function void connect_ph();
foreach(p[i]) begin
p[i].b_port.tlm_bind(c.b_export, i);
end
endfunction
endclass
vmm_tlm_port_base::tlm_import()
Imports a port from an inner level in the hierarchy, to an outer level.
SystemVerilog
function void tlm_import(vmm_tlm_port_base#(DATA,PHASE)
peer, string fname = "", int lineno = 0);
Description
This is a special port-to-port binding. It simplifies the binding for
hierarchical ports and exports, by making the inner port visible to the
outer hierarchy. The binding finally resolves to a port-export binding.
The method allows only parent-child ports to be imported. An error is
generated, if the ports do not share a parent-child relationship. It is
an error to import a port that is already imported. It is an error to
import a port that is already bound.
The method can be called for both parent-to-child binding and childto-parent binding. The parent transactors must be derivatives of
vmm_object. If the parent is a vmm_xactor extension, then the
vmm_xactor base class should be underpinned. If the
vmm_xactor is not underpinned, or the parent is not a derivative of
vmm_object, then only
child.port.tlm_import(parent.port) is allowed. The error
checks are not executed, and you must ensure legal connections.
The fname and lineno arguments are used to track the file name
and the line number, where tlm_import is invoked from.
Example
class initiator_child extends vmm_xactor;
vmm_tlm_b_transport_port#(initiator_child) b_port;
endclass
class initiator_parent extends vmm_group;
vmm_tlm_b_transport_port#(initiator_parent) b_port;
initiator_child initiator;
function void connect_ph();
initiator.b_port.tlm_import(this.b_port);
endfunction
endclass
class target extends vmm_xactor;
vmm_tlm_b_transport_export b_export;
endclass
class my_env extends vmm_group;
initiator_parent initiator;
target target;
function void connect_ph();
initiator.b_port.tlm_bind(target.b_export);
endfunction
endclass
vmm_tlm_port_base::tlm_unbind()
Removes the existing port binding.
SystemVerilog
function void tlm_unbind(string fname = "", int lineno = 0);
Description
Sets the port binding to null. Also, removes the current port
descriptors binding from the export that the port is bound to. A
warning is generated if a binding does not exist for this port.
This method can be used to dynamically change existing bindings for
a port. The fname and lineno arguments are used to track the file
name and the line number, where tlm_unbind is invoked from.
Example
class my_env extends vmm_group;
producer p1;
consumer c1, c2;
function void connect_ph();
p1.b_port.tlm_bind(c1.b_export);
endfunction
endclass
class test2 extends vmm_test;
function void configure_test_ph();
env.p1.b_port.tlm_unbind();
env.p1.b_port.tlm_bind(c2.b_export);
endfunction
endclass
vmm_tlm_initiator_socket#(I,D,P)
Bidirectional socket port providing both blocking and non-blocking
paths.
SystemVerilog
class vmm_tlm_initiator_socket#(
type INITIATOR = vmm_tlm_xactor, type DATA = vmm_data,
type PHASE = vmm_tlm::phase_e)
extends vmm_tlm_socket_base#(DATA,PHASE);
Description
Bidirectional socket port providing blocking transport port, nonblocking transport port for the forward path, and non-blocking
transport export for the backward path, in a single transport socket.
Only one-to-one binding is allowed for this bidirectional socket. The
vmm_tlm_initiator_socket can only be bound to the
vmm_tlm_target_socket.
The vmm_tlm_socket_base provides all access methods that are
provided by the vmm_tlm_port_base class. The methods
available with this class are tlm_bind(), tlm_unbind(),
tlm_import(), and get_peer(). For more information on those
methods, see the vmm_tlm_port_base class description.
This class provides a blocking b_transport() transport method,
and non-blocking nb_transport_fw() and
nb_transport_bw() transport methods for the forward path and
the backward path, respectively.
Example
class producer extends vmm_xactor;
vmm_tlm_initiator_socket#(producer) socket =
new(this,"producer_socket");
function vmm_tlm::sync_e nb_transport_bw(int id=-1,
my_trans trans, ref vmm_tlm ph, ref int delay);
endfunction
virtual task run_ph();
my_trans tr;
while(1) begin
tr = new();
tr.randomize();
this.socket.nb_transport_fw(tr,ph,delay);
#5;
end
endtask
endclass
Summary
`vmm_tlm_initiator_socket()
Shorthand macro to create unique classes of the bidirectional
socket. This is useful if multiple vmm_tlm_initiator_socket
instances are required in the same initiator transactor, each having
its own implementation of the nb_transport_bw() method.
SystemVerilog
`vmm_tlm_initiator_socket(SUFFIX)
Description
The use model is similar to the shorthand macros, provided for the
unidirectional non-blocking ports. For more information, see the
description of the `vmm_tlm_nb_transport_fw_export macro.
Example
class producer extends vmm_xactor;
`vmm_tlm_initiator_socket(_1)
`vmm_tlm_initiator_socket(_2)
vmm_tlm_initiator_socket_1#(producer) s1;
vmm_tlm_initiator_socket_2#(producer) s2;
function vmm_tlm::sync_e nb_transport_bw_1(
int id=-1,my_trans trans,ref vmm_tlm::phase ph,
ref int delay);
endfunction
function vmm_tlm::sync_e nb_transport_bw_2(
int id=-1,my_trans trans,ref vmm_tlm::phase_e ph,
ref int delay);
endfunction
endclass
vmm_tlm_target_socket#(T,D,P)
Bidirectional socket export providing both blocking and non-blocking
paths.
SystemVerilog
class vmm_tlm_target_socket#(
type TARGET = vmm_tlm_xactor, type DATA = vmm_data,
type PHASE = vmm_tlm::phase_e)
extends vmm_tlm_socket_base#(DATA,PHASE);
Description
Bidirectional socket export providing blocking transport export, nonblocking transport export for the forward path, and non-blocking
transport port for the backward path in a single transport socket.
Only one-to-one binding is allowed for this bidirectional socket. The
vmm_tlm_target_socket can only be bound to the
vmm_tlm_initiator_socket.
The vmm_tlm_socket_base provides all access methods that are
provided by the vmm_tlm_port_base class. The methods
available with this class are tlm_bind(), tlm_unbind(),
tlm_import(), and get_peer(). For more information on these
methods, refer to the vmm_tlm_port_base class description.
This class provides a blocking b_transport() transport method,
and non-blocking nb_transport_fw() and nb_transport_bw()
transport methods for the forward and backward paths, respectively.
Example
class consumer extends vmm_xactor;
vmm_tlm_target_socket#(consumer) nb_export =
new(this,"consumer_socket");
function vmm_tlm::sync_e nb_transport_fw(int id=-1,
my_trans trans,ref vmm_tlm::phase_e ph,
ref int delay);
endfunction
task b_transport(int id=-1, my_trans trans,
ref int delay);
endtask
virtual task run_ph();
my_trans tr;
while(1) begin
this.tr.notify.wait_for(vmm_data::ENDED);
this.nb_port.nb_transport_bw(tr,ph,delay);
#5;
end
endtask
endclass
Summary
`vmm_tlm_target_socket()
Shorthand macro to create unique classes of the bidirectional
socket. Used if multiple vmm_tlm_target_socket instances are
required in the same target transactor, each having its own
implementation of the nb_transport_bw() method.
SystemVerilog
`vmm_tlm_nb_simple_target_socket(SUFFIX)
Description
The use model is similar to the shorthand macros provided for the
unidirectional exports. For more information, see the
`vmm_tlm_nb_transport_fw_export macro description.
Example
class consumer extends vmm_xactor;
`vmm_tlm_target_socket(_1)
`vmm_tlm_target_socket(_2)
vmm_tlm_target_socket_1#(producer) soc1;
vmm_tlm_target_socket_2#(producer) soc2;
function vmm_tlm::sync_e nb_transport_fw_1(
int id=-1,my_trans trans, ref vmm_tlm::phase_e ph,
ref int delay);
endfunction
function vmm_tlm::sync_e nb_transport_fw_2(
int id=-1,my_trans trans, ref vmm_tlm::phase_e ph,
ref int delay);
endfunction
task b_transport_1(int id=-1, my_trans trans,
ref int delay);
endtask
vmm_tlm_transport_interconnect#(DATA)
Interconnect transport class.
Class extended from
vmm_tlm_transport_interconnect_base. This class is
specific to vmm_tlm::phase_e type.
The parameter DATA is the type of the transaction object of the port/
export services. The default type is vmm_data.
SystemVerilog
class vmm_tlm_transport_interconnect #(type DATA = vmm_data)
extends vmm_tlm_transport_interconnect_base#(DATA);
Description
Used to connect vmm_tlm port to a non-matching export.
Summary
vmm_tlm_transport_interconnect::new()
Constructor of an interconnect class.
SystemVerilog
function new(vmm_object parent,string name);
Description
Sets the parent, if it is an extension of vmm_object. Sets the name
of the instance.
vmm_tlm_transport_interconnect_base#(DATA,PHASE
)
Interconnect transport base class.
Base class for vmm_tlm_transport_interconnect class. This
class contains tlm_bind method which is used to connect below
ports and exports.
vmm_tlm_b_transport_port to
vmm_tlm_nb_transport_export
vmm_tlm_b_transport_port to
vmm_tlm_nb_transport_fw_export
vmm_tlm_nb_transport_port to
vmm_tlm_b_transport_export
vmm_tlm_nb_transport_fw_port to
vmm_tlm_b_transport_export
Any user-defined interconnect class should be extended from this
base class. The parameter DATA is the type of the transaction object
of the port/export services. The default type is vmm_data. The
parameter PHASE is the type of the phasing class. The default value
is vmm_tlm::phase_e.
SystemVerilog
class vmm_tlm_transport_interconnect_base #(type DATA =
vmm_data , type PHASE = vmm_tlm::phase_e) extends vmm_object;
Description
Used to connect vmm_tlm port to a non-matching export.
Summary
vmm_tlm_transport_interconnect_base::new()
Constructor of an interconnect base class.
SystemVerilog
function new(vmm_object parent, string name);
Description
Sets the parent, if it is an extension of vmm_object. Sets the name
of the instance.
vmm_tlm_transport_interconnect_base::tlm_bind()
Binds the TLM port to TLM export.
SystemVerilog
function int tlm_bind(vmm_tlm_base tlm_intf_port,
vmm_tlm_base tlm_intf_export, vmm_tlm::intf_e intf, string
fname = "", int lineno = 0);
Description
Binds the tlm_intf_port to tlm_intf_export, which are
passed as arguments to the function.
First argument to the function is tlm port and the second argument is
tlm export. If wrong types are passed to first or second argument
then an error is issued.
Third argument takes type of the non-blocking port or export.
vmm_tlm::TLM_NONBLOCKING_EXPORT
This is used when producer is vmm_tlm_b_transport_port
and consumer is vmm_tlm_nb_transport_export.
vmm_tlm::TLM_NONBLOCKING_FW_EXPORT
This is used when producer is vmm_tlm_b_transport_port
and consumer is vmm_tlm_nb_transport_fw_export.
vmm_tlm::TLM_NONBLOCKING_PORT
This is used when producer is vmm_tlm_nb_transport_port
and consumer is vmm_tlm_b_transport_export.
vmm_tlm::TLM_NONBLOCKING_FW_PORT
This is used when producer is
vmm_tlm_nb_transport_fw_port and consumer is
vmm_tlm_b_transport_export.
Any other values for third argument will issue an error.
SystemVerilog
class vmm_tlm_reactive_if#(type DATA = vmm_data, int q_size
= 1) extends vmm_object;
Description
It facilitates writing reactive transactors using a polling approach
rather than an interrupt approach. It provides blocking, nonblocking_fw and non-blocking (bi-directional) exports and can be
bound to more than one port.
Summary
vmm_tlm_reactive_if::completed() .................
vmm_tlm_reactive_if::get() .......................
vmm_tlm_reactive_if::new() .......................
vmm_tlm_reactive_if::tlm_bind() ..................
vmm_tlm_reactive_if::try_get() ...................
page
page
page
page
page
B-371
B-372
B-373
B-374
B-376
vmm_tlm_reactive_if::completed()
Indicate that the previously activated transaction has been
completed.
SystemVerilog
function void completed();
Description
The completed method must be called by the transactor to indicate
the completion of active transaction. The blocking port which initiated
the transaction will be unblocked and nb_transport_bw method is
called for non-blocking bi-directional with TLM_COMPLETED phase.
For vmm_data derivatives vmm_data::ENDED is also indicated.
The transaction is removed from the pending queue only when
completed is called.
Example
class consumer extends vmm_xactor;
vmm_tlm_reactive_if#(my_trans, 4) reac_export1 = new(this,
"export1");
virtual task run_ph();
my_trans trans;
fork
while (1)
begin
reac_export1.get(trans);
reac_export1.completed();
end
join_none
endtask : run_ph
endclass : consumer
vmm_tlm_reactive_if::get()
Blocking method to get the next transaction object.
SystemVerilog
task get(output DATA tr);
Description
Blocks until a transaction object is available. If there is more than one
object then gets the first transaction object. Subsequent get calls
must be preceded by calling the completed() method. Else, an
error is issued.
Example
class consumer extends vmm_xactor;
vmm_tlm_reactive_if#(my_trans, 4) reac_export1 = new(this,
"export1");
virtual task run_ph();
my_trans trans;
fork
while (1)
begin
reac_export1.get(trans);
reac_export1.completed();
end
join_none
endtask : run_ph
endclass : consumer
Indicate that the previously activated transaction has been
completed.
vmm_tlm_reactive_if::new()
Constructor of reactive interface class.
SystemVerilog
function new(vmm_object parent, string name);
Description
Sets the parent, if it is an extension vmm_object. Sets the name of
the instance.
vmm_tlm_reactive_if::tlm_bind()
Binds the TLM port passed as an argument to the corresponding
TLM export depending on the enum passed in second argument.
SystemVerilog
function int tlm_bind(vmm_tlm_base tlm_intf,
vmm_tlm::intf_e intf);
Description
Binds the TLM port passed as an argument to one of the export in
the class depending on the enum value passed as second
arguement.
The second argument can be,
vmm_tlm::TLM_NONBLOCKING_EXPORT
Port passed as an argument is connected to
vmm_tlm_nb_transport_export (bi-directional)
vmm_tlm::TLM_BLOCKING_EXPORT
Port passed as an argument is connected to
vmm_tlm_b_transport_export
vmm_tlm::TLM_NONBLOCKING_FW_EXPORT
Port passed as an argument is connected to
vmm_tlm_nb_transport_fw_export (forward only)
Example
class consumer extends vmm_xactor;
vmm_tlm_reactive_if#(my_trans, 4) reac_export1 = new(this,
"export1");
virtual task run_ph();
my_trans trans;
fork
while (1)
begin
reac_export1.get(trans);
reac_export1.completed();
end
join_none
endtask : run_ph
endclass : consumer
class producer extends vmm_xactor;
vmm_tlm_b_transport_port#(producer) b_port = new(this,
"producer port");
endclass
class my_env extends vmm_group;
producer p1;
producer p2;
consumer c;
function void connect_ph();
c.reac_export1.tlm_bind(p1.b_port,
vmm_tlm::TLM_BLOCKING_EXPORT);
c.reac_export1.tlm_bind(p2.b_port,
vmm_tlm::TLM_BLOCKING_EXPORT);
endfunction
endclass
vmm_tlm_reactive_if::try_get()
Non-blocking function to get the next transaction object.
SystemVerilog
Function DATA try_get();
Description
Returns null if no transaction object is received. If there are more
than one object then returns the first transaction object. Subsequent
try_get calls must be preceded by calling the completed()
method. Else, an error is issued.
Example
class consumer extends vmm_xactor;
vmm_tlm_reactive_if#(my_trans, 4) reac_export1 = new(this,
"export1");
virtual task run_ph();
my_trans trans;
fork
while (1)
begin
trans = reac_export1.try_get();
reac_export1.completed();
end
join_none
endtask : run_ph
endclass : consumer
vmm_unit
Base class for providing pre-defined simulation phases.
SystemVerilog
virtual class vmm_unit extends vmm_object;
Description
This class is used as the base class that provides pre-defined
simulation phases to structural elements, such as transactors,
transaction-level models and generators. The purpose of this class
is to:
- connect_ph()
- configure_test_ph()
- start_of_sim_ph()
- reset_ph()
- training_ph()
- config_dut_ph()
- start_ph()
- start_of_test_ph()
- run_ph()
- shutdown_ph()
- cleanup_ph()
- report_ph()
- final
Summary
vmm_unit::build_ph() .............................
vmm_unit::cleanup_ph() ...........................
vmm_unit::config_dut_ph() ........................
vmm_unit::configure_ph() .........................
vmm_unit::connect_ph() ...........................
vmm_unit::consensus_requested() ..................
vmm_unit::consent() ..............................
vmm_unit::disabled_ph() ..........................
vmm_unit::disable_unit() .........................
vmm_unit::forced() ...............................
vmm_unit::force_thru() ...........................
vmm_unit::get_timeline() .........................
vmm_unit::is_unit_enabled() ......................
vmm_unit::new() ..................................
vmm_unit::oppose() ...............................
vmm_unit::override_phase() .......................
vmm_unit::report_ph() ............................
vmm_unit::request_consensus() ....................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
B-380
B-381
B-382
B-383
B-384
B-385
B-386
B-387
B-388
B-390
B-391
B-392
B-393
B-394
B-395
B-396
B-397
B-398
vmm_unit::reset_ph() .............................
vmm_unit::run_ph() ...............................
vmm_unit::shutdown_ph() ..........................
vmm_unit::start_of_sim_ph() ......................
vmm_unit::start_of_test_ph() .....................
vmm_unit::start_ph() .............................
vmm_unit::training_ph() ..........................
page
page
page
page
page
page
page
B-399
B-400
B-401
B-402
B-403
B-404
B-405
vmm_unit::build_ph()
Method to build this component.
SystemVerilog
virtual function void vmm_unit::build_ph();
Description
Builds this component. Leaf level or independent root components
associated can be created here.
Example
class memsys_env extends vmm_group;
cpu_subenv extends cpu0;
vmm_ms_scenario_gen gen;
memsys_scenario memsys_scn;
...
function void build_ph();
cpu0 = new("subenv", "CPU0", this);
cpu1 = new("subenv", "CPU1", this);
memsys_scn = new();
gen = new("MS-Generator");
...
endfunction
endclass
vmm_unit::cleanup_ph()
Method for post-execution.
SystemVerilog
virtual task vmm_unit::cleanup_ph();
Description
Method to perform post-execution verification, if it is enabled.
Example
class groupExtension extends vmm_group;
task cleanup_ph();
`vmm_note(log,`vmm_sformatf(
"groupExtension::cleanup_ph"));
...
endtask:cleanup_ph
endclass
vmm_unit::config_dut_ph()
Method for DUT configuration.
SystemVerilog
virtual task vmm_unit::config_dut_ph();
Description
Initialization of the DUT attached to this component, if it is enabled.
Example
class vdmsys_env extends vmm_group;
task config_dut_ph;
top.write_reg(N_RD_PORT, 20);
top.write_reg(N_WR_PORT, 30);
...
endtask
endclass
vmm_unit::configure_ph()
Method for functional configuration.
SystemVerilog
virtual function void vmm_unit::configure_ph();
Description
Functional configuration of this component.
Example
class groupExtension extends vmm_group;
...
function void configure_ph();
`vmm_note
(log,`vmm_sformatf("groupExtension::configure_ph"));
...
endfunction:configure_ph
endclass
vmm_unit::connect_ph()
Method for connecting components.
SystemVerilog
virtual function void vmm_unit::connect_ph();
Description
Connects the interfaces that are wholly contained within this
component.
Example
class memsys_env extends vmm_group;
cpu_subenv extends cpu0;
vmm_ms_scenario_gen gen;
memsys_scenario memsys_scn;
...
function void build_ph();
cpu0 = new("subenv", "CPU0", this);
cpu1 = new("subenv", "CPU1", this);
memsys_scn = new();
gen = new("MS-Generator");
...
endfunction
function void memsys_env::connect_ph();
gen.register_channel("cpu0_chan",
cpu0.gen_to_drv_chan);
gen.register_channel("cpu1_chan",
cpu1.gen_to_drv_chan);
gen.register_ms_scenario( "memsys_scn", memsys_scn);
...
endfunction
endclass
vmm_unit::consensus_requested()
A consensus request is made.
SystemVerilog
virtual function void consensus_requested(vmm_unit who);
OpenVera
Not supported
Description
When this method is called, it indicates that a consensus request is
made to this currently-opposing unit by the specified unit, by calling
the vmm_unit::request_consensus() method.
This method should be extended, if this unit is to honor consensus
requests.
vmm_unit::consent()
Expresses the consent of this vmm_unit to the consensus for the
specified reason.
SystemVerilog
function void vmm_unit::consent(string why =
"No reason specified");
Description
Expresses the consents of this vmm_unit to the consensus for the
specified reason.
Example
class groupExtension extends vmm_group;
...
task reset_ph();
this.oppose("reset phase running");
fork
begin
#50;
this.consent("reset phase finished");
end
join_none
endtask:reset_ph
...
endclass
vmm_unit::disabled_ph()
Method executes instead of the reset_ph() method, when unit
disabled.
SystemVerilog
virtual task vmm_unit::disabled_ph();
Description
This Method gets executed instead of the reset_ph() method, if
this vmm_unit instance is disabled.
Example
class groupExtension extends vmm_group;
function void disabled_ph();
`vmm_note(log,`vmm_sformatf(
"groupExtension::disabled_ph"));
...
endfunction:disabled_ph
endclass
vmm_unit::disable_unit()
Disables a unit instance.
SystemVerilog
function void vmm_unit::disable_unit();
Description
Disables this instance of the vmm_unit class. This method must be
called, before the start_of_sim phase. A vmm_unit instance can
only be re-enabled by resetting its timeline to the configure phase
or earlier.
Example
class groupExtension extends vmm_group;
...
endclass
groupExtension m1 = new ("groupExtension","m1");
m1.disable_unit();
vmm_unit::final_ph()
Method to publish final report.
SystemVerilog
function void vmm_unit::final_ph();
Description
In case of multiple concatenated tests, final phase can be used to
summarize the final report.
Example
class testExtension extends vmm_test;
.
function void final_ph();
env.summary();
endfunction
endclass
vmm_unit::forced()
Forces consensus on this unit.
SystemVerilog
function void forced(string why = "No reason specified");
OpenVera
Not supported
Description
Forces consensus for this unit to be reached. The consensus may
be subsequently consented to by calling the
vmm_unit::consent() method, or it may be opposed by calling
the vmm_unit::oppose() method.
The forcing of consensus through the parent unit occurs, only if this
unit is configured to force through to its parent by the
vmm_unit::force_thru() method. The why argument is a string
that specifies the reason why the consensus is forced on this unit.
vmm_unit::force_thru()
Forces sub-consensus from a sub-unit through or not.
SystemVerilog
function void force_thru(vmm_unit child, bit thru = 1);
OpenVera
Not supported
Description
If the thru argument is TRUE, any consensus forced on the
specified child unit instance will force the consensus on this unit
instance.
If the thru argument is FALSE, any consensus forced on the
specified child unit instance will simply consent to the consensus on
this unit instance.
vmm_unit::get_timeline()
Returns the enclosing timeline.
SystemVerilog
function vmm_timeline vmm_unit::get_timeline();
Description
Returns the runtime timeline, this unit is executing under.
Example
class groupExtension extends vmm_group;
...
function void build_ph();
vmm_timeline t = this.get_timeline();
...
endfunction
endclass
vmm_unit::is_unit_enabled()
Returns 1, if unit is enabled.
SystemVerilog
function bit vmm_unit::is_unit_enabled();
Description
Checks if this vmm_unit instance is disabled or not. By default, all
units are enabled. A unit may be disabled by calling its
disable_unit() method, before the start_of_sim phase.
Example
class groupExtension extends vmm_group;
...
endclass
class udf_start_def extends vmm_fork_task_phase_def
#(groupExtension);
...
task do_task_phase(groupExtension obj);
if(obj.is_unit_enabled())
obj.udf_start_ph();
endtask:do_task_phase
...
endclass
vmm_unit::new()
Constructor for the vmm_unit.
SystemVerilog
function vmm_unit::new(string name, string inst,
vmm_object parent = null);
Description
Constructs an instance of this class with the specified name,
instance name, and optional parent.
The specified name is used as the name of the embedded vmm_log.
The specified instance name is used as the name of the underlying
vmm_object.
Example
class vip1 extends vmm_group;
function new (string name, string inst);
super.new (name, inst, this);
endfunction
endclass
vmm_unit::oppose()
Expresses the opposition of this vmm_unit to the consensus for the
specified reason.
SystemVerilog
function void vmm_unit::oppose(string why =
"No reason specified");
Description
Expresses the opposition of this vmm_unit to the consensus for the
specified reason.
Example
class groupExtension extends vmm_group;
...
task reset_ph();
this.oppose("reset phase running");
fork
begin
#50;
this.consent("reset phase finished");
end
join_none
endtask:reset_ph
...
endclass
vmm_unit::override_phase()
Method to execute new phase definition instead of the existing one.
SystemVerilog
virtual function vmm_phase_def
vmm_unit::override_phase(string name, vmm_phase_def def);
Description
Overrides the specified phase with the specified phase definition for
this instance. If def is null, the override (if any) is removed. Returns
the previous override phase definition (if any).
Example
class cust_configure_phase_def #(type T = groupExtension)
extends vmm_topdown_function_phase_def #(T);
function void do_function_phase( T obj);
obj.cust_config_ph();
endfunction
endclass
class groupExtension extends vmm_group;
function void config_ph();
`vmm_note(log,`vmm_sformatf(
"groupExtension::configure_ph"));
endfunction:config_ph
function void cust_config_ph();
`vmm_note(log,`vmm_sformatf(
"groupExtension::cust_config_ph"));
endfunction:cust_config_ph
endclass
cust_configure_phase_def cust_cfg = new();
groupExtension
m1 = new("groupExtension","m1");
`void(m1.override_phase("configure",cust_cfg ));
vmm_unit::report_ph()
Method for test reporting.
SystemVerilog
virtual function void vmm_unit::report_ph();
Description
Method to perform post-test pass or fail reporting, if it is enabled.
Example
class memsys_env extends vmm_group;
function void report_ph();
sb.report;
...
endfunction
endclass
vmm_unit::request_consensus()
Requests that a consensus be reached.
SystemVerilog
task request_consensus(string why = No reason specified);
OpenVera
Not supported
Description
Makes a request of all currently-opposing participants in this unit
instance that they consent to the consensus.
A request is made by calling the
vmm_unit::consensus_requested() method in this unit, and
all currently-opposing child units. If a forced consensus on this unit
forces through to a higher-level unit, then the consensus request is
propagated upward as well. This task returns when the local unitlevel consensus is reached.
The why argument is a string that specifies the reason why the
consensus is forced on this unit.
vmm_unit::reset_ph()
Method for reset.
SystemVerilog
virtual task vmm_unit::reset_ph()
Description
Resets this unit, if it is enabled. This method is executed at the reset
phase.
Example
class memsys_env extends vmm_group;
task reset_ph();
// Resetting the DUT
test_top.reset <= 1'b0;
repeat(1) @(test_top.port0.cb)
test_top.reset <= 1'b1;
repeat(10) @(test_top.port0.cb)
test_top.reset <= 1'b0;
`vmm_verbose(this.log,"RESET DONE...");
endtask
endclass
vmm_unit::run_ph()
Body of test, if it is enabled.
SystemVerilog
virtual task vmm_unit::run_ph();
Description
Body of test, if it is enabled. Can be interrupted by resetting this
component. May be stopped.
Example
class groupExtension extends vmm_group;
task run_ph();
`vmm_note(log,`vmm_sformatf(
"groupExtension::run_ph"));
...
endtask : run_ph
endclass
vmm_unit::shutdown_ph()
Method to stop all unit components.
SystemVerilog
virtual task vmm_unit::shutdown_ph();
Description
Method to stop processes within this component, if it is enabled.
Example
class cpu_subenv extends vmm_group;
...
task shutdown_ph();
if (enable_gen) this.gen.stop_xactor();
endtask
...
endclass
vmm_unit::start_of_sim_ph()
Method executes at start of simulation.
SystemVerilog
virtual function void vmm_unit::start_of_sim_ph();
Description
Method called at start of the simulation.
Example
class cpu_driver extends vmm_group;
...
function void start_of_sim_ph();
if (iport == null)
`vmm_fatal(log, "Virtual port not connected to the
actual interface instance");
endfunction
...
endclass
vmm_unit::start_of_test_ph()
Method called at start of the test body.
SystemVerilog
virtual function void vmm_unit::start_of_test_ph();
Description
Method called at start of the test body, if it is enabled.
Example
class groupExtension extends vmm_group;
function void start_of_test_ph();
`vmm_note(log,`vmm_sformatf(
"groupExtension::start_of_test_ph"));
...
endfunction:start_of_test_ph
endclass
vmm_unit::start_ph()
Method to start unit components.
SystemVerilog
virtual task vmm_unit::start_ph();
Description
Method to start processes within this component, if it is enabled.
Example
class memsys_env extends vmm_group;
...
task start_ph();
this.gen.start_xactor();
endtask
...
endclass
vmm_unit::training_ph()
Method for training.
SystemVerilog
virtual task vmm_unit::training_ph();
Description
Initialization of this component, such as interface training.
Example
class groupExtension extends vmm_group;
task training_ph();
`vmm_note(log,`vmm_sformatf(
"groupExtension::training_ph"));
...
endtask:training_ph
endclass
vmm_version
This class is used to report the version and vendor of the VMM
Standard Library implementation.
Summary
vmm_version::display() ...........................
vmm_version::major() .............................
vmm_version::minor() .............................
vmm_version::patch() .............................
vmm_version::psdisplay() .........................
vmm_version::vendor() ............................
page
page
page
page
page
page
B-407
B-408
B-409
B-410
B-411
B-412
vmm_version::display()
Displays the version.
SystemVerilog
function void display(string prefix = "");
OpenVera
Not supported.
Description
Displays the version image returned by the psdisplay() method,
to the standard output.
The argument prefix is used to append a string to the content
displayed by this method.
vmm_version::major()
Returns the major revision number.
SystemVerilog
function int major();
OpenVera
Not supported.
Description
Returns the major version number of the implemented VMM
Standard Library. Should always return 1.
vmm_version::minor()
Returns the minor revision number.
SystemVerilog
function int minor();
OpenVera
function integer minor();
Description
Returns the minor version number of the implemented VMM
Standard Library. Should always return 5, if the additions and
updates specified in this appendix are fully implemented.
Example
Example B-132
initial begin
string minor_ver;
vmm_version v = new;
$sformat(minor_ver,"VMM Minor Version %d", v.minor());
`vmm_note(log,minor_ver);
end
vmm_version::patch()
Returns the patch number.
SystemVerilog
function int patch();
OpenVera
Not supported.
Description
Returns the patch number of the implemented VMM Standard
Library. The returned value is vendor-dependent.
vmm_version::psdisplay()
Formats the major and minor version, patch, and vendor information.
SystemVerilog
function string psdisplay(string prefix = "");
OpenVera
Not supported.
Description
Creates a well formatted image of the VMM Standard Library
implementation version information. The format is:
prefix VMM Version major.minor.patch (vendor)
vmm_version::vendor()
Returns the name of the library vendor.
SystemVerilog
function string vendor();
OpenVera
Not supported.
Description
Returns the name of the vendor supplying the VMM Standard Library
implementation. The returned value is vendor-dependent.
vmm_voter
This class is an interface to participate in a consensus, and indicates
consent or opposition to the end of test. It is created through the
vmm_consensus::register_voter() method. Its
constructor is not documented, therefore, it must not be created
directly.
Summary
vmm_voter::consent()
Agrees to a consensus.
SystemVerilog
function void consent(string why = "No specified reason");
OpenVera
task consent(string why = "No specified reason");
Description
Allows consensus to be reached for the optionally specified reason.
This method may be called repeatedly to modify the reason for the
consent. A consent may be withdrawn by calling the
vmm_voter::oppose() method.
Example
Example B-133
program test_consensus;
string who[];
string why[];
vmm_consensus vote = new("Vote", "Main");
vmm_voter v1;
initial begin
v1 = vote.register_voter("Voter #1");
v1.consent("Consent by default");
...
end
endprogram
vmm_voter::forced()
Forces a consensus.
SystemVerilog
function void forced(string why = "No specified reason");
OpenVera
task forced(string why = "No specified reason");
Description
Forces an end of test consensus for the optionally specified reason.
The end of test is usually forced by a directed testcase, but can be
forced by any participant, as necessary. A forced consensus may be
cancelled (if the simulation is still running) by calling the
vmm_voter::oppose() or vmm_voter::consent()
method.
Example
Example B-134
initial begin
...
vmm_voter test_voter = env.end_vote.register_voter(
"Test case Stimulus");
test_voter.oppose("Test not done");
...
test_voter.forced("Test is done");
end
vmm_voter::oppose()
Opposes to a consensus.
SystemVerilog
function void oppose(string why = "No specified reason");
OpenVera
task oppose(string why = "No specified reason");
Description
Prevents consensus from being reached for the optionally specified
reason, by default. This method may be called repeatedly to modify
the reason for the opposition.
Example
Example B-135
initial begin
my_env env = new();
vmm_voter test_voter = env.end_vote.register_voter(
"Test case Stimulus");
test_voter.oppose("test not done");
end
vmm_xactor
This base class is to be used as the basis for all transactors,
including bus-functional models, monitors, and generators. It
provides a standard control mechanism expected in all transactors.
Summary
vmm_xactor::append_callback() ....................
vmm_xactor::do_psdisplay() .......................
vmm_xactor::do_reset_xactor() ....................
vmm_xactor::do_start_xactor() ....................
vmm_xactor::do_stop_xactor() .....................
vmm_xactor::do_what_e ............................
vmm_xactor::exp_vmm_sb_ds() ......................
vmm_xactor::get_input_channels() .................
vmm_xactor::get_instance() .......................
vmm_xactor::get_name() ...........................
vmm_xactor::get_output_channels() ................
vmm_xactor::inp_vmm_sb_ds() ......................
vmm_xactor::kill() ...............................
vmm_xactor::log ..................................
vmm_xactor::main() ...............................
vmm_xactor::new() ................................
vmm_xactor::notifications_e ......................
vmm_xactor::notify ...............................
vmm_xactor::prepend_callback() ...................
vmm_xactor::psdisplay() ..........................
vmm_xactor::register_vmm_sb_ds() .................
vmm_xactor::reset_xactor() .......................
vmm_xactor::restore_rng_state() ..................
vmm_xactor::stream_id ............................
vmm_xactor::save_rng_state() .....................
vmm_xactor::start_xactor() .......................
vmm_xactor::stop_xactor() ........................
vmm_xactor::unregister_callback() ................
vmm_xactor::unregister_vmm_sb_ds() ...............
vmm_xactor::vmm_callback() ......................
vmm_xactor::wait_if_stopped() ....................
vmm_xactor::wait_if_stopped_or_empty() ...........
vmm_xactor::xactor_status() ......................
vmm_xactor_member_begin() .......................
vmm_xactor_member_end() .........................
vmm_xactor_member_scalar*() .....................
vmm_xactor_member_string*() .....................
vmm_xactor_member_enum*() .......................
vmm_xactor_member_vmm_data*() ...................
vmm_xactor_member_channel*() ...................
vmm_xactor_member_xactor*() .....................
vmm_xactor_member_user_defined() ................
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
page
B-418
B-419
B-420
B-422
B-424
B-426
B-428
B-429
B-430
B-431
B-432
B-433
B-434
B-435
B-436
B-437
B-438
B-440
B-442
B-444
B-445
B-446
B-449
B-450
B-451
B-452
B-453
B-454
B-455
B-456
B-457
B-459
B-461
B-462
B-463
B-464
B-466
B-468
B-470
B-472
B-474
B-476
vmm_xactor::append_callback()
Appends the specified callback faade instance with this instance of
the transactor.
SystemVerilog
virtual function void
append_callback(vmm_xactor_callbacks cb);
OpenVera
Not supported.
Description
Callback methods are invoked in the order in which they were
registered.
A warning is generated, if the same callback faade instance is
registered more than once with the same transactor. A faade
instance can be registered with more than one transactor. Callback
faade instances can be unregistered and re-registered dynamically.
vmm_xactor::do_psdisplay()
Overrides the shorthand psdisplay() method.
SystemVerilog
virtual function string do_psdisplay(string prefix = "")
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_xactor::psdisplay() method, created by the
vmm_xactor shorthand macros. If defined, it will be used instead of
the default implementation.
Example
Example B-136
class eth_frame_gen extends vmm_xactor;
...
`vmm_xactor_member_begin(eth_frame_gen)
...
`vmm_xactor_member_end(eth_frame_gen)
virtual function string do_psdisplay(string prefix = "")
$sformat(do_psdisplay,"%s Printing Ethernet frame \n
generator members \n",prefix);
...
endfunction
...
endclass
vmm_xactor::do_reset_xactor()
Overrides the shorthand reset_xactor() method.
SystemVerilog
protected virtual function void do_reset_xactor(
vmm_xactor::reset_e rst_typ)
OpenVera
Not supported.
Description
Overrides the default implementation of the
vmm_xactor::reset_xactor() method created by the
vmm_xactor shorthand macros. If defined, it is used instead of the
default implementation.
Example
Example B-137
class xact1 extends vmm_xactor;
...
endclass
class xact2 extends vmm_xactor;
...
endclass
class xact extends vmm_xactor;
xact1 xact1_inst;
xact2 xact2_inst;
...
`vmm_xactor_member_begin(xact)
vmm_xactor_member_xactor(xact1_inst,DO_ALL)
vmm_xactor_member_xactor(xact2_inst,DO_ALL)
`vmm_xactor_member_end(xact)
protected virtual function void do_reset_xactor ();
`ifdef XACT_2
xact2_inst.reset_xactor();
`else
xact1_inst.reset_xactor();
`endif
...
endfunction
...
endclass
vmm_xactor::do_start_xactor()
Overrides the shorthand start_xactor() method.
SystemVerilog
protected virtual function void do_start_xactor()
OpenVera
Not supported.
Description
Overrides the default implementation of the
vmm_xactor::start_xactor() method, created by the
vmm_xactor shorthand macros. If defined, it is used instead of the
default implementation.
Example
Example B-138
class xact1 extends vmm_xactor;
...
endclass
class xact2 extends vmm_xactor;
...
endclass
class xact extends vmm_xactor;
xact1 xact1_inst;
xact2 xact2_inst;
...
`vmm_xactor_member_begin(xact)
vmm_xactor_member_xactor(xact1_inst,DO_ALL)
vmm_xactor_member_xactor(xact2_inst,DO_ALL)
`vmm_xactor_member_end(xact)
protected virtual function void do_start_xactor ();
`ifdef XACT_2
xact2_inst.start_xactor();
`else
xact1_inst.start_xactor();
`endif
...
endfunction
...
endclass
vmm_xactor::do_stop_xactor()
Overrides the shorthand stop_xactor() method.
SystemVerilog
protected virtual function void do_stop_xactor()
OpenVera
Not supported.
Description
This method overrides the default implementation of the
vmm_xactor::stop_xactor() method, created by the
vmm_xactor shorthand macros. If defined, it will be used instead of
the default implementation.
Example
Example B-139
class xact1 extends vmm_xactor;
...
endclass
class xact2 extends vmm_xactor;
...
endclass
class xact extends vmm_xactor;
xact1 xact1_inst;
xact2 xact2_inst;
...
`vmm_xactor_member_begin(xact)
vmm_xactor_member_xactor(xact1_inst,DO_ALL)
vmm_xactor_member_xactor(xact2_inst,DO_ALL)
`vmm_xactor_member_end(xact)
protected virtual function void do_stop_xactor ();
`ifdef XACT_2
xact2_inst.stop_xactor();
`else
xact1_inst.stop_xactor();
`endif
...
endfunction
...
endclass
vmm_xactor::do_what_e
Specifies which methods are to be provided by a shorthand
implementation.
SystemVerilog
typedef enum {DO_PRINT
DO_START
DO_STOP
DO_RESET
DO_KILL
DO_ALL
='h001,
='h002,
='h004,
='h010,
='h020,
='hFFF} do_what_e;
OpenVera
Not supported.
Description
Used to specify which methods are to include the specified data
members in their default implementation. The "DO_PRINT" includes
the member in the default implementation of the psdisplay()
method. The "DO_START" includes the member in the default
implementation of the start_xactor() method, if applicable. The
"DO_STOP" includes the member in the default implementation of
the stop_xactor() method, if applicable. The "DO_RESET"
includes the member in the default implementation of the
reset_xactor() method, if applicable.
Multiple methods can be specified by adding or using or in the
individual symbolic values. All methods are specified by providing
the "DO_ALL" symbol.
Example
Example B-140
vmm_xactor_member_xactor(idler, DO_ALL - DO_STOP);
vmm_xactor::exp_vmm_sb_ds()
For more information on this method, refer to the VMM Scoreboard
User Guide.
vmm_xactor::get_input_channels()
Returns the input channels of this transactor.
SystemVerilog
function void get_input_channels(ref vmm_channel chans[$]);
OpenVera
Not supported.
Description
Returns the channels where this transactor is identified as the
consumer using the vmm_channel::set_consumer() method.
Example
Example B-141
class xactor extends vmm_xactor;
...
endclass
program prog;
xactor xact = new;
vmm_channel in_chans[$];
...
initial begin
...
xact.get_input_channels(in_chans);
...
end
endprogram
vmm_xactor::get_instance()
Returns the instance name of this transactor.
SystemVerilog
virtual function string get_instance();
OpenVera
Not supported.
vmm_xactor::get_name()
Returns the name of this transactor.
SystemVerilog
virtual function string get_name();
OpenVera
Not supported.
vmm_xactor::get_output_channels()
Returns the output channels of this transactor.
SystemVerilog
function void get_output_channels(
ref vmm_channel chans[$]);
OpenVera
Not supported.
Description
Returns the channels where this transactor is identified as the
producer, using the vmm_channel::set_producer() method.
Example
Example B-142
class xactor extends vmm_xactor;
...
endclass
program prog;
xactor xact = new;
vmm_channel out_chans[$];
...
initial begin
...
xact.get_output_channels (out_chans);
...
end
endprogram
vmm_xactor::inp_vmm_sb_ds()
For more information on this method, refer to the VMM Scoreboard
User Guide.
vmm_xactor::kill()
Prepares a transactor for deletion.
SystemVerilog
function void kill();
OpenVera
Not supported.
Description
Prepares a transactor for deletion and reclamation by the garbage
collector.
Removes this transactor as the producer of its output channels, and
as the consumer of its input channels. De-registers all data stream
scoreboards and callback extensions.
Example
Example B-143
class xactor extends vmm_xactor;
...
endclass
program prog;
xactor xact = new;
...
initial begin
xact.kill();
...
end
endprogram
vmm_xactor::log
Message service interface for messages, which are generated from
within this transactor instance.
SystemVerilog
vmm_log log;
OpenVera
Not supported.
vmm_xactor::main()
Forks-off this task whenever the start_xactor() method is
called.
SystemVerilog
protected virtual task main();
OpenVera
Not supported.
Description
This task is forked off, whenever the start_xactor() method is
called. It is terminated, whenever the reset_xactor() method is
called. The functionality of a user-defined transactor must be
implemented in this method. Any additional subthreads must be
started within this method, not in the constructor. It can contain a
blocking or non-blocking implementation.
Any extension of this method must first fork a call to the
super.main() method.
Example
Example B-144
task mii_mac_layer::main();
super.main();
...
endtask: main
vmm_xactor::new()
Creates an instance of the transactor base class.
SystemVerilog
function new(string name,string instance,int stream_id = 1,vmm_object parent);
With +define NO_VMM12
function new(string name,string instance,int
stream_id = -1);
OpenVera
Not supported.
Description
Creates an instance of the transactor base class, with the specified
name, instance name, and optional stream identifier. The name and
instance name are used to create the message service interface in
the vmm_xactor::log property, and the specified stream identifier
is used to initialize the vmm_xactor::stream_id property.
vmm_xactor::notifications_e
Predefined notifications.
SystemVerilog
typedef enum int {XACTOR_IDLE
XACTOR_BUSY
XACTOR_STARTED
XACTOR_STOPPED
XACTOR_RESET
XACTOR_STOPPING
XACTOR_IS_STOPPED
} notifications_e;
=
=
=
=
=
=
=
999999,
999998,
999997,
999996,
999995,
999994,
999993
OpenVera
static
static
static
static
static
static
int
int
int
int
int
int
XACTOR_IDLE;
XACTOR_BUSY;
XACTOR_STARTED;
XACTOR_STOPPING;
XACTOR_STOPPED;
XACTOR_RESET;
Description
Predefined notifications that are indicated, whenever the transactor
changes state.
XACTOR_IDLE
ON or OFF notification that is indicated when the transactor is
idle. Must be the complement of XACTOR_BUSY.
XACTOR_BUSY
Example
Example B-145
xactor.notify.wait_for(vmm_xactor::XACTOR_STARTED);
vmm_xactor::notify
Notification service interface and pre-configure notifications.
SystemVerilog
vmm_notify notify;
enum {XACTOR_IDLE;
XACTOR_BUSY;
XACTOR_STARTED;
XACTOR_STOPPED;
XACTOR_RESET;
XACTOR_STOPPING;
XACTOR_IS_STOPPED
};
OpenVera
Not supported.
Description
Notification service interface and pre-configures notifications to
indicate the state and state transitions of the transactor. The
vmm_xactor::XACTOR_IDLE and vmm_xactor::XACTOR_BUSY
notifications are vmm_notify::ON_OFF. All other events are
vmm_notify::ONE_SHOT.
Example
Example B-146
class consumer extends vmm_xactor;
...
virtual task main();
...
forever begin
transaction tr;
this.in_chan.peek(tr);
tr.notify.indicate(vmm_data::STARTED);
...
tr.notify.indicate(vmm_data::ENDED, ...);
this.in_chan.get(tr);
end
endtask: main
endclass: consumer
vmm_xactor::prepend_callback()
Prepends the specified callback faade instance with this instance of
the transactor.
SystemVerilog
virtual function void
prepend_callback(vmm_xactor_callbacks cb);
OpenVera
Not supported.
Description
Callback methods are invoked in the order in which they were
registered.
A warning is generated, if the same callback faade instance is
registered more than once with the same transactor. A faade
instance can be registered with more than one transactor. Callback
faade instances can be unregistered and re-registered dynamically.
Example
Example B-147
program test;
initial begin
dut_env env = new;
align_tx cb = new(...);
env.build();
foreach (env.mii[i]) begin
env.mii[i].prepend_callback(cb);
end
env.run();
end
endprogram
vmm_xactor::psdisplay()
Returns a human-readable description of the transactor.
SystemVerilog
virtual function string psdisplay(string prefix = "")
OpenVera
Not supported.
Description
This method returns a human-readable description of the transactor.
Each line is prefixed with the specified prefix.
Example
Example B-148
class xactor extends vmm_xactor;
...
endclass
program prog;
xactor xact = new;
...
initial begin
...
$display("Printing variables of Transactor\n %s \n",
xact.psdisplay());
...
end
endprogram
vmm_xactor::register_vmm_sb_ds()
For more information on this method, refer to the VMM Scoreboard
User Guide.
vmm_xactor::reset_xactor()
Resets the state, and terminates the execution threads in this
transactor instance.
SystemVerilog
virtual function void
reset_xactor(reset_e rst_typ = SOFT_RST);
OpenVera
Not supported.
Description
Resets the state, and terminates the execution threads in this
transactor instance, according to the specified reset type (see
Table B-1). The base class indicates the
vmm_xactor::XACTOR_RESET and
vmm_xactor::XACTOR_IDLE notifications, and resets the
vmm_xactor::XACTOR_BUSY notification.
Table B-1
Table B-2
Reset Types
Enumerated Value
Broadcasting Operation
vmm_xactor::SOFT_RST
vmm_xactor::PROTOCOL_RST
vmm_xactor::FIRM_RST
vmm_xactor::HARD_RST
Example
Example B-149
function void
mii_mac_layer::reset_xactor(reset_e typ = SOFT_RST);
super.start_xactor(typ);
...
endfunction: reset_xactor
vmm_xactor::restore_rng_state()
Restores the state of all random generators.
SystemVerilog
virtual function void restore_rng_state();
OpenVera
Not supported.
Description
This method restores, from local properties, the state of all random
generators associated with this transactor instance.
vmm_xactor::stream_id
Identifier for the stream of transaction and data descriptors.
SystemVerilog
int stream_id;
OpenVera
Not supported.
Description
The stream_id is a unique identifier for the stream of transaction
and data descriptors, flowing through this transactor instance. It
should be used to set the vmm_data::stream_id property of the
descriptors, as they are received or randomized by this transactor.
Example
Example B-150
class responder extends vmm_xactor;
...
virtual task main();
...
forever begin
this.req_chan.get(tr);
tr.stream_id = this.stream_id;
tr.data_id
= response_id++;
if (!tr.randomize()) ...
...
this.resp_chan.sneak(tr);
end
endtask: main
endclass: responder
vmm_xactor::save_rng_state()
Saves the state of all random generators.
SystemVerilog
virtual function void save_rng_state();
OpenVera
Not supported.
Description
This method saves, in local properties, the state of all random
generators associated with this transactor instance.
vmm_xactor::start_xactor()
Starts the execution threads in this transactor instance.
SystemVerilog
virtual function void start_xactor();
OpenVera
Not supported.
Description
Starts the execution threads in this transactor instance. The
transactor can later be stopped. Any extension of this method must
call the super.start_xactor() method. The base class
indicates the vmm_xactor::XACTOR_STARTED and
vmm_xactor::XACTOR_BUSY notifications, and resets the
vmm_xactor::XACTOR_IDLE notification.
Example
Example B-151
class tb_env extends vmm_env;
...
virtual task start();
super.start();
...
this.mac.start_xactor();
...
endtask: start
...
endclass: tb_env
vmm_xactor::stop_xactor()
Stops the execution threads in this transactor instance.
SystemVerilog
virtual function void stop_xactor();
OpenVera
Not supported.
Description
Stops the execution threads in this transactor instance. The
transactor can later be restarted. Any extension of this method must
call the super.stop_xactor() method. The transactor stops,
when the vmm_xactor::wait_if_stopped() or
vmm_xactor::wait_if_stopped_or_empty() method is
called. It is a call to these methods to define the granularity of
stopping a transactor.
vmm_xactor::unregister_callback()
Unregisters the specified callback faade instance.
SystemVerilog
virtual function void
unregister_callback(vmm_xactor_callbacks cb);
OpenVera
Not supported.
Description
Unregisters the specified callback faade instance, for this
transactor instance. A warning is generated, if the specified faade
instance is not currently registered with the transactor. Callback
faade instances can later be re-registered with the same or another
transactor.
vmm_xactor::unregister_vmm_sb_ds()
For more information on this method, refer to the VMM Scoreboard
User Guide.
vmm_xactor::vmm_callback()
Simplifies the syntax of invoking callback methods in a transactor.
SystemVerilog
vmm_callback(callback_class_name, method(args));
OpenVera
Not supported.
Example
Example B-152
Instead of:
foreach (this.callbacks[i]) begin
ahb_master_callbacks cb;
if ($cast(cb, this.callbacks[i])) continue;
cb.ptr_tr(this, tr, drop);
end
Use:
vmm_callback(ahb_master_callbacks, \
ptr_tr(this, tr, drop));
vmm_xactor::wait_if_stopped()
Suspends an execution thread.
SystemVerilog
protected task wait_if_stopped(int unsigned n_threads = 1);
OpenVera
protected task wait_if_stopped_t(integer n_threads = 1);
Description
Blocks the thread execution, if the transactor is stopped through the
stop_xactor() method. This method indicates the
vmm_xactor::XACTOR_STOPPED and
vmm_xactor::XACTOR_IDLE notifications, and resets the
vmm_xactor::XACTOR_BUSY notification. The tasks will return,
once the transactor is restarted using the start_xactor()
method, and the specified input channel is not empty. These
methods do not block, if the transactor is not stopped and the
specified input channel is not empty.
Calls to this method and the
vmm_xactor::wait_if_stopped_or_empty() methods
define the granularity, by which the transactor can be stopped
without violating the protocol. If a transaction can be suspended in
the middle of its execution, then the wait_if_stopped() method
should be called at every opportunity. If a transaction cannot be
suspended, then the wait_if_stopped_or_empty() method
should only be called after the current transaction is completed,
before fetching the next transaction descriptor for the input channel.
Example
Example B-153
protected virtual task main();
super.main();
forever begin
transaction tr;
this.wait_if_stopped_or_empty(this.in_chan);
this.in_chan.activate(tr);
...
this.wait_if_stopped();
...
end
endtask: main
vmm_xactor::wait_if_stopped_or_empty()
Suspends an execution thread or wait on a channel.
SystemVerilog
protected task wait_if_stopped_or_empty(vmm_channel chan,
int unsigned n_threads = 1);
OpenVera
protected task wait_if_stopped_or_empty_t(rvm_channel chan,
integer n_threads = 1);
Description
Blocks the thread execution, if the transactor is stopped through the
stop_xactor() method, or if the specified input channel is
currently empty. This method indicates the
vmm_xactor::XACTOR_STOPPED and
vmm_xactor::XACTOR_IDLE notifications, and resets the
vmm_xactor::XACTOR_BUSY notification. The tasks will return,
once the transactor is restarted using the start_xactor()
method, and the specified input channel is not empty. These
methods do not block, if the transactor is not stopped and the
specified input channel is not empty.
Calls to this method and the
vmm_xactor::wait_if_stopped() methods define the
granularity, by which the transactor can be stopped without violating
the protocol.
Example
Example B-154
protected virtual task main();
super.main();
fork
forever begin
transaction tr;
this.wait_if_stopped_or_empty(this.in_chan, 2);
this.in_chan.activate(tr);
...
this.wait_if_stopped(2);
...
end
forever begin
...
this.wait_if_stopped(2);
...
end
join_none
endtask: main
vmm_xactor::xactor_status()
Displays the current status of the transactor instance.
SystemVerilog
virtual function void xactor_status(string prefix = "");
OpenVera
Not supported.
Description
Displays the current status of the transactor instance in a humanreadable format using the message service interface found in the
vmm_log::log property, using the vmm_log::NOTE_TYP
messages. Each line of the status information is prefixed with the
specified prefix.
vmm_xactor_member_begin()
Starts the shorthand section.
SystemVerilog
vmm_xactor_member_begin(class-name)
OpenVera
Not supported.
Description
Start the shorthand section, providing a default implementation for
the psdisplay(), start_xactor(), stop_xactor(), and
reset_xactor() methods.
The class-name specified must be the name of the vmm_xactor
extension class that is being implemented.
The shorthand section can only contain shorthand macros, and must
be terminated by the vmm_xactor_member_end() method.
Example
Example B-155
class eth_mac extends vmm_xactor;
...
vmm_xactor_member_begin(eth_mac)
...
vmm_xactor_member_end(eth_mac)
...
endclass
vmm_xactor_member_end()
Terminates the shorthand section.
SystemVerilog
vmm_xactor_member_end(class-name)
OpenVera
Not supported.
Description
Terminates the shorthand section, providing a default
implementation for the psdisplay(), start_xactor(),
stop_xactor(), and reset_xactor() methods.
The class-name specified must be the name of the vmm_xactor
extension class that is being implemented.
The shorthand section must be started by the
vmm_xactor_member_begin() method.
Example
Example B-156
class eth_mac extends vmm_xactor;
...
vmm_xactor_member_begin(eth_mac)
...
vmm_xactor_member_end(eth_mac)
...
endclass
vmm_xactor_member_scalar*()
Shorthand implementation for a scalar data member.
SystemVerilog
vmm_xactor_member_scalar(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_scalar_array(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_scalar_aa_scalar(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_scalar_aa_string(member-name,
vmm_xactor::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified scalar-type, array of scalars, scalar-indexed
associative array of scalars, or string-indexed associative array of
scalars data member to the default implementation of the methods
specified by the do_what argument.
A scalar is an integral type, such as bit, bit vector, and packed
unions.
The shorthand implementation must be located in a section started
by the vmm_xactor_member_begin() method.
Example
Example B-157
class eth_frame_gen extends vmm_xactor;
local integer fr_count;
...
`vmm_xactor_member_begin(eth_frame_gen);
`vmm_xactor_member_scalar (fr_count, DO_ALL)
...
`vmm_xactor_member_end(eth_frame_gen)
...
endclass
vmm_xactor_member_string*()
Shorthand implementation for a string data member.
SystemVerilog
vmm_xactor_member_string(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_string_array(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_string_aa_scalar(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_string_aa_string(member-name,
vmm_xactor::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified string-type, array of strings, scalar-indexed
associative array of strings, or string-indexed associative array of
strings data member to the default implementation of the methods
specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_xactor_member_begin() method.
Example
Example B-158
class eth_frame_gen extends vmm_xactor;
vmm_xactor_member_enum*()
Shorthand implementation for an enumerated data member.
SystemVerilog
vmm_xactor_member_enum(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_enum_array(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_enum_aa_scalar(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_enum_aa_string(member-name,
vmm_xactor::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified enum-type, array of enums, scalar-indexed
associative array of enums, or string-indexed associative array of
enums data member to the default implementation of the methods
specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_xactor_member_begin() method.
Example
Example B-159
class eth_frame_gen extends vmm_xactor;
fr_type fr_type_var;
...
`vmm_xactor_member_begin(eth_frame_gen);
`vmm_xactor_member_enum (fr_type_var, DO_ALL)
...
`vmm_xactor_member_end(eth_frame_gen)
...
endclass
vmm_xactor_member_vmm_data*()
Shorthand implementation for a vmm_data-based data member.
SystemVerilog
vmm_xactor_member_vmm_data(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_vmm_data_array(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_vmm_data_aa_scalar(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_vmm_data_aa_string(member-name,
vmm_xactor::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified vmm_data-type, array of vmm_datas, scalarindexed associative array of vmm_datas, or string-indexed
associative array of vmm_datas data member to the default
implementation of the methods, specified by the do_what
argument.
The shorthand implementation must be located in a section started
by the vmm_xactor_member_begin() method.
Example
Example B-160
class eth_frame extends vmm_data;
...
endclass
class eth_frame_gen extends vmm_xactor;
eth_frame eth_frame_packet;
...
`vmm_xactor_member_begin(eth_frame_gen);
`vmm_xactor_member_vmm_data (eth_frame_packet, DO_ALL)
...
`vmm_xactor_member_end(eth_frame_gen)
...
endclass
vmm_xactor_member_channel*()
SystemVerilog
vmm_xactor_member_channel(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_channel_array(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_channel_aa_scalar(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_channel_aa_string(member-name,
vmm_xactor::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified channel-type, array of channels, dynamic array of
channels, scalar-indexed associative array of channels, or stringindexed associative array of channels data member to the default
implementation of the methods specified by the do_what
argument.
The shorthand implementation must be located in a section started
by the vmm_xactor_member_begin() method.
Example
Example B-161
class eth_frame_gen extends vmm_xactor;
eth_frame_channel in_chan
...
`vmm_xactor_member_begin(eth_frame_gen);
`vmm_xactor_member_channel (in_chan, DO_ALL)
...
`vmm_xactor_member_end(eth_frame_gen)
...
endclass
vmm_xactor_member_xactor*()
Shorthand implementation for a transactor data member.
SystemVerilog
vmm_xactor_member_xactor(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_xactor_array(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_xactor_aa_scalar(member-name,
vmm_xactor::do_what_e do_what)
vmm_xactor_member_xactor_aa_string(member-name,
vmm_xactor::do_what_e do_what)
OpenVera
Not supported.
Description
Adds the specified transactor-type, array of transactors, dynamic
array of transactors, scalar-indexed associative array of transactors,
or string-indexed associative array of transactors data member to
the default implementation of the methods, specified by the
do_what argument.
The shorthand implementation must be located in a section started
by the vmm_xactor_member_begin() method.
Example
Example B-162
class custom_gen extends vmm_xactor;
...
endclass
class eth_frame_gen extends vmm_xactor;
custom_gen custom_gen_inst;
...
`vmm_xactor_member_begin(eth_frame_gen);
`vmm_xactor_member_xactor (custom_gen_inst, DO_ALL)
...
`vmm_xactor_member_end(eth_frame_gen)
...
endclass
vmm_xactor_member_user_defined()
User-defined shorthand implementation data member.
SystemVerilog
vmm_xactor_member_user_defined(member-name)
OpenVera
Not supported.
Description
Adds the specified user-defined default implementation of the
methods specified by the do_what argument.
The shorthand implementation must be located in a section started
by the vmm_xactor_member_begin() method.
Example
Example B-163
class eth_frame_gen extends vmm_xactor;
integer fr_no;
...
`vmm_xactor_member_begin(eth_frame_gen);
`vmm_xactor_member_user_defined (fr_no, DO_ALL)
...
`vmm_xactor_member_end(eth_frame_gen)
function bit do_fr_no(input vmm_data::do_what_e do_what)
do_fr_no = 1; // Success, abort by returning 0
case (do_what)
endcase
endfunction
endclass
vmm_xactor_callbacks
This class implements a virtual base class for callback containments.
For more information, see the documentation for the
vmm_xactor::append_callback() on page 418.
vmm_xactor_iter
This class can iterate over all known vmm_xactor instances, based
on the names and instance names, regardless of their location in the
class hierarchy.
VMM adds this class to traverse list a registered transactors that
match a regular expression. This feature is useful to register specific
transactor callbacks, connect specific transactors to a scoreboard
object, and re-allocate transactor, by killing its channels and
reassigning some new ones.
class driver_typed #(type T = vmm_data) extends vmm_xactor;
function new(string instance);
super.new("driver", instance);
endfunction
virtual protected task main();
vmm_channel chans[$];
super.main();
get_input_channels(chans);
foreach (chans[i]) begin
vmm_channel_typed #(T) chan;
$cast(chan, chans[i]);
start_drive(chan, i);
end
endtask
virtual task start_drive(vmm_channel_typed #(T) chan);
T tr;
fork
forever begin
chan.get(tr);
`vmm_note(log, tr.psdisplay(Executing.."));
wait_if_stopped();
end
join_none
endtask
endclass
vmm_xactor_iter=new(/ahb/, /./);
xact.first()
...
ahb1
xact.next()
ahb1
ahb1
xact.next()
xact.xactor()
vmm_xactor_iter::first()
Resets the iterator to the first transactor, that is to the start of the
queue.
vmm_xactor_iter::xactor()
Returns a reference to the current transactor iterated on.
vmm_xactor_iter::next()
Moves the iterator to the next transactor.
The following below shows how to start all transactors extended from
the ahb_transactor class. The ahb_transactor class is
extended from the vmm_xactor class.
vmm_xactor_iter iter = new("/./", "/./");
// Returns a list of all vmm_xactor objects
while( iter.xactor() != null) begin
ahb_transactor ahb;
if($cast(ahb, iter.xactor()) begin
//get abh_transactor extended objects
ahb.start_xactor();
end
iter.next();
end
The variable name, xact, of the type specified as the first argument
is implicitly declared.
The following example achieves the same functionality as above,
using the shorthand macro.
The macro must be used in the declarative portion of the code, or
immediately followed by the begin keyword.
begin
`foreach_vmm_xactor(ahb_transactor, "/./" , "/./")
begin
xact.start_xactor();
end
end
Summary
vmm_xactor_iter::first() .........................
vmm_xactor_iter::new() ...........................
vmm_xactor_iter::next() ..........................
vmm_xactor_iter::xactor() ........................
foreach_vmm_xactor() ............................
page
page
page
page
page
B-482
B-483
B-485
B-486
B-487
vmm_xactor_iter::first()
Resets the iterator to the first transactor.
SystemVerilog
function vmm_xactor first();
OpenVera
Not supported.
Description
Resets the iterator to the first transactor matching the name and
instance name patterns specified, when the iterator was created
using the vmm_xactor_iter::new() method and return a
reference to it, if found.
Returns NULL, if no transactors match.
The order in which transactors are iterated on is unspecified.
Example
Example B-164
int i = 0;
vmm_xactor_iter iter = new("/AHB/", "");
vmm_xactor xa;
for (xa = iter.first(); xa != null; xa= iter.next())
i++;
`vmm_note (log, $psprintf("No. of AHB transactors = %0d ",i))
vmm_xactor_iter::new()
Creates a new transactor iterator.
SystemVerilog
function void new(string name = "", string inst = "");
OpenVera
Not supported.
Description
Creates a new transactor iterato,r and initializes it using the specified
name and instance name. If the specified name or instance name is
enclosed between / characters, they are interpreted as regular
expressions. Otherwise, they are interpreted as the full name or
instance name to match.
The vmm_xactor_iter::first() is implicitly called. So,
once created, the first transactor matching the specified name and
instance name patterns is available, using the
vmm_xactor_iter::xactor() method. The subsequent
transactors can be iterated on, one at a time, using the
vmm_xactor_iter::next() method.
Example
Example B-165
vmm_xactor_iter iter = new("/AHB/");
while (iter.xactor() != null) begin
ahb_master ahb;
if ($cast(ahb, iter.xactor()) begin
...
end
iter.next();
end
vmm_xactor_iter::next()
Moved the iterator to the next transactor.
SystemVerilog
function vmm_xactor next();
OpenVera
Not supported.
Description
Moved the iterator to the next transactor, matching the name and
instance name patterns specified, when the iterator was created
using the vmm_xactor_iter::new() method and return a
reference to it, if found.
Returns NULL, if no transactors match.
The order in which transactors are iterated on is unspecified.
Example
Example B-166
int i = 0;
vmm_xactor_iter iter = new("/AHB/", "");
vmm_xactor xa;
for (xa = iter.first(); xa != null; xa= iter.next())
i++;
`vmm_note (log, $psprintf("No. of AHB transactors = %0d ",i))
vmm_xactor_iter::xactor()
Returns the current transactor iterated on.
SystemVerilog
function vmm_xactor xactor();
OpenVera
Not supported.
Description
Returns a reference to a transactor, matching the name and instance
name patterns specified ,when the iterator was created using the
vmm_xactor_iter::new() method.
Returns NULL, if no transactors match.
Example
Example B-167
vmm_xactor_iter iter = new("/AHB/");
while (iter.xactor() != null) begin
ahb_master ahb;
if ($cast(ahb, iter.xactor()) begin
...
end
iter.next();
end
foreach_vmm_xactor()
Shorthand transactor iterator macro.
SystemVerilog
foreach_vmm_xactor(type, name, inst) begin
xact...
end
OpenVera
Not supported.
Description
Shorthand macro to simplify the creation and operation of a
transactor iterator instance, looking for transactors of a specific type,
matching a specific name and instance name. The subsequent
statement is executed for each transactor iterated on.
A variable named "xact" of the type specified as the first argument
to the macro is implicitly declared, and iteratively set to each
transactor of the specified type that matches the specified name and
instance name.
The macro must be located immediately after a "begin" keyword.
Example
Example B-168
begin
foreach_vmm_xactor(ahb_master, "/./", "/./")
begin
xact.register_callback(...);
VMM User Guide
B- 487
end
end
C
Command Line Reference
Run-Time Switches
Option
Description
+vmm_break_on_phase
+vmm_break_on_timeline
+vmm_channel_fill_thresh=<int>
+vmm_channel_shared_log
+vmm_force_verbosity=[ERROR,
WARNING, NORMAL, TRACE, DEBUG,
VERBOSE]
+vmm_ gen_rtl_config
Table C-1
Run-Time Switches
Option
Description
+vmm_help
+vmm_list_timeline
+vmm_list_phases
+vmm_object_children_thresh=<int>
+vmm_object_root_thresh=<int>
+vmm_ object_thresh_check
+vmm_opts+enable_auto_start=0/
1@<pattern>
+vmm_opts+enable_auto_stop=0/
1@<pattern>
+vmm_opts_file+filename
+vmm_opts+<option1>+<option2>+....
+vmm_opts+pull_mode_on@<pattern>
+vmm_opts+stop_after_n_insts=[int]@<
pattern>
+vmm_opts+stop_after_n_scenarios=[in
t]@<pattern>
Table C-1
Run-Time Switches
Option
Description
+vmm_log_debug
+vmm_log_default=[FATAL, ERROR,
WARNING, NORMAL, TRACE, DEBUG,
VERBOSE]
+vmm_log_nowarn_at_200
+vmm_log_nofatal_at_1000
+vmm_rtl_config
+vmm_tr_verbosity=[NORMAL, TRACE,
DEBUG, VERBOSE]
+vmm_test= <test>
+vmm_test_file=filename
+vmm_test_help
Table C-2
Option
Description
+define+VMM_11
+define+VMM_IN_PACKAGE
+define+VMM_LOG_ANSI_COLOR
Description
+define+VMM_LOG_FORMAT_FILE_LINE
+define+VMM_NULL_LOG_MACROS
+define+VMM_NO_NOTIFICATION
+define+VMM_PARAM_CHANNEL
+define+ VMM_POST_INCLUDE=filename
+define+VMM_PRE_INCLUDE=filename
+define+VMM_RAL_DATA_WIDTH
+define+VMM_RW_ADDR_WIDTH
+define+ VMM_SB_DS_IN_STDLIB
D
Release Notes
Multi-test concatenation
Hierarchical options
vmm_connect
vmm_notify_observer
vmm_group