# Enumerated type with common member

**URL:** <https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, enum\
**Created:** [May 23, 2018, 3:02am UTC](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488 "2018-05-23T03:02:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![verif\_learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/7993a0/32.png) [@verif\_learner1](https://verificationacademy.com/forums/u/verif_learner1)\
**Post date:** [May 23, 2018, 3:02am UTC](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488/1 "2018-05-23T03:02:30Z")

</div>

As a part of a agent, I am implementing multiple state machines.  
I have encoded the states of these state machines as enumerated type.  
Needless to say, all of them have IDLE state as a common state.

Example,  
enum {IDLE, TX\_ON, TX\_WAIT …} tx\_state;  
enum {IDLE, RX\_ON, RX\_WAIT …} rx\_state;

Right during the compilation, the compiler complains that the second enumerated type has IDLE which has already been declared. I don’t know if there is a way to get out of this.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [May 23, 2018, 4:10am UTC](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488/2 "2018-05-23T04:10:20Z")

</div>

_In reply to [verif\_learner](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488):_

Enum label names exist in the same scope as the enum itself. You’ll need to use TX\_IDLE and RX\_IDLE similar top what you did with the other names.

---

<div class="post-metadata">

**Author:** ![sbellock](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/f4b2a3/32.png) [@sbellock](https://verificationacademy.com/forums/u/sbellock)\
**Post date:** [May 23, 2018, 3:33pm UTC](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488/3 "2018-05-23T15:33:50Z")

</div>

_In reply to [verif\_learner](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488/2):_

See also [A New Twist on SystemVerilog Enumerated Types](http://blog.verificationgentleman.com/2014/10/a-new-twist-on-sv-enums.html).

---

<div class="post-metadata">

**Author:** ![verif\_learner1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/7993a0/32.png) [@verif\_learner1](https://verificationacademy.com/forums/u/verif_learner1)\
**Post date:** [May 24, 2018, 2:56am UTC](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488/4 "2018-05-24T02:56:03Z")

</div>

_In reply to [sbellock](https://verificationacademy.com/forums/t/enumerated-type-with-common-member/34488/3):_

Thanks, Dave and Bellock. I think I understand the issue now.  
Probably, the best option in my case would be to simply declare the enumerated type declaration its individual class as these are very class specific and unlikely to be used by anyone else.
