I am trying to constrain an enum variable to be randomized in a class but I get the following error on Questa Sim:
** Failure: noc_prog.sv(0): Invalid random variable in index expression for constraint.
My constraint is:
constraint links {
if ((this.noc_member.router_grid[this.router_row_idx][this.router_col_idx].row_idx == 0) && (this.noc_member.router_grid[this.router_row_idx][this.router_col_idx].col_idx == 0) && (! (this.noc_member.router_grid[this.router_row_idx][this.router_col_idx].isLinkActive(EAST)) || ! (this.noc_member.router_grid[this.router_row_idx][this.router_col_idx].isLinkActive(SOUTH))))
router_links inside {NORTH, WEST};
else
router_links inside {NORTH, EAST , SOUTH, WEST};
}
Where “router_links” is of type:
typedef enum {NORTH = 0, EAST = 1, SOUTH = 2, WEST = 3, LOCAL = 4} e_ports_direction;
and “router_row_idx”, “router_col_idx”, “row_idx”, “col_idx” are of type “int”.
A glimpse of my class members:
class disable_links_random;
static rand int router_row_idx;
static rand int router_col_idx;
static rand e_ports_direction router_links;
static noc noc_member;
...
What am I doing wrong?