Anywho, let me see if I have this right in my tiny brain:
use IEEE.std_logic_1164.all;
defines what various 'standard' states a signal state can be in at any given point in time, i.e. 'Z' 'X' '1' '0' 'W' 'U' 'L' 'H' '-'
A signal (or vector) can be all of these states, or indeed a subset of these. If using a subset, then depending on what is missing (e.g. 'Z') then the simulation may miss out on telling the user that something 'weird' is going on.
use ieee.numeric_std.all;
A standard library one would want to use.
It defines (among other things I guess):
UNSIGNED
SIGNED
+
-
*
/
mod
So that simple signed and unsigned math can be used on vectors: add, subtract, multiply, divide and modulus.
Also comparisons (operators) between vectors of whatever type, SIGNED or UNSIGNED:
=
/=
<=
>=
>
<
So thinking ahead then, if I wish to use a counter which I know I will want to add 1 to it periodically and then compare it to another number... hence I would want to declare it as an UNSIGNED (or SIGNED):
signal counter : UNSIGNED (7 downto 0);
And hence in a process somewhere, this is therefore OK to then do if I want to increase that counter by 1:
counter <= counter + 1;
Now I want to compare that number to another number say from a data-bus at a certain point in time. the data bus is however declared thus:
DataBus_7_0 : in STD_LOGIC_VECTOR (7 downto 0);
So, in order to match the two types, one must therefore 'cast' into the numeric_std type as this is where the compare '=' operator is defined.
Am I right in assuming this is how this is done correctly:
if counter = UNSIGNED(DataBus_7_0) then
do_something_very_cool;
But what about comparing to a fixed number? Is this OK:
if counter = b"0010_0000" then
do_something_even_cooler;
Question here: that number: b"0010_0000" isn't really a 'number' per-se is it? The above comparison will actually be a logical comparison of bits yes? in other words it is both SIGNED and UNSIGNED if you get my drift? Or is this a necessity instead (or 'better practice')?:
if counter = UNSIGNED(b"0010_0000") then
do_make_Andy_cool_and_not_a_pedantic_nerd;
Cheers,
Andy