In reply to Reuben:
I tried to simulate the following and found no issue.
Currently, I don’t have access to Questasim and so I ran on NC.
class packet;
rand bit [15:0] addr;
endclass
module randomize;
bit [14:0] addr_arr[3] = {15’h7ffc, 15’h7ff2, 15’h7ffb};
int msg_id = 0;
packet pkt;
initial begin
pkt = new();
repeat(3) begin
$display ("msg_id is: %0d, addr_arr[msg_id] is %0h", msg_id, addr_arr[msg_id]);
pkt.randomize() with {addr == addr_arr[msg_id];};
$display ("pkt address choosen is: %0h", pkt.addr);
msg_id++;
end
end
endmodule
Output:
msg_id is: 0, addr_arr[msg_id] is 7ffc
pkt address choosen is: 7ffc
msg_id is: 1, addr_arr[msg_id] is 7ff2
pkt address choosen is: 7ff2
msg_id is: 2, addr_arr[msg_id] is 7ffb
pkt address choosen is: 7ffb