Variables can also map to FF's and signals to wires ...
Let me explain a little (and thus incomplete) the background of
signals and varaibles.
VHDL is not a 'sequential language', e.g. concurrent statements
can execute at the same time. However on my INTEL platform
these concurrent statements are executed sequentially!
Concurrent statements can only communicatie with each
others using SIGNALS. The simulation cycle of VHDL has
two stages:
- execute processes (SIGNALS VALUES do ot change)
- update signals (if necessary)
Due to this mechanism concurrent statements can be in any order
in the description whereas the simulation behavior remains the same.
This also explains why SIGNALS are declared in the the
declaration area of the ARCHITECTURE (and some other
places, e.g. ENTITY).
VARIABLE are like variables in other languages. They can only
be declared within a SEQUENTIAL piece of code, e.g.
process, function procedure (forget 'shared variable') and therefore
can not be used for communication with other concurrent statements.
As Pieter already mentioned, variables are always updated
immediatly.
PROCESS(reset,clk)
VARIBALE count : INTEGER;
BEGIN
IF reset='0' THEN
counter := 0; ten<=false;
ELSIF rising_edge(clk) THEN
IF d='1' THEN counter:= counter+1; END IF;
ten <= counter=10;
END IF;
END PROCESS;
Variables can map to FF's. Have a look at the previous description.
After each rising edge of the clock the counter value is incremented
if d is '1'. In this case the variable counter must be remembered, and
indeed your synthesis tool will use a FFs for this variable.
If a variable is always assigned a value BEFORE it is read the
synthesis tool will not use FF's.
The counter value is updated immediatly, e.g. after execution of
counter:= counter+1
counter is incremented immediatly (like in most programming languages)
PROCESS(reset,clk)
VARIBALE count : INTEGER;
BEGIN
IF reset='0' THEN
...
ELSIF rising_edge(clk) THEN
b <= a;
c <= b;
Lets have a look at signals. In the description above SIGNAL b get the
value of a, and next the statement is executed that c gets the value of b.
BUT!!! remember signal values are frozen during execution (=
are never updated immediatly). That means that after execution of
b <= a;
b remains it (old) value. The update of signal b occurs after all concurrent
statements are finished (after a delta delay).
That means that the statement
c <= b;
wil NOT use the value of a. Indeed this looks like a delay line. After
2 active clock edges signal c will have the value of a.
perform a simulation!, and indeed your synthesis tool will also
map this to a cascade of two FFs.
Hope this helps,
Egbert Molenkamp