Hi All,
Currently I am working one one code which generates the randomize size between 7&8. and i want the values inside the array to be inside[5:6]. But when i run the below code . I am getting different values other than the expected.
class array_example;
int i;
rand int arr[];
constraint array_size{arr.size() inside{[7:8]};}
constraint array_value{arr[i] inside{[5:6]};}
endclass:array_example
module abc();
array_example ae_1;
int i;
initial
begin
ae_1 =new();
ae_1.randomize();
$display("the value of the array size is %d",ae_1.arr.size());
foreach(ae_1.arr[i])
$display("the value of the array is %d",ae_1.arr[i]);
end
endmodule
Simulation results i am getting
Compiler version L-2016.06-SP1_Full64; Runtime version L-2016.06-SP1_Full64; Sep 16 21:46 2021
the value of the array size is 8
the value of the array is 5
the value of the array is 217190416
the value of the array is 1193078623
the value of the array is -1364192802
the value of the array is -505257340
the value of the array is 2045249375
the value of the array is 390798217
the value of the array is -1137671976
But my expected solution is
Compiler version L-2016.06-SP1_Full64; Runtime version L-2016.06-SP1_Full64; Sep 16 21:46 2021
the value of the array size is 8
the value of the array is 5
the value of the array is 6
the value of the array is 6
the value of the array is 5
the value of the array is 6
the value of the array is 6
the value of the array is 5
the value of the array is 5
I mean i want the array values either 5 or 6 and array size should be either 7 or 8.