I have multiple inputs that belong together(get sampled at the same clock etc.) but are not logically a vector(i.e. not a parallel bus) in a piece of existing code I need to modify.
Previously, they were defined as
type my_type is array (my_width - 1 downto 0) of std_logic;
signal my_signal : my_type;
Until now, for this purpose, I always used this:
subtype my_subtype is std_logic_vector(my_width - 1 downto 0);
signal my_signal : my_subtype;
For most intentions and purposes, an array and a vector can be handled pretty much the same, so my question is:
Is there any advantage to either way of doing things? Is there a preferred/standard way?
std_logic_vectorin theieee.std_logic_1164package, the other means you have to write and test your own. It's a no-brainer. - user_1818839std_logic_vectoris intended to represent arrays of bits that belong together. It is actually more suited to something like a group of status LEDs than (eg) an address bus. This is because something like an address bus is actually a number and one should be cautious about usingstd_logic_vectorto represent a number. Instead you should consider using theunsignedtype for an address bus. (Though, it is common to restrict oneself tostd_logicandstd_logic_vectorfor inputs and outputs of main blocks, because that might ease the later stages of the flow.) - Matthew Taylor