Verification Academy

Search form

My Account Menu

  • Register
  • Log In
  • Topics
  • Courses
  • Forums
  • Patterns Library
  • Cookbooks
  • Events
  • More
  • All Topics
    The Verification Academy offers users multiple entry points to find the information they need. One of these entry points is through Topic collections. These topics are industry standards that all design and verification engineers should recognize. While we continue to add new topics, users are encourage to further refine collection information to meet their specific interests.
    • Languages & Standards

      • Portable Test and Stimulus
      • Functional Safety
      • Design & Verification Languages
    • Methodologies

      • UVM - Universal Verification Methodology
      • UVM Framework
      • UVM Connect
      • FPGA Verification
      • Coverage
    • Techniques & Tools

      • Verification IP
      • Simulation-Based Techniques
      • Planning, Measurement, and Analysis
      • Formal-Based Techniques
      • Debug
      • Clock-Domain Crossing
      • Acceleration
  • All Courses
    The Verification Academy is organized into a collection of free online courses, focusing on various key aspects of advanced functional verification. Each course consists of multiple sessions—allowing the participant to pick and choose specific topics of interest, as well as revisit any specific topics for future reference. After completing a specific course, the participant should be armed with enough knowledge to then understand the necessary steps required for maturing their own organization’s skills and infrastructure on the specific topic of interest. The Verification Academy will provide you with a unique opportunity to develop an understanding of how to mature your organization’s processes so that you can then reap the benefits that advanced functional verification offers.
    • Universal Verification Methodology (UVM)

      • Advanced UVM
      • Basic UVM
      • Introduction to UVM
      • UVM Connect
      • UVM Debug
      • UVMF - One Bite at a Time
    • Featured Courses

      • Introduction to ISO 26262
      • Introduction to DO-254
      • Clock-Domain Crossing Verification
      • Portable Stimulus Basics
      • Power Aware CDC Verification
      • Power Aware Verification
      • SystemVerilog OOP for UVM Verification
    • Additional Courses

      • Assertion-Based Verification
      • An Introduction to Unit Testing with SVUnit
      • Evolving FPGA Verification Capabilities
      • Metrics in SoC Verification
      • SystemVerilog Testbench Acceleration
      • Testbench Co-Emulation: SystemC & TLM-2.0
      • Verification Planning and Management
      • VHDL-2008 Why It Matters
    • Formal-Based Techniques

      • Formal Assertion-Based Verification
      • Formal-Based Technology: Automatic Formal Solutions
      • Formal Coverage
      • Getting Started with Formal-Based Technology
      • Handling Inconclusive Assertions in Formal Verification
      • Sequential Logic Equivalence Checking
    • Analog/Mixed Signal

      • AMS Design Configuration Schemes
      • Improve AMS Verification Performance
      • Improve AMS Verification Quality
  • All Forum Topics
    The Verification Community is eager to answer your UVM, SystemVerilog and Coverage related questions. We encourage you to take an active role in the Forums by answering and commenting to any questions that you are able to.
    • UVM Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • UVM Forum
    • SystemVerilog Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • SystemVerilog Forum
    • Coverage Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • Coverage Forum
    • Additional Forums

      • Announcements
      • Downloads
      • OVM Forum
  • Patterns Library
    The Verification Academy Patterns Library contains a collection of solutions to many of today's verification problems. The patterns contained in the library span across the entire domain of verification (i.e., from specification to methodology to implementation—and across multiple verification engines such as formal, simulation, and emulation).
    • Implementation Patterns

      • Environment Patterns
      • Stimulus Patterns
      • Analysis Patterns
      • All Implementation Patterns
    • Specification Patterns

      • Occurrence Property Patterns
      • Order Property Patterns
      • All Specification Patterns
    • Pattern Resources

      • Start Here - Patterns Library Overview
      • Whitepaper - Taking Reuse to the Next Level
      • Verification Horizons - The Verification Academy Patterns Library
      • Contribute a Pattern to the Library
  • All Cookbooks
    Find all the methodology you need in this comprehensive and vast collection. The UVM and Coverage Cookbooks contain dozens of informative, executable articles covering all aspects of UVM and Coverage.
    • UVM Cookbook

      • UVM Basics
      • Testbench Architecture
      • DUT-Testbench Connections
      • Configuring a Test Environment
      • Analysis Components & Techniques
      • End Of Test Mechanisms
      • Sequences
      • The UVM Messaging System
      • Other Stimulus Techniques
      • Register Abstraction Layer
      • Testbench Acceleration through Co-Emulation
      • Debug of SV and UVM
      • UVM Connect - SV-SystemC interoperability
      • UVM Versions and Compatibility
      • UVM Cookbook
    • Coding Guidelines & Deployment

      • Code Examples
      • UVM Verification Component
      • Package/Organization
      • Questa/Compiling UVM
      • SystemVerilog Guidelines
      • SystemVerilog Performance Guidelines
      • UVM Guidelines
      • UVM Performance Guidelines
    • Coverage Cookbook

      • Introduction
      • What is Coverage?
      • Kinds of Coverage
      • Specification to Testplan
      • Testplan to Functional Coverage
      • Bus Protocol Coverage
      • Block Level Coverage
      • Datapath Coverage
      • SoC Coverage Example
      • Requirements Writing Guidelines
      • Coverage Cookbook
  • All Events
    No one argues that the challenges of verification are growing exponentially. What is needed to meet these challenges are tools, methodologies and processes that can help you transform your verification environment. These recorded seminars from Verification Academy trainers and users provide examples for adoption of new technologies and how to evolve your verification process.
    • Upcoming & Featured Events

      • Low Power Verification - 4/29
      • Fault Campaign for Mixed-Signal - 5/4
      • User2User - 5/26
      • Webinar Calendar
    • On-Demand Webinars

      • CDC+RDC Analysis
      • Basic Abstraction Techniques
      • Safety Analysis Techniques
      • QVIP Workflow and Debug for PCIe
      • Writing a Proxy-driven Testbench
      • Achieving High Defect Coverage
      • Visualizer Features
      • All On-Demand Webinars
    • Recording Archive

      • Siemens EDA 2021 Functional Verification Webinar Series
      • Improving Your SystemVerilog & UVM Skills
      • Should I Kill My Formal Run?
      • Visualizer Debug Environment
      • Industry Data & Surveys
      • All Recordings
    • Conferences

      • DVCon 2021
      • DVCon 2020
      • DAC 2019
      • All Conferences
    • Mentor Learning Center

      • SystemVerilog Fundamentals
      • SystemVerilog UVM
      • View all Learning Paths
  • About Verification Academy
    The Verification Academy will provide you with a unique opportunity to develop an understanding of how to mature your organization's processes so that you can then reap the benefits that advanced functional verification offers.
    • Blog & News

      • Verification Horizons Blog
      • Academy News
      • Academy Newsletter
      • Technical Resources
    • Verification Horizons Publication

      • Verification Horizons - March 2021
      • Verification Horizons - November 2020
      • Verification Horizons - July 2020
      • Issue Archive
    • About Us

      • Verification Academy Overview
      • Subject Matter Experts
      • Contact Us
    • Training

      • Questa Basic
      • Questa Advanced
      • Mastering Questa
Ask a Question
SystemVerilog
  • Home
  • Forums
  • SystemVerilog
  • System verilog randomization: inconsistency in LRM?

System verilog randomization: inconsistency in LRM?

SystemVerilog 5100
constraint 46 randomization 17
sharatk
sharatk
Full Access
38 posts
March 20, 2019 at 10:59 pm

In constraint section LRM says: Pg 438
Functions(Inside the constraint) shall be called before constraints are solved, and their return values shall be treated as state variables.

It also says:
Random variables used as function arguments shall establish an implicit variable ordering or priority. Constraints that include only variables with higher priority are solved before other, lower priority constraints. Random variables solved as part of a higher priority set of constraints become state variables to the remaining set of constraints.

From the first sentence it seems to say if I have something like.
class B;
rand int x, y;
constraint C { x <= F(y); }
constraint D { y inside { 2, 4, 8 } ; }
endclass
It will evaluate F(y) with unrandomized value of y which is 0. But second statement contradicts it?
Someone please help me thro this confusion.

Replies

Log In to Reply
Tudor Timi
Tudor Timi
Full Access
333 posts
March 21, 2019 at 3:48 am

In reply to sharatk:

Functions aren't called before all constraints are solved, but before the relevant constraints are solved.

In your case, the function creates an implicit solve y before x. This means constraint D will be solved first to yield a value of y. Afterwards, F will be called with the value of y obtained from the previous step. Then, constraint C will be solved to yield x.

Constrained random thoughts on SystemVerilog and e: http://blog.verificationgentleman.com/

sharatk
sharatk
Full Access
38 posts
March 21, 2019 at 7:56 am

In reply to Tudor Timi:

For a simple case like say countones, you are correct and I validated it. But when I go ahead and wrote much complicated constraint, It totally failed. I had to work around creating temporary array and using inbuilt "sum" function.
It could be a quirk of cadence Simulator, but I had no other way of validating it.

dave_59
dave_59
Forum Moderator
8749 posts
March 21, 2019 at 8:54 am

In reply to sharatk:

To say that a function call creates an implicit solve y before x constraint is slightly misleading (see this description of the solve before construct).

The constraint solver works in solution spaces. A solution space is the collection of all possible values sets for the random values that satisfy the active constraints. You can think of the constraint solver as building the solution space first, then randomly choosing one set of values for the random variables.

Calling a user function breaks the solution space in half—one for the input, and one for the output of the function. The input solution space gets built and values picked before building the output space. This means that any constraints involving the function output have no effect on the input space, and could result in constraint failure. For example

class A
rand int x,y;
function int f(int a);
  return a;
endfunction
constraint c1 { x == f(y); }
constraint c2 { x inside {[1:20]}; }
constraint c3 { y inside {[10:30]}; }
endclass
The constraint solver can choose any value between 10 to 30 for y, but the fact that x is constrained between 1 to 20 has no effect on the choice for y. So if 21 gets chosen for y, the solver will fail because constraint c2 cannot be satisfied.

— Dave Rich, Verification Architect, Siemens EDA

Tudor Timi
Tudor Timi
Full Access
333 posts
March 21, 2019 at 9:20 am

In reply to dave_59:

Some tools work back in this case and choose a different value for y, such that the randomize doesn't fail.

Constrained random thoughts on SystemVerilog and e: http://blog.verificationgentleman.com/

sharatk
sharatk
Full Access
38 posts
March 21, 2019 at 9:26 am

In reply to dave_59:

Thank you Dave. Your insights are great as usual.
I worked on an example which going by your description should have worked. It was a little complicated as main class has other class as members and randomization fails.
I had to code a hack to proceed.
If you would like to see the example, please let me know where I can send it to you? You can probably check it in Modelsim (I only have IUS, which is not too great with constraints)

dave_59
dave_59
Forum Moderator
8749 posts
March 21, 2019 at 10:46 am

In reply to Tudor Timi:

That works in some cases, but you could not rely on it. Also, some people depend on this behavior to limit the scope of overriding soft constraints

— Dave Rich, Verification Architect, Siemens EDA

Etrx91
Etrx91
Forum Access
56 posts
March 21, 2019 at 11:39 am

In reply to dave_59:

Hi Dave ,

Could you please elaborate on " this behavior to limit the scope of overriding soft constraints "

dave_59
dave_59
Forum Moderator
8749 posts
March 21, 2019 at 1:00 pm

In reply to Etrx91:
I think soft constraints add unnecessary complexity, and there is usually a better way to write your constraints. So I'n not about to provide an example.

— Dave Rich, Verification Architect, Siemens EDA

Siemens Digital Industries Software

Siemens Digital Industries Software

##TodayMeetsTomorrow

Solutions

  • Cloud
  • Mendix
  • Siemens EDA
  • MindSphere
  • Siemens PLM
  • View all portfolio

Explore

  • Digital Journeys
  • Community
  • Blog
  • Online Store

Siemens

  • About Us
  • Careers
  • Events
  • News and Press
  • Newsletter
  • Customer Stories

Contact Us

USA:

phone-office +1 800 547 3000

See our Worldwide Directory

  • Contact Us
  • Support Center
  • Give us Feedback
©2021 Siemens Digital Industries Software. All Rights Reserved.
Terms of Use Privacy Cookie Policy