tudortimi / constraints

Reusable constraints
Apache License 2.0
3 stars 1 forks source link

Add possibility to add constraints infrastructure for classes that already have an implementation of `pre_randomize` #6

Closed tudortimi closed 1 year ago

tudortimi commented 2 years ago

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
tudortimi commented 2 years ago

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.

tudortimi commented 1 year ago

Fixed in #11