A VHDL synthesis attribute that specifies the logic encoding for an Enumeration Type. By default, the Quartus® Prime Standard Edition software "one-hot" encodes all user-defined Enumeration Types. With this attribute, you can override this default "one-hot" encoding to improve the efficiency of the logic Quartus® Prime Standard Edition synthesizes for your Enumeration Type.
To use the enum_encoding attribute in a VHDL Design File (.vhd) Definition, first declare the attribute with a string type using an Attribute Declaration. Then, associate the attribute with the Enumeration Type whose encoding you wish to control. The enum_encoding attribute must follow the Enumeration Type Definition but precede its use. In addition, the attribute value must be a string literal that specifies either an arbitrary user encoding or an encoding style of "default", "sequential", "gray", "johnson", or "one-hot".
An arbitrary user encoding consists of a space-delimited list of encodings. The list must contain as many encodings as there are enumeration literals in your Enumeration Type. In addition, the encodings must all have the same length, and each encoding must consist solely of values from the std_ulogic type declared by the std_logic_1164 package in the IEEE library. For example, in the following code fragment, the enum_encoding attribute specifies an arbitrary user encoding for the Enumeration Type fruit.
type fruit is (apple, orange, pear, mango); attribute enum_encoding : string; attribute enum_encoding of fruit : type is "11 01 10 00";
In this example, the enumeration literals are encoded as follows:
apple = "11" orange = "01" pear = "10" mango = "00"
Sometimes you wish to specify an encoding style, rather than a manual user encoding, especially when the Enumeration Type has a large number of enumeration literals. The Quartus® Prime Standard Edition software can implement Enumeration Types with four different encoding styles:
Observe that in the previous example, the enum_encoding attribute manually specified a "gray" encoding for the Enumeration Type fruit. This example could be written more concisely by specifying the "gray" encoding style instead of a manual encoding:
type fruit is (apple, orange, pear, mango); attribute enum_encoding : string; attribute enum_encoding of fruit : type is "gray";