Variables Vs signals

Z

zingafriend

I was wondering what are the advantages and drawbacks on using
variables as compared to signals in vhdl. I know what they are used to
model, but are there any specific reasons say as regards to simulation
etc?
 
P

Paul Uiterlinden

I was wondering what are the advantages and drawbacks on using
variables as compared to signals in vhdl. I know what they are used to
model, but are there any specific reasons say as regards to simulation
etc?

For communication between processes, only signals can be used (not
considering shared variables here).

If a signal is only used within a process and not read by any other
process, it can be replaced by a variable. The advantage is that the
scope is limited (localized), which in general is a good thing.

In contrast to signals, the order of reading/assigning variables is
important. Remember: the value assigned to a signal can be read back
only after at least a delta cycle. Another way of looking at it (in case
of a flip-flop): a signal only allows acces to the Q output of a
flipflop, a variable also makes it possible to read the D input of a
flipflop.

Variables allow for a more sequential style of "programming", which can
be an advantage.

Finally, when modeling memory (RAM), it is better to use a variable.
Because variables do not have an event queue associated, their space
requirement (memory footprint on your workstation/PC) is about ten times
smaller than the equivalent signal. For large RAMs this could make the
difference between being able to run, or just thrashing your disk caused
by swapping.

Paul.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top