• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. Randomizing object-arrays: IUS 8.2s003 ncvlog ERROR *EX...

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 64
  • Views 13162
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Randomizing object-arrays: IUS 8.2s003 ncvlog ERROR *EXPRDV

cubicle82
cubicle82 over 16 years ago
I can't seem to run rand_mode() or constraint_mode() directly on an (indexed) element of an array.

Example:

module randfail;

class cls_randomer;

  rand int unsigned x, y;
  constraint con_x {
    x < 1000;
    x > 15;
  }
constraint con_y { y < 100; }

endclass : cls_randomer

//cls_randomer randomer[] = new[5]; // dynamic array
cls_randomer randomer[5];  // non-dynamic array

initial begin : initial_begin
  static cls_randomer temp;

  // Init: shut off randomization of 'x' , later we'll re-enable them on  case-by-case

  foreach( randomer[i] ) begin : foreach_i
    temp = new();
    temp.rand_mode(0);
    temp.constraint_mode(0);
    temp.con_x.constraint_mode(1);

    randomer[i] = new();
    randomer[i].rand_mode(0); // ncvlog: *E,EXPRDV
    randomer[i].constraint_mode(0);
    randomer[i].con_x.constraint_mode(1);

//    randomer[i] = temp;
    $display("creating & randomizing object#%0d", i );
  end : foreach_i

end :initial_begin

endmodule : randfail

irun: 08.20-s003: (c) Copyright 1995-2008 Cadence Design Systems, Inc.

    randomer[i].rand_mode(0);
                        |
ncvlog: *E,EXPRDV (randfail.sv,29|24): Expecting a rand or randc variable as the prefix to the rand_mode task/function.
...

errors: 3, warnings: 0

Basically, I have to use a temporary (scalar) object to do the following:  run the built-in methods rand_mode() and constraint_mode() on the scalar-object, then assign the object back to the target element of my object-array.

 
  • Cancel
  • tpylant
    tpylant over 16 years ago

    Looks like a current limitation in IUS. Your temp idea looks like the best solution:

     initial begin : initial_begin
      // Init: shut off randomization of 'x', re-enable them on case-by-case

      foreach( randomer[i] ) begin : foreach_i
        rand_off(randomer[i]);
        randomer[i].x.rand_mode(1);
        randomer[i].con_x.constraint_mode(1);
        void'(randomer[i].randomize());
        $display("creating & randomizing object#%0d: x=%0d y=%0d", randomer[i], randomer[i].x, randomer[i].y);
      end : foreach_i

    end :initial_begin

    function void rand_off (output cls_randomer temp);
        temp = new();
        temp.rand_mode(0);
        temp.constraint_mode(0);
    endfunction : rand_off

     Tim

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information