# Enum type generation with distributed wight

**URL:** <https://verificationacademy.com/forums/t/enum-type-generation-with-distributed-wight/33466>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, constraint-dist\
**Created:** [September 7, 2017, 9:02pm UTC](https://verificationacademy.com/forums/t/enum-type-generation-with-distributed-wight/33466 "2017-09-07T21:02:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Daniel\_Ciupitu](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/65b543/32.png) [@Daniel\_Ciupitu](https://verificationacademy.com/forums/u/Daniel_Ciupitu)\
**Post date:** [September 14, 2017, 3:52pm UTC](https://verificationacademy.com/forums/t/enum-type-generation-with-distributed-wight/33466/4 "2017-09-14T15:52:32Z")

</div>

Hi Guy,

Dave’s solution is good but the percentage of no\_error packets will be greater than 25%:

- 25% because error\_mode will be 0 in 25% of the cases
- 
  - an additional percentage because no\_error will also appear when error\_mode is 1

The complete solution is:

```verilog

  rand bit error_mode;
  rand Error_t Error_Type;

  constraint Error_Type_c {
    solve error_mode before Error_Type;

    error_mode dist {0:=25, 1:=75};

    error_mode == 0 -> Error_Type == no_error;
    error_mode == 1 -> Error_Type != no_error;
  }

```

Best regards,  
Daniel.

---

_[View the full topic](https://verificationacademy.com/forums/t/enum-type-generation-with-distributed-wight/33466)._
