In the following code, I have 2 cyclic random variables in a class. One (an enumerated type) takes 3 possible values, and the other takes 288 possible values (due to a constraint). So, I expect to get unique values for 288*3 randomize calls before the values repeat again.
I tried to randomize using two different methods:
- body: randomizes each variable independently, this results in 579 unique random values
- body2: randomizes the whole class, this results in 674 unique random values
So am I getting less than 288*3 unique values ?
typedef enum logic [1:0] {a,b,c} DecodeMode_t;
class seq;
randc integer CaseNum;
randc DecodeMode_t DecodeMode;
constraint cons {
CaseNum > 0;
CaseNum <= 288;
}
task print;
$display("CaseNum=%0d, DecodeMode=%s", CaseNum, DecodeMode);
endtask
task body;
repeat(288) begin
randomize(CaseNum);
repeat(3) begin
randomize(DecodeMode);
print;
end
end
endtask
task body2;
repeat(288*3) begin
randomize();
print;
end
endtask
endclass
module tb;
seq myseq;
initial begin
myseq = new;
// This gives 674 unique results:
//myseq.body2;
// while this gives 579 unique results:
myseq.randomize();
myseq.print;
myseq.body;
end
endmodule
I am running QuestaSim 10.7c simulation tool.