I want to have a class where I want to put all of the rand variables with some default value which should be only randomized if they are assigned non-default value from their handle
Example
typedef enum {
NORTH = 0,
SOUTH = 1,
EAST = 2,
WEST = 3,
DEFAULT_DIR = 4
} direction_t;
class dir_class;
rand direction_t dir;
// I want something like
// rand direction_t dir = DEFAULT_DIR;
constraint dir_c
{
if(dir != DEFAULT_DIR)
{
dir inside {NORTH,SOUTH,WEST,EAST};
}
}
endclass: dir_class
Now what I want is when I take handle of this class I might want to assign some non default value (which could be done with inline constraint) but I don’t want to use that because I might end up having 100s of such variable.
So what I need is that initially all of the variables should be having some default enum value like DEFAULT_RAND
and only be randomized if they hold this default value otherwise keep the value that is passed via handle