Unit2 Basic Structures of VHDL
Unit2 Basic Structures of VHDL
| Operators
DESIGN UNIT
| It is a VHDL construct that can be separately
compiled and stored in a design library
| It consists of a context clause followed by a
library unit.
y A context clause consists of a library clause and a
use clause
y Example of a context clause:
library ieee;
use ieee.std_logic_1164.all;
LIBRARY UNIT
| It is the compilation of specific design units
| It has 5 kinds:
y Entity declaration
y Architecture body
y Package declaration
y Package body
y Configuration declaration
DESIGN ENTITY
| It is the basic unit of a hardware design.
| It has at least one pair of:
y An entity declaration that defines the inputs and
outputs—the ports—of this design; and
y An architecture body that defines what the design
actually does, using a single concurrent assignment.
Design Entity
DESIGN ENTITY
Entity Declaration
(external view)
Architecture Body
(internal function)
ENTITY DECLARATION
| It defines the entity’s name and its interface.
| It includes the ff.:
y Entity name
y Port statement/list
| Port names
| Direction (either in, out, or inout)
| Type
| Example:
entity Full_Adder is
port(A, B, Cin : in std_logic;
Sum, Cout : out std_logic);
end Full_Adder ;
PORT MODES
| A port’s mode specifies its direction of
information transfer.
| There are 5 modes, namely:
y in
y out
y inout
y buffer
y linkage (removed)
| If no mode is specified, default is in.
PORT MODES
ENTITY DIAGRAM
Inputs
entity Outputs
(architecture)
ARCHITECTURE BODY
| The architecture describes the actual function—
or contents—of the entity to which it is bound.
| It includes the ff.:
y Declarative part wherein the components and signals
are being declared
y Statement part wherein the component instantiation
statements, signal assignments, and behavioral
constructs (such as process statements) are stated
ARCHITECTURE BODY
| Syntax:
architecture arch_name of entity_name is
declarative part
begin
statement part
end architecture arch_name;
ARCHITECTURE BODY
| Example:
architecture Structural of Full_Adder is
component Half_Adder is
Port ( A, B : in STD_LOGIC;
Sum, Cout : out STD_LOGIC);
end component;
signal sumsig, coutsig1, coutsig2 : STD_LOGIC;
begin
HA1: Half_Adder port map ( A, B, sumsig, coutsig1 );
HA2: Half_Adder port map ( A => sumsig,
B => Cin,
Sum => Sum,
Cout => coutsig2);
Cout <= coutsig1 or coutsig2;
end Structural;
CODING STYLES
| Architectures can be written in any of the ff:
y Dataflow
| Uses only concurrent signal assignments
| For low-level (very basic) design entities
y Behavioral
| Uses only process statements
| For systems whose function is algorithmic
y Structural
| Uses only component instantiation statements
| Appropriate for design entities comprised of several low-
| Named Association
y Each association is explicit and the listing order is of
no concern
y More readable and less error prone
SEATWORK 2-1
A B C X Y 1. Given the following
0 0 0 0 1 truth table:
0 0 1 1 0 a. Write a canonical
0 1 0 1 1 sum-of-products
0 1 1 0 0 Boolean equation for
1 0 0 1 0 each output.
1 0 1 0 0 b. Write a complete
1 1 0 0 0 dataflow VHDL
description of the
1 1 1 1 1
design entity that
accomplishes the
function defined by
the truth table.
SEATWORK 2-1
character
Enumeration
Severity_level
discrete File_open_kind
File_open_status
Scalar
Integer Integer
Floating real
STD_ULOGIC
Value State Strength
U uninitialized none
X unknown forcing
0 0 forcing
1 1 forcing
Z none high impedance
W unknown weak
L 0 weak
H 1 weak
- don’t care none
STD_ULOGIC
• It is an unresolved type.
• The state value denotes its logic level.
• The strength denotes the electrical
characteristics of the source that drives the
signal. These driving strengths are:
• Forcing – signals driven by active output drivers
(such as that of a CMOS circuit)
• Weak – are used to represent signals from resistive
drivers (such as pull-up resistor, or pull-down
resistor outputs, or pass transistors)
• High impedance – represents the output of a 3-
state buffer when it is not enabled
STD_ULOGIC
• The uninitialized value is the default value
given to all std_ulogic signals before the start of
simulation.
• The unknown value is used to represent a
signal that is being driven, but whose value
cannot be determined to be a 0 or a 1.
• Don’t care is interpreted by a synthesis tool as
representing common don’t care condition used in
logic design.
RESOLVED TYPE
| A resolved type is a type declared with a
resolution function.
| A resolution function is a function that defines
the resulting (resolved) value of a signal.
| Std_logic is a subtype of std_ulogic declared in
STD_LOGIC_1164.
RESOLUTION TABLE FOR STD_LOGIC
U X 0 1 Z W L H -
U U U U U U U U U U
X U X X X X X X X X
0 U X 0 X 0 0 0 0 X
1 U X X 1 1 1 1 1 X
Z U X 0 1 Z W L H X
W U X 0 1 W W W W X
L U X 0 1 L W L W X
H U X 0 1 H W W H X
- U X X X X X X X X
USE OF STD_LOGIC VS STD_ULOGIC
| A disadvantage of using std_logic instead of
std_ulogic is that signals that ate unintentionally
multiply driven will not be detected as an eror
during compilation.
| IEEE recommends use of std_logic for the reason
that the standard expects simulator vendors to
design their simulators to optimize the
simulation of models using the resolved subtype,
but they need to optimize the simulation of
models using the unresolved types
SCALAR LITERALS
| A literal is a value that is expressed as itself
| It can be directly assigned to a signal or used in
an expression that determines the value assigned
to a signal
| Literals don’t have an explicit type
Unconstrained constrained
Bit_vector string
COMPOSITE TYPE
| A composite type consists of a collection of
related elements that form either an array or a
record.
| It may contain elements that are scalar,
composite, or access type.
SOURCE
| VHDL for Engineers, Kenneth Short, Pearson
Education, Inc., 2009