Quantcast
Channel: Cadence Functional Verification Forum
Viewing all articles
Browse latest Browse all 1074

Constraints for multidimensional array

$
0
0

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]


Viewing all articles
Browse latest Browse all 1074

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>