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 is there any way how to do following using only numeric_std library? ASamplexDY(to_integer(IsISamplexS)) <= DxDY; where IsISamplexS is type std_logic Of course the line above does not work as there is no function to_integer which would take std_logic. If I try to convert first to unsigned, it does not work either because it is not vector. One can do trick like this: AVERAGERS : process (ClkxC, ResetxRNA) is variable vMessxD : std_logic_vector(1 downto 0); --! bleh begin -- process AVERAGERS if ResetxRNA = '0' then --! asynchronous reset (active low) ASamplexDY <= (others => (others => '0')); elsif rising_edge(ClkxC) then --! rising clock edge vMessxD := '0' & IsISamplexS; -- we are inside the processing of the I sample: if SwitchSignxS = '0' then ASamplexDY(to_integer(unsigned(vMessxD))) <= DxDY; else ASamplexDY(to_integer(unsigned(vMessxD))) <= ASamplexDY(to_integer(unsigned(vMessxD))) + OpositeSignDataxM; end if; end if; end process AVERAGERS; but it looks ugly and stupid. thanks .d.