How to convert enumerated data type to std_log_vector in VHDL?

Status
Not open for further replies.

bansalr

Full Member level 3
Joined
Dec 22, 2005
Messages
152
Helped
20
Reputation
40
Reaction score
5
Trophy points
1,298
Activity points
2,165
Is there any simple way to convert enumerated data type to std_log_vector in vhdl
 

Re: enumerated data type

bansalr said:
Is there any simple way to convert enumerated data type to std_log_vector in vhdl

Yes, VHDL has POS attribute that returns an integer value of enum.

Code:
   my_int <= my_enum_type'pos(my_enum);

If you need direct SLV, then

Code:
  my_slv <= std_logic_vector(to_unsigned(my_enum_type'pos(my_enum), 8);

HTH
Ajeetha, CVC
www.noveldv.com
 

Re: enumerated data type

type state is (a,b,c,d,e,f);
signal cur_state :state;

I want to convert the state to std_logic_vector.
POS will return the individual position of the type.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…