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.

Type attribute for enum types in VHDL

Status
Not open for further replies.

ash72

Newbie level 5
Joined
Feb 10, 2020
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
88
VHDL question:

Assume you have an enum type as follows

type color is (R, G, B);

Type attribute color'left will give "R". And color'low will also give "R". In such a case will 'left and 'low ever produce different result? If no, then what's the use of these two different attributes for enum type?
 

Solution
But it says that the numeric values associated are always in ascending range - 0 to N. So, 'Left and 'Low will still result in the same value. Maybe I am missing something.
Yes they do. You are missing nothing. The attributes are not specifically made for enums, they exist as general feature for vectors and other aggregates. It's your choice if you consider positional or numerical order for enums more intuitive.
The reason for getting the reported attribute values can be understood by reviewing the VHDL LRM, specifically
5.2.2 Enumeration types
5.2.2.1 General
You see that enumerations have an implicite order.
If no, then what's the use of these two different attributes for enum type?
The predefined attributes exist for all types they can be applied on, no matter if they have a specific use.
 

    ash72

    Points: 2
    Helpful Answer Positive Rating
Thanks much for the pointer to LRM. There is only one paragraph in LRM that talks about encoded values of the enumeration literals. But it says that the numeric values associated are always in ascending range - 0 to N. So, 'Left and 'Low will still result in the same value. Maybe I am missing something. Thanks in advance.

LRM:
Each enumeration literal yields a different enumeration value. The predefined order relations between
enumeration values follow the order of corresponding position numbers. The position number of the value
of the first listed enumeration literal is zero; the position number for each additional enumeration literal is
one more than that of its predecessor in the list.
 

But it says that the numeric values associated are always in ascending range - 0 to N. So, 'Left and 'Low will still result in the same value. Maybe I am missing something.
Yes they do. You are missing nothing. The attributes are not specifically made for enums, they exist as general feature for vectors and other aggregates. It's your choice if you consider positional or numerical order for enums more intuitive.
 
  • Like
Reactions: ash72

    ash72

    Points: 2
    Helpful Answer Positive Rating
Solution
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top