Currently, constraints_utils tries to define pre_randomize. This doesn't work for classes that already have an implementation of pre_randomize. In such a case, we should split the macro into one that creates the necessary infrastructure for the add_<scope>_constraint functions, and another macro that hooks it up in pre_randomize, which the user can insert in their implementation of pre_randomize:
class some_class;
function void pre_randomize();
// do stuff
// ...
`constraints_pre_randomize_hook
endfunction
`constraint_infrastructure_wo_pre_randomize_hook(some_class)
endclass
This would also help for classes that don't have a base class, as constraints_infrastructure inserts a call to super.pre_randomize, which isn't legal in such a context.
Currently,
constraints_utils
tries to definepre_randomize
. This doesn't work for classes that already have an implementation ofpre_randomize
. In such a case, we should split the macro into one that creates the necessary infrastructure for theadd_<scope>_constraint
functions, and another macro that hooks it up inpre_randomize
, which the user can insert in their implementation ofpre_randomize
: