L2 (Parts 1,2)
L2 (Parts 1,2)
1214-0420
Anas Melhem
Computer System Engineering Department
Palestine Technical University
Today: Readings:
• VHDL Data Types • B. J. LaMeres, Quick
• VHDL Model Construction Start Guide to VHDL,
Chapter 2
Hardware Description Languages
•HDL is a specialized computer language used to program electronic and
digital logic circuits.
•The structure, operation and design of the circuits are programmable using
HDL.
•HDL includes a textual description consisting of operators, expressions,
statements, inputs and outputs.
•Example of HDL’s: ABEL, VERILOG, VHDL
•Advantages:
◦ Documentation
◦ Flexibility (easier to make design changes or mods)
◦ Portability (if HDL is standard)
◦ One language for modeling, simulation (test benches), and synthesis
VHDL
•VHSIC Hardware Description Language
◦ Very High Speed Integrated Circuit
•Advantages:
◦ Allows the behavior of the required system to be described (modeled) and
verified (simulated) before synthesis tools translate the design into real hardware
(gates and wires).
◦ VHDL allows the description of a concurrent system. VHDL is a dataflow language
in which every statement is considered for execution simultaneously, unlike
procedural computing languages such as BASIC, C, and assembly code, where a
sequence of statements is run sequentially one instruction at a time.
What is VHDL
•A way of describing the operation of a system
◦ Example: a 2-input multiplexer
Example Synthesis Results
Introduction to VHDL
•VHDL is not case sensitive.
•Each VHDL assignment, definition, or declaration is terminated with
a semicolon (;).
• Line wraps are allowed and do not signify the end of an assignment,
definition, or declaration.
•Comments in VHDL are preceded with two dashes (i.e., --) and continue until
the end of the line.
•All user-defined names in VHDL must start with an alphabetic letter, NOT a
number.
•User-defined names are not allowed to be the same as any VHDL keyword.
•In VHDL, every signal, constant, variable, and function must be assigned a
data type.
VHDL Data Types
•The IEEE standard package provides a variety of pre-defined data types.
•The following are the most commonly used data types in the VHDL Package
standard of library std (Included by default ):
◦ Enumerated Types
◦ Range Types
◦ Physical Types
◦ Vector Types
◦ User-Defined Enumerated Types
◦ Array Type
◦ Subtypes
Enumerated Types
•An enumerated type is one in which the exact values that the type can take
on are defined.
•The individual scalar values are indicated by putting them inside single
quotes (e.g., ‘0,’ ‘a,’ ‘true’).
•The type bit is synthesizable, while Boolean and character are NOT.
Enumerated Types: example
•Example:
◦ SIGNAL x: BIT;
◦ x <= '1’;
◦ variable VAR1: boolean := 'FALSE';
Range Types
•A range type is one that can take on any value within a range.
•The base unit for time is fs, meaning that, if no units are provided, the value
is assumed to be in femtoseconds.
•The value of time is held as a 32-bit, signed number and is not synthesizable.
•Example: Delay: TIME := 0 ns
Vector Types
•A vector type is one that consists of a linear array of scalar types.
•The size of a vector type is defined by including the maximum index, the keyword
downto, and the minimum index.
◦ For example, if a signal called BUS_A was given the type bit_vector(7 downto 0), it
would create a vector of 8 scalars, each of type bit. The leftmost scalar would have an
index of 7 and the rightmost scalar would have an index of 0.
•Each of the individual scalars within the vector can be accessed by providing the
index number in parentheses.
◦ For example, BUS_A(0) would access the scalar in the rightmost position. The indices
do not always need to have a minimum value of 0, but this is the most common
indexing approach in logic design.
•The type bit_vector is synthesizable, while string is not. The values of these types
are indicated by enclosing them inside double quotes (e.g., “0011,” “abcd”).
Vector Types: example
•SIGNAL y: BIT_VECTOR (3 DOWNTO 0);
•SIGNAL w: BIT_VECTOR (0 TO 7);
a user can define his/her own type in VHDL!!!
•Port names with the same mode and type can be listed on the same line
separated by commas.
Example 2.1 shows multiple approaches for defining an entity
The Architecture
•The architecture in VHDL describes the behavior of a system.
•There are numerous techniques to describe behavior in VHDL that span
multiple levels of abstraction.
•The architecture is where the majority of the design work is conducted.
Signal Declarations
•A signal that is used for internal connections within a system is declared in the
architecture.
•Each signal must be declared with a type. The signal can only be used to make
connections of like types.
•A signal is declared with the keyword signal followed by a user-defined name,
colon, and the type.
•Signals of like type can be declared on the same line separated with a comma.
•All of the legal data types described in slides before can be used for signals.
•Signals represent wires within the system so they do not have a direction or
mode.
•Signals cannot have the same name as a port in the system in which they reside.
Signal Declarations
Signal Declarations
•VHDL supports a hierarchical design approach.
◦ Signal names can be the same within a sub-system as those at a higher level
without conflict.
Constant Declarations
•A constant is useful for representing a quantity that will be used multiple
times in the architecture.
•Once declared, the constant name can now be used throughout the
architecture.
•Notice that since we defined the constant to be the actual width of the
vector (i.e., 32-bits), we need to subtract one from its value when defining
the indices (i.e., 31 down to 0).
Component Declarations
•A component is the term used for a VHDL sub-system that is instantiated
within a higher-level system.
•If a component is going to be used within a system, it must be declared in
the architecture before the begin statement.
•The port definitions of the component must match the port definitions of
the sub-system’s entity exactly. As such, these lines are typically copied
directly from the lower-level systems VHDL entity description.
•Once declared, a component can be instantiated after the begin statement in
the architecture as many times as needed.
VHDL Sample Code