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

      • The Digital Twin: An Aerospace and Defense Revolution - March 9th
      • VIP solutions for Protocol and Memory Verification  - March 11th
      • Advance your Designs with Advances in CDC and RDC - March 23rd
      • Webinar Calendar
    • On Demand Seminars

      • The ABC of Formal Verification
      • I'm Excited About Formal...
      • 2020 Functional Verification Study
      • All On-Demand Seminars
    • Recording Archive

      • Improving Your SystemVerilog & UVM Skills
      • Should I Kill My Formal Run?
      • Visualizer Debug Environment
      • 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® & ModelSim®
      • Questa® inFact
      • Functional Verification Library
Ask a Question
UVM
  • Home
  • Forums
  • UVM
  • Randomizing a UVM_SEQUENCE using a config object from the sequencer upon which it will be run

Randomizing a UVM_SEQUENCE using a config object from the sequencer upon which it will be run

UVM 5593
sequence 26 UVM Configuration... 8
ndesch
ndesch
Full Access
4 posts
November 11, 2015 at 1:52 pm

I have a uvm_sequence subclass with random constraints which need to access some of the runtime behavior knobs present in the config object for the sequencer which will run it:

class my_seq extends uvm_sequence#(my_tr);
my_config cfg;
rand bit foo;
constraint c {
 if( cfg.always_use_foo ) foo == 1;
}
/* ... body(), etc ... */
endclass

My problem is that the sequence needs to be randomized before I send it to the sequencer but it doesn't know what sequencer it will run on when I randomize it. Normally I would get the config object from the uvm_config_db at the beginning of the sequence's run phase, but in this case I want to base my random constraint on information on the config object.

my_seq p = my_seq::type_id::create();
assert( p.randomize() ); // <-- can't randomize here because p.cfg hasn't been set, and p doesn't know what sequencer will run it
p.start( some_sequencer );

I know I can just set p.cfg before I randomize it, but I'm looking for some way for this to happen automatically, similar to when I get the config object in body() it can automatically retrieve it from the sequencer on which the sequence is running.

Unfortunately sequences don't seem to have any kind of pre-run setup which configures the sequencer the way sequence_items do:

start_item(tr);
assert( tr.randomize() ); // <-- tr knows what its sequencer is already because of start_item()
finish_item(tr);

Replies

Log In to Reply
cgales
cgales
Forum Moderator
1577 posts
November 11, 2015 at 3:19 pm

In reply to ndesch:

You can use the uvm_config_db() in the pre_randomize() function of your sequence. Use m_sequencer as the context for the get().

function void pre_randomize();
  if (cfg == null) begin
    if (!uvm_config_db#(my_config)::get(m_sequencer, "", "cfg", cfg)) begin
      `uvm_error("NOCFG", "No config object available");
    end
  end
endfunction
bmorris
bmorris
Full Access
274 posts
November 11, 2015 at 7:16 pm

In reply to cgales:

I don't see how this option works, as m_sequencer would be null; the sequence hasn't been started on a sequencer yet.

Off the cuff, perhaps you could use set_sequencer() before calling randomize, if, by then you know which sequencer it will use.

not as ideal, but you could use the config db as you mentioned (or p_sequencer) at the beginning of body, and have the sequence randomize itself; slightly less flexible.

ndesch
ndesch
Full Access
4 posts
November 12, 2015 at 5:27 am

In reply to bmorris:

Yes, m_sequencer is null during pre_randomize unless I first call set_sequencer. I think this may be the best solution:

my_seq p = my_seq::type_id::create();
p.set_sequencer( some_sequencer );
assert( p.randomize() );
p.start( some_sequencer );

And then pre-randomize looks pretty much as cgales posted. Thanks, everyone.

I can just add an error message to my sequence to remind me if I forget to use it this way.

bmorris
bmorris
Full Access
274 posts
November 12, 2015 at 7:18 am

In reply to ndesch:

Also use if instead of assert for your randomize; asserts are generally for verifying design constructs, not testbench. also they can be disabled

cgales
cgales
Forum Moderator
1577 posts
November 12, 2015 at 2:17 pm

In reply to ndesch:

Sorry about that. I missed that the sequence didn't have the sequencer set.

If you have to set something directly in the sequence, my recommendation would be to set the cfg directly (if possible), instead of the sequencer. This would save you the overhead of using the config_db().

Tudor Timi
Tudor Timi
Full Access
333 posts
November 13, 2015 at 2:14 am

What I use in this case is the config in the p_sequencer:

class some_sequence extends uvm_sequence;
  `uvm_declare_p_sequencer(some_sequencer)
 
  constraint some_constraint {
    if (p_sequencer != null)
      some_field == p_sequencer.cfg.some_field;
  }
endclass

When you start the sequence, just make sure that it gets created on your specific sequencer:

some_sequence seq;
`uvm_create_on(seq, some_seqr)
 
seq.randomize();
`uvm_send(seq)

Sequences don't have to be started on the sequencer to be associated with it.

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

cgales
cgales
Forum Moderator
1577 posts
November 13, 2015 at 5:36 am

In reply to Tudor Timi:

It is highly recommended to NOT use p_sequencers. The main reason is that it requires you to create a specific sequencer type, which normally isn't needed. It also requires that a specific sequencer of that type exist in your environment, which limits re-usability.

By not using p_sequencer, your sequence can run on any sequencer that is type-compatible and is therefor inherently more re-usable.

Tudor Timi
Tudor Timi
Full Access
333 posts
November 16, 2015 at 1:05 am

In reply to cgales:

It's possible to split it: define the sequence without knowledge of p_sequencer and then implement the code to do the auto-setting separately:

class some_sequence extends uvm_sequence;
  my_config cfg;
 
  // ...
  // keep it reusable
 
  `uvm_object_utils(some_sequence)
endclass
 
// more sequences
// ...

In a certain testbench you can define a mixin that handles setting the cfg based on the sequencer:

class set_cfg_mixin #(type T) extends T;
  `uvm_declare_p_sequencer
 
  function void pre_randomize();
    if (cfg == null)
      if (p_sequencer != null)
        cfg = p_sequencer.cfg;
      else
        `uvm_fatal("...")
  endfunction
 
  `uvm_object_param_utils(set_cfg_mixin #(T))
endclass
 
 
some_sequence seq = set_cfg_mixin #(some_sequence)::type_id::create(...);

Factory overrides should also work. Depending on how many sequences you have and how much of a concern reusability is for you, this is something you could consider.

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

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