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

      • Creating an Optimal Safety Architecture  - February 9th
      • The ABC of Formal Verification - February 11th
      • Events Calendar
    • On Demand Seminars

      • I'm Excited About Formal...
      • Visualizer Coverage
      • Formal-based ‘X’ Verification
      • 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
    • Mentor Training Center

      • SystemVerilog for Verification
      • SystemVerilog UVM
      • UVM Framework
      • Instructor-led Training
    • Mentor Learning Center

      • SystemVerilog Fundamentals
      • SystemVerilog UVM
      • Questa Simulation Coverage Acceleration Apps with inFact
      • 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 - November 2020
      • Verification Horizons - July 2020
      • Verification Horizons - March 2020
      • Issue Archive
    • About Us

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

      • Questa® & ModelSim®
      • Questa® inFact
      • Functional Verification Library
Ask a Question
SystemVerilog
  • Home /
  • Forums /
  • SystemVerilog /
  • inline constraint while using uvm_do_on_with

inline constraint while using uvm_do_on_with

SystemVerilog 4893
#systemverilog #arrays... 6 #systemverilog #UVM 6 #systemverilog ... 22 #uvm 38
megamind
megamind
Full Access
40 posts
August 27, 2020 at 1:21 pm

I have below code in my virtual sequencer, except the data array inline constraint(shown below as commented at present in READ transaction), everything works well, if I take off the data constraint in the READ transaction below, it works well.

class my_sequence;
      axi_base_seq         axi_wseq;
      axi_base_seq         axi_rseq;
      axi_master_sequencer axi_seqr;
      axi_seqr = uvm_test_top.env_h.axi_agent.seqr;

  `uvm_do_on_with(axi_wseq, axi_seqr, 
  {
    s_kind == axi_type_pkg::WRITE;
    s_id inside {[axi_seqr.cfg_h.id_lo:axi_seqr.cfg_h.id_hi]};
    s_addr == 'haaaaaaa;
    s_length inside {[1:15]};
    s_size inside {[1:4]};
    s_wait_for_rsp == 1;
  })
 
  `uvm_do_on_with(axi_rseq, axi_seqr, 
  {
    s_kind == axi_type_pkg::READ;
    s_id == axi_wseq.req.id;
    s_addr == axi_wseq.req.addr;
    s_length == axi_wseq.req.length;
    s_size == axi_wseq.req.size;
    s_burst == axi_wseq.req.burst;
    s_wait_for_rsp == axi_wseq.req.wait_for_rsp;
    //##foreach(axi_wseq.req.data[k]) s_data[k] == axi_wseq.req.data[k]; //I need this for score boarding purpose, so this is my question??? please share the answer for this line.
  })

This is the base sequence I am using,

class axi_base_seq extends uvm_sequence #(axi_seq_item);
  string tID;
 
  rand axi_type_pkg::eAxiKind s_kind;
  rand bit [8:0] s_id;
  rand bit [31:0] s_addr;
  rand bit [255:0] s_data[];
  rand bit [4:0] s_length;
  rand bit [2:0] s_size;
  rand bit [3:0] s_qos;
  rand bit [5:0] s_user;
  rand eAxiBurstKind s_burst;
  rand bit s_wait_for_rsp;
 
  task body();
    req = axi_seq_item::type_id::create("req");
    `uvm_info(tID,$sformatf("sequence RUNNING id=%x addr=0x%0x length=%d", s_id, s_addr, s_length),UVM_DEBUG)
    `uvm_do_with(req, {
      req.addr == s_addr;
      req.length == s_length;
      req.size == s_size;
      req.burst == s_burst;
      req.id == s_id;
      req.kind == s_kind;
      req.addr == s_addr;
      req.wait_for_rsp == s_wait_for_rsp;
      foreach(s_data[i]) req.data[i] == s_data[i];
    })
 
    `uvm_info(tID,$sformatf("sequence COMPLETE id=%x", s_id), UVM_DEBUG)    
  endtask : body

This is my sequence item and its constraint,

class axi_seq_item_base  extends uvm_sequence_item; 
 
  rand eAxiKind kind;
  rand bit [8:0] id;
  rand bit [32:0] addr;
  rand bit [255:0] data []; 
  rand bit [4:0] length;
  rand bit [2:0] size;
  rand bit [3:0] qos;
  rand bit [5:0] user;
  rand eAxiBurstKind burst;
  rand eAxiRspKind resp;
  rand bit wait_for_rsp;
 
  constraint c_data_array { 
    data.size() == length+1; 
  }
 
  constraint c_max_length { length < 16; }
  constraint c_align { addr % 2**size == 0; }
  constraint c_burst { burst inside {axi_type_pkg::FIXED, axi_type_pkg::INCR,axi_type_pkg::WRAP};}
  constraint wrap_lenght {if (burst == axi_type_pkg::WRAP) length inside {1,3,7,15};}
 
  constraint c_dj_bytes {if (burst == axi_type_pkg::WRAP) {2**size *(length+1) == 64};}
  constraint c_dj_alow  {if (burst == axi_type_pkg::WRAP) {addr[4:0] == 0};}
  constraint c_dj_user  {if (burst == axi_type_pkg::WRAP) {addr[11:6] == user[5:0]};}
  //constraint c_dj_bit5  {if (burst == axi_type_pkg::WRAP) {addr[5] == !addr[5]};}

Why my randomization fails when I try to keep the inline constraint for the data array?

I start my_sequence from my top_test class with null sequencer, as I use sequencer as shown above for the axi item, which using uvm_do_on_with.

This is the error message --->> This constraint was not processed due to: array index out of bounds The array involved is: rand bit [255:0] s_data[]; (from the base sequence shown above)

As I shown above , if I remove this array constraint line, ultimately both arrays from axi_wseq and axi_rseq have the same length(that is because axi_rseq length is also assigned with axi_wseq and randomization go well) but different data.

Thank you and best regards.

Replies

Log In to Reply
cgales
cgales
Forum Moderator
1556 posts
August 27, 2020 at 3:10 pm

In reply to megamind:

I would recommend not using the `uvm_do_* macros. These add a layer of complexity which make things difficult to debug. Instead, use the start_item()/randomize()/finish_item() methodology.

Additionally, if you are assigning every element of your transaction to a known value, why call randomize? I would skip calling randomize() and just assign the values required.

megamind
megamind
Full Access
40 posts
August 27, 2020 at 3:35 pm

In reply to cgales:

Thank you.

Please let me clarify the example I showed was for just explanation, WRITE transaction need to be completely random but the READ transaction should match with WRITE transaction, so READ transaction should be directed with WRITE transaction values, and for a reason it is not taking those directed values!!! which I want to know how can be best handled.

>>I would recommend not using the `uvm_do_* macros. These add a layer of complexity which make things difficult to debug. Instead, use the start_item()/randomize()/finish_item() methodology.
I can try this, if this is the cause of the failure.

>>Additionally, if you are assigning every element of your transaction to a known value, why call randomize? I would skip calling randomize() and just assign the values required.
How can I do that here in this context? can you please show syntax for example instead of,

`uvm_do_on_with(axi_rseq, axi_seqr, 
  {
    s_kind == axi_type_pkg::READ;
    s_id == axi_wseq.req.id;
    s_addr == axi_wseq.req.addr;
    s_length == axi_wseq.req.length;
    s_size == axi_wseq.req.size;
    s_burst == axi_wseq.req.burst;
    s_wait_for_rsp == axi_wseq.req.wait_for_rsp;
    //##foreach(axi_wseq.req.data[k]) s_data[k] == axi_wseq.req.data[k]; //I need this for score boarding purpose, so this is my question??? please share the answer for this line.
  })

What should be replaced?

cgales
cgales
Forum Moderator
1556 posts
August 28, 2020 at 6:02 am

In reply to megamind:

You can read about the sequence/sequencer flow at this UVM Cookbook page.

Instead of calling randomize(), you can just assign your fields:

  task body();
    req = axi_seq_item::type_id::create("req");
    `uvm_info(tID,$sformatf("sequence RUNNING id=%x addr=0x%0x length=%d", s_id, s_addr, s_length),UVM_DEBUG)
    start_item(req);
    req.addr == s_addr;
    req.length == s_length;
    req.size == s_size;
    req.burst == s_burst;
    req.id == s_id;
    req.kind == s_kind;
    req.addr == s_addr;
    req.wait_for_rsp == s_wait_for_rsp;
    foreach(s_data[i]) req.data[i] == s_data[i];
    finish_item(req);
    `uvm_info(tID,$sformatf("sequence COMPLETE id=%x", s_id), UVM_DEBUG)    
  endtask : body
megamind
megamind
Full Access
40 posts
August 28, 2020 at 1:38 pm

In reply to cgales:

Thank you, I have updated your syntax recommendation inside my base sequence "class axi_base_seq", as you suggested, but that did not solve the issue. Also "class my_sequence" is a virtual sequence, which I am starting in my top test, so later in the my_sequence, I am using uvm_do_on_with, as I need to pass some sequencer.

However I could solve my problem with below change in the "class my_sequence"

  `uvm_do_on_with(axi_rseq, axi_seqr, 
  {
    s_kind == axi_type_pkg::READ;
    s_id == axi_wseq.req.id;
    s_addr == axi_wseq.req.addr;
    s_length == axi_wseq.req.length;
    s_size == axi_wseq.req.size;
    s_burst == axi_wseq.req.burst;
    s_wait_for_rsp == axi_wseq.req.wait_for_rsp;
    s_data.size() == axi_wseq.req.data.size();                       //This solved the issue
    foreach(axi_wseq.req.data[k]) s_data[k] == axi_wseq.req.data[k]; //Now this line don't produce any error and randomization works well with uvm_do_on_with
  })

Do you have any further comments? Thank you.

cgales
cgales
Forum Moderator
1556 posts
August 29, 2020 at 4:46 am

In reply to megamind:

If you are starting a sequence from a virtual sequencer, the flow is similar:

  axi_rseq = axi_base_seq::type_id::create("axi_rseq");
  axi_rseq.s_kind == axi_type_pkg::READ;
  axi_rseq.s_id = axi_wseq.id;
  ...
  axi_rseq.start(axi_seqr);
megamind
megamind
Full Access
40 posts
August 29, 2020 at 3:24 pm

In reply to cgales:

Got it, I have made some changes to my sequence item and base sequence as below. Also for the READ where I need directed values from the previous WRITE transaction(for score boarding purpose), I can make changes according your inputs. Your valuable inputs are helping me to move, thank you for that.

Please let me ask further for the WRITE transaction randomization, where I want to understand more about it to make sure I am not doing anything wrong or want to follow proper guidelines.

THIS IS MY sequence item WITH CONSTRAINTS,

class axi_seq_item_base  extends uvm_sequence_item; 
 
  rand eAxiKind kind;
  rand bit [8:0] id;
  rand bit [32:0] addr;
  rand bit [255:0] data []; 
  rand bit [4:0] length;
  rand bit [2:0] size;
  rand bit [3:0] qos;
  rand bit [5:0] user;
  rand eAxiBurstKind burst;
  rand eAxiRspKind resp;
  rand bit wait_for_rsp;
 
  constraint c_data_array { 
    data.size() == length+1; 
  }
 
  constraint c_max_length { length < 16; }
  constraint c_align { addr % 2**size == 0; }
  constraint c_burst { burst inside {axi_type_pkg::FIXED, axi_type_pkg::INCR,axi_type_pkg::WRAP};}
  constraint wrap_lenght {if (burst == axi_type_pkg::WRAP) length inside {1,3,7,15};}
 
  constraint c_dj_bytes {if (burst == axi_type_pkg::WRAP) {2**size *(length+1) == 64};}
  constraint c_dj_alow  {if (burst == axi_type_pkg::WRAP) {addr[4:0] == 0};}
  constraint c_dj_user  {if (burst == axi_type_pkg::WRAP) {addr[11:6] == user[5:0]};}
  //constraint c_dj_bit5  {if (burst == axi_type_pkg::WRAP) {addr[5] == !addr[5]};}

THIS IS MY BASE SEQUENCE, HERE I DON'T USE ANY CONSTRAINT,

class axi_base_seq extends uvm_sequence #(axi_seq_item);
  string tID;
 
  rand axi_type_pkg::eAxiKind s_kind;
  rand bit [8:0] s_id;
  rand bit [31:0] s_addr;
  rand bit [255:0] s_data[];
  rand bit [4:0] s_length;
  rand bit [2:0] s_size;
  rand bit [3:0] s_qos;
  rand bit [5:0] s_user;
  rand eAxiBurstKind s_burst;
  rand bit s_wait_for_rsp;
 
  task body();
    req = axi_seq_item::type_id::create("req");
    `uvm_info(tID,$sformatf("sequence RUNNING id=%x addr=0x%0x length=%d", s_id, s_addr, s_length),UVM_DEBUG)
    start_item(req);
    if (!req.randomize() with 
    {
      addr == s_addr;
      length == s_length;
      size == s_size;
      burst == s_burst;
      id == s_id;
      kind == s_kind;
      addr == s_addr;
      wait_for_rsp == s_wait_for_rsp;
      foreach(s_data[i]) data[i] == s_data[i];
    })
    `uvm_error(get_type_name(), "Randomize failed")
    finish_item(req);    
    `uvm_info(tID,$sformatf("sequence COMPLETE id=%x", s_id), UVM_DEBUG)    
  endtask : body


Now when I call below from my virtual sequence(please note that I have to update below code as per your guideline and use create and start methods instead of uvm_do_on_with, which I am going to do later),

        axi_base_seq        axi_wseq;
repeat (10) begin
        `uvm_do_on_with(axi_wseq, axi_seqr, 
        {
          s_kind == axi_type_pkg::WRITE;
          s_id inside {[axi_seqr.cfg_h.id_lo:axi_seqr.cfg_h.id_hi]};
          s_addr inside {['hb0000000:'hbfffffff]};
          s_length inside {[0:axi_seqr.cfg_h.max_length]};
          s_size inside {[0:axi_seqr.cfg_h.max_size]};
          s_burst == axi_type_pkg::INCR;
          s_wait_for_rsp == 1;
        })
end

For some iteration randomization works and for some iteration randomization fails and produces below error,

axi_base_seq.sv: The randomize method call failed. These constraints contribute to the set of conflicting constraints:
  constraint c_align { addr % 2**size == 0; } (axi/axi_seq_item.sv)
      addr == s_addr; (./axi/axi_base_seq.sv)
      size == s_size; (./axi/axi_base_seq.sv)
These variables contribute to the set of conflicting constraints:
state variables:
       s_addr (3033572225) [./axi/axi_base_seq.sv]
       s_size (4) [./axi/axi_base_seq.sv]
rand variables:
       addr [./axi/axi_seq_item.sv]
       size [./axi/axi_seq_item.sv]

I thought I was doing it correct , as from the virtual sequence , I gave the ranges to different control fields and then randomized it, shouldn't it work?

Can you please explain me if the constraint need to be updated here or I need to enhance constraint in the axi_base_seq(and if that need to be matching with axi_seq_item constraints) or basically what I need to take care to avoid failing randomization?

Thank you and Best regards.

© Mentor, a Siemens Business, All rights reserved www.mentor.com

Footer Menu

  • Sitemap
  • Terms & Conditions
  • Verification Horizons Blog
  • LinkedIn Group
SiteLock