VHDL 1
VHDL 1
HDL Programming
-VHDL-
Textbook: Volnei A. Pedroni, “Circuit Design with
VHDL”, MIT Press London, England, 2004.
GENERIC:
specifying a generic parameter (that is, a static
parameter ).
code more flexibility and reusability.
must be declared in the ENTITY.
VHDL>Static and non-static data
SIGNAL:
pass values in and out the circuit, as well as between its
internal units.
circuit interconnects (wires).
VHDL>Static and non-static data
VARIABLE:
represents only local information.
It can only be used inside a sequential code (PROCESS
for example).
VHDL>Static and non-static data
VHDL> Operators
Assignment operators
Operator using
<= SIGNAL.
:= VARIABLE, CONSTANT,
GENERIC,
initial values.
=> vector elements or with
OTHERS.
VHDL> Operators
Assignment operators
VHDL> Operators
Logical operators:
perform logical operations.
Data types: BIT, STD_LOGIC, STD_ULOGIC,
BIT_VECTOR, STD_LOGIC_VECTOR, or
STD_ULOGIC_VECTOR
NOT
AND
OR
NAND
NOR
XOR
XNOR
VHDL> Operators
Arithmetic Operators:
perform arithmetic operations
data types: INTEGER, SIGNED, UNSIGNED, or
REAL
With std_logic_signed or std_logic_unsigned
package: STD_LOGIC_VECTOR.
VHDL> Operators
N bit adder circuit:
VHDL> Operators
N bit adder circuit:
VHDL> Operators
Comparison Operators:
Used for making comparisons.
Data types: any.
VHDL> Operators
N bit comparator:
VHDL> Operators
VHDL> Operators
Shift Operators:
Syntax:
VHDL> Data Attributes
The pre-defined, synthesizable data attributes are the
following:
d‟LOW: Returns lower array index
d‟HIGH: Returns upper array index
d‟LEFT: Returns leftmost array index
d‟RIGHT: Returns rightmost array index
d‟LENGTH: Returns vector size
d‟RANGE: Returns vector range
d‟REVERSE_RANGE: Returns vector range in
reverse order
VHDL> Data Attributes
VHDL> Signal Attributes
Let us consider a signal s. Then:
s‟EVENT: Returns true when an event occurs on s.
s‟STABLE: Returns true if no event has occurred on s.
VHDL> User-Defined Attributes
VHDL also allows the construction of user defined
attributes.
VHDL> Examples
Generic Parity Detector:
The circuit must provide output = „0‟ when the number
of „1‟s in the input vector is odd, or output = „1‟
otherwise.
VHDL> Examples
Generic Parity Detector:
temp input
0 1
0
1
1
XOR 0
1 1
1
0
VHDL> Examples
Generic Parity Generator:
The circuit must add one bit to the input vector (on its
left).
Such bit must be a „0‟ if the number of „1‟s in the input
vector is even, or a „1‟ if it is odd, such that the resulting
vector will always contain an even number of „1‟s (even
parity).
VHDL> Examples
Generic Parity Generator:
input temp2
1 1
0 0
1 1
1 1
0 0
1 1
1 1
0
temp1
0
VHDL> Examples
Generic Decoder:
If ena = „0‟, then all bits of x should be high; otherwise,
the output bit selected by sel should be low.
VHDL> Examples
Generic Decoder: