I have looked around on SE but couldn t find anything that worked properly for me.
I am looking for a way to convert a 4 bit signal_vector to an integer. However I do calculations on signals as well. This means I need the library called
use IEEE.std_logic_arith.all
This is (the condensed version of) what I have so far:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
USE ieee.numeric_std.ALL;
use IEEE.std_logic_unsigned.all;
signal counter: std_logic_vector(3 downto 0);
counter<=counter + "0001";
...
if ((to_integer(counter)) < (to_integer("0100"))) then
-- do something
end if;
this gives me the following error: Identifier "unsigned" is not directly visible.
Best Answer
Please do not use the ieee.std_logic_arith library. It is outdated and makes problems when combining with others.
You can convert your signal as following:
If you plan to use a signal as a number most of the time, try to use type unsigned or signed if possible. You can always convert it to a std_logic_vector if needed.
Source: http://www.bitweenie.com/listings/vhdl-type-conversion/
EDIT:
I made a complete codesample that compiles and simulates in Vivado (should also work in modelsim):