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 agothere are a couple of methods.
Convert it to unsigned by implicitly making it an array: ASamplexDY(to_integer( unsigned'("" & IsISamplexS) )) <= DxDY; here, the ( "" & IsISamplexS ) makes it an array of length 1, and the unsigned' qualifies it as an unsigned because it could be signed or unsigned. Secondly, write a conversion function yourself:
function to_integer( s : std_logic ) return natural is
begin
if s = '1' then
return 1;
else
return 0;
end if;
end function;
ASamplexDY(to_integer( IsISamplexS )) <= DxDY;