How to step through an enumerated type?

A

Andrew FPGA

Hi,
It would seem the use of the predifined attribute "succ" is a nice way
to sequence through the values in an enumerated type.
e.g. next_enum_value := enum_value_type'succ(current_enum_value);

Only problem is, it does not appear to be synthesizable in XST 8.1i
sp3. I get the error message below:
Analyzing Entity <Dummy> (Architecture <dummyarch>).
ERROR:Xst:772 - "C:/project...../Dummy.vhd" line 92: Attribute is not
authorized : 'succ'.

Can anyone suggest a better way of doing this? I.e. it needs to be
synthesisable.

Regards
Andrew
 
A

amakyonin

I have not checked out how XST handles enumeration attributes. You may
have some luck using the 'val and 'pos attributes to replicate 'succ:

next_enum_value :=
enum_value_type'val(enum_value_type'pos(current_enum_val)+1);

You will have to ensure you don't attempt to index past the end of the
enum.

If you're iterating over a fixed sequence of elements in the
enumeration type you should try using the 'range attribute in a loop or
a for-generate:

for i in enum_value_type'range loop
...
end for;

With Synplify this works provided the enum has a binary encoding. If
you only want to iterate over a subset of the enum then you can create
a subtype with the necessary bounds and use its 'range attribute for
the loop boundy condition.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top