Академический Документы
Профессиональный Документы
Культура Документы
Vera
User Guide
Version 6.3 September 2004
Comments?
E-mail your comments about Synopsys
documentation to vera-doc@synopsys.com
Copyright Notice and Proprietary Information
Copyright © 2004 Synopsys, Inc. All rights reserved. This software and documentation contain confidential and proprietary
information that is the property of Synopsys, Inc. The software and documentation are furnished under a license agreement and
may be used or copied only in accordance with the terms of the license agreement. No part of the software and documentation may
be reproduced, transmitted, or translated, in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without
prior written permission of Synopsys, Inc., or as expressly provided by the license agreement.
Right to Copy Documentation
The license agreement with Synopsys permits licensee to make copies of the documentation for its internal use only.
Each copy shall include all copyrights, trademarks, service marks, and proprietary rights notices, if any. Licensee must
assign sequential numbers to all copies. These copies shall contain the following legend on the cover page:
“This document is duplicated with the permission of Synopsys, Inc., for the exclusive use of
__________________________________________ and its employees. This is copy number __________.”
SystemC is a trademark of the Open SystemC Initiative and is used under license.
ARM and AMBA are registered trademarks of ARM Limited.
All other product or company names may be trademarks of their respective owners.
ii
Contents
1. Introduction
Overview of Testbench Development . . . . . . . . . . . . . . . . . . . . . . . 1-3
Components of a Basic Vera Verification Environment . . . . . . . . . . 1-4
SystemClock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
The Template Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Vera Graphical Debugger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Running Vera Standalone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
2. Using Vera
The Vera Testbench Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Verilog-based Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
VCS Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
VHDL-based Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
iii
VHDL Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Simulator Specific Instructions . . . . . . . . . . . . . . . . . . . . . . . 2-16
Mixed HDL-based Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
VCS_MX (Verilog on top) . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-17
VCS-MX (VHDL on top) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22
SystemC-based Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
Creating an OpenVera Interface. . . . . . . . . . . . . . . . . . . . . . 2-26
Running SystemC with OpenVera . . . . . . . . . . . . . . . . . . . . 2-27
Calling OpenVera Tasks from SystemC . . . . . . . . . . . . . . . . 2-30
Calling SystemC from OpenVera . . . . . . . . . . . . . . . . . . . . . 2-30
iv
SystemC Memory Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
SystemC Memory Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Interface Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
Using Vera to Create the TLI Infrastructure . . . . . . . . . . . . . . . . 4-7
Creating the Vera Testbench Program . . . . . . . . . . . . . . . . . . . . 4-8
Create SystemC main Program . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
Compile and Run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
5. Randomization in Vera
Random Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Seeding for Randomization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
Randomization: Hierarchical Seed Saving . . . . . . . . . . . . . . . . . . . 5-10
randcase Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12
Random Number Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
random() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14
urandom() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15
rand48() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16
urand48() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16
urandom_range() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-17
Constraint Based Randomization . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18
Random Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24
Constraint Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29
External Constraint Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31
Set Membership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32
v
Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-33
Conditional Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-35
Hierarchical Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-38
Variable Ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-40
Dynamic Constraint Modification . . . . . . . . . . . . . . . . . . . . . 5-43
Array Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-43
Default Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-58
Randomize Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-65
Inline Constraints Using "randomize() with" . . . . . . . . . . . . 5-66
pre_randomize() and post_randomize() . . . . . . . . . . . . . . . . 5-68
Disabling Random Variables . . . . . . . . . . . . . . . . . . . . . . . . 5-70
Disabling Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-72
Static Constraint Blocks and Random Variables . . . . . . . . . . . . 5-74
Dynamic Constraint Modification . . . . . . . . . . . . . . . . . . . . . . . . 5-74
Debugging Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-75
Solver Choice. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-77
Internal Caching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-77
Efficient Use of Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-78
Compatibility with Vera Version 5.2 and older . . . . . . . . . . . . . . 5-79
Pre-6.0 Boundary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-82
Random Sequence Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
VSG Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86
Production Declaration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-87
Production Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-89
Weights for Randomization . . . . . . . . . . . . . . . . . . . . . . . . . 5-90
if-else Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-91
case Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-92
repeat Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-93
vi
break Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-94
continue Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-94
Passing Values Between Productions . . . . . . . . . . . . . . . . . . . . 5-95
Value Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-95
Value Passing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-96
7. Functional Coverage
Coverage Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Defining Coverage Models Using Coverage Groups . . . . . . . . . . . 7-3
Embedded Coverage Group . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5
Instantiating Embedded Coverage Groups . . . . . . . . . . . . . 7-8
Vera Scoping Rules in Coverage Groups . . . . . . . . . . . . . . . . . 7-13
Defining Sampled Coverage Points . . . . . . . . . . . . . . . . . . . . . . 7-14
State and Transition Bins for Coverage Points . . . . . . . . . . . 7-17
Auto-Bin Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
Overview of User Defined Bins for Coverage Points . . . . . . 7-22
User-defined States for Coverage Points . . . . . . . . . . . . . . . 7-27
vii
User-defined Illegal States for Coverage Points . . . . . . . . . . . . 7-34
User-defined Transitions for Coverage Points . . . . . . . . . . . 7-35
User-defined Illegal Transitions for Samples . . . . . . . . . . . . 7-42
Cross Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43
User-defined Cross Coverage Bins . . . . . . . . . . . . . . . . . . . 7-46
Enhancements to cross coverage . . . . . . . . . . . . . . . . . . . . . . . 7-53
Saving/reporting missing cross product bins . . . . . . . . . . . . 7-54
Disabling generation of automatic cross product bins . . . . . 7-57
Sample Event. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-61
Types of Sampling Events . . . . . . . . . . . . . . . . . . . . . . . . . . 7-62
Passing Arguments to Coverage Groups. . . . . . . . . . . . . . . . . . 7-69
Expressions within Coverage Group Definitions . . . . . . . . . . . . 7-74
Cumulative and Instance-based Coverage . . . . . . . . . . . . . . . . . . . 7-76
Cumulative Coverage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-76
Instance-based Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-76
Measuring Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-77
Coverage Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-79
Coverage Group Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-81
Persistent Storage of Coverage Data and Post-processing Tools . 7-87
File Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-88
Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-89
Loading Coverage Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-90
Test Merging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-93
Test Grading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-96
Instance Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-97
viii
Predefined Coverage Group Tasks and Functions . . . . . . . . . . . . . 7-98
Activation/Deactivation: User Defined Bins . . . . . . . . . . . . . . . . . . 7-107
Coverage Feedback: query() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-113
ix
New Features and the New OVAsim Flow . . . . . . . . . . . . . . . . . 9-14
-ova option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-16
New Vera-OVASIM Flow with Different Simulators . . . . . . . . . . 9-16
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-18
Task Invocation from the Simulator’s Prompt . . . . . . . . . . . . . . . 9-18
Viewing Results with the Report File . . . . . . . . . . . . . . . . . . . . . 9-19
Using OVA Assertions with Vera and Third Party Simulators . . . . . 9-20
Compiling and Simulating with VCS . . . . . . . . . . . . . . . . . . . . . 9-20
Vera and VCS MX simulation Verilog top . . . . . . . . . . . . . . . 9-20
Vera and VCS MX simulation . . . . . . . . . . . . . . . . . . . . . . . . 9-21
Compiling and Simulating with NC-Verilog . . . . . . . . . . . . . . . . 9-22
Compiling and Simulating with NC-VHDL . . . . . . . . . . . . . . . . . 9-23
Compiling and Simulating with MTI Verilog . . . . . . . . . . . . . . . . 9-24
Compiling and Simulating with MTI VHDL . . . . . . . . . . . . . . . . . 9-25
x
Save and Restart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17
Linking Vera with VCS’s Save/Restart . . . . . . . . . . . . . . . . . . . . 10-18
Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
Dynamic Loading of Vera Object Files . . . . . . . . . . . . . . . . . . . . . . 10-22
Creating a Vera Dynamic Executable Object (VDEO) . . . . . . . . 10-23
Loading and Unloading a VDEO File . . . . . . . . . . . . . . . . . . . . . 10-25
Loading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
Unloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-25
Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-27
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-28
Vera Interactive Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-29
Compiling Vera Source Code for Debugging . . . . . . . . . . . . . . . 10-29
Launching the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-30
Debugger Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-31
Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-34
File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-34
Debug Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-35
Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-41
Source Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-42
xi
Plotting for VirSim Waveform Tool . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Post Simulation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Interactive Simulation Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Plotting for MTI-ModelSim Waveform Tool . . . . . . . . . . . . . . . . . . . 11-12
Post Simulation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-13
Plotting for Novas-Debussy Waveform Tool. . . . . . . . . . . . . . . . . . . 11-14
Post Simulation Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-15
Interactive Simulation Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
xii
Mixed HDL Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-15
xiii
File Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-26
Developing a VIP Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-26
Avoiding Naming Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . 13-27
Connecting to HDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-28
Automatic Object Loading . . . . . . . . . . . . . . . . . . . . . . . . . . 13-28
Including Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-30
Preventing Multiple Inclusion . . . . . . . . . . . . . . . . . . . . . . . . 13-30
VIP File Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-31
Deliverable Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-31
VIP Coding Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-32
Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-32
Header File Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-33
Version Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-33
Classes and Coverage Object Declarations. . . . . . . . . . . . . 13-35
Multiple Instance Support. . . . . . . . . . . . . . . . . . . . . . . . . . . 13-36
Index
xiv
Preface FIX ME!
This preface includes the following sections:
For details of these new features and enhancements, see the Vera
6.3 Release Notes. A list of Vera documents, including the latest
release notes, is available through the Vera Document Navigator:
%vera -doc
xv
Unless otherwise noted, you can find additional information regarding
these changes later in this book.
Language Enhancements
• Object finalize method
• error_mode() Enhancement
• Changes to existing support for array aggregates and array
containment in constraints.
• Default Constraints
• System Tasks for Save and Restore of a Global Random State
for Objects and Threads
• Support for External Class Method Definitions
• DirectC: Variable Length Argument List
• New Attribute for object_print()
• Coverage Point: Querying for Coverage Denominator
• Controlling Coverage Collection Globally.
Tool Enhancements
• Debugger Enhancements
• VHDL Template Generator
• New Compile Switch: -local
• New Compile Switch: -no_warn_null
• New Runtime option: vera_random_seed_automatic
xvi
• Enhancement to -dep_check -print_deps
xvii
About This Guide
The Vera User Guide introduces you to Vera, an advanced testbench
automation solution. This guide covers basic Vera tool operation and
testbench design topics. The OpenVera LRM: Testbench and
Reference Verification Methodology User Guide documents address,
in more detail, the OpenVera hardware verification language and the
Reference Verification Methodology, respectively. This guide serves
as a supplemental teaching guide as well as a reference for the user.
Audience
This book is intended to be used by engineers experienced with either
Verilog or VHDL. Because OpenVera is used to create programs that
link with Verilog and/or VHDL hardware designs, you should have a
fundamental understanding of the hardware description language
used in the design. This book assumes basic knowledge of hardware
design verification.
http://www.synopsys.com/products/sw_platform.html
Related Publications
For additional information about Vera see
xviii
• The Synopsys Print Shop, from which you can order printed
copies of Synopsys documents, at http://docs.synopsys.com
• The Vera Installation Guide is available through the Vera
Document Navigator.
You might also want to refer to the documentation for the following
related Synopsys products:
• VCS
• DesignWare Library
• FlexModel
• VirSim
xix
Conventions
The following conventions are used in Synopsys documentation.
Convention Description
xx
Customer Support
Customer support is available through SolvNet and through
contacting Vera Support.
Accessing SolvNet
SolvNet is the Synopsys electronic knowledge base, which contains
information about Synopsys and its tools and is updated daily.
To access SolvNet,
If you need help using SolvNet, click SolvNET Help in the column on
the left side of the SolvNET Web page.
xxi
• Telephone the Synopsys Technical Support Center.
- Call (800) 245-8005 from within the continental United States.
- Call (650) 584-4200 from Canada.
• Open a call to your local support center from the Web by going to
http://solvnet.synopsys.com (SolvNet user name and password
required), then clicking “Enter a Call.”
xxii
1
Introduction 1
Vera® is an integral part of the Synopsys Smart Verification platform.
It is the comprehensive testbench automation solution for module,
block and full system verification. The Vera testbench automation
system is based on the OpenVera™ language. This is an intuitive,
high-level, object-oriented programming language developed
specifically to meet the unique requirements of functional
verification.
1-1
simulation waveforms and reports. Its built-in dynamic coverage
analysis provides instant coverage feedback, facilitating the efficient
generation of high coverage stimuli.
Introduction
1-2
Overview of Testbench Development
Architectural and block-level specifications capture the intended
functionality of a design. These are the standards that designers rely
on to implement as a product. In parallel with the design effort, a
verification plan is created. This document prioritizes the various
features (whether visible to the end user or not) that need to be
tested as the design evolves from specification to implementation.
The relative priority of these tests is established in the verification
plan, as is the schedule for developing the infrastructure and actual
tests for each.
Introduction
1-3
Components of a Basic Vera Verification Environment
A basic Vera verification environment includes a Vera testbench, a
Vera shell file, an HDL design (Device Under Test, or “DUT”), and a
top level HDL file that includes the DUT, the Vera shell file, and a
clock generator (see Figure 1-1).
~ clock generator
Introduction
1-4
Example 1-1 shows an example of an OpenVera interface
declaration for a 2-bit round-robin arbiter design, rrarb.if.vrh:
program rrarb_test
{
// reset
rrarb.request = 2'b00;
rrarb.reset = 1;
@1 rrarb.reset = 0;
// single request
@1 rrarb.request[0] = 1'b1;// drive request
@2 rrarb.grant == 2'b01;// sample grant
printf("Request from device 0:\tgrant = %b\n", rrarb.grant);
@1 rrarb.request[0] = 1'b0;// release request
rrarb.request[1] = 1'b1;
Introduction
1-5
@2 rrarb.grant == 2'b10 ;
printf("Request from device 1:\tgrant = %b\n", rrarb.grant);
rrarb.request[1] = 1'b0 ;
// round-robin test
@1 rrarb.request[0] = 1'b1 ;
rrarb.request[1] = 1'b1 ;
@2 rrarb.grant == 2'b01 ;// should get grant 0, since last
//request was 1
printf("Requests from device 0 and device 1:\tgrant = %b\n",
rrarb.grant);
@1 rrarb.grant == 2'b10 ; // keep asserting both ports, should
// get grant 1
printf("Requests from device 0 and device 1:\tgrant = %b\n",
rrarb.grant);
rrarb.request[0] = 1'b0 ;
rrarb.request[1] = 1'b0 ;
} // end of program rrarb_test
Introduction
1-6
SystemClock
SystemClock is a Vera internal reference signal used only for the
OpenVera system function, get_cycle(), and when using the
keyword, CLOCK. Connecting SystemClock to the master clock of
a verification environment is recommended. SystemClock can be
left unconnected if the get_cycle() function or CLOCK keyword is not
used.
The template generator is for DUT designed using Verilog. For VHDL
designed DUTs, see page 2-11).
Note:
Verilog users should remember that the HDL module name
cannot start with a digit (for example, ‘2mod’ is not permitted).
Introduction
1-7
template_options:
is one or more of the following options:
-I path_name
adds an absolute or relative path to the search path for include
files.
-c clock_signal
specifies the clock signal on the HDL module, where clock_signal
is the DUT signal to be connected to SystemClock. SystemClock
is a clock generated by Vera.
When specified, the defined (DUT) clock signal is connected to
SystemClock and is identified as CLOCK in the interface
specification.
If omitted, SystemClock is used as the sampling clock.
-t module_name and HDL_filename
specifies the top HDL module name. The -t option is
mandatory.
where:
Introduction
1-8
- The file HDL_name.v is the Verilog file containing the top level
module instantiated within the test_top.v file.
For example:
% vera -tem -t rrarb -c clk rrarb.v
where “rrarb” is the module name, and “clk” is the clock signal
name in the DUT file, “rrarb.v”.
http://www.synopsys.com/products/sw_platform.html
Introduction
1-9
When the standalone debugger has started, test the menus and
open a file via the File Open dialog box. If all these steps work, you
should be ready to run a real debug session.
To use the stand-alone simulator, compile the Vera files and then use
the following command line to run the simulation:
% vera_cs filename.vro
Note:
All drives in vera_cs are ignored, and all samples are received as
Xs.
Introduction
1-10
2
Using Vera 2
A Vera testbench can drive the design under test (DUT) effectively
for verification, abstracting the stimulus generation-response
checking mechanism for productivity. The DUT can be written in one
or more of the existing Hardware Design Languages currently
available: Verilog, VHDL, or SystemC. This chapter details the
mechanisms through which the DUT is wired to the testbench so that
the testbench can drive its inputs and observe its outputs.
Using Vera
2-1
The Vera Testbench Flow
There are numerous ways to construct a Vera testbench. This
section outlines a simple flow for Verilog and VHDL-based designs.
The Vera template generator is used here to start the process.
Figure 2-1 illustrates the components of the Vera testbench.
top_level file
DUT Vera
instance Shell
File
interface
filename.if.vrh
filname.v filename_shell.v
or
Vera
filename_shell.vhd Program
Template
~ clock generator
filename.vr.tmp
• Verilog-based Flow
• VHDL-based Flow
Using Vera
2-2
Verilog-based Flow
The procedure for creating a Vera testbench for Verilog-based
designs is as follows:
Using Vera
2-3
6. Run the simulation:
simv +vera_load=filename.vro
Note:
The command line here is appropriate for VCS on Solaris. For
other Verilog simulators, see the Vera Installation Guide in:
$VERA_HOME/doc/install.pdf
total mismatch:
is a counter for all expect failures in which “soft” is not used. For
example, for each failure of the following line:
@0 counter.cnt == 8’h05;
Using Vera
2-4
fail (expected):
counts the failures you expect. All “soft” expects which result in
failures are counted here. Note, if “soft” is used for an expect
which is bound to fail, then “fail (expected)” will increment, and
not “mismatch.” If you omit “soft,” then “mismatch” will increment.
drive:
the number of variable assignments to output signals from Vera.
expect:
the number of times an expect statement was executed
regardless of the result. This count is incremented for the
following successful expect:
@0 counter.cnt == 8’h04; //This is the correct expect.
###########END PROGRAM
sample:
the number of times an input signal is sampled and assigned to
a variable or signal.
sync:
the number of times Vera is explicitly synchronized to a clock. For
example, each of these statements will increment the count by 1:
@(posedge CLOCK);
@(posedge a.clk);
Using Vera
2-5
exit_status
if the Vera program has exited with non-zero status (usually an
indication of an error), “exit_status” will appear. For example:
exit_status: 33
VCS Example
This example starts with the following design under test (an adder):
always@(posedge clk)
begin
out0 <= in0 + in1;
end
endmodule
#ifndef INC_ADDER_IF_VRH
#define INC_ADDER_IF_VRH
Using Vera
2-6
interface adder{
output [7:0] in0 OUTPUT_EDGE OUTPUT_SKEW;
output [7:0] in1 OUTPUT_EDGE OUTPUT_SKEW;
input [8:0] out0 INPUT_EDGE #-1;
input clk CLOCK;
} //end of interface adder
#endif
reg SystemClock;
wire [7:0] in0;
wire [7:0] in1;
wire [8:0] out0;
assign clk = SystemClock;
‘ifdef emu
/*DUT is in emulator, so not instantiated here*/
‘else
adder dut(
.in0 (in0),
.in1 (in1),
.out0 (out0),
.clk (clk),
);
‘endif
Using Vera
2-7
c. The Vera file (adder.vr), which is copied from the Vera template
file (adder.v.tmp):
// adder.vr (copied from the template adder.v.tmp)
#include "adder.if.vrh"
program adder_test
{ // start of top block
// Example of drive:
// @ 1 adder.in0 = 0;
// Example of expect:
// @ 1,100 adder.out0==0;
Using Vera
2-8
d. The Vera shell file (adder_shell.v; do not edit this file):
// adder_shell.v
module vera_shell(
SystemClock,
adder_in0,
adder_in1,
adder_out0,
adder_clk
);
input SystemClock;
output [7:0] adder_in0;
output [7:0] adder_in1;
input [8:0] adder_out0;
inout adder_clk;
//Nest which VMC will reference
// System clock:SystemClock
wire SystemClock;
endmodule
2. The next step is to compile the adder.vr file, which creates the
adder_shell.v and adder.vro files:
% vera -cmp -vlog adder.vr
Figure 2-2 summarizes the testbench setup flow using the Template
Generator.
Using Vera
2-9
Figure 2-2 Testbench Flow using the Template Generator
Verilog Source
adder.v
Generate Template
vera -tem -t adder -c clock adder.v
Test
Test Top File
File Temporary File
Temporary File Interface
Interface Header File
Header File
Vera Template
adder.vr
Vera Compile
vera -cmp -g adder.vr
adder.vshell adder.vro
VCS Compile
vcs -vera adder.v adder.test_top.v adder.vshell
Run Simulation
simv +vera_load=adder.vro
Using Vera
2-10
VHDL-based Flow
The procedure for creating a Vera testbench for VHDL-based
designs is as follows:
top_entity
Using Vera
2-11
This creates two files:
VHDL Example
//alu.vhd
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity alu_ent is
port (
rst : in std_logic;
clk : in std_logic;
op : in std_logic_vector(1 downto 0);
inp1 : in std_logic_vector(7 downto 0);
inp2 : in std_logic_vector(7 downto 0);
outp : out std_logic_vector(7 downto 0)
);
end;
begin
proc1 : process(clk)
begin
if (clk'event and clk = '1') then
if (rst = '1') then
outp <= (others=>'0');
Using Vera
2-12
else
case op is
when "00" =>
outp <= inp1 + inp2;
when "01" =>
outp <= inp1 - inp2;
when "10" =>
outp2 <= inp1 * inp2;
outp <= outp2(15 downto 8);
when "11" =>
-- outp <= inp1 / inp2;
outp <= (others=>'0');
when others =>
null;
end case;
end if;
end if;
end process proc1;
end;
vera_shell_param vera_vhdl_temp_ieee =
"ieee::std_logic_unsigned:std_logic_1164:";
/*
* User may modify the interface to add additional signals
* or paths to hdl_node(s)
*/
Using Vera
2-13
interface alu_ent
{
input [7:0] outp INPUT_EDGE INPUT_SKEW hdl_node "{STD_LOGIC}";
output [7:0] inp2 OUTPUT_EDGE OUTPUT_SKEW hdl_node "{STD_LOGIC}";
output [7:0] inp1 OUTPUT_EDGE OUTPUT_SKEW hdl_node "{STD_LOGIC}";
output [1:0] op OUTPUT_EDGE OUTPUT_SKEW hdl_node "{STD_LOGIC}";
input clk CLOCK;
output rst OUTPUT_EDGE OUTPUT_SKEW hdl_node "{STD_LOGIC}";
} // end of interface alu_ent
#endif
ENTITY dut_bench IS
END;
COMPONENT alu_ent
PORT (
SIGNAL outp : OUT std_logic_vector(7 downto 0);
SIGNAL inp2 : IN std_logic_vector(7 downto 0);
SIGNAL inp1 : IN std_logic_vector(7 downto 0);
SIGNAL op : IN std_logic_vector(1 downto 0);
SIGNAL clk : IN std_logic;
SIGNAL rst : IN std_logic
);
END COMPONENT;
BEGIN
system_clock <= not system_clock after 50 ns;
alu_ent_clk <= not alu_ent_clk after 50 ns;
vera_shell_inst : vera_shell
PORT MAP(
Using Vera
2-14
SystemClock => system_clock,
alu_ent_outp => alu_ent_outp,
alu_ent_inp2 => alu_ent_inp2,
alu_ent_inp1 => alu_ent_inp1,
alu_ent_op => alu_ent_op,
alu_ent_clk => alu_ent_clk,
alu_ent_rst => alu_ent_rst
);
dut_inst : alu_ent
PORT MAP(
outp => alu_ent_outp,
inp2 => alu_ent_inp2,
inp1 => alu_ent_inp1,
op => alu_ent_op,
clk => alu_ent_clk,
rst => alu_ent_rst
);
END
c. The Vera file (alu.vr), which is copied from the Vera template
file alu_ent.vr.tmp):
#include <vera_defines.vrh>
#include "alu_ent.if.vrh"
program alu_ent_test
{ // start of top block
// Start of alu_ent_test
//
// Example of drive:
Using Vera
2-15
// @1 alu_ent.outp = 0 ;
//
//
// Example of expect:
// @1,100 alu_ent.inp2 == 0 ;
//
2. The next step is to compile the alu.vr file, which creates the
alu_shell.v and alu.vro files:
% vera -cmp -simulator alu.vr
1. vlib work
2. vsim –c dut_bench –do “run –all; quit”
3. vmap work work
4. vcom filename.vhd filename_shell.vhd filename_top.vhd
5. vsim –c dut_bench –do “run –all; quit”
Compiling and Simulating with VCS-MX
Using Vera
2-16
Compiling and Simulating with NC-VHDL
1. mkdir work
2. ncvhdl –mefilename.vhd filename_shell.vhd filename_top.vhd
3. ncelab –me –access +rwc work.dut_bench:dut_bench_arch
4. ncsim –me work.dut_bench:dut_bench_arch
Using Vera
2-17
Sample/drive statically connected signal. If you want to statically
connect a Vera signal to an intermediate node (a non-port signal in
the design under test, which may or may not be a mixed signal), use
the keyword hdl_node when specifying the signal connections inside
the interface.
1. Verilog modules
module top(a, b, c); // the top module
......
......
reg d;
......
vh_inst vh_mod(a, d); // Instantiating a VHDL module
vl_inst vl_mod(b, c); // Instantiating a Verilog module
......
endmodule
2. VHDL module
entity vh_mod is
port (sig1 : IN std_logic; sig2 : OUT std_logic);
......
architecture arch of vh_mod is
......
signal local: std_logic;
......
end arch;
Using Vera
2-18
Vera Testbench. Say the top module is instantiated inside the
test_top file as dut. The Vera testbench can then access the
intermediate nodes like dut.vh_inst.local or dut.vl_inst.local or
dut.vh_inst.sig1. These signals are accessed in the same way as
any intermediate node in other simulators.
interface
{
......
output vh_local PHOLD #1 hdl_node "dut.vh_inst.local";
input vl_local PSAMPLE hdl_node "dut.vl_inst.local" ;
output vh_port PHOLD #1 hdl_node "dut.vh_inst.sig1" ;
......
};
1. Place all the VHDL tasks in a separate package. Note that only
those Verilog tasks that are defined in the top Verilog layer
modules can be imported.
2. Inside the Vera testbench, use the keyword hdl_task to declare
all the tasks you want to import.
3. Insert the keywords verilog_task or vhdl_task, as appropriate,
enclosed within braces inside the task path.
For example:
........
hdl_task veri_task_imported()"{verilog_task}top.top_veri_task";
hdl_task
vhdl_task_imported()"{vhdl_task}work.vhdl_task_pkg.proc0";
hdl_task arg_vh_task_imported(var int a)
"{vhdl_task}work.vhdl_task_pkg.proc1";
........
// The default hdl_task type is verilog_task.
...
Using Vera
2-19
program import_task_test()
{
int b=10;
...
veri_task_imported();
vhdl_task_imported();
...
arg_vh_task_imported(b);
...
}
Using Vera
2-20
Note:
While importing VHDL tasks, the vera_mx shell generator will
generate a new vhdl shell file vhdltasks_shell.vhd which also
needs to be analyzed.
4. Compile the Verilog files.
You must provide two switches to VCS: -mhdl and -vera, or
-mhdl and -vera_dbind,
When the two switches -mhdl and -vera are used with VCS, the
cli option +cli+4 is enabled by default. You can override this cli
option by explicitly providing the options +cli+2, or +cli+3. The
effects of the different cli options are:
Using Vera
2-21
VCS-MX (VHDL on top)
Using this type of mixed flow you can:
dut_vhdl shell_vhdl
vlog_mod
reg veri_reg; //a register in vlog_mod
Using Vera
2-22
Assume that the instance for vlog_mod is vlog_inst and the instance
for dut_vhdl is dut_inst. To access the register veri_reg, the path is
“top_vhdl: dut_inst: vlog_inst: veri_reg".
interface interface_name
{
...
inout vl_reg PSAMPLE PHOLD #1 hdl_node
"top_vhdl:dut_inst:vlog_inst:veri_reg";
...
}
Using Vera
2-23
3. Analyze all the Verilog files.
vlogan filename1.v ... filenameN.v
4. Analyze all the required VHDL files, including the shell file
vhdlan filename1.vhd ... filenameN.vhd
Note:
+cli+n enables capabilities “incrementally,” i.e., +cli+2 enables
+cli+1 capabilities, +cli+3 enables +cli+2 capabilities and so
on.
+cli+n is not necessary if the Vera testbench is connecting
Vera signals to VHDL signals in the top VHDL layer. The top
layer VHDL signals can be driven and sampled, without giving
the +cli option.
+cli+1 is sufficient if the Vera testbench is neither driving nor
sampling an MHDL signal.
Use +cli+2 if the Vera testbench is just sampling a Verilog
signal.
Use +cli+3 if the Vera testbench is driving a Verilog net.
Use +cli+4 if the Vera testbench is driving a Verilog register.
Using Vera
2-24
6. Include the vera_load=filename.vro, vera_mload=filename.vrl or
the vera_pload=filename.proj options in the vera.ini file.
7. If there were no errors, an executable scsim, will be generated.
scsim can be executed by entering the command
scsim -include filename
Note:
Use +cli+n option judiciously, as this affects performance.
SystemC-based Flow
OpenVera supports integration with SystemC. The integration
supports:
Using Vera
2-25
Creating an OpenVera Interface
To connect OpenVera to a SystemC design, you need to specify an
appropriate collection of interfaces in the OpenVera program file. An
interface is a list of signals that crosses the SystemC/OpenVera
boundary. SystemC and OpenVera types are not directly equivalent
so a mapping from one type to the other must be performed. For
example, assume you wish to test a SystemC module named
“Device,” which has the following declaration.
SC_MODULE(Device)
{
sc_in<sc_lv<8> > sig1;
sc_out<sc_logic> sig2;
sc_in<bool> clk;
...
}
This module has an 8-bit logic input, a 1-bit logic output, and a
boolean clock. Assuming you wish to have access to all three of
these signals from OpenVera, you would define an interface in your
OpenVera program, as illustrated below. Except for “clk,” which is
always an input signal, the signal directions are reversed (e.g., an
sc_in signal is a OpenVera output signal). The skew constants are of
course arbitrary and not significant for this example.
interface ifc1
{
output [7:0] sig1 PHOLD #3;
input sig2 NSAMPLE #-3;
input clk CLOCK hdl_node "{bool}";
}
Using Vera
2-26
Running SystemC with OpenVera
Note:
The SystemC integration does not support dynamically bound
signals or integration with a third language.
1. Generate the shell file, the top file and the vro. The shell file is a
SystemC header which contains the routines to communicate
with the OpenVera runtime. Within it is a SystemC module called
vera_shell, which you must instantiate and connect to the
SystemC signals. The top file is an example of instantiating the
vera_shell module. The top file always requires some
modification to suit the particular design being tested.
The command to generate these files is:
Using Vera
2-27
2. Modify the top file. The top file assumes your module is named
“test.” You should rename “test” to the name of your module and
include the header for this module in the top file. For this example
you would change “test” to “Device” and include Device.h. This
assumes Device.h contains the declaration of the Device module.
The signal connections should generally be correct for all but
clock signals. The generated top file includes a SystemC clock
which it ties to the OpenVera SystemClock. This clock should
often be tied to the SystemC module’s clk signal and in this
example the OpenVera interface clk signal.
3. The OpenVera runtime library expects a set of runtime
arguments. These are forwarded by the generated top file from
the command line of the C++ executable using:
VeraSystemC::SetArguments(argc, argv)
Using Vera
2-28
6. Link the final executable. The executable should include the
SystemC library, the OpenVera library for SystemC, test_top.o
and the your SystemC code. The OpenVera library for SystemC
is located at $VERA_HOME/lib/systemc/libVERA.a. Depending
on the machine, additional system libraries may be required. The
commands below assume the final executable will be called
run.x.
On Solaris:
g++ -g -L$VERA_HOME/lib/systemc \
-L$SYSTEMC/lib-gccsparcOS5 -o run.x \
test.o test_top.o -lVERA -lsystemc \
-lm -lsocket -lnsl -ldl
Note:
For machines not qualified for the Synopsys configuration, the
-ldl and -lnsl need to be added to the g++ link command.
On Linux:
g++ -g -L$VERA_HOME/lib/systemc \
-L$SYSTEMC/lib-linux -o run.x \
test.o test_top.o -lVERA -lsystemc -lm -ldl
Using Vera
2-29
Calling OpenVera Tasks from SystemC
The above description does not include imported and exported
functions. To call an OpenVera task from SystemC, you must prefix
the declaration in OpenVera with the export keyword. This causes
the generated vera_shell module to contain a task, task_taskname,
with mapped arguments.
Using Vera
2-30
You must then write a task matching the generated extern
declarations.
Using Vera
2-31
Using Vera
2-32
3
Compiling and Running Testbenches 3
This chapter describes how to compile and run testbenches using
Vera. It includes the following sections:
General Options
General options can be passed to the Vera compiler to return tool
information and to create template files. When these options are
used, the OpenVera source code files are not compiled and therefore
no Vera object files are created. The syntax to invoke the compiler is:
Option Definition
-help Lists valid Vera executable options
-pp Invokes the Vera preprocessor
-print Creates a PostScript file
-proj Creates Vera shell files from the project file
-rvm_version displays rvm version
-tem Invokes the Vera template generator
-v Returns the Vera compiler version
-V Prints complete version information
-vcon For multiple module support
-vmc Prints version information for the Vera virtual
machine.
-help
lists all the valid Vera executable options.
-tem verilog_filename
invokes the Vera template generator (see The Template
Generator” on page 1-7).
-v
prints the version number of the Vera installation. For example, a
version number will look similar to: 5.1.0
Compilation Options
The Vera compiler is primarily used to compile Vera source code
using the -cmp option. The syntax is:
compiler_options:
is one or more of the following:
Option Definition
-ansi Invokes the ansi preprocessor
-aop Used to compile aspect oriented extensions
files.
-D Specifies a macro name
-dep_check Detects files with circular dependencies
-dyn Used to ensure that the VDEO has a unique
entry point defined.
-f Automates capturing file dependencies across
multiple files.
-F Automates capturing file dependencies across
multiple files.
-g Includes debugger information
Note:
The same AOP .vro file should not be listed in both the
+vera_aspect list and in the .vrl file.
Example 3-1
// foo.vr
class foo {
integer x;
}
// fooAop.vr:
#include "foo.vrh"
extends fooAop(foo) {
before task new() {
printf("New called\n");
}
}
// top.vr:
#include "foo.vrh"
Note:
When using the automated build option, the -aop switch should
be specified within the file.list and not on the command line.
Using the above example:
# file.list
-HC foo.vr
-aop fooAop.vr
top.vr
vera -cmp -f file.list -dep_check
Option 2:
// object.vrl
// must use +vera_aspects=fooAop.vro on simulation
// command line
foo.vro
top.vro
Simulation
Option 1:
vera_cs +vera_mload=object.vrl
main Master
master_cov_aspect.vro ##coverage aspect for master
master.vro
main slave
slave_cov_aspect.vro ##coverage aspect for slave
slave.vro
Note:
When using VIP, or attributes to load .vro files, use the
+vera_aspects runtime option as described above to ensure
that the aspect .vro files are loaded first.
The woven code itself can also have semantic errors or introduce
semantic errors, for example, a reference that was resolved to an
integer variable in a super class now resolves to a string variable.
In these cases, either the compiler, or the runtime loader prints
error messages that describe the extension, statement, and
target scope that caused the error.
-D macro_name=value
specifies a text macro, where macro_name is the string of text to
be substituted for and the text macro is optionally set to value.
Text macros defined at compile time are particularly useful when
using conditional compilation directives.
------------------------
#file.list
topTest.vr
packet.vr
checker.vr
------------------------
vera -cmp -f file.list
-F
The -F works similarly to the -f option but the supplied path is
prepended to all source files contained within the file list. Since
the supplied path is prepended, it is recommended that absolute
pathnames not be used within the list file when using -F.
Assuming file.list:
tb1.vr
tb2.vr
file.list
-F include/include.list
-F library/library.list
include.list
tb1.vr
library.list
tb2.vr
tb3.vr
Compile Command:
vera -cmp -HC -f file.list out
Within a list file, a user can specify general options that effect all
subsequent source files. The option to do this is with the list file
command 'opts:' These general options apply until another opts:
command is reached within the file. At this point the previous 'opts:'
option is no longer applied. General options supplied via the
command line apply to all files unless overridden by local options,
while general options supplied via 'opts:' are applied to all files until
another 'opts:' command is found. All general options can be
overridden with local options supplied at the individual source file
level.
file.list
-letc -HC packet.vr
-y library
file.list:
# example of output directory
-y library library/out
# example of output file
-Ietc -HC packet.vr out
file: A.vr:
#include "B.vrh"
class A {
B b;
...
...
}
Example 2
file: B.vr
extern integer i;
extern class C {....}
class B {
...
...
}
Compile command:
vera -cmp -H B.vr
-HC
The -HC option automatically creates a header file with extern
declarations and include directives for files included in the source
files. It updates the .vrh file. An object file is generated.
Example
vera -cmp -HC a.vr
-HCnu
The -HCnu option automatically creates a header file with extern
declarations and include directives for files included in the source
files. It updates the .vrh file only if it has changed. An object file
is generated. For example:
vera -cmp -HCnu a.vr
-hnu
The -hnu option functions like the -h option except that it only
updates the .vrh file if there are changes to it.
-Hnu
Updates the .vrh header file only if it has changed.
-I
The -I option adds a specified path to the search path for include
files.
Syntax
-Idirectory
directory
is the absolute or relative path to the directory you want
to add to your search path.
However, if there are two files with the same name, for example,
a foo.h in the current directory and a foo.h in another directory,
then these files must be declared as follows:
#include "foo.h" // Use "" when the file to be included is in same
// directory where the file to be compiled
// is located.
#include <foo.h> // Use <> when the file to be included is another
// directory. Used in conjunction with -I option.
On the vera -cmp command line you must then specify the path
to the <foo.h> file. For example:
vera -cmp -I.. test.vr
-i
Generates an ASCII file (.vri) containing the interface definition.
This interface specification produces the corresponding
generated interface file:
input data_in[31:0] PSAMPLE 1
output ack[31:0] PHOLD 0
inout data_out[1:0] PSAMPLE 0 PHOLD 1
-i_skew
The -i_skew option allows you to specify a default input skew for
all interface input and inout signals that do not have explicit skews
defined in their interface declarations on the command line. Input
and inout signals that do have explicit skews defined in their
interface declarations continue to use their explicitly specified
-local
When used in combination with one of the header file generation
options (e.g -H, -h), local variables will be included in the resulting
autogenerated .vrh file.
-max_error number
The -max_error_number option specifies the maximum number
of errors the compiler can encounter before the compilation fails.
-no_dep_graph
The –no_dep_graph bypasses the generation of the dependency
graph when using the -dep_check switch. It’s function is to
expedite compiles of large file sets when –dep_check has
previously been run on a set of files. Use with caution since, if the
directory structure or dependencies of the files change, the build
will not succeed.
Considering the previous example, say you have already
executed the command:
vera -cmp -f files.list -dep_check -print_deps.
-no_warn_null
-no_warn_null disables warning messages that are given when
objects contained in the object being packed are NULL. It also
disables randomization warning messages that are given when
objects contained in the object being randomized are NULL.
-print_deps
The –print_deps is a supplied with -dep_check telling the Vera
compiler to output the dependencies for the source files to
standard out or to a user specified file.
Syntax
vera -cmp -f file.list -dep_check
-print_deps[=filename]
filename is the name of the file where the user wants the results
to be printed to.
Example 3-2
vera -cmp -f file.list -dep_check -print_deps=
"file_dep_report"
Example 3-3
vera -cmp -f file.list -dep_check -print_deps
Dependencies:
tb1.vro: tb1.vr tb2.vrh
tb1.vrh: tb1.vr tb2.vrh
tb2.vro: tb2.vr
tb2.vrh: tb2.vr
Dependencies:
-q
compiles the code in quiet mode. When the compiler is run in
quiet mode, the header information is shortened and limited to
only compile information.
This switch applies to the whole testbench; you cannot mix new
and old random values.
-systemc
generates the shell file, which is a SystemC header containing
the routines that communicate with Vera runtime.
-tdef
enables the old usage of typedef so that existing code can be
compiled, which is useful in compiling existing Vera code.
In Vera releases before 4.0, typedef could sometimes be used in
place of an extern class definition. In Vera 4.0 and later, typedef
is a forward reference mechanism within a compilation file. T
Note:
This switch should not be used for new Vera development as it
can sometimes cause compilation errors.
-tradition
Preprocesses file.vr in non-ANSI mode
-vip
generates encrypted Vera source files that can be used as IP
cores (see Testbenches for Verification Intellectual Property).
Vera will compile all the .vr files in $MY_VR_FILES_DIR with the -HC
option. The –y option supports the use of -dep_check, -print_deps
and -no_dep_graph. Use of these additional options will result in Vera
determining the dependencies for all of the ‘.vr’ files in the directory
along with incremental compilation.
Usage note
- More than one –y option is allowed within the list file. It,
however, is not legal syntax to include both –f and –y on the
command line.
simulator:
is one of the following:
Simulator Switch
Verilog -vlog
VHDL -mti, -sro, -nc_vhdl
SystemC -systemc
Option Definition
-alim Defines the maximum variable size for
which mirrored HDL variables will be
created.
-cfg Includes the specified .vcon file
-shell Sets the module name in the HDL shell.
-timescale Specifies a timescale
-top Generates a VHDL test_top file
-vlog Names the Vera shell file
“filename_shell.v”
-alim number
defines the maximum variable size for which mirrored HDL
variables will be created. The default value is 0. If 0, it indicates
that no global variables are declared in the shell files and Vera will
not create any mirrored HDL variables.
When you use the Vera delay() system task, or have skews on
interface signals, you should compile the Vera source file
containing the program block with this option. The scale value
sets the units to which the delay(), or skew, refers.
simulator [switch_+arg]
where:
simulator
is the simulator executable linked with Vera (specify the full path
if it is not in your search path). To run Vera as a standalone, enter
vera_cs as the simulator name.
Runtime Options
There are two types of runtime options:
• In the vera.ini file, the “+” is omitted, and the parameter name and
value can be separated by either an equals sign, an underscore
or a space:
Note:
The file from which Vera reads initialization values is named
vera.ini by default. An alternative filename may be specified
with the VERA_INI environment variable. Vera attempts to
open this file first in the current working directory, then in the
$VERA_HOME directory.
vera_continue_on_error
causes the simulation to continue after a verification error is
encountered. This option causes the simulation to continue when
verification errors (such as failed expects) occur. This option
overrides the vera_exit_on_error option.
vera_debug_on_error
invokes a debugger when a verification error (such as a failed
expect) is encountered. This option determines the debugger
used when a verification error is encountered. If the HDL
simulator has control when the error occurs, the simulator’s
debugger is invoked. If Vera has control when the error occurs,
Vera’s debugger is invoked. If this option is not used, the behavior
depends on the particular HDL simulator.
vera_debug_on_int
when the simulation is running, the debugger will start after you
press Ctrl-C.
vera_interactive_plot
in an interactive simulation, you must specify this option when
using vera_plot(), otherwise vera_plot() will dump in
post-processing mode only.
vera_aspects
Files compiled using the -aop option must be loaded before any
non aspect .vro files. This may be done by either listing the .vro
files first in the .vrl file, or by setting vera_aspects to the
filenames:
vera -cmp -aop cov1.vr
vera -cmp -aop cov2.vr
vera -cmp -aop cov3.vr
simv +vera_aspects=cov1.vro,cov2.vro,cov3.vro
Note:
When using VIP, or attributes to load .vro files, use the
+vera_aspects runtime option as described above to ensure
that the aspect .vro files are loaded first.
Note:
The same AOP .vro file should not be listed in both the
+vera_aspect list and .vrl file.
vera_cache_dir
specifies the directory location of the cache that Vera maintains
as an internal disk cache for randomization:
simv +vera_cache_dir=/u/myself/tmp_cache...
vera_profile_range
sets the start and stop time for generating memory usage
reports. This allows for generation of memory profile reports
during a specific time in the simulation. This command must be
used in conjunction with +vera_profile_interval. A final end of
simulation memory report will also be added to the file.
+vera_profile_range=yyy:zzz
Predefined Macros:
The valid values for plus argument requests are:
Request Action
plus_arg
is the plus argument you want to evaluate.
The get_plus_arg() system function returns a value based on the
request type and plus_arg value.
For example:
#include <vera_defines.vrh>
#define DEF_RP_TIMES 10
#define DEF_RSEED 32'habcd_ef01
#define DEF_LOG_FILE_NAME "test.log"
program test{
integer repeat_times = DEF_RP_TIMES;
reg [31:0] random_seed = DEF_RSEED;
reg [2047:0] bit_str; //max 256 char
string log_file_name = DEF_LOG_FILE_NAME;
Referencing Variables
Forward reference is allowed with interface signals, port signals, bind
signals, global variables, and task and function calls that are present
at the top level.
Note:
When using external subroutines, the argument types that are
passed must match exactly. So take extra care when passing
arguments to external subroutines.
The default values can be set locally, and independently, for each
compilation unit using extern declarations with default values. A
general library, which can then be customized for a particular user or
testbench, can be implemented by using include files with different
defaults.
// file A (library)
task write (integer i, k, reg[5:0] data)
{
// write definition
}
// file B (testbench)
extern task write(integer i = 10,integer k,reg[5:0] data=6'b1);
task xyz () {
write (*, 5);
//continue task declaration
4-1
Overview
The following are the basic steps to enable Vera-SystemC TLI
transactions:
Vera Shell
Trans
Transaction Object Trans
Master
Object Clock
(write)
Generator
transaction channel
Trans
Object DUT
#include <systemc.h>
#include "mem_if.h"
public :
Mem(sc_module_name name);
void read(unsigned int addr, unsigned int &datao);
void write(unsigned int addr, unsigned int datai);
};
Mem::Mem(sc_module_name name):
sc_module(name),
idx(0)
{}
Note:
mem_if.h (see Example 4-3) is the SystemC interface class from
which Mem.h is derived.
SC_If_Header_File_Name: Header_file_name
Interface_Begin name_of_SystemC_interface_class
Template_Map_List_Begin
Template_Map_List_End
Map_List_Begin
Map_List_End
Transaction_Begin name_of_method
IMC_Arg_List: comma_separated_list_of_arguments
Tx_Begin argument_name
Data_Type: data_type
ArraySize: array_size
Tx_End
Rx_Begin <arg_name>
Data_Type: data_type
ArraySize:array_size
IsReturnData;
Rx_End
Transaction_End
Interface_End
• TO_mem_if.cpp
• TO_mem_if.h
• mem_if_master.cpp
• mem_if_master.h
• mem_if_slave.cpp
• mem_if_slave.h
• TO_mem_if.vr
The TO_mem_if.cpp and TO_mem_if.h files contain the
implementation of the transaction objects such as display, pack.
To send data from Vera to the SystemC model, the user will
instantiate the transaction object and channel classes (declared in
the TO_mem_if.vr file listed above) in the main program. The
Transaction Object can be, for example, randomized on the Vera
side. It is then sent to the SystemC model (Mem) via the Transaction
Channel. Here is an example of testbench.vr:
repeat(30)
@(posedge CLOCK);
%g++ -g -c -Wno-deprecated-I${SYSTEMC}/include \
-I$VERA_HOME/ include/systemc -I$VERA_HOME/lib \
-I$VERA_HOME/include/rvm_sc \
-I$VERA_HOME/include/rvm_sc/osci \
-I./include/rvm_sc/osci Mem.cpp
Solaris
% g++ \
-o mem_testbench \
TO_mem_if.o mem_if_master.o Mem.o main.o \
-L${VERA_HOME}/lib/systemc -lVERA -lrvm_sc_osci \
-L${SYSTEMC}/lib-gccsparcOS5 -lsystemc -lsocket -ldl -lnsl
-uspawn_tattletale_sc2vr
Run
% mem_testbench
Output
SystemC 2.0.1 --- Oct 31 2003 10:33:56
++---------------------------------------------------------------++
|| VERA System Verifier (TM) ||
|| Version: 6.3.0 (Beta4) -- Mon Jul 26 13:28:58 2004 ||
|| Copyright (c) 1995-2004 by Synopsys, Inc. ||
|| All Rights Reserved ||
|| ||
|| For support, send email to vera-support@synopsys.com ||
|| ||
|| This software and the associated documentation areconfidential||
|| and proprietary to Synopsys Inc.Your use or disclosure of this||
|| software is subject to the terms and conditions of a written ||
|| license agreement between you or your company and Synopsys,Inc.||
++---------------------------------------------------------------++
Vera: Loading /<VERA_HOME_INSTALL>/vro/rvm_sc/rvm_sc_lib.
vro..
Vera: Loading TO_mem_if.vro..
Vera: Loading main.vro..
Start of Vera
VERA - creating channelsVERA - put data into the write channel
writing:addr = 0x00000000datai = 0x00000000 CPP - accessing Mem::write
writing:addr = 0x00000001datai = 0x0000000a CPP - accessing Mem::write
writing:addr = 0x00000002datai = 0x00000014 CPP - accessing Mem::write
writing:addr = 0x00000003datai = 0x0000001e CPP - accessing Mem::write
writing:addr = 0x00000004datai = 0x00000028 CPP - accessing Mem::write
writing:addr = 0x00000005datai = 0x00000032 CPP - accessing Mem::write
writing:addr = 0x00000006datai = 0x0000003c CPP - accessing Mem::write
writing:addr = 0x00000007datai = 0x00000046 CPP - accessing Mem::write
writing:addr = 0x00000008datai = 0x00000050 CPP - accessing Mem::write
writing:addr = 0x00000009datai = 0x0000005a CPP - accessing Mem::write
VERA - done with put data into the write channel
VERA - get data out of the read channel CPP - accessing Mem::read
• Random Stability
• Seeding for Randomization
• randcase Statements
• Random Number Generation
• Constraint Based Randomization
• Random Sequence Generation
Randomization in Vera
5-1
Random Stability
Random Number Generation (RNG) is now localized to threads and
objects. Because the stream of random values returned by a thread
or object is independent of the RNG in other threads or objects, this
property is called Random Stability. Random stability applies to
Compatibility
• Random stability is enabled by default. The command line option,
+vera_disable_random_stability, disables all of the random
stability modes. The overall stream of random values will then be
the same as in pre-5.2 versions of Vera.
• In Vera 6.1, newed objects that do not contain rand or randc
members will not take a random value from the parent thread's
RNG.
This can cause a change in the random data values generated
between Vera 6.0 and 6.1. However, only testbenches that
compare results to a golden file should be affected.
Randomization in Vera
5-2
Random Stability Properties
Random stability encompasses the following properties:
• Object stability
Each class instance (“object”) has an independent RNG source
for the randomization method in the class. When an object is
created using new(), its RNG is seeded with the next random
value from the thread that created the object.
• Manual seeding
You can manually seed all RNG sources. Combined with
hierarchical seeding, this allows you to define the operation of a
subsystem (hierarchy subtree) completely with a single seed at
the root thread of the system.
Randomization in Vera
5-3
Program and thread stability
Random values returned from Vera system calls (e.g., random(),
urandom(), the randcase, and the Vera Stream Generator (“VSG”)
randseq(){}), are independent of thread execution order.
integer x, y, z;
fork //set a seed at the start of a thread
{srandom(100); x = random();}
//set a seed during a thread
{y = random(); srandom(200);}
//randcase draws a value from the thread RNG
{z = random(); randcase(){ … }}
join all
Randomization in Vera
5-4
Object Stability
The randomize() method built into every class exhibits “object
stability.” This is the property that calls to randomize() in one instance
are independent of calls to randomize() in other instances, and
independent of calls to the system randomize functions.
Example
program main
{
Foo foo = new();
Bar bar = new();
integer z;
void = foo.randomize();
// z = random();
void = bar.randomize();
• The values returned for foo.x and bar.y are independent of each
other
• The calls to randomize() are independent of the random system
calls. If we uncomment the line “z = random()” above, there is no
change in the values assigned to foo and bar.
• Each instance has a unique source of random values that can be
seeded independently. That random seed is taken from the
parent thread when the instance is created.
• Instances can be seeded at any time using the srandom()
initstate(), and setstate() system calls with an optional object
argument.
Randomization in Vera
5-5
class Foo
{
task new (integer seed)
{
//set a new seed for this instance
srandom(seed, this);
}
}
Manual Seeding
Threads may also be seeded using srandom(), initstate(), or
setstate(). There is no way for a thread to set the random state of
another thread. The srandom() system call in the example initializes
the state for the thread’s RNG state using the seed (see srandom(),
initstate(), and setstate() below).
Reseeding
A thread may set a new seed at any time during execution.
Randomization in Vera
5-6
Seeding for Randomization
srandom()
Syntax
The srandom() task initializes the current RNG array using the value
of the seed.
Note:
The seed value may not be 0.
initstate()
The initstate() task allows a user-defined state array, pointed to by
the state argument, to be initialized for future use.
Syntax
Note:
The seed value may not be 0.
Randomization in Vera
5-7
The initstate() task initializes the state array using the seed and then
attaches the state array to the current randomizer using the
setstate() semantics below. The optional object argument is used to
seed an object instead of the current thread (context).
setstate()
Syntax
The setstate() task attaches the state array to the current thread or
specified object. The state array will be changed whenever random()
or urandom() is called on the current randomizer. The optional object
argument is used to seed an object instead of the current thread
(context).
Randomization in Vera
5-8
getstate()
Syntax
This call returns a copy of the state values for the current thread or
specified object.
Randomization in Vera
5-9
Sometimes it is desirable to manually seed an object’s RNG using
the srandom() system call. This can be done either in a class
method, or external to the class definition:
class Packet
{
rand bit[15:0] header;
...
or externally:
Randomization in Vera
5-10
Syntax
task vera_save_rng_state([object]);
task vera_restore_rng_state([object]);
Example 5-1
#include <vera_defines.vrh>
class C
{
rand bit[8:0] v;
}
Randomization in Vera
5-11
program rand_test
{
C c = new;
vera_save_rng_state(c);
void = c.randomize()
vera_restore_rng_state(c);
void = c.randomize();
}
In the above example, both calls to randomize will produce the same
random numbers.
randcase Statements
The randcase statement specifies a block of statements, one of
which is executed randomly.
randcase
{
weight1 : statement1
weight2 : statement2
...
weightN : statementN
}
weight
can be any valid expression, including a constant. The weight
expression is evaluated every time a randcase is executed. If
weight is zero, that branch will not be used.
Randomization in Vera
5-12
statement
can be any valid statement or block of statements. If a code block
is used, the entire block is executed.
When the randcase statement is executed, a statement is
randomly selected from the randcase block. Different weights can be
used to change the probability that any given statement is
selected. The probability that any single statement is selected is
determined by weight/total_weight.
Example 5-2
randcase
{
10: i=1;
20: i=2;
50: i=3;
}
Randomization in Vera
5-13
Random Number Generation
random()
The random() function returns a 31-bit pseudo-random positive
integer value from the current thread RNG.
Syntax
seed
is an optional argument that determines which random number
sequence is generated. The seed can be any valid Vera
expression, including variable expressions. The random number
generator generates the same number sequence every time the
same seed is used.
Note:
A seed value of 0 is a special case in which the random
number sequence is the same as the one generated with a
seed value of 1.
The random() function takes an optional seed argument that is used
to call srandom() before computing the random value. In this case
the system behaves as if srandom(seed) had been called before
random().
Randomization in Vera
5-14
Typically, to generate random numbers, you first call the random()
system function with an integer seed value. Then call the random()
function without a seed each time you need a new random number.
Example 5-3
random( 184984 ); // Initialize the generator
addr = {random(),random()};
ph_number = random() >> 5;
Example 5-4
program dut_test
{
printf("First random value = %h\n", random(1));
}
urandom()
The urandom() function returns a 32-bit pseudo-random unsigned bit
vector value from the current thread RNG.
Syntax
Note:
The seed value may not be 0.
Randomization in Vera
5-15
In this case the system behaves as if srandom(seed) had been
called before urandom().
rand48()
The rand48() function generates an integer (random) number based
on the lrand48 algorithm.
Syntax
Note:
The random() function is recommended over rand48() because it
yields a better distribution of random values. Also, rand48() does
not adhere to random stability.
urand48()
The urand48() function generates an unsigned 32-bit random
number based on the mrand48 algorithm.
Syntax
Note:
Also, urand48() does not adhere to random stability
Randomization in Vera
5-16
For more information on the mrand48 algorithm, see the Unix man
pages (from a Unix shell, type “man mrand48”).
urandom_range()
Syntax
Example: val=urandom_range(7,0);
Example: val=urandom_range(7);
Example: val=urandom_range(0,7);
Randomization in Vera
5-17
Constraint Based Randomization
This section introduces basic concepts and uses for generating
random stimulus within objects. The OpenVera language uses an
object-oriented method for assigning random values to the member
variables of an object subject to user-defined constraints.
Example
class Bus{
rand bit[15:0] addr;
rand bit[31:0] data;
The Bus class models a simplified bus with two random variables:
addr and data, representing the address and data values on a bus.
The word_align constraint declares that the random values for
addr must be such that addr is word-aligned (the low-order 2 bits
are 0).
randomize()
The randomize() method is called to generate new random values for
a bus object:
program test{
Bus bus = new;
repeat (50){
integer result = bus.randomize();
if (result == OK)
printf("addr = %16h data = %32h\n",
bus.addr, bus.data);
else
printf("Randomization failed.\n");
}
}
Randomization in Vera
5-18
New values are selected for all of the random variables in an object
such that all of the constraints are true (“satisfied”). In the program
test above, a “bus” object is created and then randomized 50 times.
The result of each randomization is checked for success. If the
randomization succeeds, the new random values for addr and data
are printed; if the randomization fails, an error message is printed. In
this example, only the addr value is constrained, while the data value
is unconstrained. Unconstrained variables are assigned any value in
their declared range.
Example 5-5
enum AddrType = low, mid, high;
class MyBus extends Bus{
rand AddrType type;
constraint addr_range{
(type == low ) => addr in { 0 : 15};
(type == mid ) => addr in { 16 : 127};
(type == high) => addr in {128 : 255};
}
}
Randomization in Vera
5-19
The MyBus class inherits all of the random variables and constraints
of the Bus class, and adds a random variable called type that is used
to control the address range using another constraint. The
addr_range constraint uses implication to select one of three range
constraints depending on the random value of type. When a MyBus
object is randomized, values for addr, data, and type are computed
such that all of the constraints are satisfied. Using inheritance to build
layered constraint systems allows you to develop general-purpose
models that can be constrained to perform application-specific
functions.
Example 5-6
task exercise_bus (MyBus bus)
{
integer res;
// EXAMPLE 2:
// restrict to address between 10 and 20
res = bus.randomize() with
{10 <= addr && addr <= 20;};
...
// EXAMPLE 3:
// restrict data values to powers-of-two
res = bus.randomize() with
{data & (data - 1) == 0;};
...
}
Randomization in Vera
5-20
• Constraints can be any OpenVera expression with variables and
constants of type bit, integer, or enumerated type.
• Constraint expressions follow Verilog syntax and semantics,
including precedence, associativity, sign extension, truncation,
and wrap-around.
• The Vera constraint solver is very general and can handle a wide
spectrum of seemingly hard problems, including algebraic
factoring, complex Boolean expressions, and mixed integer and
bit expressions. In the example above, the power-of-two
constraint was expressed arithmetically. It could have also been
expressed using a shift operator. For example, 1 << n, where n is
a 5-bit random variable.
• The Vera constraint solver is robust. If a solution exists, the solver
will find it. The solver only fails when the problem is
over-constrained and there is no combination of random values
that satisfy the constraints.
• Constraints interact bidirectionally. In this example, the value
chosen for addr depends on type and how it is constrained, and
the value chosen for type depends on addr and how it is
constrained. It is important to understand that Vera treats all
expression operators bidirectionally, including the implication
operator (=>).
Sometimes it is desirable to disable constraints on random variables.
For example, consider the case where we want to deliberately
generate an illegal address (non-word aligned):
Randomization in Vera
5-21
Example 5-7
task exercise_illegal(MyBus bus, integer cycles)
{
integer res;
repeat (cycles)
{
// CASE 1: restrict to small addresses.
res = bus.randomize() with {addr[0] || addr[1];};
...
}
Randomization in Vera
5-22
Occasionally, it is desirable to perform operations immediately before
or after randomization. Vera provides two built-in methods,
pre_randomize() and post_randomize(). These methods are
automatically called before and after randomization. These methods
can be overloaded with the desired functionality:
Example 5-8
class XYPair
{
rand integer x, y;
}
task post_randomize()
{
super.post_randomize();
printf("After randomize x=%0d, y=%0d\n", x, y);
}
}
Randomization in Vera
5-23
Random Variables
Class variables can be declared random using the rand and randc
type-modifier keywords.
Syntax
rand variable;
randc variable;
Randomization in Vera
5-24
Syntax
array_name.size() constraint
array_name
is the name of the array or SmartQ.
Example 5-9
array_name.size() <= 10;
Randomization in Vera
5-25
Example 5-10
class GroupLine
{
rand integer x;
rand integer a[] assoc_size x;
constraint c
{
x >=0 ; x <= 5;
}
}
is equivalent to:
class GroupLine
{
rand integer a[];
constraint c
{
a.size() >=0 ; a.size() <= 5;
}
}
Randomization in Vera
5-26
Example 5-11
rand bit[7:0] len;
rand integer data[] assoc_size len;
Example 5-12
rand bit[7:0] x;
Randomization in Vera
5-27
This is an 8-bit unsigned integer with a range of 0 to 255. If
unconstrained, this variable will be assigned any value in the range
0 to 255 with equal probability. In this example, the probability of the
same value repeating on successive calls to randomize is 1/256.
randc Modifier
Variables declared with the randc keyword are random-cyclic
variables that cycle through all the values in a random permutation
of their declared range. Random-cyclic variables can only be bit or
enumerated types, and are limited to a maximum size of 8 bits, so
the maximum range for any randc variable is 0 to 255.
Example 5-13
randc bit[1:0] y;
initial permutation: 0 3 2 1
next permutation: 2 1 3 0
next permutation: 2 0 1 3
Randomization in Vera
5-28
The basic idea is that randc randomly iterates over all the values in
the range and that no value is repeated within an iteration. When the
iteration is finished, a new iteration is automatically started.
The randc variables are solved for first, using only constraints that
involve one randc variable and other non-random variables. The
values obtained for the randc variables are used as constants while
solving for the remaining random variables.
Example 5-14
randc bit[3:0] x,y;
rand integer z;
constraint C
{
x < 10;
y > 5;
z == x+y;
}
Here x will get a value between 0 and 9 and y will get a value
between 6 and 15. These values will be chosen to cycle over values
in these ranges, over successive calls to randomize(). The values
obtained will be used to solve for z.
Constraint Blocks
The values of random variables are determined using constraint
expressions that are declared using constraint blocks. Constraint
blocks are class members, like tasks, functions, and variables. They
must be defined after the variable declarations in the class, and before
the task and function declarations in the class. Constraint block
names must be unique within a class.
Randomization in Vera
5-29
Syntax
constraint_name
is the name of the constraint block. This name can be used to
enable or disable a constraint using the built-in
constraint_mode() method.
constraint_expressions
are a list of expression statements that restrict the range of a
variable or define relations between variables. A constraint
expression can be any OpenVera expression, or can use the
constraint-specific set operators: in, !in, and dist.
The declarative nature of constraints requires the following
restrictions on constraint expressions:
Randomization in Vera
5-30
// class declaration
class XYPair
{
rand integer x, y;
constraint c;
}
Inheritance
Constraints follow the same general rules for inheritance as class
variables, tasks, and functions:
class B extends A
{
constraint c { x > 0; }
}
Randomization in Vera
5-31
An instance of class A constrains x to be less than zero whereas
an instance of class B constrains x to be greater than zero. The
extended class B overrides the definition of constraint c. Note:
constraints are treated the same as virtual functions, so casting
an instance of B to an A does not change the constraint set.
Set Membership
Constraints support integer value sets and set membership
operators.
expression
can be any OpenVera expression.
set_operator
can be in or !in. The in operator returns true if the expression is
contained in the set; otherwise it returns false. The !in operator
returns the negated value of the in operator. For example, x !in {
} is the same as ! ( x in { } )
In the absence of any other constraints, all values (either single
values or values within ranges), have an equal probability of
being chosen by the in or !in operators.
Randomization in Vera
5-32
value_range_list
is a comma-separated list of integers, enumerated types, bit
expressions, and ranges. Ranges are defined by specifying a low
and high bound, separated by a colon (low_bound : high_bound).
Ranges include all of the integer elements between the bounds.
The bound to the left of the colon MUST be less than or equal to
the bound to the right, otherwise the range is NULL and contains
no values.
Example 5-15
rand integer x, y, z;
constraint c1 {x in {3, 5, 9:15, 24:32, y:2*y, z};}
rand integer a, b, c;
constraint c2 {a in {b, c};}
Set values and ranges can be any OpenVera expression. Values can
be repeated; values and ranges can overlap. It is important to note
that the in and !in operators are bidirectional, so the second example
is equivalent to a == b || a == c.
Distributions
In addition to set membership, constraints support sets of weighted
values called distributions. Distributions have two properties: they are
a relational test for set membership, and they specify a statistical
distribution function for the results.
expression
can be any OpenVera expression that refers to at least one
variable declared as rand.
Randomization in Vera
5-33
dist_operator:
is dist. The dist operator returns true if the expression is
contained in the set; otherwise it returns false.
In the absence any other constraints, the probability that the
expression matches any value is proportional to its specified
weight. Dist expressions can only be top-level expressions.
value_range_ratio_list
is a comma-separated list of integer, enumerated type, bit
expressions, and ranges (the same as the value_range_list
for set membership). Optionally, each term in the list has a weight,
which is specified using the := or :/ operators. If no weight is
specified, the default weight is 1. The weights may be any
OpenVera expression.
The := operator assigns the specified weight to the item, or if the item
is a range, to every value in the range.
The :/ operator assigns the specified weight to the item, or if the item
is a range, to the range as a whole. If there are n values in the range,
the weight of each value is range_weight/n.
Example 5-16
x dist {100 := 1, 200 := 2, 300 := 5}
x != 200;
x dist {100 := 1, 200 := 2, 300 := 5}
Randomization in Vera
5-34
It is easier to think about mixing ratios, such as 1-2-5, than the actual
probabilities because mixing ratios do not have to be normalized to
100%. It is also easy to convert probabilities to mixing ratios.
Example 5-17
x dist {100:102 := 1, 200 := 2, 300 := 5}
means x is equal to 100, 101, 102, 200, or 300 with a weighted ratio
of 1-1-1-2-5.
means x is equal to one of 100, 101, 102, 200, or 300 with a weighted
ratio of 1/3-1/3-1/3-2-5.
Conditional Constraints
OpenVera provides two constructs for declaring conditional
(predicated) constraints: implication and if-else.
Randomization in Vera
5-35
expression
can be any OpenVera expression.
=>
The implication operator is =>. The implication operator returns
true if the expression is false or the constraint is satisfied;
otherwise it returns false.
constraint
Any valid constraint.
constraint_set
is a set of semi-colon separated constraints. If the expression is
true, all of the constraints in the constraint set must be satisfied.
Example
mode == small => len < 10;
mode == large => len > 100;
In this example, the value of mode implies that the value of len is
less than 10 or greater than 100. If mode is neither small nor
large, the value of len is unconstrained.
The boolean equivalent of (a => b) is (!a || b). Implication is a
bidirectional operator. Consider the following example:
bit[3:0] a, b;
constraint c {(a == 0) => (b == 1)};
Randomization in Vera
5-36
It is important to understand that Vera is designed to cover the whole
random value space with uniform probability. This allows
randomization to better explore the whole design space than in
cases where certain value combinations are preferred over others.
Syntax
expression
can be any OpenVera expression
constraint
is any valid constraint. If the expression is true, the first constraint
must be satisfied; otherwise the optional else-constraint must be
satisfied.
constraint_set
is a set of semi-colon separated constraints. If the expression is
true, all of the constraints in the first constraint set must be
satisfied, otherwise all of the constraints in the optional
else-constraint-block must be satisfied.
If-else style constraint declarations are equivalent to implications:
if (mode == small)
len < 10;
else
if (mode == large)
len > 100;
Randomization in Vera
5-37
is equivalent to
In this example, the value of mode implies that the value of len is
less than 10, greater than 100, or unconstrained.
Hierarchical Constraints
When an object member of a class is declared rand, all of its
constraints and random variables are randomized simultaneously
along with the other class variables and constraints. Constraint
expressions involving random variables from other objects are called
“hierarchical constraints.”
class A
{
rand bit[7:0] x;
}
class B
{
rand A left;
rand A right;
rand bit[7:0] x;
Randomization in Vera
5-38
B .x
.left .right
.x .x
A A
Randomization in Vera
5-39
definition is recursive and includes all of the active random
objects that can be reached from the starting object. The objects
selected in this step are referred to as the active random objects.
2. Global randomization next selects all of the active constraints
from the set of active random objects. These are the constraints
that are applied to the problem.
3. Global randomization finally selects all of the active random
variables from the set of active random objects. These are the
variables that are randomized. All other variable references are
treated as state variables, whose current value is used as a
constant.
Variable Ordering
Vera assures that the random values are selected to give a uniform
value distribution over legal value combinations (that is, all
combinations of values have the same probability of being chosen).
This important property guarantees that all value combinations are
equally probable.
Example 5-18
class B
{
rand bit s;
rand bit[31:0] d;
constraint c { s => d == 0; }
}
Randomization in Vera
5-40
The constraint c says “s implies d equals zero”. Although this reads
as if s determines d, in fact s and d are determined together. There
are 2**32 valid combinations of {s,d}, but s is only true for {1,0}. Thus,
the probability that s is true will be 1/2**32, which is almost never.
Example 5-19
class B
{
rand bit s;
rand bit[31:0] d;
constraint c { s => d == 0; }
constraint order { solve s before d; }
}
In this case, the order constraint instructs Vera to solve for s before
solving for d. The effect is that s is now chosen true with 50%
probability, and then d is chosen subject to the value of s. Accordingly,
d == 0 will occur 50% of the time, and d != 0 will occur for the other
50%.
variable_list
is a comma-separated list of integral scalar variables or array
elements.
The following restrictions apply to variable ordering:
Randomization in Vera
5-41
• The variables can only be those declared as rand. Variables
declared as randc are disallowed.
• The variables must be integral scalar values of type integer, bit,
or enumerated type.
• A named constraint block member of a class may contain both
regular value constraints and ordering constraints. Ordering
constraints must occur at the top-level of the named constraint
block.
• A randomize-with constraint block in a task or function may
contain both value constraints and ordering constraints. Ordering
constraints must occur at the top-level of the randomize-with
constraint block.
• There must be no circular dependencies in the ordering, such as
solve a before b combined with solve b before a.
• Variables that are not explicitly ordered will be solved with the last
set of ordered variables. These values are deferred until as late
as possible to assure a good distribution of value.
• Variables can be solved for in an order that is not consistent with
the ordering constraints. An example situation where this might
occur is:
x == 0;
x < y;
solve y before x;
In this case, since x has only one possible assignment (0), x can
be solved for before y. The constraint solver uses this flexibility to
speed up the solving process.
Randomization in Vera
5-42
Dynamic Constraint Modification
There are several ways to dynamically modify constraints on
randomization:
Array Constraints
Array constraints allow specification of templated constraints that will
be elaborated by the solver. We currently support two flavors for
array constraints viz. foreach loops and array aggregates/
containment operators.
Randomization in Vera
5-43
Syntax
name
is the name of the array or SmartQ.
loop_variable
is the name of the index variable that is generated automatically
and acts as an indexing member. It only needs to be declared in
the argument list of the foreach block and has the scope of that
block.
loop_variable_list
is a comma-separated list of loop variables. An asterisk, *, can be
used as a placeholder for an index in a multidimensional array.
That index is ignored in the foreach loop.
constraint_set
can be any valid code for constraints.
Randomization in Vera
5-44
Example 5-21 Foreach loop on a two dimensional array
class A
{
rand integer d[2][2];
foreach(d, *, index) {
(d[0][index] > 22) && (d[0][index] < 33);
}
}
Example 5-22 Use of guards for constraining two dimensional array, integer
d[2][2]
class C{
rand integer size;
rand integer arr[*];
constraint cc{
size > 0; size < 5;
Randomization in Vera
5-45
Example 5-23 Applying constraints to specific ranges in an array
class D
{
rand integer arr[*] dynamic_size 30;
constraint cc {
arr.size() == 30;
foreach (arr, index) {
(index < 10 ) =>
{ arr[index] > 0;
arr[index] < 10;}
(index > 9 && index < 20 ) =>
{arr[index]> 20; arr[index] < 30;}
(index > 19 && index < 30) =>
{arr[index] > 30; arr[index] < 40;}
}
}
class E
{
constraint size_cons
{
x.size() == 10;
y.size() == 10;
Randomization in Vera
5-46
Example 5-25 Nested foreach
class MyClass {
rand integer a[$];
constraint c0{
a.size() >= 10;
a.size() != 15;
a.size() <= 20;
foreach(a , i){
a[i] in {0:1000};
foreach(a , j){
(i != j ) => a[i] != a[j];
}
}
}
}
program ConstraintTest
{
MyClass c0 = new();
void = c0.randomize();
foreach(c0.a, index)
{
printf("a[%0d]: %0d\n",index, c0.a[index]);
}
}
In the nested foreach example the nested foreach loops are used to
constrain elements of an integer array such that all elements of the
array are unique. A further constraint is applied limiting the values of
each element between 0 and 1000.
Example results:
a[0]: 833
a[1]: 425
a[2]: 788
a[3]: 336
a[4]: 304
a[5]: 352
a[6]: 509
a[7]: 434
a[8]: 779
a[9]: 339
Randomization in Vera
5-47
Note on elaboration guards inside foreach loops
Constraints residing within the scope of a foreach block can
optionally be guarded using a top level implication (=>) operator. If
such a guard is specified for a “foreach” constraint and if that guard
comprises of only state variables or random variables whose rand
mode is “OFF,” then the solver will evaluate the guard before any
error checking is performed. If such a guard evaluates to "FALSE,"
then the solver will not generate a verification error for the following
conditions.
class problem{
rand integer buf[5];
The solver will generate the following error for this example
Randomization in Vera
5-48
READY in function problem.randomize (bounds.vr, line 12, cycle 0)
class problem{
rand integer buf[5];
program no_run_time_error{
problem p = new;
void = p.randomize();
}
Syntax
array_name
is the name of the array or SmartQ.
Randomization in Vera
5-49
aggregate_operator
is any one of the following: sum, product, logical_and, logical_or,
bit_and, bit_or, bit_xor, bit_xnor, contains. Detailed descriptions
are in the next section.
loop_variable
is the variable used to loop through the array or SmartQ.
loop_variable_list
is a list of loop variables. A loop_variable_list is only used with
multi-dimensional arrays. The syntax for a loop_variable_list is:
* | loop_variable, * | loop_variable...
asterisk *
is the place holder for an index of one of the dimensions. The
actual index can be specified in the loop_expression.
loop_variable_list
- cannot contain only the star, *, which is a placeholder
- the number of loop_variables and stars together must match
the number of dimensions in the multi-dimensional array.
- loop_variables and stars can occur in any order:
For example:
loop_var1, *, *, loop_var2 // four dimensional array
or
*, *, loop_var1, loop_var2
loop_expression
any valid OpenVera expression.
Randomization in Vera
5-50
The array aggregate expression is a valid part of a constraint
expression and can be used any place that a variable can be used,
with the exception of solve-before constraints.
Example 5-26
x+arr.sum() == 10;
contains operator
The array aggregate operator, contains has the following syntax:
array_name.contains(contains_expression) [with
loop_variable|loop_variable_list: (loop_expression)]
array_name
is the name of the array or SmartQ.
contains_expression
is any valid OpenVera expression.
aggregate_operator
is any one of the following: sum, product, logical_and, logical_or,
bit_and, bit_or, bit_xor, bit_xnor, contains. Detailed descriptions
are in the next section.
loop_variable
is the variable used to loop through the array or SmartQ.
loop_variable_list
is a list of loop variables. A loop_variable_list is only used with
multi-dimensional arrays. The syntax for a loop_variable_list is:
* | loop_variable, * | loop_variable...
asterisk *
Randomization in Vera
5-51
is the place holder for an index of one of the dimensions. The
actual index can be specified in the loop_expression.
loop_variable_list
- cannot contain only the asterisk, *, which is a placeholder
- the number of loop_variables and asterisks together must
match the number of dimensions in the multi-dimensional
array.
- loop_variables and asterisks can occur in any order:
For example:
loop_var1, *, *, loop_var2 // four dimensional array
or
*, *, loop_var1, loop_var2
loop_expression
any valid OpenVera expression.
The contains expression is a valid part of a constraint expression and
can be used any place that a variable can be used, with the
exception of solve-before constraints.
Example 5-27
arr.contains(x+y) || (p < q);
Randomization in Vera
5-52
If, for example, operator is sum, and the size of the array or SmartQ
is three, then the generated expression is:
For example:
Randomization in Vera
5-53
List of Aggregate Operators
Table 5-1
Operator Description
sum performs addition (see Table 4-1)
product performs multiplication (see Table 4-1)
logical_and performs logical AND operation (see Table 4-1)
logical_or performs logical OR operation (see Table 4-1)
bitwise_and performs bitwise AND operation (see Table 4-1)
bitwise_or performs bitwise OR operation (see Table 4-1)
bitwise_xor performs bitwise exclusive OR operation (see Table 4-1)
bitwise_xnor performs bitwise exclusive NOR operation (see Table 4-1)
contains creates a set membership (see page 5-51)
Example 5-28
class C {
rand integer size;
rand integer arr[*] dynamic_size size;
constraint cc {
size == 3;
arr.sum() < 100;
}
}
Example 5-29
class C {
rand integer size;
rand integer arr[*] dynamic_size size;
constraint cc {
size == 3;
arr.sum() with i: (arr[i]+i) < 100;
}
}
Randomization in Vera
5-54
In the above example, the constraint expression generated is:
x in { arr[0],arr[1],arr[2]};
Randomization in Vera
5-55
Example 5-33 Multi-dimensional array
class C
{
rand bit[15:0] x[3][3][3];
constraint aggr
{
x.contains(253) with i,j,*: (x[j][i][0]);
}
}
Note:
When "*" is specified as a placeholder for a particular dimension
in the context of array aggregates/containment, that particular
dimension is skipped for elaboration.
Notes
1. Empty array - It is illegal to specify/constrain the size of the array,
over which an aggregate operator is specified, to value "0". The
runtime will generate a solver error for the same.
2. Array types - The array aggregate operators and the foreach loop
support the fixed size array, dynamic array, associative array, and
SmartQ types of arrays in every context.
Note on elaboration guards inside array aggreagates/
containment operators
Aggregates/Containment operators are applied over the expressions
that are optionally specified using associated “with” construct.
Furthermore, such expressions can optionally be guarded by using
a ternary operator. If such a ternary operator is specified and the
predicate expression of that ternary comprises of only state variables
or random variables whose rand mode is “OFF”, then the solver will
evaluate the predicate before any error checking is performed. The
Randomization in Vera
5-56
solver will choose expression specified in the true (false) branch, if
the predicate evaluates to true (false) and apply specified aggregate/
containment operator over the same. For the expression that was not
chosen, the solver will not generate any verification error for the
following conditions.
Example 5-34
class problem
{
rand integer buf[5];
program run_time_error
{
problem p = new;
void = p.randomize();
}
The solver will generate the following error for this example.
Randomization in Vera
5-57
Consider a minor variation of the same example, where the
aggregate expression is guarded using an appropriate ternary
operator.
Example 5-35
class problem
{
rand integer buf[5];
constraint guarded /* When i < 4, buf[i+1]are valid array
indices */
{
foreach(buf,i)
{
buf.sum() with i: ( i<4 ? buf[i+1]:0) == 10;
}
}
}
program no_run_time_error
{
problem p = new;
void = p.randomize();
}
Default Constraints
Default constraints can be specified by placing the keyword “default”
ahead of a constraint block definition.
Randomization in Vera
5-58
Example 5-36 illustrates the specification of default constraints.
Randomization in Vera
5-59
Overriding default constraints. The default variables of a default
constraint are defined as those variables that are "rand" and are
"rand mode ON" and part of the default constraint. Default
constraints will be applied when they are not overridden by any
non-default constraints and contain at least one default variable.
Default constraints that do not contain any default variables are
ignored.
• The constraint mode for the constraint block that contains the
non-default constraint is ON, or is inside a randomize-with
constraint block.
• The non-default constraint contains at least one default variable
of the default constraint.
• If the non-default constraint expression is guarded and the guard
is a state expression, the guard must evaluate to true. If the guard
contains a default variable, then the constraint expression
including the guard is treated as an unguarded constraint
expression.
• The non-default constraint should not be an ordering constraint.
A default constraint does not override other default constraints under
any condition. Thus, if all constraint blocks are declared as default,
then none of them will be overridden.
Randomization in Vera
5-60
Example 5-37
class C {
rand bit[3:0] x;
default constraint c1 {x == 0;}
}
class D extends C {
constraint d1 {x > 5;}
}
program P {
D d = new();
void = d.randomize();
void = d.constraint_mode(OFF, "d1");
void = d.randomize();
}
Example 5-38
class C {
rand bit[3:0] x;
default constraint c1 {x >= 3; x <= 5;}
}
class D {
C c;
bit y;
constraint d1 {y => c.x > 5;}
}
program P {
D d = new();
d.c = new();
d.y = 1;
void = d.randomize();
d.y = 0;
void = d.randomize();
}
Randomization in Vera
5-61
In Example 5-38, the default constraint in block c1 is overriden by the
non-default constraint in block d1. The first call to randomize will pick
a value between 6 and 15 for x, since the non-default constraint is
applicable, given that the guard evaluates to TRUE. The default
constraint is ignored. The guard for the non-default constraint
evaluates to FALSE in the second call, and a value of between 3 and
5 will be picked for x in the next call to randomize. In this randomize()
call, the default constraint is applied.
Example 5-39
class A
{
rand bit[3:0] x;
rand bit[3:0] y;
default constraint T
{
x == 10 ; y == 10;
}
constraint E
{
y == 0;
}
task post_randomize()
{
printf("x = %0d y = %0d
}
}
program test
{
integer ret;
A a = new;
ret = a.randomize();
}
x = 10 y = 0
EXPLANATION
x = 10 since only the second constraint in the default constraint
block is overridden.
Randomization in Vera
5-62
Example 5-40
#include "vera_defines.vrh"
class A
{
rand bit[3:0] x;
rand bit[3:0] y;
rand bit g;
default constraint T
{
x + y == 10 ;
}
constraint E
{
g => y == 1;
}
task post_randomize()
{
printf("x = %0d y = %0d g = %0d
}
}
program test
{
integer ret;
A a = new;
printf("First call to randomize, rand mode of g is ON
ret = a.randomize();
printf("Second call to randomize, rand mode of g is OFF and
the guard g evaluates to FALSE
ret = a.rand_mode(OFF , "g");
a.g = 0;
ret = a.randomize();
printf("Third call to randomize, rand mode of g is OFF and the
guard g evaluates to TRUE);
a.g = 1;
ret = a.randomize();
printf("Fourth call to randomize, constraint mode of
constraint block E is OFF
ret = a.constraint_mode(OFF, "E");
ret = a.rand_mode(OFF, "g");
ret = a.randomize();
}
Randomization in Vera
5-63
x = 9 y = 1 g = 0
Third call to randomize, rand mode of g is OFF and the guard g evaluates
to TRUE
x = 3 y = 1 g = 1
Fourth call to randomize, constraint mode of constraint block E is OFF
x = 1 y = 9 g = 1
In the first call to randomize, the guard has a rand variable in the
non-default constraint.
Example 5-41
#include "vera_defines.vrh"
class A
{
rand bit[3:0] x;
rand bit[3:0] y;
default constraint T
{
x + y == 10 ;
}
task post_randomize()
{
printf("x = %0d y = %0d
}
}
program test
{
integer ret;
A a = new;
Randomization in Vera
5-64
printf("First call to randomize, rand mode of x and y are ON
ret = a.randomize();
printf("Second call to randomize, rand mode of x and y are OFF
ret = a.rand_mode(OFF , "x");
ret = a.rand_mode(OFF , "y");
a.x = 0; a.y = 0;
ret = a.randomize();
printf("Return status of randomize is %0d
}
In the second call to randomize, the rand mode of x and y are turned
OFF and both are set to 0.
Randomize Methods
Variables in an object are randomized using the randomize() class
method. Every class has a built-in randomize() virtual method.
Syntax
Randomization in Vera
5-65
The randomize() method returns OK if it successfully sets all the
random variables and objects to valid values, otherwise it returns
FAIL.
Example 5-42
class SimpleSum
{
rand bit[7:0] x, y, z;
constraint c {z == x + y;}
}
SimpleSum p = new;
integer success = p.randomize();
if (success == OK ) ...
Syntax
Randomization in Vera
5-66
class_object_name
is the name of the instantiated object.
constraint_block
is an anonymous constraint block. The constraint_block
contains the additional inline constraints to be applied along with
the object constraints declared in the class.
Example 5-43
class SimpleSum{
rand bit[7:0] x, y, z;
constraint c {z == x + y;}
}
Randomization in Vera
5-67
For instance, see the scoping example below, where the randomize()
with class is “Foo.”
Example 5-44
class Foo
{
rand integer x;
}
class Bar
{
integer x;
integer y;
Randomization in Vera
5-68
Built-in definition for pre_randomize():
task pre_randomize(){
if (super) super.pre_randomize();
/* Optional programming before randomization goes here. */
}
task post_randomize(){
if (super) super.post_randomize();
/* Optional programming after randomization goes here. */
}
NOTES:
Randomization in Vera
5-69
• Random variables declared as static are shared by all instances
of the class in which they are declared. Each time the
randomize() method is called, the variable is changed in every
class instance.
• If randomize() fails, the constraints are infeasible and the random
variables retain their previous values. In this event, the
post_randomize() method is not called.
• The randomize() method is implemented using object random
stability. To seed an object, use the srandom() system call,
specifying the object in the second argument.
• The randomize() method may not be overloaded.
• The built-in pre_randomize() and post_randomize() tasks should
not perform blocking operations because their automatic
traversal temporarily locks objects from access. If these routines
block and another call to randomize attempts to visit the locked
object, undefined behavior will occur.
rand_mode()
Syntax
Randomization in Vera
5-70
object_name
is the name of the object in which the random variables are
defined.
Predefined Macros:
ON, OFF, and REPORT specify the action
Macro Action
ON Sets the specified variables to active so that they
are randomized on subsequent calls to the
randomize() method.
OFF Sets the specified variables to inactive so that
they are not randomized on subsequent calls to the
randomize() method.
REPORT Returns the current ON/OFF value for the specified
variable.
variable_name
is a string with the name of the variable to be made active or
inactive. The variable_name can be the name of any variable
in the class hierarchy. If no variable_name is specified, the action
is applied to all variables within the specified object.
index
is an optional array index. If the variable is an array, omitting the
index results in all the elements of the array being affected by the
call. An index value of -1 is treated the same as index omission.
The rand_mode() method returns the new mode value (either OFF,
which is 0, or ON, which is 1) if the change is successful. If the
specified variable does not exist within the class hierarchy, the
method returns a -1. If the specified variable exists but is not
declared as rand or randc, the function returns a -1. If the variable is
an array, the array name and index must be specified for a REPORT.
Randomization in Vera
5-71
If the variable is an object, only the mode of the variable is changed.
If the variable is an array, then the mode of each array element is
changed.
Example 5-45
class Packet
{
rand integer source_value, dest_value;
... other declarations
}
This example first disables all the random variables in packet, and
then enables the source_value variable.
Disabling Constraints
OpenVera provides the predefined constraint_mode() method to
control whether a constraint is active or inactive. All constraints are
initially active.
Syntax
object_name
is the name of the object in which the constraint block is defined.
Randomization in Vera
5-72
Predefined Macros:
ON, OFF, and REPORT specify the action.
Macro Action
ON Sets the specified constraint block to
active so that it is enforced on
subsequent calls to the randomize()
method.
OFF Sets the specified constraint block to
inactive so that it is not enforced on
subsequent calls to the randomize()
method.
REPORT Returns the current ON/OFF value for
the specified variable.
constraint_name
is the name of the constraint block to be made active or inactive.
The constraint name can be the name of any constraint block in
the class hierarchy. If no constraint name is specified, the switch
is applied to all constraints within the specified object.
The constraint_mode() method returns the value of switch (either
OFF or ON) if the change is successful. If the specified constraint
block does not exist within the class hierarchy, the method returns a
-1. The constraint name must be specified for a REPORT.
Example 5-46
class Packet{
rand integer source_value;
constraint filter1{
source_value > 2 * m;
}
}
Randomization in Vera
5-73
This example first makes constraint filter1 inactive (OFF) and returns
OFF to the variable ret. Then it makes constraint filter1 active (ON)
and returns ON to the variable ret.
Randomization in Vera
5-74
Debugging Constraints
Vera supports a debug mode that displays diagnostics when the
randomize() method is called. To enable this mode, use the runtime
option vera_enable_solver_trace.
Syntax
+vera_enable_solver_trace=[value]
Value Description
0 disables tracing
1 enables tracing
2 enables more verbose message in trace
vera_enable_solver_trace=[value]
There are two differences between these options. First, the “enable
solver trace on failure” mode prints trace information only when the
solver fails to compute a solution, usually due to inconsistent
constraints. Second, when the value of the option is 2, the analysis
narrows down to the smallest set of inconsistent constraints, thus
aiding the debugging process.
Randomization in Vera
5-75
For example, if the constraints are:
x == 0;
x > y;
y < z+w;
x == 5;
y != 6;
x == 0;
x == 5;
Syntax
+vera_enable_solver_trace_on_failure =[value]
Value Description
0 disables tracing
1 enables tracing
2 enables more verbose message in trace
vera_enable_solver_trace_on_failure=[value]
Randomization in Vera
5-76
Solver Choice
Vera incorporates two different solvers, each of which supports the
entire Vera constraint language. You may select the solver you want
using the runtime option vera_solver_mode, which takes the values
1 or 2. The default value is 2.
Example 5-47
simv +vera_solver_mode=2 ...
Internal Caching
Vera maintains an internal disk cache for randomization. This cache
improves performance and reduces memory use by re-using
randomization problem data from previous runs. By default, Vera
creates a cache called “.__solver_cache__” in the current working
directory. You may specify an alternate cache location by specifying
the directory location via the runtime option vera_cache_dir. For
example:
Randomization in Vera
5-77
Example 5-48
simv +vera_cache_dir=/u/myself/tmp_cache ...
The contents of the Vera cache can be removed at any time, except
when Vera is running. There is no internal caching when
+vera_solver_mode=2 is the mode in which the run is done.
Randomization in Vera
5-78
Example 5-49
rand integer x;
integer pkt_type_one = 0;
integer pkt_type_two = 1;
constraint C
{
x dist {pkt_type_one :/ 1, pkt_type_two :/2};
}
Randomization in Vera
5-79
gave the operator higher precedence than normal. Now all
constraint expressions, have Verilog precedence and
associativity.
Example: a < b < c previously grouped as a < (b < c). It now
groups as (a < b) < c. Similarly, a < b ? c : d was previously
grouped as a < (b ? c : d) and will now be grouped as (a < b) ?
c:d
Implication (=>) is a special case: it is right associative and
high-precedence.
- Expressions can be satisfied using wrap-around values. For
example, a + b == 2 where a and b are four bits wide, can be
satisfied by a = 9 and b = 9. That is, 9 + 9 = 18 (1 0010).
Dropping the fifth bit leaves 2 (0010).
- Relational operators are evaluated by extending the smaller
operand to match the precision of the larger operand. Thus if a
is two bits wide, and b is four bits wide, then the values a =
2'b11 and b = 4'b1100, satisfy the constraint a < b.
• The solver now chooses values with a uniform distribution.
Previously, expressions such as x < y favored larger values on the
right-hand-side of the operator. Values are now evenly distributed
between x and y. In general, this means that the random values
generated by previous Vera versions will not match the values
generated in Vera versions 6.0 and later.
• Only 2-state logic is supported: X and Z logic values and their
associated operators are not allowed. Accordingly, the ===, !==,
=?=, and !?= operators are not supported because they operate
on 4-state logic values.
• The randomize() method may not be overloaded.
Randomization in Vera
5-80
• The pre_randomize() and post_randomize() methods of object
members are now called concurrently with randomize().
• The boundary() method is not supported in Vera 6.0 and later.
Likewise, pre_boundary() and post_boundary() are not
supported. The boundary methods will be revised in a later
version. (See Pre-6.0 Boundary on page 5-82 for documentation
of these methods.)
You can revert to the previous style of constraint expressions and
solver semantics by specifying the –random_compat option to the
Vera compiler. This option must be specified for all source files:
constraint c0
{
// supported on Vera 5.1 or later
if (payload_format == CONTROL) dst ==
48'h0180C2000001;
}
or:
Randomization in Vera
5-81
constraint c0
{
// supported on Vera 6.0 or later
(payload_format == CONTROL) => dst ==
48'h0180C2000001
}
Pre-6.0 Boundary
Vera’s boundary capabilities are used to generate values that match
the upper and lower limits of a random variable’s valid value range.
This is particularly useful because many design flaws occur at
boundaries. Boundaries are generated when the system function
boundary() is called.
object_name
is the name of the object on which the boundary() call is being
made.
Randomization in Vera
5-82
Predefined Macros:
- FIRST sets the affected random values to their first boundary
condition.
- NEXT cycles through each subsequent boundary condition.
Boundaries for random variables are determined by the constraints
on a random variable. For instance, examine this constraint block:
class foo
{
rand integer a, b, c;
constraint c1
{
a>=10; a<=20;
b>=0; b<=100;
c in {1:15, 32:63};
}
}
For this constraint block, a has the boundaries 10 and 20, b has the
boundaries 0 and 100, and c has the boundaries 1, 15, 32, and 63.
This results in 16 different boundary combinations that would be
generated with the boundary() method.
The boundary() method treats rand and randc variables the same
way. Note that you can also use random variables within the
constraints so that boundaries are dependent on random values.
However, if the values of the right-hand side of a constraint change
while the boundary() method is being invoked, the boundaries are
determined by the values at the time of the function call. Subsequent
changes to the boundaries do not affect the current call, but they will
affect future calls.
Randomization in Vera
5-83
argument is set to NEXT, the next set of boundaries in the sequence
is used. The sequence of boundaries is influenced by a number of
factors, including the order of variable declaration and the order they
are named in the constraints.
Syntax
object_name
is the name of the object on which the pre_boundary() call is
being made.
Randomization in Vera
5-84
Predefined Macros:
- FIRST sets the affected random values to their first boundary
condition.
- NEXT, cycles through each subsequent boundary condition.
Syntax
object_name
is the name of the object on which the post_boundary() call is
being made.
Predefined Macros:
- FIRST sets the affected random values to their first boundary
condition.
- NEXT cycles through each subsequent boundary condition.
This is an example of the boundary() system function:
program b
{
integer success;
my_object obj = new;
success = obj.boundary(FIRST);
while (success==OK) success =
obj.boundary(NEXT);
if (success!=OK_LAST) printf(“Boundary problem (%0d)\n",
success)
}
This example defines the object obj. The random variables within
obj are set to their initial boundaries with the first boundary() call.
The while loop sets them to their other boundaries.
Randomization in Vera
5-85
Random Sequence Generation
Vera’s sequence generation allows you to specify the syntax of valid
sequences using BNF-like notation. Random sequences are ideal
for generating streams of instructions for which it is easier to specify
the syntax of valid streams than the constraints on specific values.
VSG Overview
The syntax for programming languages is often expressed in Backus
Naur Form (BNF) or some derivative thereof. Parser generators use
this BNF to define the language to be parsed. However, it is possible
to reverse the process. Instead of using the BNF to check that
existing code fits the correct syntax, the BNF can be used to
assemble code fragments into syntactically correct code. The result
is the generation of pseudo-random sequences of text, ranging from
sequences of characters to syntactically and semantically correct
assembly language programs.
randseq (production_name)
{
production_definition1;
production_definition2;
...
production_definitionN;
}
Randomization in Vera
5-86
Any VSG code block is comprised of production definitions. Vera also
provides weights, production controls, and production system
functions to enhance production usage. Each of these VSG
components is discussed in detail in subsequent sections.
Production Declaration
A language is defined in BNF by a set of production definitions. The
syntax to define a production is:
production_name : production_list;
production_name
is the reference name of the production definition.
production_list
is made up of one or more production_items.
One or more production items makes up a production list. Production
items are made of terminals and non-terminals.
Randomization in Vera
5-87
Multiple production items specified in a production list can be
separated by white space or by the or operator (|). Production items
separated by white space indicate that the items are streamed
together in sequence. Production items separated by the | operator
force a random choice, which is made every time the production is
called.
Randomization in Vera
5-88
initialized_data: { /* Vera code */ }
uninitialized_data: { /* Vera code */}
.text
my_code output
.data
initialized_data output OR uninitialized_data output
Production Controls
Vera provides several mechanisms that can be used to control
productions: weights for randomization, if-else statements, case
statements, and repeat loops.
Randomization in Vera
5-89
• repeat Loops
• break Statement
• continue Statement
Syntax
weight
must be in the form of &(expression) where the expression can
be any valid OpenVera expression that returns a non-negative
integer. Function calls can be made within the expression, but the
expression must return a numeric value, or else a simulation
error is generated.
Assigning weights to a production item affects the probability that it
is selected when the randseq block is called. Weight should only be
assigned when a selection is forced with the | operator. The weight
for each production item is evaluated when its production definition
is executed. This allows you to change the weights dynamically
throughout a sequence of calls to the same production.
Randomization in Vera
5-90
This example defines the production integer_instruction in
terms of the weighted production items add_instruction and
sub_instruction. If i is 1 when the definition is executed, there is
a 60% (3/5) chance that add_instruction is selected, and a 40%
(2/5) chance that sub_instruction is selected.
if-else Statements
A production can be conditionally referenced using an if-else
statement.
condition
can be any valid Vera expression
If the conditional evaluates to true, the first production item is
selected. If it evaluates to false, the second production item is
selected. The else statement can be omitted. If it is omitted, a false
evaluation ignores the entire if statement.
Randomization in Vera
5-91
case Statements
A general selection mechanism is provided by the case statement.
The syntax to declare a case statement within a production definition
is:
production_name : <case(primary_expression)
case1_expression : production_name
case2_expression : production_name
...
caseN_expression : production_name
[default : production_name > ;]
primary_expression
is evaluated. The value of the primary_expression is
successively checked against each case_expression. When
an exact match is found, the production corresponding to the
matching case is executed, and control is passed to the
production definition whose name is in the case item with the
matching case expression. If other matches exist, they are not
executed. If no case item value matches the evaluated primary
expression and there is no default case, nothing happens.
case_expression
can be any valid Vera expression or comma-separated list of
expressions. Expressions separated by commas allow multiple
expressions to share the same statement block
A case statement must have at least one case item aside from the
default case, which is optional. The default case must be the last item
in a case statement.
assembly_block : <case(i*3)
0 : seq_block
3 : loop_block
default : any_block> ;
Randomization in Vera
5-92
This example defines the production assembly_block with a case
statement. The primary expression i*3 is evaluated, and a check is
made against the case expressions. The corresponding production
item is executed.
repeat Loops
The repeat loop is used to loop over a production a specified number
of times.
expression
can be any valid Vera expression that evaluates to a
non-negative integer, including functions that return a numeric
value.
The expression is evaluated when the production definition is
executed. The value specifies how many times the corresponding
production item is executed.
Randomization in Vera
5-93
break Statement
The break statement is used to terminate a randseq block.
Syntax
break;
SETUP_COUNTER:
{
integer regis = regFile.getRegister();
integer value = ADDI;
nestingLevel++;
if (nestingLevel == MAX_NESTING) break;
...
} ;
continue Statement
The continue statement is used to interrupt the execution of the
current production. The execution continues on the next item in the
production from which the call is made.
Syntax
continue;
Randomization in Vera
5-94
The continue statement passes control to the next production item in
the production from which the call is made without executing any
code in between. This is an example of a production definition using
a continue statement:
SETUP_COUNTER:
{
integer regis = regFile.getRegister();
integer value = ADDI;
nestingLevel++;
if (nestingLevel == MAX_NESTING) continue;
...
} ;
Value Declaration
To associate a data type and value with a given non-terminal
production, you must declare the production using the prod
declaration.
Randomization in Vera
5-95
data_type
can be integer, bit, string, enum, or any object.
production_name
is the name of the production that is passing the value.
Multiple productions can be declared in a single declaration
statement, similar to variables. Vera performs strict type checking for
passing values.
prodset()
The prodset() system task is used to set a value associated with a
non-terminal.
Syntax
value
is the value you want to pass. It must be of the same type as the
prod declaration. It can be an integer, bit, string, enumerated
type, or object.
Randomization in Vera
5-96
production_name
optionally specifies the name of the non-terminal production the
value is being assigned to. If it is omitted, the production that the
task is called in is assumed to
be the production to the left of the colon (:).
occurrence_number
optionally specifies which occurrence of the same production
name receives the value. If the same production is referred to
multiple times in the same definition, the first is 1, and the others
are numbered sequentially. If it is omitted, it is assumed to be 1.
The prodset() system task assigns the specified value to the
specified occurrence of the non-terminal production. This value can
be retrieved using the prodget() system function.
prodget()
The prodget() system function is used to retrieve values assigned to
non-terminal productions.
Syntax
production_name
specifies the name of the non-terminal production the value has
been assigned to. If it is omitted, the production that the task is
called in is assumed to be the
production to the left of the colon (:).
Randomization in Vera
5-97
occurrence_number
optionally specifies which occurrence of the same production
name receives the value. If the same production is referred to
multiple times in the same
definition, the first is 1, and the others are numbered sequentially.
If it is omitted, it is assumed to be 1.
The prodget() system function returns the value assigned to the
specified non-terminal production.
You cannot set a value for a production that has not yet been
executed. For example:
Randomization in Vera
5-98
This is an example of how to pass values within a randseq block:
program GenList
{
list vsgList;
randseq()
{
prod list_node ELEMENT;
This example defines the list object vsgList. When the randseq
block is entered, the TOP production is executed. First, a list object is
instantiated. Then the LIST production is executed. The LIST
production consists of a weighted LIST ELEMENT production and an
ELEMENT production. If the LIST ELEMENT production is selected,
the LIST production is called recursively and the ELEMENT
production is postponed. The original selection between ELEMENT
and LIST ELEMENT is then made again. The cycle continues until
the ELEMENT production is selected. At that time, lnode is assigned
Randomization in Vera
5-99
a value via the prodset call in the ELEMENT production. That value is
inserted into vsgList via the insert call in the code block. Finally,
the previously unexecuted ELEMENT calls that had been postponed
when LIST ELEMENT was selected are executed. Control is then
passed back to the TOP production, which executes the END
production.
Randomization in Vera
5-100
6
Data Packing and Unpacking 6
Transactors or Bus-Functional Models transfer data to or from the
design under test via a bus. For example, in a networking testbench,
a transactor on the transmit side will take packets (which are higher
level data structures) generated from the packet generator and send
them to the design under test in the form of a serial bit stream. In the
same way, a transactor on the receive side will take the serial bit
stream and transform it into the higher level data structure
corresponding to the packet.
Data packing consists of packing data fields into a serial bit stream
and then unpacking the bit stream to re-form a data structure. Data
packing is particularly useful for sending packets over serial
communication streams and then converting them back to a packet
structure.
Example 6-1
packed integer n;
Example 6-2
packed {
integer n;
reg[15:0] b;
}
The data types you can pack and the number of bits for each type
that are packed are as follows:
Packing Attributes
The packing method is controlled by one or more attributes
immediately following the packed keyword. These attributes are:
little_endian
The least significant segment, or piece equal in size to the output
array, is written first. If the segment does not fill the entire word in
the output array, it is aligned towards the LSB, or right side of the
word. The values of the right and index arguments are updated
to reflect the first bit following the last bit written. The value of the
left argument is reset to 0 when the write crosses a word
boundary.
Example 6-3
packed bit_reverse {
integer i;
bit_normal string str;
unpacked {
integer k;
}
integer n;
}
Example 6-4
packed [attribute] data_type array_name[*]
dynamic_size size;
Example 6-5
packed [attribute] data_type array_name[*]
assoc_size size;
Packing Methods
The input consists of a class object containing variables of type bit,
integer, enum and string. The output is to an associative array
organized as ‘n’ words of ‘m’ bits. The arguments specify the object
to be packed, the index into the array and two values, left and right,
which specify how many bits in the output word pointed to by index
have been used, starting from the left and right of the word
respectively.
Data is written one segment at a time with the ordering and word
alignment specified by the little_endian or big_endian attribute. The
output array is filled starting from the specified index and leftmost
unused bit for little_endian, or rightmost unused bit for big_endian. If
all the bits in the current word are filled, left is zeroed for the
big_endian case, or right for the little_endian case. At the end of the
pack operation, index points to the last word written to. For
big_endian data, the value of left is updated to specify how many
Syntax
array
specifies the array into which data is to be packed. The array is
an associative array of bit width N.
index
specifies the array index at which to start packing.
left
specify the number of bits on the left to leave unchanged in
array[index]. Normally, you initialize them to 0 before calling
pack().
right
specify the number of bits on the right to leave unchanged in
array[index]. Normally, you initialize them to 0 before calling
pack().
The pack() method returns the number of bits packed. It also updates
index, left, and right so that they can be used as arguments to
subsequent pack() calls when packing multiple objects into a single
stream.
Unpacking Methods
The unpacking methods are analogous to the packing methods.
Syntax
The parameters have the same definitions as for pack(). The array
parameter should be set to the array into which data was packed.
The index, left, and right variables are normally initialized to 0. They
are then updated with each call to unpack(). This allows you to
unpack multiple objects from a single array.
You should generally unpack multiple objects from one array in the
same order in which they were packed. For example:
Example 6-8
virtual function integer MyClass::pack(reg[N-1:0] array[],
var integer offset, var integer left, var integer right,
integer flag = 1)
{
integer nbits = 0;
if (flag == 1)
this.pre_pack();
// code to pack the member variables of "this" that are marked packed
// -- in order, including nested objects -- adding to nbits
if (flag == 1)
this.post_pack();
pack = nbits;
}
task MyClass::pre_pack() {
super.pre_pack();
}
task MyClass::post_pack() {
super.post_pack();
}
Example 6-9
#include <vera_defines.vrh>
class Serial_Data_Type {
static integer total_inst_count = 0;
packed {
rand reg [19:0] bit_data;
string comment;
}
task new() {
integer status;
status = this.randomize();
if ( !status )
error ("Randomize failed!\n");
comment = psprintf("comment_%0d", total_inst_count) ;
printf("inst = %-9d , data = %-25b comment = %0s\n",
total_inst_count, bit_data, comment );
total_inst_count++ ;
} // new
}
Example 6-10
#include<vera_defines.vrh>
class Packet{
packed rand reg [47:0] da;
packed rand reg [47:0] sa;
packed rand reg [15:0] type;
packed rand reg [7:0] payload[5];
task print(){
integer i;
printf("Packet da is %h
printf("Packet sa is %h
printf("Packet type is %h
for(i=0;i<5;i++){
printf("Packet byte %0d is %h
}
}
}
packet_to_be_sent.print();
printf("____________________________________________________");
printf("The above packet when driven across the Bus Functional\n");
printf("Model appears as the following stream of bytes\n");
for(i=0;i<num_packet_bits/8;i++){
printf("Packet byte %0d is %h\n",i,packet_bytes[i]);
}
//Now that packet has been packed into bits, it can easily be driven
//across a bus functional model //...............
printf("___________________________________________________\n");
printf("At the receiving Bus Functional Model, the above
stream\n");
printf("of bytes is assembled into the following higher level
packet\n");
offset=0;left=0;right=0;
packet_received=new();
num_received_packet_bits =
packet_received.unpack(packet_bytes,offset,left,right);
printf("num_received_packet_bits is %d\n",
num_received_packet_bits);
packet_received.print();
/*__________________________________
//Unpack
// unpack packet
length = received_packet.unpack(cap_packet,o,l,r);
packet_ext1 received_packet;
int o=0;
int l=0;
int r=0;
int length;
// unpack packet
length = received_packet.unpack(cap_packet,o,l,r);
*/
Compilation errors: 0
++---------------------------------------------------------------------++
|| VERA System Verifier (TM) ||
|| Version: 6.0.11 () -- Thu Nov 6 14:01:23 2003 ||
|| Copyright (c) 1995-2002 by Synopsys, Inc. ||
|| All Rights Reserved ||
|| ||
|| For support, send email to vera-support@synopsys.com ||
|| ||
|| This program is proprietary and confidential information of ||
|| Synopsys Inc. and may be used and disclosed only as authorized in ||
|| a license agreement controlling such use and disclosure. ||
++---------------------------------------------------------------------++
The following packet has been generated
Packet da is a13c05e23536
Packet sa is 33e2be7fe77d
Packet type is 440b
Packet byte 0 is df
program main{
Instruction Instr;
integer num_instruction_bits;
reg [15:0] packed_instr[];
integer offset=0,left=0,right=0;
Instr = new();
void = Instr.randomize();
printf("__________________________________________________\n");
Instr.print();
num_instruction_bits =
Instr.pack(packed_instr,offset,left,right);
printf("_________________________________________________\n");
printf("We now pack the instruction, so it can be placed in
Instruction\n");
printf("Memory Packed Instruction is as %h\n");
printf("__________________________________________________\n");
Compilation errors: 0
++---------------------------------------------------------------------++
|| VERA System Verifier (TM) ||
|| Version: 6.0.11 () -- Thu Nov 6 14:32:45 2003 ||
|| Copyright (c) 1995-2002 by Synopsys, Inc. ||
|| All Rights Reserved ||
|| ||
|| For support, send email to vera-support@synopsys.com ||
|| ||
|| This program is proprietary and confidential information of ||
|| Synopsys Inc. and may be used and disclosed only as authorized in ||
|| a license agreement controlling such use and disclosure. ||
++---------------------------------------------------------------------++
• Coverage Overview
• Defining Coverage Models Using Coverage Groups
• Cumulative and Instance-based Coverage
• Measuring Coverage
• Coverage Attributes
• Persistent Storage of Coverage Data and Post-processing Tools
• Instance Names
• Predefined Coverage Group Tasks and Functions
• Coverage Feedback: query()
Functional Coverage
7-1
Coverage Overview
As chip designs grow more complex and testing environments
become increasingly sophisticated, emphasis has been placed on
testing the chip completely. With hundreds of possible states in a
system and thousands of possible transitions, the completeness of
tests must be a primary focus of any verification tool.
Functional Coverage
7-2
• Open-loop analysis monitors the bins during the simulation and
writes a report at the end summarizing the results.
• Closed-loop analysis monitors the bins during the simulation and
checks for areas of sparse coverage. This information is then
used to drive subsequent test generation to ensure satisfactory
coverage levels.
1. coverage_points
2. cross products
3. sampling event
Functional Coverage
7-3
• Optionally, cross products of subsets of the sampled coverage
points (cross coverage).
The coverage_group construct is similar to an OpenVera class in that
the definition is written once and is instantiated one or more times.The
construct can be defined as a top-level (file scope) construct (referred
to as standalone), or may be contained inside of a class. Once
defined, standalone coverage is instantiated with the new() system
call while embedded (contained) coverage groups are automatically
instantiated with the containing object.
class class_name
{
// class properties
// coverage
coverage_group definition_name .... (same as external).
// constraints
// methods
}
Functional Coverage
7-4
Example 7-1
interface ifc
{
input clk CLOCK;
input sig1 PSAMPLE #-1;
}
coverage_group CovGroup
{
sample_event = @ (posedge CLOCK);
sample var1, ifc.sig1;
sample s_exp(var1 + var2);
}
program covTest
{
integer var1, var2;
CovGroup cg = new();
}
Functional Coverage
7-5
The syntax for declaring a class with an embedded coverage_group
is:
class class_name {
...
coverage_group coverage_group_name{}
...
}
Example 7-2
class MyClass {
bit [3:0] m_x;
integer m_y;
bit m_z;
}
class MyClass {
bit [3:0] m_x;
integer m_y;
bit m_z;
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample m_x, m_y;
}
}
Data members m_x and m_y will be sampled upon every positive
edge of the system clock.
Functional Coverage
7-6
A coverage_group construct that is embedded in a class can be
instantiated in the body of the new task for the class.This eliminates
the need for creating separate coverage objects for each instance of
the class and binding them to the class data members that are to be
covered. You can use an embedded coverage_group to define the
coverage model for protected and private (local) data members as
well as public members of a class. This way you do not need to
jeopardize the data encapsulation of a class to define the coverage
model for it.
Example 7-3
class MyClass {
bit [3:0] m_x;
local bit m_z;
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample m_x
{
state s0(0:7) if (m_z > 0);
state s1(8:15);
}
}
coverage_group cov2
{
sample_event = wait_var(m_z);
sample m_z;
}
}
Functional Coverage
7-7
In coverage_group cov1, public class member variable m_x is
sampled at every positive edge of the system clock. State s0 defines
a named bin for values 0 to 7 of the sampled variable. Local class
member m_z controls when bin s0’s hit count is incremented. State
s0 is incremented only when the current value of m_z is non-zero.
Note that in this example the two coverage groups are sampled on
different events.
Explicit Instantiation
Explicit instantiation of an embedded coverage group is done by the
user, using the new assignment statement, and can only happen
within the body of the new task for the embedding class. Embedded
coverage groups which need to have arguments passed in must be
explicitly instantiated in the new task of the embedding class. The
Vera compiler issues an error if an embedded coverage group which
needs arguments is not explicitly instantiated.
Functional Coverage
7-8
coverage_group_name
is the name of the embedded coverage group.
arguments
passed to the coverage group.
Example 7-4 instantiates an embedded coverage group MyCov of
class MyClass. A passed-in argument is used for setting the
at_least attribute of the coverage group.
Example 7-4
class MyClass
{
bit [7:0] m_x;
coverage_group MyCov (integer param1)
{
sample_event = @(posedge CLOCK);
at_least = param1;
sample m_x;
}
program simple
{
MyClass obj = new(4);
@(posedge CLOCK);
// ...
}
Functional Coverage
7-9
The syntax for disabling an embedded coverage group is:
coverage_group_name = null;
coverage_group_name
This is the name of the embedded coverage group.
Note that disabling an embedded coverage group using the above
syntax can be done only within the body of the new task of the
enclosing class.The instantiation or disabling of an embedded
coverage group can be done inside nested blocks, like an
if-then-else construct, so different instances of the class may have
the embedded coverage groups as enabled or disabled. This is
demonstrated in Example 7-5:
Example 7-5
class A {
integer x;
coverage_group cov1 {
sample x;
sample_event = @(posedge CLOCK);
}
task new(integer flag)
{
x = 0;
// Coverage group can be instantiated
// inside a conditional block
if (flag) {
// Instantiation using new, cov1 will
// be instantiated.
cov1 = new;
} else {
// Instantiation using null, cov1 will
// not be active (not instantiated).
//must be inside the constructor, i.e.
// task new()
cov1 = null;
}
}
}
Functional Coverage
7-10
program test
{
A obj1;
A obj2;
// Embedded cov_grp cov1 will be active for
// this instance of A.
obj1 = new(1);
// Embedded cov_grp cov1 will not be active
// for this instance of A
obj2 = new(0);
...
}
Implicit Instantiation
Implicit instantiation of embedded coverage groups occurs under the
following conditions.
• There is no user defined new task for the class, or the embedded
coverage group is not initialized (disabled or instantiated) in the
user defined new task for the class.
• The embedded coverage group requires no arguments.
Implicit instantiation means that the Vera compiler automatically
instantiates the embedded coverage group as the first statement in
the new task for the enclosing class. Users should be careful when
availing of implicit instantiation as there may be some cases where
implicit instantiation may lead to run time errors. Example 7-6 is of an
embedded coverage_group that does not have any passed-in
parameters, yet requires explicit instantiation in the task "new" of the
embedding class:
Functional Coverage
7-11
Example 7-6
class Helper
{
event m_ev;
// ...
}
class MyClass
{
Helper m_obj;
integer m_a;
coverage_group Cov
{
sample m_a;
sample_event = sync(ALL, m_obj.m_ev);
}
task new()
{
m_obj = new;
/* Instantiate embedded coverage_group here, after
instantiating m_obj */
Cov = new;
}
}
Functional Coverage
7-12
Vera Scoping Rules in Coverage Groups
You can leverage Vera scoping rules for easy and simple definitions
of coverage models without the need for passing variables as
arguments to a coverage_group. You can specify coverage
information for any Vera variable (or interface signal) that is visible in
the scope that a coverage_group is defined in. This includes:
• Global variables
• Interface signals
• Static binds
• Global virtual ports
In addition, embedded coverage_groups can refer to:
Functional Coverage
7-13
Example 7-7
#include "MyInterface.vrh" // Interface ifc1
extern integer g1;
extern MemberClass { extern integer m_y; }
extern MyBaseClass { extern integer m_z; }
coverage_group cov1()
{
sample_event = @(posedge CLOCK);
sample m_x ; // Sample member of this class
sample g1; // Sample global variable
sample ifc1.sig; // Sample interface signal
sample m_z; // Base class member
sample m_obj.m_y; // Member of member object
sample exp1(m_x + g1); // expression
}
}
coverage_point
is either an sample_expression or a sample_variable.
sample_expression
is a Vera expression that needs to be sampled. The syntax for the
sample_expression is:
sample_name (expression)
Functional Coverage
7-14
sample_name
is a name associated with the expression.
expression
is an OpenVera expression.
sample_variable
is a Vera variable.
To define state or transition bins for a sampled coverage point, or to
specify the setting of a sample’s attributes, use the following syntax:
sample coverage_point
{
[state_bin_definitions]
[transition_bin_definitions]
[attribute_definitions]
}
coverage_point
is either a variable or an expression as defined above.
state_bin_definitions
You can associate named bins with ranges of values of a
sampled coverage point using the state, m_state, or bad_state
constructs. See Overview of User Defined Bins for Coverage
Points for more details.
transition_bin_definitions
You can associate named bins with value transitions of a
sampled coverage point using the trans, m_trans, or bad_trans
constructs. See Overview of User Defined Bins for Coverage
Points for more details.
Functional Coverage
7-15
attribute_definitions
You can use attributes for controlling various aspects of a sample.
The Coverage Attributes section details the attributes that can be
specified at the sample level, and their default values. You can
specify an attribute’s value as follows:
attribute_name = value_expression;
Functional Coverage
7-16
Example 7-8
extern integer x, y;
coverage_group Cov
{
sample sam2 (x * y);
sample sam1 (x + y)
{
state s1 (0: 50) if (sam2 > 30); // same as
//if (x*y > 30)
}
sample_event = @(posedge CLOCK);
}
You can either let Vera automatically create state bins for a coverage
point or explicitly define named state and/or transition bins for each
of the coverage points. Each named bin groups a set of values
(state) or a set of value transitions (trans) associated with a coverage
point.
Auto-Bin Creation
When you let Vera automatically create state bins for a coverage point
you do not need to specify states for that coverage point. In that case
you use the following shorthand syntax (see Defining Sampled
Coverage Points for full definition) for defining the coverage point:
Functional Coverage
7-17
Note that you can refer to multiple coverage points in a single sample
statement. In Example 7-9, Vera automatically creates state bins for
coverage points m_x and m_y.
Example 7-9
class MyClass
{
bit [0:7] m_x, m_y;
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample m_x, m_y;
}
}
By default, Vera creates automatic state bins for the first 64 distinct
sampled values of a coverage point. Each bin will have a name of the
form:
s_value
Note:
For enumerated types, auto_bin_max has no effect.
sample a {
auto_bin_max = 7;
}
Functional Coverage
7-18
or
or
...
sample a, b
{
auto_bin_max = 7;
}// affects both a and b
Functional Coverage
7-19
Example 7-10
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample m_x, m_y;
auto_bin_max = 2; // max of 2 auto-created bins
}
...
m_x = 12;
m_y = 23;
@(posedge CLOCK);
m_x = 21;
m_y = 23;
@(posedge CLOCK);
m_x = 13;
m_y = 24;
@(posedge CLOCK);
The Table 7-1 shows the automatically created bins (and their hit
counts) after the first “@(posedge CLOCK)”:
The Table 7-2 shows the automatically created bins (and their hit
counts) after the second “@(posedge CLOCK)”:
Functional Coverage
7-20
TheTable 7-3 shows the automatically created bins (and their hit
counts) after third (and final) “@(posedge CLOCK)”:
Functional Coverage
7-21
Example 7-11
enum cellType =
blue,
red,
green;
extern cellType sParam;
coverage_group covType
{
sample_event = wait_var(sParam);
sample sParam;
auto_bin_max = 2; // Does not affect the number
// auto-bins for sParam
}
Vera will automatically create three state bins even though the
auto_bin_max attribute has been set to 2.Example 7-11 is
shorthand for explicitly typing out the following coverage_group:
Example 7-12
coverage_group covType {
sample_event = wait_var(sParam);
sample sParam
{
state s_blue(blue); // sParam == blue
state s_red(red); // sParam == red
state s_green(green); // sParam == green
}
}
Functional Coverage
7-22
The syntax for defining explicit state and/or transition bins uses
ranges of values to define states and transitions. In Example 7-13 we
define two state bins and a transition bin for the sampled variable
port_number of coverage_group MyCov. We sample variable
port_number (assumed to be global) every time that it changes.
Example 7-13
coverage_group MyCov ()
{
sample_event = wait_var(port_number)async;
// Sample every time port_number changes
sample port_number
{
state s0(0:7);
state s1(8:15);
trans t1("s0"->"s1");
}
}
m_state ms(0:7);
Functional Coverage
7-23
Each of the automatically created bins is prefixed with the name
used in the m_state construct. In the example above, Vera creates
state bins ms_0, ms_1, ms_2, ms_3, ms_4, ms_5, ms_6, and ms_7.
State bin ms_0 is the state bin associated with the coverage point
having value 0.
m_trans ms(0:1->3:4);
Functional Coverage
7-24
Wildcard State and Transition Definitions
By default, a state or transition bin definition that uses an ‘x’ is only
matched if the coverage point has an ‘x’ in that bit position (the
semantics are similar to the “===” operator). The wildcard state and
wildcard trans bin definitions cause the Vera coverage engine to
consider an ‘x’ in the bin definition as a wildcard.
Illegal or bad states are those values of the coverage point that,
when sampled, result in a verification error.
Functional Coverage
7-25
This statement indicates that Vera will create a bin for each of
sampled values of the coverage point (or increment the bin hit count).
Note that the all state or transition specifications are intended for
debugging coverage information only. The bin hit counts associated
with the individual bins created for all state or transitions do not
affect coverage numbers. More important, if you use state(all) or
trans(all), a significant amount of memory may be used if the number
of unique values of the coverage point is large. Finally, individual bins
for state(all) or trans(all) are created (and their hit count
incremented) even if the sampled value matches other user-defined
bins.
When using this construct, all values not recorded by other states will
increment the bin-hit counter for state_bin_name.
Functional Coverage
7-26
the conditional. When a conditional is attached to a bin definition, the
bin is only updated (i.e., its hit count is incremented) if the conditional
evaluates to true and the value of the coverage point matches the
bins specification.
Note that in the above example g_var could be any variable visible
to the coverage_group based on Vera’s normal scoping rules (e.g.
involving global variables, class data members, etc.).
In the following sections we will describe the syntax for defining state
and transition bins in detail.
Functional Coverage
7-27
Syntax
state_specification
is a list of elements (separated by commas) that are matched
against the current value of the coverage point.
In a state declaration, a single state or multiple states are associated
with a monitor bin by means of a state specification. For the current
cycle, any matches increment the bin counter by one.
expression
A counter is added to the bin when the state of the coverage point
matches the expression exactly. “x” or “z” must match exactly.
low:high
A counter is added to the bin when the state of the coverage point
matches any value in the range from low to high.
low:high:step:repeat
This creates multiple ranges. The first block ranges from low to
high. The second block ranges from (high+step) to
(2*high-low+step). New blocks are generated repeat times. For
example:
2:5:10:3 would produce states {2, 3, 4, 5,15, 16, 17, 18, 28, 29,
30, 31}
(2, 3, 4, 5) --> (15, 16, 17, 18) -->(28, 29, 30, 31)
Complex state specifications can be generated by separating
multiple formats with commas.
Functional Coverage
7-28
Example 7-14
state bin1 (8’b0000_01XX, 8:10, 15:17:7:2);
This state specification will increment the bin counter if any of the
specifications matches the state of the coverage point. In this
example, a counter will be added to the bin if:
m_state
The m_state state declaration is used to declare multiple state bins
up to a maximum of 4096 bins.
Syntax
state_bin_name
is the base name of the state bins being created.
Functional Coverage
7-29
exp
can be any valid coverage expression. You cannot call functions
in the expressions. The expressions can include variables.
When the m_state declaration is used, multiple state bins are
created, covering all the values in the range. The expressions are
evaluated when the coverage object is instantiated. For example:
m_state s1 (2:4);
This example creates these bins with their respective state values:
Functional Coverage
7-30
All States and Not State
A special case of a state declaration uses the all state
specification. The all state specification should only be used when
debugging coverage information. It does not contribute to the
coverage statistics for the enclosing sample and coverage_group.
This statement indicates that Vera should create a unique state bin
for each sampled value of the coverage point. The generated state
bins are named:
s_value
Note:
If you use state(all), a significant amount of memory is used if the
number of sampled and unique states is large.
Functional Coverage
7-31
asterisk (*), and period (.). The following characters are ignored
when the bin name is generated: double quote ("), brackets ([]),
parentheses (()), dollar sign ($), caret (^), back slash (\), and braces
({}). For example, see Table 7-4:
Note:
You do not need to pass variables used in coverage conditionals
as arguments to the coverage object, if the variables are visible
in the scope where the coverage_group is defined.
Functional Coverage
7-32
Passing Arguments to Coverage Groups for more details. A
sample name associated with a sampled expression can also be
used in the conditional expression.
Example 7-15
state jmp_ins (8’b0000_01XX, 8:10, 15:17:7:2) if (test == ON);
This state declaration creates the bin jmp_ins. The bin counter is
incremented when both the state of the coverage point matches the
specification and the conditional is true.
Example 7-16
wildcard state sw(4’b11xx);
In this example, b0, b1, and b2 are separate state bins, each with its
own state specification.
Further, multiple state declarations are allowed, and the same value
can be associated with multiple state bins.
Functional Coverage
7-33
Example 7-17
state b0 (0:10);
state b1 (10:20);
Syntax
Illegal or bad states are those states in the design that, when
entered, result in verification errors.
This statement increments the specified bin counter every time the
state of the coverage point matches a value not defined in the state
declarations and a runtime verification error is issued. If you do not
specify an error bin name, the implicit name is s_not_state.
If you want to specify multiple bad states, you can use the
m_bad_state declaration.
Functional Coverage
7-34
Syntax
Syntax
trans_bin_name
This is the name of the transition bin.
transition_sequence_list
A transition sequence list is a comma-separated list of transition
sequences.
Defining Transition Sequences
Each transition sequence defines value transitions of the coverage
point. A transition sequence has the following form:
Functional Coverage
7-35
• a state bin name, specified in a state declaration and enclosed in
double quotes,
• a Perl regular expression matching a state bin name, enclosed in
double quotes
If a value range set has more than one value range, the set must be
enclosed by brackets ([]), and the members separated by commas:
Example 7-18
trans trans_bin_name (["jms_ins", br:xor, "jmp[0-9]+"] -> [
15:20:2:100]);
Functional Coverage
7-36
m_trans
The m_trans transition declaration is used to declare multiple
transition bins up to a maximum of 4096 bins.
Syntax
trans_bin_name
is the base name of the transition bins being created.
exp
can be any valid coverage expression. You cannot call functions
in the expressions. The expressions can include variables that
are visible in the scope that the coverage_group is being defined
in.
When the m_trans declaration is used, multiple transition bins are
created, covering all the transitions in the specified ranges. Each set
of expressions specifies a range. A bin is created for each
permutation of valid values.
Example 7-19
m_trans t1 (2:3 -> 4:5);
t1:2->4 2 to 4
t1:2->5 2 to 5
t1:3->4 3 to 4
t1:3->5 3 to 5
Functional Coverage
7-37
If no bin name is specified, the same example yields these bin
names and values:
t_s_2_3_s_4_5:2->4 2 to 4
t_s_2_3_s_4_5:2->5 2 to 5
t_s_2_3_s_4_5:3->4 3 to 4
t_s_2_3_s_4_5:3->5 3 to 5
In this case, Vera creates and tracks a transition bin for every two-
state value transition of the coverage point.
Note:
The automatically created bins associated with the all transition
specification do not contribute to the coverage statistics of the
enclosing sample and coverage_group constructs.
Note:
If you use trans(all), a significant amount of memory is used if the
number of sampled and unique transitions is large.
Functional Coverage
7-38
Transition Bin Names
Bins can be assigned explicit names, or the Vera compiler can
generate implicit names. The Vera compiler generates implicit bin
names based on the value transition. The general format is always
prefaced by t_. The following characters are converted to
underscores (_): comma (,), colon (:), slash (/), dash (-), plus (+),
asterisk (*), and period (.). The following characters are ignored
when the bin name is generated: double quote (""), brackets ([]),
angled brackets (<>), parentheses (()), dollar sign ($), caret (^), back
slash (\), and braces ({}). For example:
Conditional
You can add conditional statements at the end of any transition
declaration. Conditional statements can be any valid Vera
conditional statement. Functions other than get_cycle() and
get_time() cannot be called in the conditional. If there is a
conditional statement attached to the transition declaration, the bin
counter will be incremented only if both the condition is true and the
state of the coverage point makes the specified transition at the
same time.
Note:
You do not need to pass variables used in coverage conditionals
as arguments to the coverage object. However, you must declare
those variables using the extern construct within the main
program.
Functional Coverage
7-39
If you use a passed-by-value parameter of the coverage_group in
a conditional, then the value of the parameter at time that the
coverage_group is instantiated is used. If you use a
passed-by-reference parameter of the coverage_group in a
conditional, then the value of the parameter at the time that the
conditional is evaluated (at every sample point) is used. See the
Passing Arguments to Coverage Groups section for more details.
Example 7-20
trans jmp_ins (8:10 -> 15:17:7:2) if (test == ON);
This transition declaration creates the bin jmp_ins. The bin counter
is incremented when both the state of the coverage point makes the
specified transition and the conditional is true. If you specify a
sequence of transitions, the conditional is only evaluated during the
final transition.
Example 7-21
wildcard trans tw(2’b0x -> 2’b1x);
00 -> 10
00 -> 11
01 -> 10
01 -> 11
Functional Coverage
7-40
Defining Multiple Transitions in One Statement
A transition declaration can have multiple bins declared on a single
line:
In this example, b0, b1, and b2 are separate transition bins, each
with its own transition specification.
[.constant.]
[.min_constant:max_constant.]
constant
must be an unsigned integer constant. It may not be an
expression that evaluates to a constant.
Using the first construct, the transition value preceding the constant
must be repeated a fixed number of times.
Functional Coverage
7-41
This transition declaration creates a single monitor bin that is
equivalent to these transition declarations:
It is important to note that the first example uses a single monitor bin
to count any of the valid transitions, whereas the second example
uses three separate bins to monitor the same transitions.
Syntax
Functional Coverage
7-42
The not trans modifier applies only to single transitions between two
values (or two value range sets). It does not apply to larger transition
sequences. So, if you define a bad_trans using not trans then you
must make sure that all valid single transitions are covered in one of
the transition bins.
If you want to specify multiple bad transitions, you can use the
m_bad_trans declaration.
Syntax
Cross Coverage
You can define cross coverage by crossing subsets of the coverage
points being sampled by a coverage_group. Crosses of coverage
points of a coverage_group can be specified using the cross
construct. In its simplest form the cross construct has the following
form:
In this case Vera automatically creates bins for the cross product of
state or transition bins that are hit in each sampled coverage point.
Functional Coverage
7-43
crosses (cross constructs) and coverage points (sample constructs)
are sampled using the same sampling event (sample_event of the
coverage_group).
Example 7-22
extern integer g_var1;
class MyClass
{
bit [3:0] m_x;
integer m_y;
bit m_z;
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample m_x, m_y, g_var1;
cross cc1(m_y, g_var1);
}
}
...
MyClass Obj1 = new;
...
Obj1.m_y = 20;
g_var1 = 2;
@(posedge CLOCK); // First sampling event
@(posedge CLOCK); // Second sampling event
Obj.m_y++;
@(posedge CLOCK); // Third sampling event
...
Functional Coverage
7-44
After the first sampling event Vera creates an automatic state bin
s_20 for sampled variable m_y and an automatic state bin s_2 for
sampled variable g_var1. Each bin has a hit count of 1. Vera then
creates an automatic cross bin (s_20, s_2) for cross cc1. This bin is
associated with the cross product of m_y and g_var bins that are hit
at this sample point. The bin has a hit count of 1.
After the second sampling event Vera increments the hit count for bin
s_20 of sampled variable m_y, bin s_2 of sampled variable g_var1,
and bin (s_20, s_2) of cross cc1.
After the third sampling event Vera creates a new automatic state bin
s_21 for sampled variable m_y, and increments the hit count of bin
s_2 of sampled variable g_var1. Vera then creates a new bin (s_21,
s_2) for cross cc1 with hit count of 1.In general you can have several
crosses in a coverage_group definition. Example 7-23 shows
crosses cc1 and cc2 defined inside of a coverage_group.
Example 7-23
class MyClass
{
bit [3:0] m_x;
integer m_y;
bit m_z;
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample m_x, m_y, g_var1;
cross cc1(m_y, g_var1);
cross cc2(m_x, m_y, g_var1);
}
}
Functional Coverage
7-45
User-defined Cross Coverage Bins
You can define your cross coverage bins. User-defined (and named)
cross coverage bins can be used for:
You can use Vera expressions for easy and concise specification of
cross coverage bins. The syntax for a cross construct that defines
cross coverage bins is:
cross_name
is the name for the cross. You can use this name to access the
cross (query or set information about the cross) in the testbench.
cross_bin_definitions
You can use Vera expressions for defining named cross coverage
bins. To define a cross coverage bin that combines several cross
products into single named bin or equivalence class use the
following syntax:
state state_name (expression) [ if (expression) ];
Functional Coverage
7-46
If the expression for the state evaluates to true, then cross
coverage bin state_name’s hit count is incremented. You can
optionally specify a conditional for the cross coverage state. In
that case the bin is only hit if both the expression that defines the
bin as well as the conditional evaluate to true.
To define cross products that should not be considered for
coverage calculations, use the ignored keyword.
Syntax
ignored state_name (expression) [ if (expression) ];
To define cross products that are illegal and should not occur, use
the bad_state keyword
Syntax
bad_state state_name (expression) [ if (expression) ];
Functional Coverage
7-47
where attribute_name is the name of the attribute, and
value_expression is a Vera expression. See section
Expressions within Coverage Group Definitions for allowed
expressions inside of coverage_group and coverage point
definitions.
Precedence Semantics for User Defined Cross Bins
You can have several user-defined cross coverage bins of each kind
(i.e., state, bad_state, and ignored). The question that arises is how
should Vera behave when your cross construct includes
user-defined cross coverage bins of each kind. Moreover, what
should the precedence semantics be when the expression for more
than one of the user-defined cross coverage bins evaluates to true?
Example 7-24
extern i, j, k;
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample i, j, k;
cross cc1 (i,j)
{
state MyCrossBin(i < 50 );
ignored IgnoredCrossProds(i > 40 && j > 20 && j < 26);
bad_state BadCrossProds(i == 45 && j == 24);
}
}
Functional Coverage
7-48
• Otherwise, every one of the user defined (non-illegal,
non-ignored) cross coverage bins (state) that match (expression
evaluates to true) are updated (i.e., their hit count is incremented).
• Otherwise, Vera creates an automatic cross product bin (if
necessary), and updates the hit count of that bin. The bin is
associated with the state and/or transition bins that are hit in each
coverage point involved in the cross.
We will now analyze Example 7-24 for different values of sampled
variables i, j, and k using the precedence semantics described
above.
If i is 45 and j is 24, then the expressions for all three bins evaluate
to true, according to the precedence semantics described above.
Vera flags a verification error, and does not proceed to update the hit
count for MyCrossBin. Vera does not ignore the cross either, even
though the expression for IgnoredCrossProds also evaluates to
true. “bad_states” have the highest precedence.
Functional Coverage
7-49
Examples of Embedded Coverage Groups with User-defined
Cross Coverage Bins
In the following code fragment we show an embedded
coverage_group that defines a cross cc1 for sampled variables m_y,
m_z, and g_var1.
Example 7-25
class MyClass
{
...
coverage_group cov1 {
sample_event = @(posedge CLOCK);
sample m_x, m_y, g_var1;
cross cc1(m_y, m_z, g_var1) {
bad_state bad1(m_y < 12 && m_z == 0 ||
m_y > 1024 && g_var1 == 0);
ignored ig1(m_y < 128 && m_z == 0);
}
}
}
Functional Coverage
7-50
Example 7-26
extern integer g_var1;
class MyClass {
bit [0:4] m_x, m_y;
coverage_group cov1 {
sample_event = @(posedge CLOCK);
sample m_x, m_y, g_var1;
cross cc1(m_y, m_z, g_var1) {
state s1 (m_y == 0 && m_z == 2);
}
}
}
Functional Coverage
7-51
• Definition of the cross bin (in terms of the range of values of the
crossed coverage point) should not change in every sample.
Otherwise, coverage number computation will be very expensive,
and even impossible in certain cases.
• Since tasks and functions can be blocking, you cannot use task
or function calls.
• A sample name associated with a sampled expression can be
used in the expression, provided it is present in the list of samples
for the cross.
The first rule implies that each sub-expression must contain only one
crossed coverage point. Example 7-27 involves two invalid
expressions (flagged as errors by the Vera Compiler), and two valid
expressions
Example 7-27
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample m_x, m_y, g_var1;
cross cc1(m_y, m_z)
{
ignored invalid1 (m_y > m_z);
ignored invalid2 (m_y + m_z == 2);
ignored ok1 (m_y * 2 > 24);
ignored ok2 (m_y * 2 < g_var1);
state s1 (m_y == 0 && m_z == 2);
}
}
The expression used in the ignored state invalid1 uses the crossed
sampled variables on both sides of the relational operator ‘>’. The
expression used in ignored state invalid2 uses both of the sampled
variables in its ‘+’ sub-expression. The expressions used for ok1 and
ok2 are valid since they do not use more than one of the crossed
sampled variables in their sub-expressions.
Functional Coverage
7-52
In Example 7-27, the expression m_y == 0 && m_z == 2 (used
for defining cross coverage bin s1) conjoins two sub-expressions
“m_y == 0” and “m_z == 2”. Each sub-expression has only one
sampled variable on each side of the relational. The expression is
therefore valid. An invalid expression would be m_y <= m_z &&
m_z == 2. In that case, the first sub-expression (“m_y <= m_z”) has
the sampled variables on both sides of the relational.
Functional Coverage
7-53
Saving/reporting missing cross product bins
In Vera 6.0, the functional coverage engine creates
auto-cross-product bins solely for cross-products that are observed
during the simulation.
Example 7-28
coverage_group Cov
{
sample_event = @(posedge CLOCK);
sample x {
state sx_1(4'h1), sx_2(4'h2);
trans tx_1_2(4'h1->4'h2);
}
sample y {
state sy_a(4'ha), sy_b(4'hb);
trans tx_a_b(4'ha->4'hb);
}
cross cc1 (x,y);
}
program test
{
bit [3:0] x, y;
Cov cov = new;
@(posedge CLOCK);
x= 4'h1;
y= 4'ha;
@(posedge CLOCK);
x= 4'h2;
@(posedge CLOCK);
}
Functional Coverage
7-54
CoverageGroup: Cov
Cross: cc1
Summary
Coverage: 33.33
Goal: 90
Number of Samples Crossed: 2
Samples Crossed: x y
Number of Expected Cross Bins: 9
Number of User Defined Cross Bins: 0
Number of Automatically Generated Cross Bins: 3
Number of Missing Cross Bins: 6
x y # hits at least
=======================================================
sx_1 sy_a 1 1
sx_2 sy_a 1 1
tx_1_2 sy_a 1 1
=======================================================
• cross_num_print_missing
In Vera 6.1 you can specify the number of missing (not created)
auto-cross-product bins that should be printed by the coverage
engine. This is controlled by the “cross_num_print_missing”
attribute. The attribute can be set for a particular cross or for the
coverage_group as a whole (affecting all crosses of the
coverage_group).
Functional Coverage
7-55
Syntax
cross_num_print_missing = expression;
expression
is any Vera expression that evaluates to an integer (greater than
or equal to zero). The expression may not include any task or
function calls other than the coverage_group query() or
inst_query() built-in functions.
The expression is evaluated at the time that a coverage_group is
instantiated.
Example 7-29
coverage_group Cov
{
sample x {
state sx_1(4'h1), sx_2(4'h2);
trans tx_1_2(4'h1->4'h2);
}
sample y {
state sy_a(4'ha), sy_b(4'hb);
trans tx_a_b(4'ha->4'hb);
}
cross cc1 (x,y);
sample_event = @(posedge CLOCK);
// save/print 2 of the missing auto-cross-product
// bins
cross_num_print_missing = 2;
}
Functional Coverage
7-56
The coverage report for the modified coverage_group definition now
includes the following information:
x y # hits at least
=======================================================
sx_1 sy_b 0 1
sx_1 tx_a_b 0 1
=======================================================
then all missing auto-cross-product bins are printed, and the report
for Example 7-29 would include the following information:
x y # hits at least
=======================================================
sx_1 sy_b 0 1
sx_1 tx_a_b 0 1
sx_2 sy_b 0 1
sx_2 tx_a_b 0 1
tx_1_2 sy_b 0 1
tx_1_2 tx_a_b 0 1
=======================================================
Functional Coverage
7-57
creating any auto-cross-product bins. Alternately the user may want
to limit the number of auto-cross-product bins that are created by the
coverage engine. Example 7-30 illustrates the point.
Example 7-30
coverage_group Cov
{
program test
{
bit [2:0] x,y;
Cov c = new;
@(posedge CLOCK);
x=3'b0;
y=3'b100;
// sx0 gets a hit
@(posedge CLOCK);
x=3'b010;
y=3'b101;
// automatic cross product bin (s_2,s_5)
@(posedge CLOCK);
x=3'b011;
y=3'b101;
// automatic cross product bin (s_3,s_5)
@(posedge CLOCK);
x=3'b001;
y=3'b001;
// sx1 gets a hit
@(posedge CLOCK);
}
Functional Coverage
7-58
be created (two user defined bins, and 64 auto-cross-product bins
associated with the 23 * 23 cross products of “x” and “y”—these
variables are 3 bit bit-vectors).
Cross: cc1
Summary
Coverage: 6.06
Goal: 90
Number of Samples Crossed: 2
Samples Crossed: x y
Number of Expected Cross Bins: 66
Number of User Defined Cross Bins: 2
Number of Automatically Generated Cross Bins: 2
x y # hits at least
=======================================================
s_2 s_5 1 1
s_3 s_5 1 1
=======================================================
• cross_auto_bin_max
In Vera 6.1 a mechanism was introduced for controlling the maximum
number auto-cross-product bins created by the coverage engine.
This is controlled by the cross_auto_bin_max attribute. This attribute
can be set for a particular cross or for the coverage_group as a whole
(affecting all crosses of the coverage_group).
Functional Coverage
7-59
Syntax
cross_auto_bin_max = expression;
expression
is any Vera expression that evaluates to an integer (greater than
or equal to zero). The expression may not include any task or
function calls other than the coverage_group query() or
inst_query() built-in functions. The expression is evaluated at the
time the coverage_group is instantiated.
If the attribute is greater than or equal to zero, it specifies the
maximum number of automatically generated cross product bins that
the Vera coverage engine will create for a cross. If the above
coverage_group definition is modified as follows, then we create only
one auto-cross-product bin.
Example 7-31
coverage_group Cov
{
sample x,y;
cross cc1 (x,y)
{
state sx0(x==3'b0);
state sx1(x==3'b001);
}
cross_auto_bin_max = 1;
sample_event = @(posedge CLOCK);
}
The cross coverage report for the modified example would then look
as follows. Note that since the maximum number automatically
generated cross product bins is set to 1, we now expect a maximum
of 3 cross product bins (2 user defined, and 1 auto). The example,
therefore, gives 100 percent coverage.
Functional Coverage
7-60
Cross Coverage report
CoverageGroup: Cov
Cross: cc1
Summary
Coverage: 100.00
Goal: 90
Number of Samples Crossed: 2
Samples Crossed: x y
Number of Expected Cross Bins: 3
Number of User Defined Cross Bins: 2
Number of Automatically Generated Cross Bins: 1
x y # hits at least
=======================================================
s_2 s_5 1 1
=======================================================
Sample Event
A sampling event expression must be specified in the coverage group
definition. This sampling event is used for all instantiations of a
coverage definition. An event expression does not need to be
specified when instantiating the coverage_group.
The sampling event expression allows you to control when the object
takes a sample. Coverage objects can be triggered on clock edges,
signal edges, variable changes, sync events and OVA events.
Functional Coverage
7-61
Types of Sampling Events
Syntax
Example 7-32
coverage_group cov1
{
sample_event = @(posedge CLOCK);
sample g_var;
}
Syntax
sample_event = wait_var(some_openvera_variable);
Functional Coverage
7-62
Example 7-33
class MyClass
{
integer xref;
coverage_group cov1
{
sample_event = wait_var(xref);
sample xref;
}
}
Syntax
Example 7-34
extern Event ev1;
class MyClass
{
integer xref;
coverage_group cov1
{
sample_event = sync(ALL, ev1);
sample xref;
}
}
Functional Coverage
7-63
Note that coverage objects waiting on a sync event do not count
towards the count for HAND_SHAKE triggers. That is, if the sync
event is triggered in the HAND_SHAKE mode, all coverage objects
waiting on that event are triggered. These do not count towards the
HAND_SHAKE. An additional explicit Vera thread waiting on that sync
event will also be triggered.
Example 7-35
sample_event = ova_object.Wait();
Example 7-36
class MyClass {
integer port_num;
OVAEvent portEvent;
coverage_group cov1 {
sample_event = portEvent.Wait()
sample port_number;
}
}
Functional Coverage
7-64
General Task Calls. In the most general case, the sampling event
expression can be any task call. This can be used when more
elaborate event sequences are needed to trigger sampling of
coverage objects.
Example 7-37
task CoverageTrigger1(integer numCycles){
integer i;
globalOVAEvent.Wait();
for (i=0;i<numCycles;i++)
{
@(posedge CLOCK);
}
}
coverage_group cov1 (integer numCyclesAfterOVAEvent)
{
sample_event = CoverageTrigger1(numCyclesAfterOVAEvent);
sample xref;
}
Note:
The task is called by the Vera Coverage system. It should not
have any side-effects such as changing the value of variables.
Unpredictable behavior could result if the task has side effects of
any kind.
The task should block. A task which does not block at all will
result in only a sampling of the coverage object in a Vera cycle.
Functional Coverage
7-65
Default Synchronous Behavior of Sampling Event. The default
behavior of sampling events is to sample the coverage object in a
synchronous fashion (i.e., The coverage object is sampled at the end
of the simulation cycle after all Vera processing that can change
variables is complete). Also, the coverage object is sampled at most
once per simulation cycle even if the sampling event triggers more
than once.
Functional Coverage
7-66
Example 7-38
class MyClass
{
integer xref;
coverage_group cov1
{
sample_event = sync(global_event) async;
sample xref;
}
}
Example 7-39
#include "my_interface.vrh"
coverage_group covType ()
{
sample_event = @(posedge ifc.clk);
sample g_var;
}
Functional Coverage
7-67
Use of Class Member Variables
The sample event expression of an embedded coverage group can
reference member variables of the nesting class. In Example 7-40,
the embedded coverage group covType will be sampled upon every
change in value of the member variable m_e of the nesting class
object (i.e., the coverage object obj1.covType will be sampled upon
the change in value of obj1.m_e, and the coverage object
obj2.covType will be sampled upon the change in value of
obj2.m_e.class).
Example 7-40
MyClass
{
integer m_e;
coverage_group covType
{
sample_event = wait_var(m_e);
sample m_e;
}
}
...
...
MyClass obj1 = new;
MyClass obj2 = new;
Functional Coverage
7-68
Example 7-41
coverage_group covType (var integer waitInt)
{
sample_event = wait_var(waitInt);
sample g_var;
}
integer gWait, gAcc;
...
Sampled Parameters
Sampled parameters are preceded by the sample keyword in the
formal parameter list of the coverage_group definition. They are
really treated like a constant “var” argument passed to a task.
Functional Coverage
7-69
Example 7-42
Functional Coverage
7-70
In Example 7-43, coverage_group MyCov defines two parameters
that are passed by value (param and param2). It also samples a
global variable (gVar) at the positive edge of the system clock.
Example 7-43
coverage_group MyCov(integer param, integer param2)
{
sample_event = @(posedge CLOCK);
sample gVar
{
state s1 (0:param);
state s2 (param+1 : 15);
state condState (16 : 31) if (param2 > 4);
}
}
...
program Example
{
bit [4:0] gVar;
integer gP1, gP2;
MyCov cov1;
...
gP1 = 7;
gP2 = 3;
cov1 = new(gP1, gP2);
...
}
Functional Coverage
7-71
Non-Sampled Parameters Passed by Reference
Parameters that are preceded by the var keyword in the parameter
list of the coverage_group definition are passed-by-reference.
Passed-by-reference arguments are really considered constant
references since the Vera coverage engine does not attempt to
modify their value.
Functional Coverage
7-72
Example 7-44
coverage_group MyCov(integer param, var integer
param2)
{
sample_event = @(posedge CLOCK);
sample gVar
{
state s1 (0:param), state s2 (param+1 : 15);
state condState (16 : 31) if (param2 > 4);
}
}
...
program Example
{
bit [4:0] gVar;
integer gP1, gP2;
MyCov cov1;
...
gP1 = 7;
cov1 = new(gP1, gP2); //instantiate cov1 and pass arguments
...
gP2 = 3;
@(posedge CLOCK); // 1st sampling event after instantiation
gP2 = 5;
@(posedge CLOCK); // 2nd sampling event after instantiation
...
}
Functional Coverage
7-73
Expressions within Coverage Group Definitions
Expressions within coverage_group definitions are used for:
Functional Coverage
7-74
The following coverage_group attributes cannot be initialized using
the query() or inst_query() function calls:
• bin_activation_mode
• cumulative
• cov_comment
• overlap_state
• overlap_trans
These attributes affect the way in which a coverage_group instance
is initialized, and therefore their value must be determined before
Vera instantiates the coverage_group. The Vera compiler issues an
error if you try to initialize the above attribute with the query() or
inst_query() function.
Interface signals and port variables declared via the bind construct
are allowed. Expressions within a coverage_group can reference
any variable or signal that is visible in the scope the coverage_group
is being defined in, including arguments passed to the
coverage_group. For example, an embedded coverage_group can
include expressions that refer to the data members of the class (see
page 7-4 for the definition of an embedded coverage_group).
Functional Coverage
7-75
Cumulative and Instance-based Coverage
Coverage statistics can be gathered both cumulatively and on a
per-instance basis.
Cumulative Coverage
Cumulative implies that coverage statistics (i.e., bin hit counts and
coverage numbers) are computed for the coverage_group definition.
In this case all instances of the coverage_group contribute to a single
set of statistics maintained for the coverage_group definition. By
default, Vera computes cumulative coverage information.
Note:
In cumulative mode, only cumulative information can be queried
for. Furthermore, the coverage reports only report on cumulative
data for the coverage group definitions, and not instances.
Instance-based Coverage
Instance-based coverage statistics involve computing coverage
statistics for every instance of a coverage_group as well as the
coverage_group definition as a whole. Vera computes per-instance
coverage statistics when you set the cumulative attribute of the
coverage_group to 0.
Functional Coverage
7-76
Measuring Coverage
Vera computes a coverage number (or percentage) for the testbench
run as whole. Here, the coverage number is referred to as
“coverage.” The coverage for the testbench is the weighted average
of the coverages of every coverage_group in the testbench. When
per-instance data is available, Vera also computes an instance
coverage for the testbench. That number is the weighted average of
the coverages of every coverage_group instance.
Functional Coverage
7-77
By default, Vera does not create automatic bins for ’X’ or ’Z’ values
of a coverage point. For example, if a coverage point is a 4 bit
bit-vector and the auto_bin_max attribute is set to 64 (default), then
by default the total number of possible bins for the coverage point is
16 (24). On the other hand, if Vera coverage is sampling the coverage
point when it has ’X’ or ’Z’ values (auto_bin_include_xz attribute of
the sample is set to ON or 1), then the total number of possible bins
for the 4 bit bit-vector is 64 (MIN(auto_bin_max attribute, 44)). Finally,
if the auto_bin_max attribute is set to 5, then the total number of
possible bins for the 4 bit bit-vector is 5.
Functional Coverage
7-78
You can also query for the testbench coverage during the Vera run.
This allows you to react to the coverage statistics dynamically (e.g.,
stop the Vera run when the testbench achieves a particular
coverage).
Note:
The get_inst_coverage() system function returns -1 when there
is no instance-based coverage information (i.e., the cumulative
attribute of the coverage_group has not been set to 0).
The Coverage Feedback: query() section details how to query for the
coverage of individual sample and crosses of each coverage_group.
Coverage Attributes
This section lists the attributes that are used as part of the coverage
group specification. You can set attributes in the coverage_group,
sample, or cross constructs. You can set an attribute’s value in the
coverage group’s definition (i.e., inside a coverage_group, sample, or
cross construct).
Syntax
attribute_name = value_expression;
Functional Coverage
7-79
where attribute_name is the name of the attribute, and
value_expression is an OpenVera expression (see Expressions
within Coverage Group Definitions for allowed expressions inside of
coverage_group definitions.) When an attribute in a
coverage_group’s definition is set, the value_expression is
evaluated at the time the coverage_group is instantiated.
Example 7-45
class Packet {
bit [7:0] m_packetSize;
bit [7:0] m_packetId;
coverage_group PacketCov {
at_least = 2;
sample m_packetSize {
at_least = 5;
}
sample m_packetId;
cross MyCross (m_packetSize, m_packetId);
sample_event = @(posedge CLOCK);
}
Functional Coverage
7-80
Note:
Vera does not force a particular order in the definition of
coverage_group-level attributes and the sample and cross
definitions. Similarly, Vera does not force any particular order in
the definition of sample (or cross) level attributes and the
definition of the sample (or cross) bins.
Functional Coverage
7-81
- If the expression evaluates to 0 (OFF), the Vera coverage
engine assumes that all bins for the construct
(coverage_group, sample, cross) containing the attribute will
be inactive for the current instance and all subsequent
instantiations of the coverage group.
- If the expression evaluates to a non-zero value (ON), the Vera
coverage engine assumes that all bins for the construct
(coverage_group, sample, cross) containing the attribute will
be active for the current instance and all subsequent
instantiations of the coverage group.
• collect: The collect attribute turns data collection on or off.The
attribute has a default value of ON (or 1). The collect attribute can
be set at the coverage_group, sample, or cross levels. When it is
set at the coverage_group level, it applies to all samples in the
coverage group that do not explicitly set the attribute.
• cov_comment: This attribute is used to specify user-defined
comments (character string literals) in the coverage_group,
sample, and cross constructs. The comment can be used as a
mnemonic to assist in interpreting coverage results, or help in
organizing coverage results in custom ways.
Syntax
cov_comment = string_literal;
string_literal
Functional Coverage
7-82
to the enclosing coverage_group’s coverage number. The
attribute has a default value of 1. Setting this attribute at the
coverage_group level does not affect the value of the cov_weight
attribute for any of the sample or crosses of the coverage_group.
• coverage_goal: When specified for a coverage_group, the
attribute designates the desired coverage percentage for the
group. The default value is 90 (percent). When specified at the
sample or cross level, the attribute specifies the desired coverage
percentage for the sample or cross. Again, the default is value 90.
Setting coverage_goal at the coverage_group level does not affect
the value of the coverage_goal attribute for the sample and
crosses of the coverage_group (i.e., the attribute retains its default
value for the sample and crosses where coverage_goal is not
explicitly set).
• cross_auto_bin_max: This attribute controls the maximum
number of auto-cross-product bins created by the coverage
engine. The attribute can be set for a particular cross or for the
coverage_group as a whole (affecting all crosses of the
coverage_group). If the attribute is greater than or equal to zero,
it specifies the maximum number of automatically generated
cross product bins the Vera coverage engine will create for a
cross. Please refer to Cross Coverage Definition section for more
details.)
• cross_bin_max: The cross_bin_max attribute is used for
computing the coverage number for a cross. It specifies the
maximum number of cross coverage bins expected in a cross. By
default, the number of possible bins for a cross is the sum of the
user-defined bins and the number of possible automatically
generated bins. The number of possible automatically generated
bins is the product of the number of possible bins for each of the
Functional Coverage
7-83
samples being crossed. If cross_bin_max is set, its value will be
used as the upper-bound for the number of possible bins in a
cross.
• cross_num_print_missing: This attribute controls the number
of missing (not created) auto-cross-product bins that should be
printed by the coverage engine. If the attribute is greater than
zero, then it specifies the number of missing auto-cross-product
bins the Vera coverage engine saves to the database. Please
refer to Cross Coverage Definition.
• cumulative: The cumulative attribute specifies whether to
accumulate coverage data cumulatively across all instances of
the coverage group, or on a per-instance basis. The attribute has
a default value of ON (or 1). The cumulative attribute is set at the
coverage_group level only.
• overlap_state: The overlap_state attribute specifies whether
Vera should check for states with overlapping values. When set
to ON (or 1), Vera prints a warning if any two states of a sample
have overlapping values. The attribute has a default value of OFF
(or 0). The overlap_state attribute can be set at the
coverage_group or sample level. When it is set at the
coverage_group level, it applies to all samples in the coverage
group that do not explicitly set the attribute.
• overlap_trans: The overlap_trans attribute specifies whether
Vera should check for trans constructs that define overlapping
transitions. When set to ON (or 1), Vera prints a warning if any
two trans constructs of a sample define overlapping transitions.
The attribute has a default value of OFF (or 0). The overlap_trans
attribute can be set at the coverage_group or sample level. When
it is set at the coverage_group level, it applies to all samples in
the coverage group that do not explicitly set the attribute.
Functional Coverage
7-84
• auto_bin_include_xz: The auto_bin_include_xz attribute
specifies whether Vera should consider ’X’ and ’Z’ values for an
automatically binned coverage point. The default value of the
auto_bin_include_xz attribute is OFF or 0. In this case, Vera does
not create a bin for any of the ’X’ or ’Z’ values of the coverage
point. Vera functional coverage treats the coverage point as
having 2N values (where N is the number of bits for a bit-vector or
32 for an integer). If the auto_bin_include_xz attribute is set to
ON (or 1), Vera creates a bin for the ’X’ or ’Z’ values of the
coverage point. In this case, Vera functional coverage treats
bit-vector coverage points as having 4N values (where N is the
number of bits), and integer coverage points as having 232 + 1
values (-231 to 231, and ’X’).
The auto_bin_include_xz attribute can be set at the
coverage_group or sample level. When it is set at the
coverage_group level, it applies to all samples in the coverage
group that do not explicitly set the attribute. Note that this attribute
only applies to coverage points that are automatically binned.
Functional Coverage
7-85
Table 7-5 Coverage Attributes and Related Constructs
Attribute Name Type Default Defined in Defined Defined
Value coverage_group in in
sample cross
cross_bin_max integer 231-1 Yes No Yes
cumulative boolean ON Yes No No
overlap_state boolean OFF Yes Yes No
overlap_trans boolean OFF Yes Yes No
auto_bin_include_xz boolean OFF Yes Yes No
bin_activation integer 1 Yes Yes Yes
cross_num_print_mis integer 0 Yes No Yes
sing
cross_auto_bin_max integer 0 Yes No Yes
Functional Coverage
7-86
Persistent Storage of Coverage Data and
Post-processing Tools
At the end of the run, Vera writes out coverage data to a binary
database file for persistent storage. By default, the file is named:
vera_program_name.db
vera_program_name
is the name of the OpenVera program.
All coverage data for the Vera run is written to this database file. By
default, Vera writes out cumulative coverage data for each coverage
group. If the cumulative attribute of a coverage group is set to OFF
(or 0), Vera writes out coverage data for each instance of a coverage
group in addition to the coverage data for the group as a whole.
Vera’s coverage post-processing facilities can be used to report on
the coverage data saved in the database.
Subsequent Vera runs can also load coverage data from this
database if they want to accumulate incremental coverage data
building upon the results of the previous run.
Functional Coverage
7-87
File Control
By default, Vera saves the coverage database in the directory that
Vera is run in. Vera avoids overwriting existing database files by
generating unique non-clashing file names. The name of the
coverage database file can be controlled using the following system
task:
File Name
Functional Coverage
7-88
flag:
OFF for disabling database backup; ON for enabling database
backup
In order to not save the coverage data to a database file (if there is a
Verification Error for example), then use the following system task:
Reporting
Vera captures all the coverage data for a run in the database file. A
full set of HTML or text reports can be reported from the database
file. The Unix command for generating an HTML coverage report is:
list_of_files_or_directories
List of one or more Vera functional coverage database files, and/
or directories containing database files. If the list includes more
than one database file (or the directories include more than one
database file), the database files are merged before generating
the HTML report.
The above command generates the HTML reports. It writes out a
top-level HTML file named database_name.index.html and a
directory named database_name.fcov. To browse through the HTML
reports open the top-level HTML file into a browser of your choice. It
is not necessary to directly access any file in the database_name.fcov
directory.
Functional Coverage
7-89
For instance, given the coverage database file, Run1.db. After
generating the HTML report, there is a file Run1.index.html and a
directory Run1.fcov in the current directory. Open the
Run1.index.html file with a browser to view the coverage reports.
The Unix command for generating coverage reports in text format is:
list_of_files_or_directories
List of one or more Vera functional coverage database files, and/
or directories containing database files. If the list includes more
than one database file (or the directories include more than one
database file), the database files are merged before generating
the HTML report.
This command generates a single text file that includes all coverage
information stored in the coverage database. The file is called
database_name.txt. For instance if we have the coverage database
file, Run1.db. After generating the text report, you will see a file
Run1.text in the directory where the Unix command is invoked.
Functional Coverage
7-90
Loading Cumulative Coverage Data
The cumulative coverage data can be loaded either for all coverage
groups, or for a specific coverage group. To load the cumulative
coverage data for all coverage groups, use the syntax:
coverage_load("database_file_name");
coverage_load("database_file_name","coverage_group_name");
Example 7-46
MyClass
{
integer m_e;
coverage_group covType
{
sample_event = wait_var(m_e);
sample m_e;
}
}
...
...
coverage_load("Run1.db", "MyClass:covType");
Functional Coverage
7-91
Loading Instance Coverage Data
The coverage data can be loaded for a specific coverage instance.
To load the coverage data for a standalone coverage instance, use
the syntax:
coverage_instance.load("database_file_name");
class_object.cov_group_name.load("database_file_name");
The commands above direct Vera to find the coverage data for the
specified instance name in the database, and load it into the coverage
instance.
Example 7-47
MyClass {
integer m_e;
coverage_group covType {
sample_event = wait_var(m_e);
sample m_e;
}
}
...
...
MyClass obj1 = new;
obj1.load("Run1.db");
MyClass obj2 = new;
Functional Coverage
7-92
Test Merging
Vera allows generation of a coverage report representing the
aggregation of two or more Vera runs.
list_of_files_or_directories
List of one or more Vera functional coverage database files, and/
or directories containing database files. If the list includes more
that one database file (or the directories include more than one
database file), the database files are merged before generating
the HTML report.
-save_db db_filename
is the new file where the merged database created by combining
individual database files is saved.
-save_db_only db_filename
is the new file where the merged database created by combining
individual database files is saved, without generating an HTML
report.
-output_report path_to_output
Functional Coverage
7-93
This command generates an HTML report for a list of one or more
Vera functional coverage database files and/or directories that
contain database files. The merged database that is created by
combining multiple database files can also be saved.
list_of_files_or_directories
List of one or more Vera functional coverage database files, and/
or directories containing database files. If the list includes more
that one database file (or the directories include more than one
database file), the database files are merged before generating
the text report.
-save_db db_filename
is the new file where the merged database created by combining
individual database files is saved.
-save_db_only db_filename
is the new file where the merged database created by combining
individual database files is saved, without generating a text report.
-output_report path_to_output
Functional Coverage
7-94
This command generates an text report for a list of one or more Vera
functional coverage database files and/or directories that contain
database files. Can also save the merged database that is created
by combining multiple database files.
grading_options
-cov_target value:
Target coverage for grading (default 100%)
-instance;
Grade instance-based coverage rather than cumulative
coverage. The databases must include instance-based coverage
data.
-weighted:
Perform grading based on the coverage efficiency
(simulation time / coverage) of each database.
timeout value
Limits grading’s runtime to value seconds.
Functional Coverage
7-95
-cov_text_report
Generates a functional coverage text report (instead of the default
HTML report) that includes grading information.
list_of_files_or_directories
List of one or more Vera functional coverage database files, and/
or directories containing database files.
-save_db db_filename
is the new file where the database associated with the minimal
subset of tests that are selected by grading is saved.
-output_report
This option behaves the same way as in the -cov_report (if
generating the default HTML report) or the -cov_text_report
(when the -cov_text_report is specified).
This command grades a set of Vera functional coverage databases
specified as a list of database files and/or directories that contain
database files. This command generates a report (default HTML)
that includes the grading information. It can also save the database
associated with the minimal subset of tests selected by grading.
Test Grading
Vera can grade a set of functional coverage database files, allowing
you to determine a minimal subset of database files that achieve a
desired coverage percentage. This is particularly useful when there
are overlaps in the coverage space that is covered by each database
file (Vera run).
Functional Coverage
7-96
After computing the minimal subset of database files, Vera generates
a coverage report for the merged data of those files. If you generate
an HTML report (the default), the top level index page has a link to
the test grading page. If you generate a text report, test grading
information is printed at the end of the file.
Instance Names
Auto-naming
Coverage objects are named so that they can be identified in the
Vera coverage reports. By default, the name automatically generated
is based on the variable name of the Vera coverage object.
Example 7-48
coverage_group covType
{
sample_event = @(posedge CLOCK);
sample gVar;
}
...
covType cov1 = new();
Functional Coverage
7-97
In the case of an array of coverage objects, the names generated for
the coverage instances include the array index. In Example 7-49, the
coverage instances will be named covInst[0] and covInst[1].
Example 7-49
coverage_group covType(sample integer thisVar)
{
sample_event = @(posedge CLOCK);
sample thisVar;
}
...
covType covInst[2];
covInst[0] = new(localVar1);
covInst[1] = new(localVar2);
User-Specified Names
Coverage instances are created dynamically during the simulation
run. In some testbenches, a large number of coverage instances
may be created. To have greater control, explicitly name the
coverage objects to have user-specified names. The syntax for
standalone coverage groups is:
coverage_instance.set_name("user_specified_name");
class_instance.coverage_group_name.set_name("user_
specified_name");
Functional Coverage
7-98
Although predefined methods are invoked on a coverage group
instance, some are related to the cumulative coverage information
that Vera maintains for the coverage group as a whole (cumulative
coverage group information). For example, the query() function
returns coverage information related to the coverage group as a
whole (cumulative information). On the other hand, the inst_query()
function returns coverage information for the coverage group
instance on which it is invoked. If the cumulative attribute of a
coverage group is set to OFF, functions that return instance-based
information return a -1.
function return_type
coverage_group_instance_name.function_name ([arguments]);
coverage_group_instance_name
For stand-alone coverage groups,
coverage_group_instance_name is simply the name the
coverage group instance. For class embedded coverage groups,
coverage_group_instance_name has the following form:
object_name.coverage_group_name
Functional Coverage
7-99
function_name
The following table summarizes the predefined coverage group
functions and provides a brief description.
Table 7-6 Predefined Coverage Group Functions
Function Name Requires Description
Args
get_at_least() No Returns the value of the cumulative at_least
attribute for the coverage_group definition.
get_auto_bin_max() No Returns the value of the cumulative
auto_bin_max attribute for the coverage group
definition.
get_cov_weight() No Returns the value of the cumulative cov_weight
attribute for the coverage group definition.
get_coverage_goal() No Returns the value of the cumulative
coverage_goal attribute for the coverage group
definition.
get_cross_bin_max() No Returns the value of the cumulative
cross_bin_max attribute for the coverage group
definition.
inst_get_at_least() No Returns the value of the at_least attribute
for the coverage group instance.
inst_get_auto_bin_max() No Returns the value of the auto_bin_max
attribute for the coverage group instance.
inst_get_collect() No Returns the value of the collect attribute for
the coverage group instance.
inst_get_cov_weight()() No Returns the value of the cov_weight attribute
for the coverage group instance.
inst_get_coverage_goal No Returns the value of the coverage_goal
attribute for the coverage group instance.
inst_get_cross_bin_max() No Returns the value of the cross_bin_max
attribute for the coverage group instance.
inst_query() Yes Queries for coverage information related to
the coverage group instance.
inst_set_bin_activation() Yes Returns the number of bins affected by the
function.
Functional Coverage
7-100
Table 7-6 Predefined Coverage Group Functions
Function Name Requires Description
Args
set_bin_activation() Yes Returns the number of bins affected by the
function.
query() Yes Queries for coverage information related to
the coverage group as a whole (cumulative).
query_str() Yes Queries for the name of the current sample or
cross bin in a query(FIRST)/query(NEXT) or
inst_query(FIRST)/inst_query(NEXT) sequence.
arguments
Some of the predefined coverage group functions accept
arguments. The second column of Table 7-6 indicates whether a
function requires an argument.
return_type
All predefined coverage group functions have an integer return
type except for query_str(), which has a string return type.
Predefined Tasks for The coverage_group Construct
Predefined tasks can be invoked on an instance of a coverage group
and have the following syntax
coverage_group_instance_name
For stand-alone coverage groups,
coverage_group_instance_name is simply the name the
coverage group instance. For class embedded coverage groups,
coverage_group_instance_name has the following form:
object_name.coverage_group_name
Functional Coverage
7-101
where object_name is the name of the class instance, and
coverage_group_name is the name of the coverage_group
construct embedded in the class.
task_name
The following table summarizes the predefined coverage group
tasks and provides a brief description.
Table 7-7 Predefined Coverage Group Tasks
Task Name Argument Description
type
set_at_least() integer Sets the cumulative at_least attribute (which
is used for computing cumulative coverage
statistics).
set_auto_bin_max() integer Sets the cumulative auto_bin_max attribute
(which is used for controlling cumulative
coverage information).
set_cov_weight() integer Sets the cumulative cov_weight attribute
(which is used for computing cumulative
coverage statistics).
set_coverage_goal() integer Sets the cumulative coverage_goal attribute
(which is used for computing cumulative
coverage statistics).
set_cross_bin_max() integer Sets the cumulative cross_bin_max attribute
(which is used for computing cumulative
coverage statistics).
inst_set_at_least() integer Sets the at_least attribute for the coverage
group instance.
inst_set_auto_bin_max() integer Sets the auto_bin_max attribute for the
coverage group instance.
inst_set_collect() integer Sets the collect attribute for the coverage
group instance (turning off coverage data
collection for that instance).
inst_set_cov_weight() integer Sets the cov_weight attribute for the coverage
group instance.
inst_set_coverage_goal() integer Sets the coverage_goal attribute for the
coverage group instance.
Functional Coverage
7-102
Table 7-7 Predefined Coverage Group Tasks
Task Name Argument Description
type
inst_set_cross_bin_max() integer Sets the cross_bin_max attribute for the
coverage group instance.
load() string Loads data for the coverage group instance
from the Vera functional coverage database.
set_name() string Sets the name of the coverage group instance.
argument:
All predefined coverage group tasks require an argument. The
second column of Table 7-7 indicates the type of the argument for
each task.
Predefined Coverage Group Tasks and Functions for Sample
and Cross Constructs
Vera also provides predefined tasks and functions for the samples
and crosses of a coverage group. You can invoke these methods on
a sample or cross of a coverage group instance.
function integer
coverage_instance_name.member_name.method_name ([arguments]);
task
coverage_instance_name.member_name.method_name (argument);
Functional Coverage
7-103
coverage_instance_name
For stand-alone coverage groups, coverage_instance_name
is simply the name the coverage group instance. For class
embedded coverage groups, coverage_instance_name has
the following form:
object_name.coverage_group_name
Functional Coverage
7-104
Table 7-8 Predefined Coverage Group Methods for Samples or Crosses
Method Name Description
inst_get_cov_weight() Returns the value of the cov_weight attribute for a
sample or cross of a coverage group instance.
inst_get_coverage_goal() Returns the value of the coverage_goal attribute for a
sample or cross of a coverage group instance.
inst_query() Queries for coverage information related to a sample or
cross of a coverage group instance.
query() Queries for cumulative coverage information related to a
sample or cross of a coverage group.
query_str() Queries for the name of the current sample or cross bin
in a query(FIRST)/query(NEXT) or inst_query(FIRST)/
inst_query(NEXT) sequence.
set_at_least() Sets the cumulative at_least attribute (which is used
for computing cumulative coverage statistics).
set_cov_weight() Sets the cumulative cov_weight attribute (which is used
for computing cumulative coverage statistics).
set_coverage_goal() Sets the cumulative coverage_goal attribute (which is
used for computing cumulative coverage statistics).
inst_set_at_least() Sets the at_least attribute for the coverage group
instance.
inst_set_bin_activation() Activates/deactivates a user-defined state/transition bin
for a coverage_group instance.
inst_set_cov_weight() Sets the cov_weight attribute for the coverage group
instance.
inst_set_coverage_goal() Sets the coverage_goal attribute for the coverage group
instance.
set_bin_activation() Deactivates/activates a user-defined state/transition bin
for a coverage_group definition, as well as the instance
on which the function was invoked.
Functional Coverage
7-105
Table 7-9 lists the methods that can only be invoked on a sample
of the coverage_group construct.
Table 7-9 Predefined Coverage Group Methods for Samples Only
Method Name Description
get_auto_bin_max() Returns the value of the cumulative auto_bin_max
attribute for a sample.
inst_get_auto_bin_max() Returns the value of the auto_bin_max attribute for a
sample of coverage group instance.
set_auto_bin_max() Sets the cumulative auto_bin_max attribute (which is used
for controlling cumulative coverage information) on a
sample.
inst_set_auto_bin_max() Sets the auto_bin_max attribute for a sample of a
coverage group instance.
Table 7-10 lists the methods that can only be invoked on a cross
of the coverage_group construct.
Table 7-10 Predefined Coverage Group Methods for Crosses Only
Method Name Description
Functional Coverage
7-106
Activation/Deactivation: User Defined Bins
The Vera functional coverage engine assumes that all user-defined
bins (state and transition) in a coverage_group definition are of
interest to the user, therefore the coverage data is computed and
reported for all user-defined bins. However, there are scenarios
where a user may be interested in only a subset of the user defined
bins.
By default, all user defined bins are considered “active." Since Vera
6.1, functional coverage has provided an attribute based mechanism
for setting all user-defined bins in a coverage construct as “inactive."
Further, Vera 6.1 and up also provides two built-in functions that
select a subset of user defined bins for a coverage construct to be
“active” or “inactive."
Functional Coverage
7-107
The attribute is called “bin_activation,” and the built-in functions are
set_bin_activation() and inst_set_bin_activation().
bin_activation = value_expression;
value_expression
is an OpenVera expression.
The value of the expression will be evaluated when the coverage
group containing the expression is first instantiated.
Functional Coverage
7-108
The functions follow the same invocation syntax as other pre-defined
functions (e.g., query() and inst_query()). The integer value returned
by these two functions is the number of bins acted upon by the
function.
set_bin_activation()
Syntax
command
is either OFF (for deactivating a bin) or ON (for reactivating a bin).
bin_type
is an optional argument, which can be any of the valid bin types:
STATE, BAD_STATE, TRANS, BAD_TRANS. The bin_type
argument controls the set of bins on which the command is to be
applied. Multiple bin types can be specified using the ‘or’ operator
(|). If the bin_type is not specified, the command is applied to all
bins. If specified, the bin_type argument must follow the
command argument.
bin_pattern
is an optional argument that is used to further control the set of
bins upon which the command is applied. It can be any Perl
regular expression. Only those user defined bins of type
bin_type, whose names match the bin_pattern are affected by
the command. If no bin_pattern is specified, then the command
Functional Coverage
7-109
is applied to all bins of the type bin_type. If the bin_pattern is
specified, then it must follow the command and bin_type
arguments.
When a user-defined state/transition bin for a coverage_group
definition is deactivated, the user-defined state/transition bin is taken
out of consideration for cumulative coverage computation and
instance coverage computation for the instance upon which the
function was invoked. Instance and cumulative hit counts are not
updated, and the bins are not considered when computing
cumulative coverage numbers and instance coverage numbers for
the affected instance. Note that if bins are deactivated using this
command, subsequent instantiations of the coverage group will also
have the bins deactivated (irrespective of the value of the
bin_activation attribute for the new instance).
inst_set_bin_activation()
command
is either OFF (for deactivating a bin) or ON (for reactivating a bin).
bin_type
is an optional argument, which can be any of the valid bin types:
STATE, BAD_STATE, TRANS, BAD_TRANS. The bin_type
argument controls the set of bins upon which the command is to
Functional Coverage
7-110
be applied. Multiple bin types can be specified using the ‘or’
operator (|). If the bin_type is not specified, the command will be
applied to all bins. If specified, the bin_type argument must follow
the command argument.
bin_pattern
is an optional argument that is used to further control the set of
bins upon which the command is applied. It can be any Perl
regular expression. Only those user defined bins of type
bin_type, whose names match the bin_pattern are affected by
the command. If no bin_pattern is specified, then the command
is applied to all bins of the type bin_type. If the bin_pattern is
specified, then it must follow the command and bin_type
arguments.
When a user-defined state/transition bin for a coverage_group
instance is deactivated, the user-defined state/transition bin is taken
out of consideration for instance-based coverage computation. The
instance based hits counts and the cumulative hit counts for the
inactive bin are not updated. The inactive bin is not considered when
computing instance-based coverage numbers, and the inactive bin
does not show up in the instance-based coverage report for the
coverage_group instance.
Functional Coverage
7-111
Example 7-50
#define READ 4'b0000
#define WRITE 4'b0001
class Driver {
bit [31:0] addr;
bit [3:0] mode;
coverage_group Cov
{
sample addr;
sample mode
{
state s_read(READ);
state s_write(WRITE);
}
cross add_mode(addr, mode)
{
state s_read(addr == READ);
state s_write(addr == WRITE);
}
sample_event = @(posedge CLOCK);
bin_activation = 1; //all bins active by default
}
}
program test
{
Driver ifc = new;
integer num_bins;
// deactivate any user-defined sample or cross
// STATE bin that starts with s_wr
Functional Coverage
7-112
Coverage Feedback: query()
One of the predefined coverage group functions that is mentioned in
the previous section is the query() function. This function allows
monitoring of the functional coverage statistics during the Vera run,
as well as enabling dynamic reactions to the functional coverage
results. The query() function can be invoked on a coverage group
instance, or a sample or cross of a coverage group instance.
Functional Coverage
7-113
exactly the same as the query() function. We will illustrate this
point with an example after introducing the syntax of the query()
function.
Table 7-11
Command Function
COVERAGE Returns the current coverage number (percentage). You do not pass
any other arguments when using this command.
GOAL Returns a 1 if the coverage goal has been met (0 otherwise). You
do not pass any other arguments when using this command.
NUM_BIN Counts the number of bins of type bin_type.
SUM Sums the counters for all bins of type bin_type.
FIRST Returns the count of the first bin of type bin_type (or -1 for
failure). It starts an iteration sequence through bins of type
bin_type.
NEXT Returns the count of the next bin of type bin_type in the sequence
started with FIRST (or -1 if the sequence is complete). You do not
pass any other arguments when using this command.
SAMPLE Returns the sampled value of the indicated coverage point (sample
construct). This command requires an additional integer argument
which is the depth of the sampled value. This command is discussed
in the following Temporal Coverage section.
Functional Coverage
7-114
The single-argument form of the command applies to all bins. The
additional arguments can be added to narrow the bin selection.
bin_type
The bin_type is any of the valid bin types:
- STATE
- BAD_STATE
- TRANS
- BAD_TRANS
Multiple bin types can be specified using the ‘or’ operator (|).
bin_pattern
The bin_pattern variable is matched against the bin names of the
specified type. It can be any regular Perl expression. Only those
bins whose names contain the bin_pattern are included in the
query. For example, if bin_pattern is “bus,” all bins with “bus” in
their names will be included. If you want to select all bins whose
names begin with a specific string, insert a caret (^) before the
string (such as “^bus”). To select all bins of the specified type
regardless of name, use ".*" as the bin_pattern.
operand
The operand must be one of:
- GT (greater than),
- GE (greater than or equal to),
- LT (less than),
- LE (less than or equal to),
- EQ (equal to),
Functional Coverage
7-115
- NE (not equal to).
hit
hit specifies the number of counter hits to which the query is
compared using the operand. It can be any non-negative integer.
Outside of a coverage declaration we need to qualify query() to get
the appropriate method. For example, to get the query method for
the cp0 coverage object, we would use cp0.query().
Example 7-51
class MyClass
{
integer m_x, m_y;
coverage_group covType
{
sample_event = wait_var(m_e);
sample m_x;
sample m_y {
m_state (0:10);
m_trans (0:10->0:10);
}
cross cc1 (m_x, m_y);
}
}
Functional Coverage
7-116
...
MyClass obj1 = new;
...
• numCrossBins = obj1.covType.query(COVERAGE);
returns the coverage number (coverage percentage) for the
embedded coverage group covType of class MyClass:
• numBins = obj1.covType.query(SUM);
returns the total hit count of all sample and cross bins in
embedded covType coverage group for object obj1.
• done = obj1.covType.m_x.query(GOAL);
returns 1 if the coverage goal associated with the m_x sample in
the embedded coverage group has been met.
• numCrossBins = obj1.covType.cc1.query(NUM_BIN);
returns the number of bins created for the cc1 cross in the
embedded coverage group covType of object obj1
In the following statement, we compute the sum of the bin counts for
state or transition bins with counts greater than 10 each:
Functional Coverage
7-117
You can also set up loops that continue processes until the coverage
goal is met:
while (!obj1.covType.query(GOAL)){...}
Example 7-52
#include <vera_defines.vrh>
class MyClass
{
integer m_var;
coverage_group MyCov
{
sample m_var;
sample_event = @(posedge CLOCK);
cumulative = OFF;
}
}
program simple
{
MyClass obj1 = new();
MyClass obj2 = new();
@(posedge CLOCK);
obj1.m_var = 100;
obj2.m_var = 200;
@(posedge CLOCK);
obj1.m_var = 300;
@(posedge CLOCK);
Functional Coverage
7-118
printf("MyCov.m_var bins: %0d\n",
obj1.MyCov.m_var.query(NUM_BIN));
printf("MyCov.m_var bins: %0d\n",
obj2.MyCov.m_var.query(NUM_BIN));
MyCov.m_var bins: 3
MyCov.m_var bins: 3
obj1.MyCov.m_var bins: 2
obj2.MyCov.m_var bins: 1
If the cumulative attribute is not set to OFF (left at its default value of
ON), the print statements produce the following output:
MyCov.m_var bins: 3
MyCov.m_var bins: 3
obj1.MyCov.m_var bins: -1
obj2.MyCov.m_var bins: -1
Functional Coverage
7-119
When the cumulative attribute is not set to OFF, Vera only maintains
cumulative information for the coverage group as whole. In that case
Vera does not maintain per instance information.
Syntax
Temporal Coverage
To return past values of a coverage group’s coverage point (i.e.,
sample construct of a coverage_group construct) you can use the
predefined query() function of the coverage_group. You can only
retrieve previous values of a coverage group’s coverage point, if the
sample construct associated with that coverage point defines
transition bins (using the trans construct).
Syntax
data_type
can be a bit, bit vector, integer, or an enumerated type.
Functional Coverage
7-120
depth
is an unsigned integer, which specifies the previously sampled
value that is returned. If the sample does not define any transition
sequences, then depth must be less than 2. If the sample defines
transition sequences, then depth must be less than the length of
any of the transition sequences. Otherwise, a simulation error
occurs.
If the command to the query() function is SAMPLE, then the function
must be invoked on the sample of the coverage group instance.
Functional Coverage
7-121
Functional Coverage
7-122
8
Reference Verification Methodology (RVM) 8
Vera's reference verification methodology enables users to realize
the full potential of a coverage-driven, constrained-random flow. In
addition to documenting testbench architecture, modeling, and
coding guidelines, Vera's support of the reference verification
methodology includes testbench building blocks (base class
libraries) that provide a solid foundation for building an advanced
verification environment, and example designs to see the
methodology and building blocks in use.
8-1
Reference Verification Methodology (RVM)
8-2
9
Temporal Assertions and Expressions 9
OpenVera provides three pre-defined classes that enable the
interaction of testbenches with OpenVera temporal expressions and
assertions (OVA). Instances of these classes (i.e., the objects) are
used to:
Table 9-2 gives the definition of the operations that can be performed
on assertions (“reset”, “disable” and “suspend”).
Note:
In this chapter the term “assertion” refers to an assert
declaration in a .ova file, and not to an object of the Vera class
type, OVAAssert. Further, the term “expression” is used here to
refer to either a bool or event declaration in a .ova file.
Actions
OVAEngine
Triggers Event
Assertions File OVAEvent
(*.ova)
Actions
OVAAssert assertion1
Triggers Event
assertion1 OVAEvent
Actions
OVAAssert expression2
Triggers Event
expression2 OVAEvent
Event
OVAEvent
Results
#include <VeraOva.vrh>
program test {
...
OVAEngine ova_engine = new();
...
}
Example 9-1
program {
...
OVAEngine ova_engine = new();
ova_engine.Configure(OVA_QUIET, OVA_FALSE);
ova_engine.Configure(OVA_INFO, OVA_TRUE);
}
ova_engine.DoAction(OVA_RESET);
Example 9-2
OVAAssert ova_check1;
ova_check1 = ova_engine.GetAssert("test.check1");
Note:
The full hierarchical name may vary depending on the simulator.
To obtain an example of the full hierarchical name for your
simulator, use the GetFirstAssert() method of the OVAEngine
class. This returns a handle for the first assertion in the design.
Example 9-3
OVAAssert ova_check[];
string ova_name[];
int i = 0;
ova_check[0] = ova_engine.GetFirstAssert()
while (ova_check[i] != null)
{
ova_name[i] = ova_check[i].GetName();
...
ova_check[++i] = ova_engine.GetNextAssert();
}
ova_check1.DoAction(OVA_RESET);
Example 9-4
ova_check1.EnableCount(OVA_FAILURE);
...
if (ova_check1.GetCount(OVA_FAILURE) > max_fail)
error("Check1 exceeded failure limit.");
Or, to watch for a global reset by the OVAEngine, use the following:
Suspending Threads
OVAEvent objects are normally used to suspend a thread until the
event happens. There are two ways to do this: the object’s Wait() task
or with Vera’s sync() task and the object’s Event variable. For
example, using the Wait() task to wait for a global reset action:
ova_engine_reset.Wait();
sync(ALL, ova_engine_reset.Event);
reason = ova_engine_reset.GetNextEvent();
Example 9-5
ova_engine.DisableTrigger(ova_engine_reset);
Example 9-6
ova_engine.DoAction(OVA_TERMINATE);
Example Testbench
The following example shows a simple testbench that tests a traffic
light controller. The testbench uses OVA objects to test for an error
condition, both lights being green at the same time, and to track the
cycles of the light.
program traffic_test {
OVAEngine ova_engine;
OVAAssert ova_assert_both_green, ova_assert_count;
OVAEvent ova_event_both_green;
// Instantiate OVAEvents.
ova_event_both_green = new(OVA_FAILURE);
repeat(20)
@(posedge traffic.clk);
printf("Light0 cycled %0d times.\n",
ova_assert_count.GetCount(OVA_SUCCESS));
}
Note:
Refer to the Vera installation examples directory README file in
the location of OVA examples within the examples directory.
Getting Started
Summary of Simulation of Vera/OVA
The Vera shell of VHDL simulators (except Scirocco) will contain the
definition of the standard OVAsim wrapper entity.
OVAsim Platform and third party simulator support (see the Vera®
6.2 Installation Guide for version numbers):
Note:
32-bit platforms only
-ova option
The new OVAsim compile option, -ova, has been introduced to the
OVAsim flow.
This option causes Vera to generate a test_shell.v file for the Verilog
simulator, or a test_shell.vhd for the Modelsim Verilog simulator
containing the definition of the OVAsim wrapper.
Limitations
The OVAsim flow for Vera 6.2.0 is not supported for NC-VHDL.
NC-VHDL users will have to use Vera 6.0 in order to simulate OVA.
$ova_stop levels
The commands can also be issued using the format used in task
calls, that is, arguments in parentheses separated by commas.
Module names must be quoted as in the task calls.
To override this default name and location for the report file, use the
-ova_report runtime option and provide the full path name of the
report file.
The report file is replaced with each simulation run. If you want to
save the results, be sure to rename the file before running the
simulation again.
Optional user-defined Expression that failed (only with failure of check assertions)
failure message
2. 2. Compile the design with the Vera testbench and OVA files
-vcs -vera test.v test_shell.v test.ova
5.
vera -ova -sro simv
5.
vera -ova -sro simv
6. Simulate
simv
Note:
-ova should always be after -cmp in the command line
3. Compile the design with the testbench
ncprep test.v test_shell.v ncvlog -f
ncvlog.args ncelab -f
ncelab.args -access +r
Note:
-cmp is not used in the Vera command line
4. Define the OVA runtime flags
setenv OVASIM_RUNTIME_FLAGS “ova_runtime_flags”
vlib work
vlog test.v ttest_shell.v
vera -voa vsim -c test +vera_load=test.vro -pli \
./path_to/veriuser.so
3. Create the working directory, then compile the design with the
testbench
vlib work
vcom test.vrh test_shell.vhd
vera -ova vsim -c cfg_tb ovasim_wrapper
Profiling Setup
The vera_report_profile() system task can be called anywhere in
an OpenVera program. When the task is called, and the runtime
option vera_profile_start is set, a profiling log file is generated,
which reports information up to the task call. Incremental profiling
results are, therefore, provided.
task vera_report_profile(
integer vera_profile_type, string filename);
vera_profile_type:
specifies the type of Vera profiling. The valid value for
performance profiling is VERA_PROFILE.
filename:
is the name of the file in which the profiler data are recorded. If it
contains a directory path that is incorrect, a warning message is
issued, and the profiling results are stored in the default log file
(vera.prof).
Vera provides a set of runtime options that enable and control
profiling.
• vera_profile_start
• vera_profile_limit
• vera_profile_filename
• vera_profile_sort_by_name
These options can be specified either in the command line or in the
vera.ini file.
+vera_profile_start +vera_profile_limit=1000
// vera.ini file
vera_profile_start
vera_profile_limit=1000
vera_profile_filename
overrides the default profiling log file name. The default
performance profiling log file name is "vera.prof."
The following example creates a profiling log file called “my.log”:
+vera_profile_filename=my.log
vera_profile_sort_by_name
sorts the profiling log file entries by the function, task and
program name. By default they are sorted from the highest to the
lowest percentage of runtime used.
task MyPrint(integer a)
{
printf("Inside MyPrint task with a = %d\n", a);
}
program MyTest
{
integer k = 0;
repeat (20)
{
@(posedge CLOCK);
k = k + 1;
MyPrint(k);
DirectC_call(1, 2);
}
@(posedge CLOCK);
}
#include "vera_user.h"
#include "vera_exp_task.h"
======================================================================
Current Simulation Time: 2050
Cycle Count: 21
Process Memory Size: 3908304
Simulation Summary
---------------------------------------------------------------------
Current Percentage Breakdown of Total Time:
HDL Simulator: 0.00
Vera Internal: 8.51
Vera Simulation: 91.49
Function/Task/Program
---------------------------------------------------------------------
Name %Totaltime No. of calls
---------------------------------------------------------------------
DirectC_call 85.11 20
---------------------------------------------------------------------
MyPrint 6.38 20
---------------------------------------------------------------------
MyTest 0.00 1
---------------------------------------------------------------------
---------------------------------------------------------------------
Total: 91.49 41
---------------------------------------------------------------------
vera_profile_type:
specifies the type of Vera profiling. The valid value for memory
profiling is VERA_OBJECT.
filename:
the name of the file in which the profiler data are recorded. If it
contains a directory path that is incorrect, a warning message is
issued, and the profiling results are stored in the default log file
(vera.object).
Vera provides a set of runtime options that enable and control
profiling.
• vera_profile_object
• vera_profile_object_verbose
• vera_object_filename
These options can be specified either in the command line or in the
vera.ini file.
simv +vera_profile_object
// vera.ini file
vera_profile_object
vera_profile_object
enables memory profiling.
Note:
vera_profile_object and vera_profile_object_verbose are
mutually exclusive. If both are specified, vera_profile_object
takes precedence and the unfreed object trace table is not
included.
vera_profile_object_verbose
causes an unfreed object trace table is included in the memory
profiling log file.
Note:
vera_profile_object_verbose and vera_profile_object are
mutually exclusive. If both are specified, vera_profile_object
takes precedence and the unfreed object trace table is not
included.
vera_object_filename
overrides the default filename. The default memory profiling log
file name is "vera.object."
Semaphore/Region/Mailbox
----------------------------------------------------------
Type Max. no. of objects No. of objects
initially allocated currently used
----------------------------------------------------------
Semaphore 2048 5
----------------------------------------------------------
Region 256 10
----------------------------------------------------------
Mailbox 256 2
----------------------------------------------------------
Fork/Join
----------------------------------------------------------
Type No. threads No. threads No. threads Max. No.
created finished remaining per instant threads
----------------------------------------------------------
Fork/Join 50 48 2 35
----------------------------------------------------------
Classes
----------------------------------------------------------
Class Name #object #object #object
allocated freed not freed
----------------------------------------------------------
Packet 11167 167 11000
Using vera_profile_object_verbose
When this option is used, the class name, the number of objects of
this class that have been new’ed and freed, and the stack trace of the
location at which the objects were new’ed are reported for each
location of unfreed objects. In addition, the total number of handles
referencing these objects is recorded.
task mytask() {
Obj1 = new();
Obj2 = new();
Obj3 = new();
Hand1 = Obj1;
Hand2 = Obj1;
Obj1 = null;
Obj2 = null;
}
mytask();
}
Run command:
The first table entry shows that all five class B objects are not freed.
Since none of these objects have been nulled, all object handles
created with new() still exist.
The second table entry shows that one class C object (Obj3) is
unfreed and is reference by one object handle. In this case, the
handle was created when the object was new’ed.
The third table entry shows that one class C object (Obj1) is unfreed
and is referenced by two object handles (Hand1, Hand2). Since
Obj1 has been nulled, the object handle created by new() no longer
exists.
Obj2 has been nulled and has no object handles referencing it.
Therefore, it has been freed and does not show in the table.
To generate a "simv" with Vera, you need to invoke "vcs" with your
verilog model(s) using the correct Vera compile time switch. For
example:
• -vera:
vcs -vera -f vcs_user_options
The -vera switch is used when all HDL signals are bound
statically to the Vera interface.
• -vera_dbind:
vcs -vera_dbind -f vcs_user_options
Note:
Dynamic linking using the libSysSciTaskPIC.a library is not
supported
simv +vera_load=compiled_vera_file.vro
simv -r savef
savef
or
$VERA_HOME/examples/vug_examples/ch21_tb_optimization
Vera may control the calls to the VCS save feature through the use
of Vera’s “hdl_task” feature. In this model, the save call is contained
in a Verilog task that Vera calls to save the simulation.
VSV
Because Vera is unable to restart the remote processes used
during VSV, a system verification that includes connections to
master or slave processes cannot be restarted. A fatal error
message will result.
ISDB
An ISDB database will not remain open across save/restarts. An
ISDB database left open at the time of the save will appear to be
closed at the time of the restart. In order to dump more
information, a new database needs to be created. The signals
and variables to be recorded in the database have to be specified
after the restart.
Debugger
The Vera debugger will not remain open across a save/restart.
That is, if the Vera debugger window is active at the time of the
save, it will not be active upon a restart. To bring up the debugger
window, you must do so manually.
The Veraget_plus_arg option may be used to specifically select
the debugger when the simulation is restarted by specifying this
plus argument in the command line.
For example:
restore_test +arg_check="start_debugger_GUI"
Example 10-7
save_task.v
module SaveTask ;
task save_sim ; begin
$save("restore_test") ;
end
endtask
endmodule
Example 10-8
#include <vera_defines.vrh>
#include "clk_gen.if.vrh"
program test
Example 10-9
vcs clock_gen.v test.vshell clk_gen.test_top.v save_task.v -vera
simv +vera_load=test.vro
restore_test +arg_check="start_debugger_GUI"
Any Vera source file can be made into a VDEO by doing the
following:
2. Provide a class derived from the in-built base class VRO or its
sub class defined in the main program. For example:
class DynTest extends VRO {
virtual task execute();
virtual task cleanup();
task new();
}
class VRO
{
virtual task execute(); // entry point to subprogram
virtual task cleanup(); // wrap up before unloading
}
4. Compile the Vera file into a VDEO using a special compiler switch
-dyn. For example, the following will produce a dynamic.vro file,
which can then be loaded at run-time using the vLoad() system
call:
vera -cmp -dyn dynamic.vr
Loading
The vLoad() system call loads a VDEO file into a running Vera
program.
Unloading
Use the following system call to unload the VDEO:
task vUnloadAll()
The vUnloadAll() call performs the following actions for each VDEO,
in this order
The cleanup() method should also close all open files, and
shutdown any DirectC or UDF code.
Objects shared between the main program and the VDEO will not be
garbage-collected when vUnloadAll() is called; the main program will
have to de reference them before they are garbage-collected.
Execution
A VDEO can be executed by calling its execute task, for example:
class TestObject{
string name;
task new(string _name) {name = _name;}
}
task DynTest::execute()
{
integer i, j = 0;
for( i = 0; i < 5; i++ )
{
@(posedge CLOCK);
// Reference external function
j += check_inp();
}
// Reference external variable
count += j;
}
task DynTest::cleanup()
{
obj = null;
}
Limitations
• All global variables, interfaces, ports and binds must be declared
and defined in the main program, that is, the program loaded at
the start of the simulation using Vera's conventional program
loading mechanism
• The main program must be self-contained, that is, it may not
contain unresolved references to either variables or functions
defined in a VDEO.
Note:
Vera object files compiled with the -g switch are slightly larger
than those compiled without the switch.
Debugger Overview
This section includes a brief overview of the new Vera debugger,
including terminology used throughout this section.
• Menu Bar - The menu bar has drop down menus that
encapsulate various debugger commands and options. To
expand a menu item, highlight it and left-click.
• Toolbar - The toolbar has icons that correspond to debugger
commands. To use a toolbar icon, highlight the icon and left-click.
• Source Window - The source window displays the Vera source
code for the active context.
File
The file commands are:
• Find - find a text string in the active source window matching the
find entry.
• Find next - find the next string in the editor window in focus.
• Goto - move the cursor to the specified line number in the active
source window and highlight that line.
• Customize - Allows you to customize toolbars and menu bars.
Debug Commands
The debug commands are:
Step
Next
Set Value
Enable Breakpoint
Disable Breakpoint
The Stop in Vera debug command halts the Vera simulation and
returns control back the Vera debugger.
Stop in HDL
Options
The Options menu allows you to set debugger preferences and fonts.
• Display limit for array & list elements. This option allows you to set
the number of array elements lists in the watch windows. If more
elements exist, they are not shown in the watch windows.
• Default Radices. This option lets you set the default radix that is
used in displaying variables and expressions in the watch
windows.
• Source window tab size. This option allows you to define the
number of spaces that are inserted when a tab character is used.
Windows
The window commands are:
• About. Displays the release version and release date of the Vera
debugger.
• What’s This. Context sensitive help. Select What’s This and then
point to the button or window for detailed help instructions.
Toolbars
The Vera debugger uses two toolbars which controls file and
simulation options. The toolbars can be undocked and moved, using
the docking bar at the left of the toolbar. The toolbars can be resized
once they are undocked. Figure 10-3 shows the file and debugger
toolbars:
The file toolbar contains 4 icons: what’s this, file open, file close, and
exit. The what’s this icon provides direct access to context sensitive
help. The file open and close features enable the opening and
closing of source files. The exit button exits the debugger and
simulation.
The debug command toolbar contains icons for the following debug
commands:
• Step
• Next
• Continue
Source Window
The source window displays the source code for the active context.
You can manually open files using the open file menu command.
Opened files are displayed in the source window. Files opened by
double-clicking on the filename in the project workspace files tab are
opened in the source window.
Syntax
filename
is the name of the file in which waveform data are stored. The
value can be overridden by the vera_plot runtime option.
variable
is a regular expression or normal string that specifies the
variables to be displayed. Hierarchical path and array elements
can be used in a normal string specification.
For example:
vera_plot("myverafile",MTI,".*", 1);
// plot Vera global variables
vera_plot("myverafile",MTI" "obj.child_obj.i", 0);
// String mode -> plot the variable specified by the
//path: "obj.child_obj.i"
Note:
Debussy supports the filters, scope_depth_limit and size_limit.
Virsim supports scope_depth_limit:
scope_depth_limit
specifies the maximum number of nested scopes that would
be dumped into the fsdb file. The default value of
scope_depth_limit is 5.
To specify an infinite scope_depth_limit, explicitly switch it
off: vera_plot(…”…scope_depth_limit = *”);
Use object_print() to view deeply nested scopes.
size_limit
Mode Description
0 displays variables matching the exact name specified in
the variable argument.
1 displays all variables matching the regular expression
specified in the variable argument.
TYPE
an optional argument that is only supported for VirSim, Debussy
and MTI waveform display tools. Specifies the data types of all
plotable variables in an OpenVera program for waveform plotting.
Multiple data types can be specified. Use a comma (,) to separate
a sequence of data types. The valid data types are:
integer, reg/bit, enum, class, port, array, assoc_array
When “array” is specified, fixed-sized arrays of the other data
types listed are plotted. When “assoc_array” is specified,
associative arrays of the other data types listed are plotted. When
there are multiple vera_plot() calls, the TYPE attributes given in
each call are mutually exclusive and therefore not a union of the
attributes of the previous calls.
vera_plot() Examples
Example 11-1 Using the scope_depth_limit filter
class A { integer data; A next; }
...
A a = new(0);
a.next = new(1);
a.next.next = new(2);
...
a.next.next.next.next.next = new(5);
vera_plot("plot", DEBUSSY, ".*", 1, "scope_depth_limit = 5");
Example 11-6 Plotting associative arrays of bits that are not class members
vera_plot("plot", VIRSIM, ".*",1, "dump=class,assoc_array,
reg");
Example 11-7 Plotting all OpenVera global variables and interface signals
vera_plot("vera",VIRSIM, ".*", 1);
Example 11-8 Plotting the variable or interface signals with the name
IFC_clk;
vera_plot("vera_ifc", VIRSIM, "IFC_clk", 0);
Example 11-9 Plotting the intarr property of the object in the array element
pkt_arry[1]
vera_plot("vera_var", VIRSIM, "pkt_array[1].intarr", 0);
Example 11-10
program test
{
....
vera_plot("myvera", DEBUSSY, ".*", 1); // Calling
//this sets plotting ON
vera_dump(OFF);
repeat (2000) @ (posedge CLOCK);
vera_plot("myvera", DEBUSSY, "str", 0);
// Switches plotting ON globally for all the preceding
//vera_plot() calls including this one
....
....
}
You can invoke the Vera debugger and step through the OpenVera
code, along with plotting the VCD+ file which is periodically read by
the VirSim user interface.
For debug mode, you have to set the “Update” interval in the VirSim
Waveform. This will determine the frequency at which the waveform
is synchronized with the VCD+ file being plotted by Vera.
This plots global variables and objects, including reg/bit, integer, port
instance (port p0 = new(); p0 = b0;) class objects (and sub objects),
fixed array of objects and enums. Local variables (variables in tasks
and functions) cannot be traced.
The Hierarchy window shows several blocks. One has the name of
the program. Beneath the program block is the name of the interface.
Clicking on the program name will show the OpenVera global
variables. You can drag objects into the VirSim Waveform window.
Push the down button that is next to the program name to see
OpenVera class objects, ports, enums. You can drag objects into the
VirSim Waveform window. After the simulation, vera_dump.vpd will
be produced (a .vpd file is a VCD+ file). Use VirSim (vcs -RPP) to
view this file (use VCD+).
3. Compile the all needed Verilog code, including the design, the
testbench, and the OpenVera shell files using MTI-ModelSim
“vlog.”
4. Run an MTI-ModelSim simulation in batch mode.
vsim -c design_test_top -do "add log -r /*; run -a ; quit f"\
+vera_load=design.vro
Limitations
The following limitations apply when plotting for MTI-ModelSim:
integer AAInt[]
AAInt[7] = 1;
Note:
The Debussy FSDB Writer versions 5.0 and 5.1 are shipped with
the Vera installation. The default library is Debussy FSDB Writer
5.0. This library will work with the Debussy GUI version 5.0 or
later. For 5.1 or later, use the following environment variables to
select different versions of the FSDB Writer for the VERA FSDB
plot.
6. Invoke Novas-Debussy.
To view OpenVera signals in Debussy, do the following:
If the Verilog simulator you are using supports updating the dump file
during interactive simulation, you can display Verilog signals along
with OpenVera.
Limitations
The following limitations apply when plotting for Novas-Debussy:
integer AAInt[];
AAInt[7] = 1;
• vera_plot() can be called multiple times but you must use the
same dumpfile name. This means you can have only one FSDB
file per OpenVera program.
• Plotting in the post processing mode only. But waveforms can
be viewed on-line during simulation by using the AutoUpdate
feature of Novas-Debussy which refreshes waveforms
continuously as and when the dump files are updated.
• vera_plot() does not work with OpenVera linked-lists.
• Due to a limitation in Novas-Debussy, OpenVera profiling
features cannot be used in conjunction with Debussy waveform
capture.
• a Vera project file (.proj) (see “Vera Project File” on page 12-2)
• a configuration file (.vcon) for each Vera main program (see “Vera
Configuration File” on page 12-3)
• all relevant Vera object files (.vro) (see “Vera Object Files” on
page 12-11)
Project-Based Testbenches
12-1
Vera Project File
The Vera project file specifies the Vera main programs that are used
in the simulation. A list of configuration and object files must be
declared for each Vera main program.
main module1_name
module1_name.vcon
module1_object1.vro
...
module1_objectN.vro
...
main moduleN_name
moduleN_name.vcon
moduleN_object1.vro
...
moduleN_objectN.vro
Project-Based Testbenches
12-2
Vera Configuration File
The Vera configuration file (.vcon) specifies how signals are
connected between Vera and the HDL design. This makes it possible
for you to develop the Vera source code independently of the actual
interface signal connections. Since direct node connection is carried
out in the .vcon file, the Vera and DUT source code does not have to
be recompiled when the signal connections are changed.
Vera loads the .vcon file and runs it through the preprocessor.
Preprocessor definitions (e.g., #ifdef, #ifndef, #endif) and comments
can be included in the .vcon file.
timescale timescale_statement
clock clock_statement
connect connect_statement
veritask veritask_statement
Timescale Statement
Sampling and drive delays are specified in Vera as integers. The
Vera/simulator interface interprets these integers in the timescale of
the Vera shell. If a specific resolution is needed, you can specify this
with a timescale statement in a Vera configuration (.vcon) file.
Project-Based Testbenches
12-3
The timescale statement is optional. If you do not include a timescale
statement in the configuration file, the Verilog simulator will use the
’timescale value declared in the most recently compiled .v file.
Syntax
integer
is a valid integer value; either 1, 10, or 100.
multiplier
is a time unit multiplier: one of “f”, “p”, “n”, “u”, “m” or “s”
(corresponding to femto, pico, nano, micro, and milli) followed by
"s" (meaning seconds).
There must not be any spaces between the integer and the
multiplier in the .vcon file.
Examples:
timescale 100ps/10ps
timescale 1ns/100ps
timescale 10ns/10ns
The “100ps”, “1ns”, and “10ns” preceding the “/” provide the scale
factor for the delay numbers in the Vera shell, which comes from
the Vera program.
The “10ps”, “100ps”, and “10ps” following the
“/” affects the maximum granularity of the simulation time step.
Note:
VHDL bridges ignore the integer and multiplier to the right of
the “/” character.
Project-Based Testbenches
12-4
Clock Statement
The clock statement creates a clock generator in the Vera shell file,
which drives the specified Vera clock.
Syntax
clock_name
is the name of the Vera clock. It is specified as either
SystemClock or interface_name.clock_name.
period_number
specifies the cycle length for the clock in the timescale of the
shell.
offset
sets the delay before the clock changes for the first time. The
default is 0.
initial_value
is the clock start value (either 0 or 1). The default is 0.
Clock Port
If a clock signal is not generated by a clock statement and it is not
connected to any HDL node through a connect statement (see
Connect Statement on page 12-6), the generated Vera shell file
includes an input port for that clock signal.
Project-Based Testbenches
12-5
Clock Alias Statement
The clock_alias statement aliases a Vera clock to another Vera
clock.
Syntax
clock_name1
is the name of the Vera clock to be made an alias.
This clock cannot also have a clock statement because two
clocks would then be assigned to the same clock name. Such an
assignment would generate compilation errors.
clock_name2
is the name of the Vera clock to which the clock is to be made an
alias.
Connect Statement
The connect statement connects a Vera interface signal or interface
clock to a specified HDL node.
Syntax
or
Project-Based Testbenches
12-6
Note:
The connect statement does not end with a semi-colon (;).
where:
direction
is a direction; one of: in, input, out, output, or inout:
- in or input specifies clocks and signals into Vera from the DUT.
- out or output specifies clocks and signals out from Vera into the
DUT.
- inout specifies bidirectional signals.
The direction is checked against the direction specified in the
interface. Mismatches result in compilation errors.
If the direction is not specified, the direction is taken from the Vera
interface.
The direction for Vera clocks is ignored.
vera_name
is the name of the Vera signal you are connecting to the DUT. The
format for the name is interface_name.signal_name, where the
interface and signal are specified in the interface specification.
HDL_path_or_type
is the name of the HDL node to which the Vera signal is being
connected. It should include the HDL hierarchical path. This
string overrides any hdl_node option in the interface signal
definition.
If the string specifies only an HDL_type, or if the
HDL_path_or_type string is blank, the interface signal becomes
a port-connected interface signal.
Project-Based Testbenches
12-7
Note:
A string specifies an hdl_type by enclosing it in curly
braces, {}. Also, the interface signal need not have had an
hdl_node phrase in its original specification.
skew
specifies the skew type, either: iskew (input skew) or oskew
(output skew). The default is no skew.
skew_value
is the length of the skew type specified. If you specify input skew,
the skew_value should be 0 or negative. If you specify output
skew, the skew_value should be 0 or positive. The default
skew_value is 0.
surrx_token
is a valid surround-by-X token: surrx, surrxR, surrxF, surrxD, or
surrxZ.
time_to_x
specifies the time after the driving clock edge that elapses before
the signal is driven to X. This value must be an integer greater
than 0. The time units used for the delay are the same as the HDL
timescale being used.
time_to_value
specifies the time after the driving clock edge that elapses before
the signal is driven to its final value. This value must be an integer
greater than 0 and greater than the time_to_x value. The time
units used for the delay are the same as the HDL timescale being
used.
Project-Based Testbenches
12-8
Note:
The SystemClock should NOT be defined as an inout signal
using the connect command. Define the SystemClock using the
clock command.
Veritask Statement
The veritask statement maps a Vera task to an HDL task. It overrides
the hdl_task statement in the Vera sources.
Syntax
vera_task_name
is the name of the Vera task being mapped to an HDL task.
HDL_task_name
is the HDL name of the task. It should include the HDL hierarchal
path.
To use the veritask statement, you must declare the hdl_task in the
source code using an arbitrary pathname. Then, in the configuration
file, you must specify the actual task pathname.
Project-Based Testbenches
12-9
Given this hdl_task declaration, the configuration file can include this
veritask statement:
Syntax
simulator
is the name of the simulator: mti, nc-vhdl, or sro.
output_filename
specifies an optional alternative output file name for the
generated .vcon file. The default file name is filename.vcon.
For example, the command:
vera -cmp -verilog -vcon test.vr
Project-Based Testbenches
12-10
vera -cmp -verilog -vcon test.vr new_test
where the file program.vr contains the program block for the
module.
Project-Based Testbenches
12-11
4. Create an overall project file that contains information on all
modules necessary for the simulation.
5. Create Vera shell files for each Vera module listed in the project
file:
vera -proj file.proj
The Vera shell files are used during the Verilog or VHDL
compilation. The Vera shell file is generated from the .vro files
created when the Vera source code is compiled.
7. Run the simulation with the vera_pload runtime option (as a plus
argument in the command line, or as an option in the vera.ini
file):
simv +vera_pload=proj_name.pro
This procedure eliminates the need for a test-top file that instantiates
the Vera shell modules. However, you can still use the test-top file
approach with a project-based approach by deliberately not
specifying connections for Vera interface signals in the .vcon file.
Unconnected signals are automatically listed as ports in the Vera
shell module. The Vera shell module must then be connected to the
rest of the simulation by instantiation.
Note:
It is possible to mix the two approaches in a single project file
where only some testbench modules require instantiation.
Project-Based Testbenches
12-12
Main-Specific Plus Arguments
Runtime options can be specified in the project (.proj) file using the
same format that the vera.ini file uses. Runtime options that are
specified in the project file apply only to the specific main block in
which they are specified.
These runtime options are ignored if they are specified within the
project file:
vera_mload_define
vera_pload_define
vera_load
vera_mload
vera_pload
vera_enable_mprint
Example 12-1
main test1
test1.vro
test1.vcon
vera_random_seed = 100
user_runtime_option = "string value for test1"
main test2
test2.vro
test2.vcon
vera_random_seed = 200
user_runtime_option = "string value for test2"
Project-Based Testbenches
12-13
Instance-Specific Properties
When more than one instance of a given main block is instantiated
in a single simulation, Vera assigns unique instance ID numbers to
each instance. The instances are numbers sequentially, starting at 0.
runtime_option_name[instance_number] = runtime_option_value
The instance number can be used with any of the valid runtime
option definition formats.
Example 12-2
main test1
vera_random_seed[0] = 100 // applies to 1st instance of test1
vera_random_seed[1] = 200 // applies to 2nd instance of test1
vera_random_seed[2] = 300 // applies to 3rd instance of test1
Project-Based Testbenches
12-14
Mixed HDL Support
Vera project-based configuration supports mixed design language
(Verilog and VHDL).
Project-Based Testbenches
12-15
Project-Based Testbenches
12-16
13
Testbenches for Verification Intellectual
Property 13
Vera offers a Vera Core license that allows an IP creator to develop
verification components, such as a bus master or a bus slave, that
can be packaged to run without the user having a Vera license. The
packaged IP is referred to as Verification Intellectual Property (VIP).
This chapter describes the VIP files, the contents of VIP packages
and their use, and how to create VIP in the following sections:
• Verification IP Files
• Setting Up a VIP Installation
• Typical VIP Contents
• Writing a VIP Testbench
• Creating Verification IP
An example VIP vendor tree and user directory tree are included in
the Vera installation in the directory $VERA_HOME/examples/VIP.
Example 13-1
vera -vip mod.vr
Note:
A Vera CORE license is required to generate a vip file.
If your VIP contains protected files, the directories will contain files
with different extensions:
1. Install the VIP package. This step compiles the Vera libraries
onsite and installs the .vro files into the vendor tree (see
Figure 13-3 on page 13-7).
2. Set any environment variables and the path for the vendor.
Vendor environment variables are used by models to automate
the loading of VRO and DirectC libraries (see “Automated
Loading” on page 13-12).
- Target simulator
- Bus widths
- Optional interfaces
• Create a vendor-specific sub-directory in the testbench directory.
• Install header files for the model’s interfaces and bindings.
• Install a sample Vera testbench. The testbench should contain a
program declaration and demonstrate how to create, connect,
and control the model.
• Install a sample makefile that compiles the sample testbench,
compiles the shell, and runs the target simulator.
Figure 13-1 shows the layout of the testbench directory after the
model setup has been completed (‘$cwd’ is used as a shorthand to
refer to your testbench directory).
• Vera sources for all verification components: .vr and .vri (header)
files.
• Vera DirectC libraries for all platforms: dynamically linked object
files; for example, Solaris .so files
Vera object (.vro) files are not shipped; rather, they are generated as
part of the installation procedure.
Figure 13-3 shows the detailed layout of the Vera sub-tree. This
sub-tree is partitioned into suite-specific trees and a common tree.
Each suite contains all the Vera sources for a family of verification
components (amba, pcix, ethernet, and so on).
The examples, include, and src sub-trees of each suite are fully
populated with Vera files:
Generated Files
The files in the src directory are compiled into the lib directory during
installation. If the models support many configurations, the
compilation of configurable sources may be deferred until the model
installation phase. For example, the site-wide installation may
compile only utility libraries, and the installation for each model will
compile the model files on demand.
Header Files
Typically, at least two header files are installed in the include
directory for each model configuration:
model.vri
contains the class and port declarations for the model.
model_load.vri
automates the loading of the model’s VRO and DirectC libraries
using the vendor’s environment variables (see “Automated
Loading” on page 13-12).
A third header may be provided but it should not be located in
the include directory:
model_ifc.vri
contains the interface and bind declarations for the model.
Because you may want to edit the interface declarations to, for
example, modify skew settings and add hdl_node connections, this
file is not located in the include directory but will have been installed
in the testbench directory during the model installation phase.
The testbench creates the models, connects them to the HDL via
port variables, and controls them via method calls. A single shell is
created because a single Vera program is used for both the
testbench and models. After the testbench has been written and
compiled, the HDL simulation is executed.
Automated Loading
As mentioned earlier, each model is responsible for loading its own
object code (.vro) files and DirectC libraries. Models self-load by
declaring special attributes within the Vera program file. For
example, using attributes, load files can be specified in the program
itself:
program testbench {
...
}
When the HDL simulation begins, the simulator calls a foreign task
inside the shell to load the files. The code shown above creates a
shell that loads two files, a local file testbench.vro and a file in the
vera_attribute RTIME_UDF_LIST_pci = \\
"$ABC_HOME/$VERA_PLATFORM/pci.so";
program testbench {
...
}
The attributes for loading all the object code (.vro) files and DirectC
libraries used by a model should be placed inside the model’s .vri file;
in this example, abc_Xyz8.vri.
# define INSIDE_PROGRAM_FILE
# include "abc_Xyz8.vri"
# include "abc/abc_Xyz8_ifc.vri"
program testbench {
...
}
vera_attribute RTIME_LOAD_LIST_abc_Xyz8 =
"$ABC_HOME/vera/Xyz8/lib/$VERA_VERSION/Xyz8.vro";
vera_attribute RTIME_UDF_LIST_abc_Xyz8 =
"$ABC_HOME/$VERA_PLATFORM/lib/Xyz8.so";
vera_attribute RTIME_LOAD_LIST_abc_utils =
"$ABC_HOME/vera/common/utils.vrl";
#endif //abc_UTIL_VRL
#endif //INSIDE_PROGRAM_FILE
switch(s)
{
case "quiet": ...
case "normal": ...
case "verbose": ...
}
C Testbenches
A C testbench controls Vera models using the Vera C-API. The API
enables C code to call exported tasks inside each Vera program.
The VIP contains a ‘hook’ that calls your C code at the start of
simulation so that it can collect handles to the exported tasks. The
hook is a designated DirectC library, and the Vera code will look
similar to this:
task $hook();
program MyModel
vera_attribute RTIME_UDF_LIST_hook =
"$ABC_HOME/$VERA_PLATFORM/hook.so";
{
$hook();
...
}
HDL Testbenches
An HDL testbench controls Vera models by calling wrapper tasks
inside each Vera shell. In turn, the wrappers execute tasks exported
from the Vera model. Each Vera model connects to the HDL via a
shell module and runs a separate Vera program. The programs
communicate with their shell via PLI. Figure 13-6 shows a possible
SOC configuration for an HDL testbench.
vera_attribute SHELL_MAX_INST = 4;
The standalone and class library approaches are not exclusive. You
can mix standalone Vera models that communicate through an HDL
task interface with other models that are created as class objects.
For example, Figure 13-7 shows how a PCI model has been brought
into the testbench as a class object, but the other Vera models
remain independent, only communicating through HDL tasks and
signals.
Creating Verification IP
Vera CORE enables full access to all the functionality of Vera. The
VIP creator can ship model libraries or full testbench environments.
As the user cannot change the VIP code the usual approach is to
ship model libraries, which consist of user interfaces (API), functional
coverage, and monitors. The VIP testbench can also be included as
a compliance suite.
There are two ways to connect the user’s environment to the VIP
creator’s environment:
vera_shell vshell(
.SystemClock ( SystemClock ),
.memsys_clk ( clk ),
.memsys_reset ( reset ),
.memsys_busAddr ( busAddr ),
.memsys_busData ( busData ),
.memsys_busRdWr_N ( busRdWr_N ),
.memsys_adxStrb ( adxStrb ),
.memsys_request ( request ),
.memsys_grant ( grant ),
.memcntlr_probe_clk ( clk),
.vendor_name_cpu_clk(clk),
.vendor_name_cpu_reset(reset),
.vendor_name_cpu_busAddr(busAddr),
.vendor_name_cpu_busRdWr_N(busRdWr_N),
.vendor_name_cpu_adxStrb(adxStrb),
.vendor_name_cpu_request(request),
.vendor_name_cpu_grant(grant)
);
2. hdl_node method
The path of the connection is contained in the Vera interface
declaration.
a. The user has Vera. Edit the hdl_node directly in the Vera
interface. This is acceptable because a Vera compiler license
will be checked out to compile the changes.
b. The user does not have Vera. Use a #define clause as
illustrated below:
#define HPATH “my_test_top
interface myInterface {
Note:
The quote (“) must be part of the define statement because in
the case of “HPATH.reset” HPATH will be treated as part of a
string and no macro substitution would be made.
When using the hdl_node method, the following construct can be
used to connect the system clock (note that it must be positioned
outside the interface definition):
interface myInterface {
...
input clk CLOCK;
}
hdl_node CLOCK "I_clk";// SystemClock Connection
This section describes the steps in building the VIP model. The
description of the procedure for creating a VIP model is based on a
practical example using a simple CPU BFM. The BFM model is
available in the Vera tutorial, see $VERA_HOME/tutorial.
task writeOp (
(bit [8:0] addr = 9'h1ff),
(bit [8:0] dat = 9'h1ff)
);
task request_bus ( );
task release_bus ( );
• classes
• ports
• binds
• interfaces
• attributes
• coverage_groups
• global enums
• global functions
• global tasks
• global variables
Connecting to HDL
This example uses the hdl_node method of HDL connection. A
#define statement must be used to hold the path to the user’s DUT,
and the user edits the path. You should automate this with scripting
during the installation of the model.
interface creator_name_cpu {
input clk CLOCK hdl_node HPATH.clk”;
input reset INPUT_EDGE INPUT_SKEW hdl_node HPATH.reset”;
. . .
}
hdl_node CLOCK HPATH.SystemClock”;
#ifndef CREATOR_NAME_CPU_LOAD_VRI
#define CREATOR_NAME_CPU_LOAD_VRI
vera_attribute RTIME_LOAD_LIST_cpu = “cpu.vro”;
#endif
Your installation script must define the path to this file name or the
user can manually edit the filename in quotes. This is one item that
can be changed in a .vrip file.
Note that the main program file name is not supplied within the load
list because the model will be available to both Vera and HDL users.
#include “creator_name_cpu_load.vri”
vera_attribute RTIME_LOAD_LIST_main = “cpu_main.vro”
program cpuStandalone {
….
}
#ifndef DEVELOPMENT_MODE
#include “filename.vri”
#else
#include “filename.vrip”
#endif
Then while developing the models, you can compile them as follows:
#ifndef CREATOR_NAME_CPU_VRI
#define CREATOR_NAME_CPU_VRI
#endif
The first time the file is included, the #ifndef clause will evaluate true,
define the unique name, and include the header. The next time it is
called, it will evaluate false and nothing will be included.
You should use -vip for all header files and –vip –prot for all source
files. For debugging purposes do not encrypt header files. When
encrypted files are included in a user’s testbench debugging is
disabled.
Deliverable Files
You will need to supply the user with the following files:
modelName.vri
contains all the model-level define statements and class
definitions. It is included in the user testbench for access to the
model.
To create this file, create a header file with the –H switch and then
copy its contents into the .vri file.
Naming Conventions
When models are distributed as class libraries they share the same
global name space and the name of each model must be unique.
• classes
• ports
• binds
Version Checking
VIP model code must check whether a compatible version of Vera is
being used. The check can be performed either with a shell script at
compile time or with preprocessor directives at runtime.
The value of the variable is exactly the same as the output of the
“vera -v” command. Although $VERA_VERSION can be used to
perform conditional loading, it is only meant to be used in printing
informative messages. You should use the VERA_VMC variable for
conditional loading.
vera_shell_param vera_load_my = \\
“$HOME/vros/$VERA_VMC/my.vro”
__VERA_VERSION__= 6
__VERA_MINOR__ = 2
__VERA_PATCH__ = 0
# if (__VERA_MAJOR__< 6 ||
(__VERA_MAJOR__== 2 && __VERA_MINOR__< 1))
# error Xyz8 requires Vera version 6.1.0 or newer
# endif
task abc_Xyz8::new()
{ if (__VERA_MAJOR__< 6 ||
(__VERA_MAJOR__== 2 && __VERA_MINOR__< 1))
{
error("Xyz8 requires Vera version 6.2.0 or newer");
exit(1);
}
...
}
When the site-wide installation script compiles the Vera source code
(.vr) file for the abc_Xyz8 class it must define the
INSIDE_ABC_XYZ8_VR symbol:
# include “abc_Xyz8.vri”
// Include local files with interface declarations
// Interface and binds for first instance
# include “abc/abc_Xyz8_ifc1.vri”
// Interface and binds for second instance
#include “abc/abc_Xyz8_ifc2.vri”
program testbench {
abc_Xyz8 u1 = new(abc_Xyz8_bind1);
abc_Xyz8 u2 = new(abc_Xyz8_bind2);
...
}
The port declarations and class declarations are included only once
by the abc_Xyz8.vri file so each instance of the model is created with
the same port type.
Example 13-7 shows a sample interface file for the first instance:
interface abc_Xyz8_ifc1 {
inout [7:0] AD PSAMPLE abc_SAMPLE_SKEW PHOLD abc_DRIVE_SKEW;
...
}
# undef abc_SAMPLE_SKEW
# undef abc_DRIVE_SKEW
# endif //abc_Xyz8_ifc1_VRI
You can edit the interface file to change the skews, add hdl_node
constructs, and modify the bindings.
IN-1
+vera_vros 3-38 randc 5-83
=> 5-21, 5-35, 5-36 boundary() 5-84
pre_boundary() 5-84
break
A usage in VSG 5-94
-alim 3-24 break and continue
-ansi 3-6 break 5-94
ANSI mode 3-6 continue 5-94
-aop 3-6
argument
external default 3-42
C
case
array_name.size() 5-24
usage in VSG 5-92
syntax 5-25
case statements 5-92
arrays
setting maximum number of elements 3-24 -cfg 3-25
assertion classes 9-2 cleanup() 10-26
assertion operations 9-2 clock 12-5
assoc_size 5-26, 5-27, 6-6 clock_alias 12-6
syntax 6-6 compilation errors
attributes for methods setting maximum number 3-18
assoc_size 6-6 compilation options 3-4–3-26
big_endian 6-5 compile options
bit_normal 6-5 general 3-2
bit_reverse 6-5 compiler options
dynamic_size 6-6 -alim 3-24
little_endian 6-4 -ansi 3-6
-aop 3-6
-cfg 3-25
B -D 3-8
bad_trans -dep_check 3-4, 3-9
not 7-42 -dyn 3-9
big_endian 6-4 -F 3-9
bin_activation 7-108 example 3-10
-f
bit_normal 6-4
syntax 3-9
bit_reverse 6-4, 6-5 -g 3-13
boundary conditions 5-82–5-85 -H 3-13
boundary() 5-82, 5-83 -h 3-13
post_boundary() 5-84 -HC 3-15
pre_boundary() 5-84 -HCnu 3-16
rand 5-83 -Hnu 3-16
IN-2
-hnu 3-16 constraint blocks, external 5-30
-i 3-17 constraint_mode() 5-22
-i_skew 3-17 syntax 5-72
-ip 3-22 constraints
-local 3-18 array aggregates
-max_error_number 3-18 syntax 5-49
-no_dep_graph 3-18 array_name.size() 5-24
-no_warn_null 3-19 default 5-58
-print_deps 3-19 distribution 5-33
-q 3-21 global 5-38
-random_compat 3-22 if-else 5-37
-shell 3-25 implication 5-35
-systemc 3-22 continue
-tdef 3-22 syntax 5-94, 5-97
-timescale 3-25 usage in VSG 5-94
-top 3-26 -cov_report 7-89
-tradition 3-22 coverag_group
-vlog 3-26 embedded
-widen_args 3-23 syntax for defining 7-4
-y 3-23 syntax for instantiating 7-8
compiler switches embedded syntax for disabling 7-9
-c 1-8 syntax for defining 7-4
-get_plus_arg 10-20 coverage
-I 1-8 attributes
-print 3-3 bin_activation, restrictions on 7-75
-t 1-8 closed-loop analysis 7-3
-V 3-4 coverage test grading
-vcon 3-4 syntax 7-95
configuration file coverage_backup_database_file() 7-88
clock 12-5 coverage_load() 7-91
clock_alias 12-6 single coverage_group 7-91
connect 12-6 coverage_save_database() 7-89
template for 12-10 coverage_set_database_file_name() 7-88
timescale statement 12-3 cross bins
veritask 12-9 precedence semantics 7-48
connect 12-6 cumulative 7-76
constraint block expressions
variable order interface signal
syntax 5-41 bind 7-75
constraint blocks 5-29 used for 7-74
inheritance 5-31 expressions, restrictions on 7-74
generating HTML report
set membership 5-32
IN-3
syntax 7-93 coverage declarations
get_coverage() 7-79 attribute definitions
get_inst_coverage() 7-79 syntax 7-47
grading set of database files ignored
unix command 7-97 syntax 7-47
inst_query() 7-113, 7-118 illegal declarations
example 7-118 m_bad_trans 7-43
instance names not_trans 7-42, 7-43
auto-naming t_not_trans 7-42
example 7-97 illegal state declarations 7-34
user-specified names bad_state 7-34
syntax 7-98 syntax 7-47
instance-based 7-76 m_bad_state 7-34
instantiation not state 7-34
explicit 7-8 multiple state bin declarations 7-33
loading coverage data m_state 7-29
coverage_instance() 7-92 state declarations
loading embedded coverage data not 7-31
coverage_instance() 7-92 transition declarations
open-loop analysis 7-3 all state transition argument 7-38
predefined function conditional 7-39
cross constructs m_trans 7-37
syntax 7-103 multiple transition states 7-36
sample constructs not trans state specification 7-38
syntax 7-103 transition bin names 7-39
predefined tasks wildcard 7-40
cross constructs wildcard state declarations 7-33
syntax 7-103
wildcard 7-33
sample constructs
coverage group attributes
syntax 7-103
async 7-66
syntax 7-101
example 7-66
query() 7-99
at_least 7-81
invoked on 7-116
auto_bin_max 7-81
used to 7-113
bin_activation 7-81, 7-108
what not used to 7-113
collect 7-82
query_str() 7-101
cov_comment
syntax 7-120 syntax 7-82
reporting
cov_comment, restrictions on 7-75
-cov_report 7-89
cov_weight 7-82
cov_text_report 7-90
coverage_goal 7-83
temporal
cross_auto_bin_max 7-83
query()
syntax 7-120 cross_bin_max 7-83
IN-4
cross_num_print_missing 7-84 data packing and unpacking 6-1
cumulative 7-84 property attributes 6-4
cumulative, restrictions on 7-75 -dep_check 3-4, 3-9
overlap_state 7-84 -y 3-23
overlap_state, restrictions on 7-75 dist 5-34
overlap_trans 7-84, 7-85 constraint expression 5-30
overlap_trans, restrictions on 7-75 -dyn 3-9, 10-24
coverage group atttributes dynamic_size 5-27
bin_activation
example 7-111
set_bin_activation() E
example 7-111
environment variables
coverage_backup_database_file() 7-88
VERA_OVERWRITE 10-19
coverage_group 7-3 VERA_SIMULATOR 3-24
embedded VERA_WIDEN_ARGS 3-23
explicit instantiation 7-8
exit_status 2-6
implicit instantiation 7-11
expression
predefined functions 7-100, 7-101, 7-102,
distribution
7-103, 7-104, 7-105, 7-106
syntax 5-33
syntax 7-99
set
predefined tasks 7-102
syntax 5-32
coverage_group_attributes
external declarations 3-41
at_least 7-77
cross_auto_bin_max 7-59
example 7-60 F
syntax 7-60
cross_num_print_missing 7-55 -F 3-9
example 7-56 example 3-10
syntax 7-56 -f
syntax 3-9
coverage_instance() 7-92
foreach
coverage_load 7-91
constraints 5-43
coverage_point
syntax 5-44
definition 7-14
functions
coverage_save_database() 7-89 external default arguments 3-42
coverage_set_database_file_name() 7-88 external functions 3-41
crosses
predefined coverage group methods 7-106
G
-g 3-13
D general options
-D 3-8 -help 3-2
IN-5
-pp 3-3 I
-print 3-3
-I 1-8, 3-16
-proj 3-3
-rvm_version 3-3 -i 3-17
-tem 3-3 -i_skew 3-17
-v 3-3 if-else
-vmc 3-4 production definition 5-91
get_at_least() 7-104 usage in VSG 5-91
get_auto_bin_least() 7-100 ignored 7-47
get_auto_bin_max() 7-100, 7-101, 7-102, implication constraint
7-103, 7-104, 7-105, 7-106 syntax 5-35
get_cov_weight() 7-104 in
constraint expression 5-30
get_cov_weightt() 7-100
set operator 5-32
get_coverage() 7-79
including files 1-8
get_coverage_goal() 7-100, 7-104
inistate() 5-7
get_cross_bin_max() 7-100, 7-106
inst_get_at_least() 7-100, 7-104
get_cycle() 7-74
inst_get_auto_bin_max() 7-100, 7-106
-get_plus_arg 10-20
inst_get_collect() 7-100
get_plus_arg() 3-39
inst_get_cov_weight() 7-100, 7-105
get_time() 7-74
inst_get_coverage_goal() 7-100, 7-105
getstate() 5-9
inst_get_cross_bin_max() 7-100, 7-106
GUI debbugger
inst_query() 7-99, 7-100, 7-105
Vera 1-9
inst_set_at_least() 7-102, 7-105
inst_set_auto_bin_max() 7-102, 7-106
H inst_set_bin_activation 7-100
-H 3-13 inst_set_bin_activation()
-h 3-13 syntax 7-110
-HC 3-15 inst_set_collect() 7-102
-HCnu 3-16 inst_set_cov_weight() 7-102, 7-105
HDL_filename.v inst_set_coverage_goal() 7-102, 7-105
definition of 1-9 inst_set_cross_bin_max() 7-103, 7-106
hdl_node 2-18 installation guide
header files 3-13 location of 2-4
-help 3-2 instance-specific
plus arguments 12-14
-Hnu 3-16
interface specifications
-hnu 3-16
generating ASCII text files 3-17
-ip 3-22
IN-6
K N
keywords -no_dep_graph
big_endian 6-5 -y 3-23
bit_normal 6-5 -no_depth_graph 3-18
bit_reverse 6-5 NO_VARS 5-84
little_endian 6-4 -no_warn_null 3-19
packed 6-5 null
prod 5-95 object handles 6-8
prodget 5-97
prodset 5-96
randcase 5-12 O
randseq 5-86 object files
unpacked 6-5 Vera 12-11
OK_LAST 5-84
L OpernVera assertion classes 9-2
OpernVera assertion operations 9-2
line wrapping 3-3
little_endian 6-4
load() 7-103 P
-local 3-18 pack() 6-6, 6-8
example 6-10
post_pack() 6-10
M pre_pack() 6-10
m_state 7-29 syntax 6-7
m_trans 7-37 packed 6-4
mailboxes packed bit_normal, 6-5
setting maximum number 3-35
packing and unpacking
main-specific pack() 6-6
plus arguments 12-13 property attributes 6-4
manual seeding unpack() 6-8
srandom() 5-10
packing methods 6-6
-max_error 3-18 attributes for
-max_error_number 3-18 big_endian 6-5
-mhdl 2-21 bit_normal 6-5
mixed HDL 2-17 bit_reverse 6-5
SRO_MX 2-22 little_endian 6-4
VCS_MX 2-17 plus arguments
MTI VHDL, compiling with 9-25 plus argument requests
CHECK 3-39
HNUM 3-39
IN-7
NUM 3-39 FIRST 7-114
STR 3-39 GOAL 7-114
post_boundary() 5-84 NEXT 7-114
syntax 5-85 NUM_BIN 7-114
post_pack() 6-10 SAMPLE 7-114
post_randomize() 5-23 SUM 7-114
post_unpack() 6-10 query_str() 7-101, 7-105
-pp 3-3 quiet mode 3-21
-Pprinter 3-3
pre_boundary() 5-84 R
syntax 5-84
rand 5-24
pre_pack() 6-10
rand_mode() 5-22, 5-70
pre_randomize() 5-23
syntax 5-70
pre_unpack() 6-10
rand48() 5-16
preprocessor options
randc 5-24
-I 3-16
randcase 5-12–5-13
-print 3-3
random number generators
-print_deps 3-19
getstate() 5-9
-y 3-23
inistate() 5-7
printing Vera files 3-3 rand48() 5-16
prodget() 5-97, 5-98 random() 5-14
prodset() 5-96 setstate() 5-8
production definitions 5-87 srandom() 5-7
production items 5-87 urand48() 5-16
weights 5-87 urandom() 5-15
production weights 5-90 urandom_range() 5-17
profiler, memory 10-7 random numbers
-proj 3-3 +vera_random_v0 3-31
project files setting seeds at compile time 3-38
#define 12-2 random() 5-14, 5-93
#include 12-2 -random_compat 3-22
main 12-2 random_compat
property attributes vera_restore_rng_state() 5-12
vera_save_rng_state() 5-12
randomize() 5-18
Q syntax 5-65
-q 3-21 randomize() with 5-20
query() 7-74, 7-101, 7-105, 7-113 syntax 5-66
query() commands randseq 5-86, 5-89, 5-94, 5-99
COVERAGE 7-114 syntax to define block 5-86
IN-8
regions syntax 7-109
setting maximum number 3-38 set_cov_weight() 7-102, 7-105
repeat set_coverage_goal() 7-102, 7-105
usage in VSG 5-93 set_cross_bin_max() 7-102, 7-106
repeat loops 5-93 set_name() 7-103
random() 5-93
setstate() 5-8
-rvm_version 3-3
-shell 3-25
shell file
S Vera 1-6
solve 5-41
sample
syntax 7-14 srandom() 5-7
samples state
predefined coverage group methods 7-106 not 7-31
samples or crosses wildcard 7-33
predefined coverage group methods 7-104 stream generation
sampling events, types of production definitions 5-86
clock edge stream generator
syntax 7-62 randseq 5-86
general task calls subroutines
example 7-65 declaring external 3-41
ova events external default arguments 3-42
example 7-64 external definitions
signal edge declaring external subroutines 3-41
syntax 7-62 external subroutines 3-41
signal edges surround-by-X 12-8
clock edge SystemC
example 7-62 calling OpenVera tasks from 2-30
sync events calling tasks from OpenVera 2-30
example 7-63 creating an interface 2-26
syntax 7-63 flow 2-25
variable changes running with OpenVera 2-27
example 7-62
-systemc 3-22
syntax 7-62
SystemClock 1-7, 12-9
save/restart 10-17, 10-18
semaphores
setting maximum number 3-38 T
set expression 5-32
-t 1-8
set_at_least() 7-102, 7-105 tasks
set_auto_bin_max() 7-102, 7-106 external default arguments 3-42
set_bin_activation 7-101 external tasks 3-41
set_bin_activation()
IN-9
-tdef 3-22 urandom_range() 5-17
-tem 3-3
template generator 1-7
invoking 3-3
V
-tem 1-7 -V 3-4
template file, blank 2-8, 2-15 -v 3-3
template options value passing
-c 1-8 value declaration 5-95
-I 1-8 prod 5-95
-t 1-8 value passing functions
test_top files prodget() 5-96
generating test_top files 3-26 prodset() 5-96
testbench properties randseq blocks 5-96
Vera properties variables
vera_profile_start 3-31 forward referencing 3-41
text macros 3-8, 3-35 referencing 3-41
timescale .vcon
statement 12-3 SystemClock 12-5
switch 3-25 .vcon file, direct connection using 12-3
-top 3-26 Vera project file 12-2
-tradition 3-22 Vera runtime options
trans 7-35, 7-42 +enable_solver_trace 3-34
all 7-38 +enable_solver_trace_on_failure 3-34
not 7-38 +vera_continue_on_error 3-28
wildcard 7-40 +vera_debug_on_error 3-28
+vera_debug_on_start 3-29
+vera_directc 3-34
U +vera_stop_on_end 3-32
unpack() 6-8, 6-10 +vera_stop_on_error 3-32
example 6-10 +vera_text_debug 3-32
syntax 6-8 +vera_udf 3-38
unpacked 6-4, 6-5 coverage_control 3-34
unpacking methods 6-8 vera_aspects 3-33
attributes for vera_cache_dir 3-33, 5-77
big_endian 6-5 vera_debug_on_error 3-28
bit_normal 6-5 vera_debug_on_int 3-28
bit_reverse 6-5 vera_directc 3-34
little_endian 6-4 vera_disable_final_report 3-29
unpack() 6-8 vera_disable_random_stability 3-29
urand48() 5-16 vera_dyn 3-29
vera_enable_mprint 3-29
urandom() 5-15
IN-10
vera_exit_on_error 3-29 syntax 5-75
vera_full_conflict_info 3-29 vera_enable_solver_trace_on_failure
vera_inst_path 3-34 syntax 5-76
vera_interactive_plot 3-29, 3-30 vera_plot() 11-2
vera_load 3-34 syntax 11-2
vera_mailbox_size 3-35 vera_profile_sort_by_name 10-4
vera_main_name 3-30 vera_profile_start 10-4
vera_mload 3-35
vera_random_see_automatic 3-31
vera_mload_define 3-35
vera_report_profile() 10-2, 10-8
vera_no_hdl_task_semaphore 3-30
vera_object_filename 3-35 vera_restore_rng_state()
example 5-11
vera_path_sep 3-30
random_compat 5-12
vera_pload 3-36
syntax 5-11
vera_pload_define 3-36
vera_plot 3-36, 11-2 vera_save_rng_state()
vera_profile_filename 3-36, 10-4, 10-9 example 5-11
vera_profile_interval 3-36 random_compat 5-12
vera_profile_limit 3-37, 10-4 syntax 5-11
vera_profile_object 3-30 VERA_WIDEN_ARGS 3-23
vera_profile_object_verbose 3-30, 10-14 VeraDyn.vrh 10-23
vera_profile_range 3-37 vera.ini
vera_profile_sort_by_name 3-31, 10-4 example of 10-3
vera_rand48_seed 3-38 verilog_task 2-19
vera_random_see_automatic 3-31 importing 2-19
vera_random_seed 3-38 veritask 12-9
vera_random_v0 3-31 vhdl_task 2-19
vera_region_size 3-38 importing 2-19
vera_semaphore_size 3-38 vLoad() 10-25
vera_solver_mode 3-38, 5-77 -vlog 3-23, 3-24, 3-26
vera_text_debug 3-32
-vmc 3-4
vera_use_system_random 3-32
VRO
vera_vros 3-38
dynamic loader 10-22
Vera shell file 1-6
VSG
Vera standalone 1-10 if-else usage 5-91
VERA Stream Generator overview 5-86
See VSG. prodget() 5-97
vera_coverage_control 3-34 prodset() 5-96
vera_cs 1-10 production definitions 5-87
-vera_dbind 2-21 production weights 5-90
vera_disable_final_report 3-29 randseq 5-86
vera_enable_solver_trace usage of case 5-92
IN-11
usage of continue 5-94 weights 5-90
usage of repeat 5-93 -widen_args 3-23
use of break 5-94
vUnLoad() 10-26
vUnloadAll() 10-26 Y
-y 3-23
-dep_check 3-23
W -print_deps 3-23
-w 3-3
IN-12