Dist operator with enum dynamic array

i am trying to form a dynamic array of enum using 2 const arrays of enums in the following manner

typedef enum bit[7:0] {read,write,decode,execute,memory,write_back} commands_t;

const commands_t cmds_one[]='{read,write,decode,execute};

const commands_t cmds_two[]='{memory,write_back};

rand commands_t cmd[];

constraint cmd_size_cnsrt {cmd.size() inside {[5:10]}; 
                           cmd dist {cmds_one:=10 ,cmds_two};
                          }

but it gives error , any help ?

In reply to bassem yasser:

Constraints only work with integral expressions, not arrays. So you need to add another random selection variable and use an implication.

rand bit select; // or use another enum

constraint cmd_select {cmd.size() inside {[5:10]}; 
                       select dist { 1:=10, 0};
                       foreach {cmd[list]} if (select)
                               cmd[list] inside {cmds_one};
                             else 
                               cmd[list] inside {cmds_two};
                      }

Did not try to compile this, so there may be syntax errors.

In reply to dave_59:

typedef enum bit[7:0] {read,write,decode,execute,memory,write_back} commands_t;
 
const commands_t cmds_one[]='{read,write,decode,execute};
 
const commands_t cmds_two[]='{memory,write_back};
 
rand commands_t cmd[];
 
constraint cmd_size_cnsrt {
                           cmd.size() inside {[5:10]}; 
                           foreach(cmd[i])
                              cmd[i] dist {[read:execute]:=10 ,[memory:write_back]};
                          }