Lect3-DSD VHDL Program Structure
Lect3-DSD VHDL Program Structure
Program
Structure
Entity, Ports and Architecture
2 11/12/2024
VHDL?
VHDL? VHSIC? VHDL Language can be regarded as
an integrated amalgamation of the
V VHSIC V Very following:
H Hardware H High Sequential language +
Concurrent Language +
D Description S Speed net-list language +
timing specifications +
L Language I Integrated Waveform generation
C Circuit =>VHDL
It is a hardware description language that can be The language not only defines the
used to model a digital system at many levels of syntax but also defines very clear
abstractions, ranging from Algorithms to Gate simulation semantics for each
Level language construct.
Complexity of the digital system being modeled could It is a strongly typed language
vary from a simple logic gate to a complete
electronic system or anything between
Hardware Abstraction?
• VHDL is used to describe a model for a digital hardware device
• This model specify the external view of the device and one or
more internal view
• The external view specifies the interface of the device through
which it communicates with the other models in its environment
• The internal view of the device specifies the functionality or
structure or device model
Entity Device
1 Model 1
Device Device Model Entity Device
External 2 Model 2
View Device
Digita
l Model Actual Entity Device
Syste Hardware N Model N
m Internal
views VHDL View
Basic Terminology?
• A hardware abstraction of • Basic Design Units of VHDL
digital system is called an – Entity Declaration
Entity – Architecture Body
Entity E2
– Configuration Declaration
– Package declaration
• An entity X, when used in – Package body
another entity Y, becomes a binding
M1: MX:
component for that entity
E2_A1 E2_A
Entity 2
Entity
Declaratio Entity E3
Hardware Entity E1
n
abstraction of Model
a Digital BX CX
BX
System :
CX
:
: :
Name of Entity In
Entity HALF_ADDER is Out
Mode of ports Inout
Port ( A : in std_logic; Buffer: can have only one source
B : in std_logic; other connected source should be a buffer
Name of ports
SUM : out std_logic; type
Carry : out std_logic); linkage
Types of ports
End HALF_ADDER;
Architecture Body?
• The internal details of an entity are specified by an Architecture using the following modelling styles:
– As a set of interconnected components (to represent structure)
Entity HALF_ADDER is
– As a set of concurrent assignment statements (to represent dataflow) Port (A , B : in std_logic;
– As a set of sequential assignment statements (to represent behaviour) SUM, Carry : out
– As any combination of the above three std_logic);
End HALF_ADDER;
Architecture HA_STRUCTURE of Architecture HA_DATAFLOW of
HALF_ADDER is HALF_ADDER is
Component XOR2 Begin
Port (X , Y : in std_logic; Z : out SUM <= A XOR B;
std_logic); Carry <= A AND B;
End component; End HA_DATAFLOW;
Component AND2 Architecture HA_Behavior of
Port (L ,M : in std_logic; N : out HALF_ADDER is
std_logic); Begin
End component; Process (A,B)
Begin SUM <= A XOR B;
X1: XOR2 port map (A,B, SUM); Carry <= A AND B;
A1: AND2 port map (A,B, Carry); End HA_Behavior;
End HA_STRUCTURE;
Mixing Style Modelling? Architecture FA_MIX of FULL_ADDER is
Component XOR2
Port (P1 , P2 : in std_logic; Pz : out std_logic);
End component;
Signal S1 : Std_logic;
Begin
---
X1: XOR2 port map (A,B, S1); Structural
Process (A,B,Cin)
Variable V1,V2,V3: std_logic; ---Behavior
begin
V1:= A and B;
V2:= B and Cin;
V3:= Cin and A;
Entity FULL_ADDER is Cout<= V1 or V2 or V3;
Port (A , B, Cin : in std_logic; End process;
SUM, Cout : out std_logic);
SUM<= S1 xor Cin; ---Dataflow
End FULL_ADDER;
End FA_MIX;
Hierarchical design (Design Methodologies)
Top-Down design methodology
Define the top level block and identify the sub-
blocks necessary to build the top-level block.
Further sub divide the sub-blocks until come to
leaf cells, which are the cells that cannot
further be divided.
Hierarchical design (Design Methodologies)
Bottom-Up design methodology
Identify the building blocks that are available to us.
Build bigger cells, using these building blocks.
These cells are then used for higher-level blocks
until we build the top-level block in the design.
Design Example (4-bit Ripple Carry Adder)
A[3: S[3:
0] 0]
4-Bit
B[3: Full Adder Cout
0]
Cin
B3 A3 B2 A2 B1 A1 B0 A0
Ci
FA3 FA2 FA1 FA0 n
Cou C2 C1 C0
t
S3 S2 S1 S0
Design Example (4-bit Ripple Carry Adder)
A S
1-Bit
Full Adder Carr
B
y
Cin
Design Example (4-bit Ripple Carry Adder)
AN AN AN AN
XOR OR XOR OR XOR OR XOR OR
D D D D
Design Example (4-bit Ripple Carry Adder)
AN AN AN AN
XOR OR XOR OR XOR OR XOR OR
D D D D
VHDL Design (4-bit Ripple Carry Adder)
library IEEE; Entity FA is
use IEEE.STD_LOGIC_1164.all;
Port (A , B, C: in std_logic;
entity adder_4bit is
port( a, b : in STD_LOGIC_VECTOR(3 downto 0); SUM, Carry : out std_logic);
cin : in STD_LOGIC_VECTOR(3 downto 0); End FA;
cout : out STD_LOGIC;
sum : out STD_LOGIC_VECTOR(3 downto 0) );
end adder_4bit;