Data Objects
Data Objects
Data Objects
q The use of constants and variables in VHDL is similar to what you are already familiar
with from other programming languages.
q Signals usually represent voltages on wires. But you can also use a signal in place of a
variable. Sometimes it may not matter if you use a signal or a variable.
q Other times there may be subtle reasons for using one over the other.
q The signal represents interconnection wires between ports
q it may be declared in the declaration part of Signal objects are typically used to
model wires and flip-flops
signal CLOCK ;
signal DATA_BUS: BIT_VECTOR(0 to 7);
signal GATE_DELAY: TIME := 10 ns;
Variable
qThe constant names specific values to make the model better documented and
easy to update.
qThe constant can be declared in all the declarative VHDL statement,
qsequential
qconcurrent
qIt may be declared in the declaration section of packages, entities, architectures,
processes, subprograms and blocks
q An object of constant class can hold a single value of a given type. This
value is assigned to the object before simulation starts and the value
cannot be changed during the course of the simulation.
constant RISE_TIME: TIME := 10ns;
constant BUS_WIDTH: INTEGER := 8;
q The value of the constant has not been specified, called as a deferred
constant and it can appear only inside a package declaration. The
complete constant declaration with the associated value must appear in
the corresponding package body.
constant NO_OF_INPUTS: INTEGER;
This example highlights the difference
between signals and variables
ARCHITECTURE test1 OF mux IS ARCHITECTURE test2 OF mux IS
SIGNAL x : BIT := '1'; SIGNAL y : BIT := '0';
SIGNAL y : BIT := '0'; BEGIN
BEGIN PROCESS (in_sig, y)
PROCESS (in_sig, x, y) VARIABLE x : BIT := '1';
BEGIN BEGIN
x <= in_sig XOR y; x := in_sig XOR y;
y <= in_sig XOR x; y <= in_sig XOR x;
END PROCESS; END PROCESS;
END test1; END test2;
File
q Files provide a way for a VHDL design to communicate with the host
environment.
q File declarations make a file available for use to a design.
q Files can be opened for reading and writing.
q It is used only in test bench; in fact File type cannot be implemented in
hardware.
q In order to use the FILE type you shall include the TextIO package that
contains all procedures and functions that allow you to read from and
write to formatted text files.
Thank
You