Randomization

Random Variables


rand modifier
Variables declared with keyword rand are random variables. Their values are uniformly distributed over their range.

Syntax:



randc modifier
Variables declared with keyword randc are random-cyclic variables. Their random values are not repeated until every possible value has been assigned.
Random-cyclic can only be of type bit or enumerated types, and can be limited to a maximum size.

Syntax:



Contraint Blocks

  • The values of the random variables are determined using constraint expressions that are declared using constraint blocks.
  • Constraint blocks are class members, like tasks, functions and variables.
  • Constraint block names must be unique within a class
External Constraint Blocks
Constraint blocks can be declared outside a class declaration, just like external task and function bodies.








Inheritance
  • Constraints follow the same general rules for inheritance as class variables, tasks and functions.
  • A constraint in a derived class that uses the same name as a constraint in its parent class overrides the constraint in the base class.








Set Membership
  • You can create sets of values with the inside operator.
  • All values(either single value or values ranges), have an equal probability of being chosen.




  • If you want any value, as long as it is not inside a set, invert the constraint with NOT operator.




  • You can use $ as a shortcut for the minimum and maximum values for a range

No comments:

Post a Comment