Hello,
I have a struct and I am trying to randomize its members with constraints (please see below). Without any constraints, randomization is fine. Can someone please let me know why I see the error mentioned below? Many thanks!
typedef enum {RED, GREEN, BLUE, YELLOW} colors_e;
typedef struct {
rand colors_e color;
rand bit[3:0] num;
} card;
class Example;
rand card c[];
constraint c1 {c.size() == 3;}
constraint c2 {foreach (c[i]){
i == 0 -> c.num[i] inside {[0:9]};}} //why is this incorrect?
endclass
module TB;
Example E;
initial begin
E = new();
if(!(E.randomize()))
$display("Failed Randomization \n");
end
endmodule
I see the following error:
Error found while trying to resolve cross-module reference.
token ‘c’. Originating package ‘$unit’.
Source info: (c.num[i] inside {[0:9]});