In the code snippet below, when I do a descr.randomize(), I want the mem_id to be randomized such that the current “mem_id” is NOT the same last 6 mem_ids. Any inputs on how to achieve this?
class my_descriptor;
rand bit [63:0] data;
rand bit[2:0] mem_id;
endclass
module my_test;
my_descriptor descr;
function void run();
descr = new();
repeat(500) begin
assert(descr.randomize());
$display("data = %d, mem_id = %d \n", descr.data, descr.mem_id);
end
endfunction
initial begin
run();
end
endmodule
Oh, correct! randc will not work here. I was expecting push_front() will also work in a same way.
Also, another way without the use of foreach loop in above snippet is inside operator,