Forum Discussion
Altera_Forum
Honored Contributor
13 years agoconversion of std_logic (NOT std_logic_vector) to integer
Dear All, could someone advice, how to convert single bit information into integer so I could use it as index to an array? Conversion of std_logic_vector/unsigned/signed vectors is easy ...
Altera_Forum
Honored Contributor
13 years agoI just thought Id show off a little bit, just to show you the things you can do with VHDL. There is nothing forcing you to using integers for arrays. You can actually use any enumerated type. eg:
type sl_array_t is array( std_logic range <> ) of integer;
signal my_array : sl_array('0' to '1');
signal sel : std_logic;
output <= my_array(sel);
This way, if sel ever becomes anything other than '0' or '1' during simulation, you will get an array index out of bounds exception. Quartus should synthesise this, Ive tested arrays using the character type as the arary index before, and it infered me a ram.