• 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. Constraints for multidimensional array

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 65
  • Views 15797
  • 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

Constraints for multidimensional array

Egor
Egor over 7 years ago

Hello guys. Have no idea why my code doesn't work in IUS 15.2/051 simulator. I tried to generate two-dimensional array with random size , but randomization method was failed ?! Can you make a comment  ? Or suggest how to fix it ? 


class test;

  rand int array[][];
  rand int first_size;
  rand int second_size;

  function new();
  endfunction // new

  constraint array_cnstr{
    array.size() == first_size;
    foreach(array[i])
    array[i].size == second_size;
  }

  constraint array_size_cnstr{
    first_size inside {[10:15]};
    second_size inside {[10:15]};
  }

  function void show_array();
    $display("first_size %0d" , first_size);
    $display("second_size %0d" , second_size);
    foreach(array[i,j])
      $display("array[%0d,%0d] = %0d" , i , j , array[i][j]);
    endfunction // show_array

  endclass // test

module test_mod();

  test ObjTest;

  initial begin
    ObjTest = new();
    ObjTest.randomize();
    ObjTest.show_array();
  end

endmodule

Error, that I got : 

ncsim> source /cad/cadence/INCISIV152.051/tools/inca/files/ncsimrc
ncsim> run
ObjTest.randomize();
|
ncsim: *W,SVRNDF (./test.sv,38|22): The randomize method call failed. The unique id of the failed randomize call is 0.
Observed simulation time : 0 FS + 0
ncsim: *W,RNDOCS: These constraints contribute to the set of conflicting constraints:

foreach(array[i]) (./test.sv,14)
second_size inside {[10:15]}; (./test.sv,20)
ncsim: *W,RNDOCS: These variables contribute to the set of conflicting constraints:

rand variables:
second_size [./test.sv, 7]

  • Cancel
Parents
  • StephenH
    StephenH over 7 years ago

    Hello Egor.

    This looks very much like the same question someone else had a few weeks ago on this forum. Is it a class homework assignment by any chance?

    Generating random data this way isn't very efficient for the tool as you're invoking a heavy complex solver to just assign simple random values (for the array contents) that you could get from $urandom(). 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • StephenH
    StephenH over 7 years ago

    Hello Egor.

    This looks very much like the same question someone else had a few weeks ago on this forum. Is it a class homework assignment by any chance?

    Generating random data this way isn't very efficient for the tool as you're invoking a heavy complex solver to just assign simple random values (for the array contents) that you could get from $urandom(). 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Egor
    Egor over 7 years ago in reply to StephenH

    Hello StephenH , thank you for your response.

    I've just shown you this code as example. Actually I used the same method in uvm sequence randomization . What I want is to have a hook to control dynamic array size from the upper layer that creates this  sequences with dynamic array using randomize with construct. I'm pretty sure that this construction is supported with SV . I tried this code on edaplayground with other vendor simulator and it works. 

    • 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