01 - Introduction To VHDL
01 - Introduction To VHDL
VISHAL MOYAL/VHDL 1
What Is VHDL?
VHDL is an acronym for
VISHAL MOYAL/VHDL 2
What Is VHDL?
sequential language +
concurrent language +
net-list language +
timing specifications +
VISHAL MOYAL/VHDL 5
Capabilities
The language can be used as an exchange
medium between chip vendors and CAD
tool users.
VISHAL MOYAL/VHDL 6
Capabilities
The language supports hierarchy.
VISHAL MOYAL/VHDL 7
Capabilities
It supports both synchronous and
asynchronous timing models.
VISHAL MOYAL/VHDL 9
Capabilities
The language supports three basic different
description styles: structural, dataflow, and
behavioral.
VISHAL MOYAL/VHDL 14
Hardware Abstraction
VISHAL MOYAL/VHDL 15
Hardware Abstraction
VISHAL MOYAL/VHDL 16
Basic Terminology
1. Entity declaration
2. Architecture body
3. Configuration declaration
4. Package declaration
5. Package body
VISHAL MOYAL/VHDL 17
Entity Declaration
VISHAL MOYAL/VHDL 18
Entity Declaration
The entity declaration specifies the name of
the entity being modeled and lists the set
of interface ports.
VISHAL MOYAL/VHDL 19
Entity Declaration
entity HALF_ADDER is
port (A, B: in BIT; SUM, CARRY: out BIT);
end HALF_ADDER;
-- This is a comment line.
VISHAL MOYAL/VHDL 20
Entity Declaration
entity DECODER2x4 is
port (A, B, ENABLE: in BIT;
Z: out BIT_VECTOR(0 to 3));
end DECODER2x4;
VISHAL MOYAL/VHDL 21
Architecture Body
1. As a set of interconnected components
(to represent structure),
4.VISHAL
Any combination of the above three.
MOYAL/VHDL 22
Dataflow Style
architecture HA_CONCURRENT of HALF_ADDER is
begin
SUM <= A xor B after 8 ns;
CARRY <= A and B after 4 ns;
end HA_CONCURRENT;
VISHAL MOYAL/VHDL 23
Dataflow Style
architecture dec_dataflow of DECODER2x4 is
signal ABAR, BBAR: BIT;
begin
Z(3) <= not (A and B and ENABLE);
Z(0) <= not (ABAR and BBAR and ENABLE);
BBAR <= not B;
Z(2) <= not (A and BBAR and ENABLE);
ABAR <= not A;
Z(1 ) <= not (ABAR and B and ENABLE);
end DEC_DATAFLOW;
VISHAL MOYAL/VHDL 24
Dataflow Style
CLK <= not CLK after 20 ns;
VISHAL MOYAL/VHDL 25
Structural Style
architecture HA_STRUCTURE of HALF_ADDER is
component XOR2
port (X, Y: in BIT; Z: out BIT);
end component;
component AND2
port (L, M: in BIT; N: out BIT);
end component;
begin
X1: XOR2 port map (A, B, SUM);
A1: AND2 port map (A, B, CARRY);
end HA_STRUCTURE;
VISHAL MOYAL/VHDL 26
Structural Style
architecture DEC_STR of DECODER2x4 is
component INV
port (A: in BIT; Z: out BIT);
end component;
component NAND3
port (A, B, C: in BIT; Z: out BIT);
end component;
VISHAL MOYAL/VHDL 28
Behavioral Style
architecture DEC_SEQUENTIAL of DECODER2x4 is
begin
process (A, B, ENABLE)
variable ABAR, BBAR: BIT;
begin
ABAR := not A;
BBAR := not B;
VISHAL MOYAL/VHDL 29
Behavioral Style
if (ENABLE = '1') then
Z(3) <= not (A and B);
Z(0) <= not (ABAR and BBAR);
Z(2) <= not (A and BBAR);
Z(1 ) <= not (ABAR and B);
else
Z<= "1111";
end if;
end process;
End DEC_SEQUENTIAL;
VISHAL MOYAL/VHDL 30
Behavioral Style
process
begin
CLK <= '0' ;
wait for 20 ns;
CLK <= '1' ;
wait for 12 ns;
end process;
VISHAL MOYAL/VHDL 31
Behavioral Style
entity LS_DFF is
port (Q: out BIT; D, CLK: in BIT):
end LS_DFF;
VISHAL MOYAL/VHDL 32
Behavioral Style
if (CLK = '1') then
Q <= D;
end if;
end process;
end LS_DFF_BEH;
VISHAL MOYAL/VHDL 33
Mixed Style
VISHAL MOYAL/VHDL 34
Mixed Style
entity FULL_ADDER is
port (A, B, CIN: in BIT;
SUM, COUT: out BIT);
end FULL_ADDER;
VISHAL MOYAL/VHDL 37
Configuration Declaration
Used to create a configuration for an entity.
VISHAL MOYAL/VHDL 39
Configuration Declaration
library CMOS_LIB, MY_LIB;
configuration HA_BINDING of HALF_ADDER is
for HA-STRUCTURE
for X1:XOR2
use entity CMOS_LIB.XOR_GATE(DATAFLOW);
end for;
for A1:AND2
use configuration MY_LIB.AND_CONFIG;
end for;
end for;
end HA_BINDING;
VISHAL MOYAL/VHDL 40
Package Declaration &
Package Body
A package declaration encapsulates a set of
related declarations such as type
declarations, subtype declarations, and
subprogram declarations that can be
shared across two or more design units.
component D_FLIP_FLOP
port (D, CK: in BIT; Q, QBAR: out BIT);
end component;
VISHAL MOYAL/VHDL 43
Simulation
The simulator simulates an entity,
represented by an entity-architecture pair or
by a configuration, by reading in its compiled
description from the design library and then
performing the following steps:
1. Elaboration
2. Initialization
3. Simulation
VISHAL MOYAL/VHDL 44
Simulation
Elaboration phase: In this phase, the
hierarchy of the entity is expanded and
linked.
components are bound to entities in a
library and the top-level entity is built as a
network of behavioral models that is
ready to be simulated.
VISHAL MOYAL/VHDL 45
Simulation
Initialization phase: The effective
values for all explicitly declared signals are
computed, implicit signals (discussed in
later chapters) are assigned values,
processes are executed once until they
suspend, and simulation time is reset to 0
ns.
VISHAL MOYAL/VHDL 46
Model Analysis
VISHAL MOYAL/VHDL 47
Basic Language Elements
Identifiers
Data Objects
Data Types
Operators
VISHAL MOYAL/VHDL 48
Identifiers
Composed of a sequence of one or more
characters
VISHAL MOYAL/VHDL 49
Identifiers
DRIVE_BUS
SelectSignal
RAM_Address
SET_CK_HIGH
CONST32_59
r2d2
VISHAL MOYAL/VHDL 50
Identifiers
entity UART is end; --This comment starts
after the entity
declaration.
VISHAL MOYAL/VHDL 51
Identifiers
The language defines a set of reserved
words; called keywords, have a specific
meaning in the language, and therefore,
cannot be used as identifiers.
VISHAL MOYAL/VHDL 52
Data Objects
Holds a value of a specified type.
VISHAL MOYAL/VHDL 53
Data Objects
Constant
Variable
Signal
VISHAL MOYAL/VHDL 54
Data Objects
Constant:
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.
VISHAL MOYAL/VHDL 55
Data Objects
VISHAL MOYAL/VHDL 56
Data Objects
Variable:
An object of variable class can also hold a
single value of a given type.
However in this case, different values can
be assigned to the object at different
times using a variable assignment
statement.
VISHAL MOYAL/VHDL 57
Data Objects
Variable CTRL_STATUS:
BIT_VECTOR(10 downto 0);
VISHAL MOYAL/VHDL 58
Data Objects
Signal:
An object belonging to the signal class has
a past history of values, a current value,
and a set of future values.
Future values can be assigned to a signal
object using a signal assignment
statement.
VISHAL MOYAL/VHDL 59
Data Objects
signal CLOCK: BIT;
VISHAL MOYAL/VHDL 60
Data Types
Scalar types:
Values belonging to these types appear in a
sequential order.
Composite types:
These are composed of elements of a single
type (an array type) or elements of different
types (a record type).
VISHAL MOYAL/VHDL 61
Data Types
Access types:
These provide access to objects of a given
type (via pointers).
File types:
These provides access to objects that
contain a sequence of values of a given type.
VISHAL MOYAL/VHDL 62
Data Types
Subtypes
A subtype is a type with a constraint.
VISHAL MOYAL/VHDL 63
Data Types
An object can be declared to either belong to
a type or to a subtype.
subtype MY_INTEGER is INTEGER range 48 to
156 ;
type DIGIT is ('0', '1', '2', '3', '4', '5', '6', '7', '8',
'9') ;
VISHAL MOYAL/VHDL 64
Data Types
Scalar Types
The values belonging to this type are
ordered, that is, relational operators can be
used on these values.
VISHAL MOYAL/VHDL 65
Data Types
There are four different kinds of scalar
types. These types are
1. enumeration,
2. integer,
3. physical,
4. floating point.
VISHAL MOYAL/VHDL 66
Data Types
Enumeration Types
An enumeration type declaration defines a
type that has a set of user-defined values
consisting of identifiers and character
literals.
VISHAL MOYAL/VHDL 67
Data Types
type MVL is ('U','0','1','Z);
VISHAL MOYAL/VHDL 68
Data Types
signal CONTROL_A: MVL;
VISHAL MOYAL/VHDL 69
Data Types
Integer Types
An integer type defines a type whose set
of values fall within a specified integer
range.
VISHAL MOYAL/VHDL 70
Data Types
type INDEX is range 0 to 15;
VISHAL MOYAL/VHDL 71
Data Types
VISHAL MOYAL/VHDL 72
Data Types
Values belonging to an integer type are
called integer literals. Examples of integer
literals are
56349
6E10
98_71_28
VISHAL MOYAL/VHDL 73
Data Types
Floating point type:
A floating point type has a set of values in
a given range of real numbers.
VISHAL MOYAL/VHDL 74
Data Types
An example of an object declaration is
variable LENGTH: REAL_DATA range 0.0 to
15.9;
VISHAL MOYAL/VHDL 75
Data Types
The range bounds specified in a floating point
type declaration must be constants or locally
static expressions.
VISHAL MOYAL/VHDL 76
Data Types
Physical Types
A physical type contains values that
represent measurement of some physical
quantity, like time, length, voltage, and
current.
VISHAL MOYAL/VHDL 77
Data Types
type CURRENT is range 0 to 1 E9
units
nA; -- (base unit) nano-ampere
uA = 1000 nA; -- micro-ampere
mA = 1000 A; --milli-ampere
Amp = 1000 mA; -- ampere
end units;
subtype FILTER_CURRENT is CURRENT range
10 A to 5 mA;
VISHAL MOYAL/VHDL 78
Data Types
The only predefined physical type is TIME and
its range of base values.
VISHAL MOYAL/VHDL 79
Data Types
Composite Types
A composite type represents a collection of
values.
an array type
a record type.
VISHAL MOYAL/VHDL 80
Data Types
Array Types
An object of an array type consists of elements
that have the same type.
VISHAL MOYAL/VHDL 81
Data Types
POSITIVE and NATURAL are predefined subtypes;
VISHAL MOYAL/VHDL 82
Data Types
Examples of object declarations using these types
are
variable ROM_ADDR: ROM;
VISHAL MOYAL/VHDL 83
Data Types
Record Types
An object of a record type is composed of
elements of same or different types.
VISHAL MOYAL/VHDL 84
Data Types
Values can be assigned to a record type object
using aggregates.
VISHAL MOYAL/VHDL 85
Data Types
Access Types:
Values belonging to an access type are pointers to
a dynamically allocated object of some other type.
They are similar to pointers in Pascal and C
languages.
VISHAL MOYAL/VHDL 86
Data Types
Access Types:
Values belonging to an access type are pointers to
a dynamically allocated object of some other type.
They are similar to pointers in Pascal and C
languages.
VISHAL MOYAL/VHDL 87
Data Types
Incomplete Types
It is possible to have an access type that points
to an object that has elements which are also
access types.
type type-name;
VISHAL MOYAL/VHDL 88
Data Types
VISHAL MOYAL/VHDL 89
Data Types
File Types
Objects of file types represent files in the
host environment.
VISHAL MOYAL/VHDL 90
Data Types
type file-type-name is file of type-name,
VISHAL MOYAL/VHDL 91
Data Types
A file is declared using a file declaration.
VISHAL MOYAL/VHDL 92
Operators
The predefined operators in the language are
classified into the following five categories:
1. Logical operators
2. Relational operators
3. Adding operators
4. Multiplying operators
5. Miscellaneous operators
VISHAL MOYAL/VHDL 93
Operators
Logical Operators
Relational Operators
VISHAL MOYAL/VHDL 94
Operators
Adding Operators
+ - &
'0' & '1'
results in an array of characters "01".
* / mod rem
A rem B = A - ( A / B ) * B
VISHAL MOYAL/VHDL 96
Operators
Miscellaneous Operators
abs **
VISHAL MOYAL/VHDL 97