Professional Documents
Culture Documents
• Subprogram
• Component
• Configuration
• Constant
• Data type
• Port
• Signal
• Variable
General aspects
Case insensitive
Comments: '--' until end of line
Statements are terminated by ';'
(may span multiple lines)
List delimiter: ','
Signal assignment: '<='
User defined names:
letters, numbers, underscores
start with a letter
• ---------------------------------
• -- Example VHDL Code --
• ----------------------------------
• end EXAMPLE;
Aggregrates
• Aggregates bundle signals together
• May be used on both sides of an assignment
• keyword 'other' selects all remaining
elements
architecture EXAMPLE of AGGREGATES is
signal BYTE : bit_vector (7 downto 0);
signal Z_BUS : bit_vector (3 downto 0);
signal A_BIT, B_BIT, C_BIT, D_BIT : bit;
begin
Z_BUS <= ( A_BIT, B_BIT, C_BIT, D_BIT ) ;
( A_BIT, B_BIT, C_BIT, D_BIT ) <=
bit_vector'(``1011``);
• Other types:
"file“
"access"
– FILE and ACCESS types are data types
that provide access to other objects.
• The FILE type is used to read or store data
in a file;
• ACCESS types are comparable with
pointers.
SUBTYPES
• Is a type with a constraint
• The type is called the base type of the
subtype
• subtype MY_WORD is INTEGER range
50 to 100;
• type DIGIT is (‘0’,’1’ ,’2’, ‘3’,’4’);
• subtype PART is DIGIT range ‘1’ to ‘3’;
• Subtypes need not impose a constraint .It
can simply give another name to a type .
Subtypes
• Subsets of existing types
• Same type as the original type
• More readable signal assignments
• Symbolic names for array ranges
ARRAY TYPES
• Definition of an array type
• constrained or unconstrained size
• Declaration of a signal of that type
• range specification necessary
•
• Arrays are a collection of a number of
values of a single data type and are
represented as a new data type in VHDL. It
is possible to leave the range of array
indices open at the time of definition. These
so called unconstrained arrays can not be
used as signals, however, i.e. the index
range has to be specified in the signal
declaration then.
• The advantage of unconstrained
arrays is the possibility to
concatenate objects of different
lengths, for example, because they
are still of the same data type. This
would not be allowed if each array
length was declared as separate data
type.
type STD_ULOGIC_VECTOR is
array (natural range <>) of STD_ULOGIC;
type MY_BYTE is
array(7 downto 0) of STD_ULOGIC;
end EXAMPLE;
• Of course, after synthesis, there will be two
bits for each signal, but a direct assignment
of a two bit vector is not allowed.
• In a signal assignment only those values
may be used which are enumerated in the
type declaration.
Enumeration Types - Example
architecture RTL of TRAFFIC_LIGHT is
type T_STATE is
(INIT,RED,REDYELLOW,GREEN,YELLOW );
signal STATE, NEXT_STATE : T_STATE;
Benefit
• Common industry standard
• gate level netlists
• mathematical functions
• Required for tri-state busses
• By far most of the connections in a design,
either as abstract signals or later on as real
wires, are from one point to another, i.e.
multiple signal drivers would indicate an
error. This kind of error will be easily
detected if just unresolved data types are
used.
• Yet, the resolved counterpart 'std_logic' has
been established as de facto industry
standard despite of some shortcomings. As
all kind of hardware structures, including
bus systems, can be modeled with this data
type it is used by synthesis tools for the
resulting gate level description of a design.
• Even a workaround exists, so that multiple
signal assignments can still be detected: the
port mode 'buffer' allows for a single signal
driver, only. According to the VHDL
language definition, however, the resolution
function has to be called when resolved
signals are assigned. The impact on
simulation performance depends on the
compiler/simulator implementation.
• The last, but certainly not the least
advantage of 'std_logic' based designs is the
existence of standard packages defining
arithmetical operations on vectors. This
eliminates the need for complex type
conversion functions and thus enhances the
readability of the code.
• The ' numeric_std ' package is located
in the library IEEE and provides two
numerical interpretations of the bit
vector, either as signed or as unsigned
integer value. Overloaded operators to
mix vectors and integers in expressions
are also available.
• The typical algebraic operators are available
for integers, such as +,-,* (multiplication),
and / (division). Although these
operations are not built-in for
bit_vectors, they are often provided in
libraries that come with your VHDL
software. They are used with bit_vectors by
interpreting them as a binary representation
of integers, which may be added,
subtracted, multiplied, or divided.
• Please note, that it is impossible to
overload the signal assignment
operator, i.e. a function must be called
in this case.
• Conversion functions ' to_integer ' and '
to_(un)signed ' are also defined in the
package.
• The equivalent of ' numeric_std ' for ' bit '
based operations is called ' numeric_bit '.
• The use of ' bit ' based signals is not
recommended, however, due to the
disadvantages of a 2-valued logic system.