IMPORTANT NOTICE: Please be advised that the Verification Academy Forums will be offline for scheduled maintenance on Sunday, March 23rd at 4:00 US/Pacific.
In reply to evilpascal:
The problem is as the error message tells you - constraint expressions need to be with integral expressions. An unpacked array is not an integral expression. you need to create a separate array, and then use a
foreachloop and break the aggregate constraint into an set of integral constraints.
bit [7:0] set_arr;
set_arr = '{8'h11, 8'h22, 8'h33};
if(!seq.randomize() with {
_num inside {[0:10]};
foreach (set_arr[ii]) _arr[ii] == set_arr[ii];
}) begin
`uvm_error("TST", "Randomization failed")
end
Thanks for the soulution dave_59. I just needed to also constrain the “_arr” variable size to the size of the “set_arr”, or there would be a failure when simulation is started:
if(!seq.randomize() with {
_num inside {[0:10]};
_arr.size() == set_arr.size();
foreach (set_arr[ii]) _arr[ii] == set_arr[ii];
}) begin
`uvm_error("TST", "Randomization failed")
end