How to step through an enumerated type?

A

Andrew FPGA

Guest
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
 
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.
 

Welcome to EDABoard.com

Sponsor

Back
Top