Thanks, I understand what you and that article are saying, but I still have questions.
I read somewhere that it is not a good idea to use signed, unsigned or integer types for ports, since sy thesis tools will always resolve them to std_logic_vector anyway, and this may result in some kind of problems. Can you comment on this?
At the end of the day its all bits. But in the code theres nothing wrong with using std_logic_vector, unsigned, integer, boolean, my_special_amazing_type or any other thing in a port map that can be represented ultimatly with 0s and 1s (this includes enumerated types you might normally use in a state machine). Its normally best to keep to a vector type (std_logic_vector, unsigned, signed etc) at the top level so you can map each bit to a specific pin, but otherwise, fill your boots with whatever types you want.
What is the difference between doing a conversion:
signal some_unsigned : unsigned(7 downto 0) := unsigned(143);
and
signal some_unsigned : unsigned(7 downto 0) := to_unsigned(143);
A big difference, because the first one is not valid VHDL (which I will explain in a minute), and the second one needs another argument to say how many bits you want.
Finally, if you can do this conversion:
signal my_slv : std_logic_vector(7 downto 0) := std_logic_vector(some_unsigned);
then is there a conversion defined:
signal my_slv : std_logic_vector(7 downto 0) := to_std_logic_vector(some_unsigned);
..analogous to to_unsigned() above? And again if so, what is the difference?
The second one doesnt exist because its not needed. In VHDL you can type convert between similar types. std_logic_vector and unsigned/signed are arrays of std_logic:
type std_logic_vector is array(natural range <>) of std_logic;
type unsigned is array(natural range <>) of std_logic;
so as they are basically the same, you can just type convert:
some_slv <= std_logic_vector(some_unsigned);
integer is not an array of std_logic, and so is not a similar type to unsigned/slv, so you need a conversion function, hence:
some_unsigned <= to_unsigned(some_integer, some_unsigned'length);
Does this help explain things?
---------- Post added at 00:44 ---------- Previous post was at 00:42 ----------
Just to add to my first point - theres this lingering idea that you must have std_logic_vector in ports, because in the old days it was the only type accepted by synthesisors for ports. But for at least the last 5 years, thats not been the case.