Ask a question about constraint

I have below code. but never hit ‘low’ with my constraint. May I know why ?


typedef enum { low, middle, hi} my_type;
rand my_type m_type;

constraint my_cons {
  ...
  (m_type == low) -> { wi_en[31:0] != 'h0;};
  (m_type == middle) -> { wi_en[31:0] == 'hFFFF;};
  (m_type == high) -> { wi_en[31:0] == 'hFFFFFFFF;};
  ...
}

In reply to zz8318:

Difficult to tell with this limited info.

  • Are there other constraints on wi_en ?
  • Are there other constraints on m_type ?

Both of the above could lead to you not seeing any “low” in the output.

In reply to zz8318:

Try adding the constraint {m_type == low;} and see if you get any conflicts. If you don’t get a failure, you have an issue with probabilities.