Generation is the process that produces values for fields and variables (data items). During the generation phase, the entire tree of instances under the struct sys is generated.
Constraints are needed because a large part of the design is exercised only by stimuli that have specific legal relationships between the fields. These legal relationships are set by the design specification and the test plan. Constraints are directives that influence the behavior of the generator. They are declared within a struct and influence the generation of values for data items within the struct and its sub-tree.
There are two basic types of constraints: value constraints and order constraints.
A constraint is a boolean expression that specifies the relationships between various fields. The most basic form of a constraint is specified using the keyword keep.
Implication constraints set up constraints on fields or list members based on another boolean expression being true. Implication constraints are specified using the => operator.
Often constraints are specified as a default preference. These constraints need to be overridden later. These are called soft constraints and are specified using the keywords keep soft.
All soft constraints for a field can be reset with the reset_soft() constraint.
A weighted constraint specifies the relative probability that a particular value or set of values is chosen from the current range of legal values. Weighted constraints are specified with the keywords keep soft select.
The default generation order is the order in which fields are defined in a struct. One can override this default order by adding explicit order rules using the keep gen before constraint.
One can inhibit generation of fields by prefixing these fields with a ! symbol.