Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] I found this syntax helpful. T'pos(X)

Status
Not open for further replies.

Port Map

Advanced Member level 4
Full Member level 1
Joined
Aug 24, 2013
Messages
118
Helped
15
Reputation
30
Reaction score
14
Trophy points
1,298
Visit site
Activity points
2,089
sometimes we need to display a state machine's state on LEDs or signals.
the syntax below helps us to display the number of state machine on LEDs.

Syntax: T'pos(X) Returns the position number of X within the type T.

example:
Code:
type tState is (S1,S2,S3);
signal sMainState:tState:=S1;
signal sLeds	:std_logic_vector(2 downto 0);
....
...
sLeds	<=conv_std_logic_vector(tState'pos(sMainState),sLeds'length);
 


Code VHDL - [expand]
1
sLeds   <=conv_std_logic_vector(tState'pos(sMainState), sLeds'length);

And here is how to do it with the standard library numeric_std:

Code VHDL - [expand]
1
sLeds   <= std_logic_vector(to_unsigned(tState'pos(sMainState),sLeds'length));

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top