HI All,
I am trying to generate the odd numbers in an ascending order in this format
1 3 5 7 9 11…
basically, the difference between each two element is exactly two.
I am getting randomization failure, could you please suggest?
Thank you,
module m1;
class packet;
rand bit [3:0] array[2][3];
constraint c2{
foreach(array[i,j])
if(i==0 && j==0)
array[i][j]==1;
else
array[i][j]==array[i][j]+2;
}
function void post_randomize();
$display("%0p", array);
endfunction
endclass
packet pkt;
initial begin
pkt = new;
repeat (1) begin
pkt.randomize();
end
end
endmodule
This expression can never be true. If you have the element array[i][j]
, what is the definition of the next element when you have a two dimensional array?
Sorry for the late reply.
I understand the definition of the two dimensional array in this way :
one dimension for row and another dimension for column.
When all the entries of the column are filled, then it iterates over the next row, this process repeats till row and column reaches their maximum size/length.
If this is functionally incorrect “array[i][j]==array[i][j]+2”, may I know the other possibilities to think of getting the above pattern please?
Thank you
You’re asking to create a non-random pattern with random constraints. It would be helpful if you shared the code for generating the pattern using procedural code. Then, someone could guide you on how to achieve the same using constraints.