Вы находитесь на странице: 1из 15

Basic Language Elements

 Identifiers : An identifier in VHDL is composed of a


sequence of one or more characters .
 A legal character is
 an upper-case letter (A... Z)
 a lower-case letter (a. .. Z)
 a digit (0 . . . 9)
 the underscore ( _ ) character
 The first character in an identifier must be a letter
and the last character may not be an underscore
 Examples of identifiers are
 DRIVE_BUS SelectSignal SET_CK_HIGH CONST32_59
Data Objects
 A data object holds a value of a specified type.
 Every data object belongs to one of the following
three classes:
 1. 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.
 2. 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.
 3. 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.
Continued..
Signal objects are typically used to model wires
and flip-flops while variable and constant
objects are typically used to model the
behavior of the circuits
Examples of constant declarations are
constant RISE_TIME: TIME := 10ns;
constant BUS_WIDTH: INTEGER := 8;
Examples of variable declarations are
Variable CTRL_STATUS: BIT_VECTOR(10 downto
0); variable SUM: INTEGER range 0 to 100 := 10;
variable FOUND, DONE: BOOLEAN;
Continued..
Examples of signal declarations.
signal CLOCK: BIT;
signal DATA_BUS: BIT_VECTOR(0 to
7);
signal GATE_DELAY: TIME := 10 ns;
Data Types
 All the possible types hat can exist in the language
can be categorized into the following four major
categories:
 1. Scalar types: Values belonging to these types
appear in a sequential.
 2. Composite types: These are composed of
elements of a single type (an array type) or elements
of different types (a record type).
 3. Access types: These provide access to objects of a
given type (via pointers).
 4. File types: These provides access to objects that
contain a sequence of values of a given type. It is
possible to derive restricted types, called subtypes,
from other predefined or user-defined types.
VHDL Data Types Diagram.
Types

Composit
File Access e

Recor
Array
d

Scalar

Physica
Enumerat l
ed
Intege
Real r
Continued..
There are four different kinds of scalar types.
These types are:
 1. enumeration
 2. integer
 3. physical
 4. floating point
Every value belonging to an enumeration type
integer type, or a physical type has a position
number associated with it. This number is the
position of the value in the ordered list of
values belonging to that type.
Continued..
Enumeration Types: An enumeration type
declaration defines a type that has a set of
user-defined values consisting of identifiers and
character literals. Examples are
Type MVL is ('U','0','1','Z); type MICRO_OP is (LOAD, STORE, ADD,
SUB, MUL, DIV); subtype ARITH_OP is MICRO_OP range ADD to DIV;

Examples of objects defined for these types are

signal CONTROL_A: MVL;


signal CLOCK: MVL range '0' to '1'; -- Implicit subtype declaration.
variable IC: MICRO_OP := STORE; -- STORE is the initial value for IC.
variable ALU: ARITH_OP;
Continued..
 Integer Types: whose set of values fall within a
specified integer range. Examples of integer type
declarations are:
type INDEX is range 0 to 15;
type WORD_LENGTH is range 31 downto 0;
subtype DATA_WORD is WORD_LENGTH range 15 downto 0;
type MY_WORD is range 4 to 6;

Some object declarations using these types are

constant MUX_ADDRESS: INDEX := 5;


signal DATA_BUS: DATA_WORD;

 INTEGER is the only predefined integer type of the


language. The range of the INTEGER type is
implementation dependent but must at least cover the
range -(2^ 31 - 1) to +(2^31 - 1).
Continued..
 Floating Point Types: floating point type has a set of values
in a given range of real numbers. Examples of floating point
type declarations are
type TTL_VOLTAGE is range -5.5 to -1.4;
type REAL_DATA is range 0.0 to 31.9;

An example of an object declaration is

variable LENGTH: REAL_DATA range 0.0 to 15.9;


variable LI, L2, L3: REAL_DATA range 0.0 to 15.9;
 The minimum range of real numbers is also specified by the
Standard package in the Standard Library, and is from 1.0E38
to 1.0E38.
Continued..
 Physical Types: physical type contains values that represent
measurement of some physical quantity, like time, length, voltage,
and current. Values of this type are expressed as integer multiples of
a base unit. An example of a physical type declaration is
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;
 The only predefined physical type is TIME and its range of base
values, which again is implementation dependent, must at least be -
Composite Types
 A composite type represents a collection of values. There are two composite
types:
 An array type: represents a collection of values all belonging to a single type
 A record type: represents a collection of values that may belong to same or
different types.
 Array Types
Examples of array type declarations are

type ADDRESS_WORD is array (0 to 63) of BIT;


type DATA_WORD is array (7 downto 0) of MVL;
type ROM is array (0 to 125) of DATA_WORD;
type DECODE_MATRIX is array (POSITIVE range 15 downto 1,
NATURAL range 3 downto 0) of MVL;
--POSITIVE and NATURAL are predefined subtypes; these are:
subtype NATURAL is INTEGER range 0 to INTEGER'HIGH;
subtype POSITIVE is INTEGER range 0 to INTEGER'HIGH;
Continued..
Examples of object declarations using these types are

variable ROM_ ADDR: ROM;


signal ADDRESS.BUS: ADDRESS_WORD;
constant DECODER: DECODE_MATRIX;
variable DECODE_VALUE: DECODE_MATRIX;
 The language also allows array types to be unconstrained
 The number of elements in the array is not specified in the type
declaration.
 The object declaration for that type declares the number of element of
the array.
 A subtype declaration may also specife index constraint for an
unconstrained array type.
Examples of unconstrained array declarations are

type STACK_TYPE is array (INEGER range <>) of ADDRESS_WORD;


subtype STACK is STACK_TYPE(0 to 63);
type OP_TYPE is (ADD, SUB, MUL, DIV);
type TIMING is array (OP_TYPE range<>, OP_TYPE range <>) of TIME;

Examples of object declarations using these types are

variable FAST_STK: STACK_TYPE(-127 to 127);


constant ALU_TIMING: TIMING :=
--ADD, SUB, MUL
((10 ns, 20 ns, 45 ns), -- ADD
(20 ns, 15 ns, 40 ns), -- SUB
(45 ns, 40 ns, 30 ns)); -- MUL
There are two predefined one-dimensional
unconstrained array types in the language
 STRING: an array of characters.
 BIT_VECTOR: an array of bits.

Вам также может понравиться