02 HWModelling VHDL
02 HWModelling VHDL
Online Course
Jan-Apr 2017
Layout
Schematic
?
y = a + b;
HDL / if (y < 0)
System Level ...
P1 P2
x=x+1 y=a-b
A B
W
X1 Y1 X2
X
Block A contains two sub-blocks: X1 and Y1
Block X is duplicated
Wire W connects A and B
(C) P. R. Panda, I.I.T Delhi, 2017 8
Requirements for Hardware
Description Languages - 5
• Bit-true data types
– Not so important in SW
– Important in HW
int<6:0> var;
• Introduction
• Signal assignment
• Modelling delays
• Describing behaviour
• Structure, test benches, libraries,
parameterisation
• Standards
(C) P. R. Panda, I.I.T Delhi, 2017 14
Hardware Description Languages
entity represents
VHDL model Entity
external interface
consists of
two parts
architecture
Architecture represents
functionality/contents
a
y
b
Entity has Model Name
interface only.
No functionality. ENTITY and_gate IS
PORT (a: IN BIT;
b: IN BIT; Port direction
Port Name y: OUT BIT);
END and_gate;
Port type
(C) P. R. Panda, I.I.T Delhi, 2017 18
Specifying Functionality:
architectures
• Introduction
• Signal assignment
• Modelling delays
• Describing behaviour
• Structure, test benches, libraries,
parameterisation
• Standards
(C) P. R. Panda, I.I.T Delhi, 2017 20
Specifying Concurrency:
Concurrent Signal Assignment
ci
ai
bi + si
ARCHITECTURE data_flow
co
OF full_adder IS
BEGIN Concurrent Signal Assignments
si <= ai XOR bi XOR ci;
co <= (ai AND bi) OR (bi AND ci)
OR (ai AND ci);
END data_flow;
(C) P. R. Panda, I.I.T Delhi, 2017 21
When is Signal Assignment
Executed?
Assignment executed when any signal on RHS changes
ARCHITECTURE data_flow
OF full_adder IS
Executed when
BEGIN
ai, bi, or ci changes
si <= ai XOR bi XOR ci;
co <= (ai AND bi) OR (bi AND ci) Executed when
OR (ai AND ci); ai, bi, or ci changes
END data_flow;
y = g (f (x))
g t = f (x) g y = g (t)
x f x f
h z = h (f (x)) h z = h (t)
Ports: x, y, z Signal: t
• Introduction
• Signal assignment
• Modelling delays
• Describing behaviour
• Structure, test benches, libraries,
parameterisation
• Standards
(C) P. R. Panda, I.I.T Delhi, 2017 28
Modelling Delays: inertial delay
• Models gate delays
• Spikes suppressed
y <= INERTIAL NOT a AFTER 10 ns;
y <= NOT a AFTER 10 ns; -- inertial delay is default
0 10 12 22 30 35
(C) P. R. Panda, I.I.T Delhi, 2017 29
Modelling Delays: transport delay
• Models wires/transmission lines
– used in more abstract modelling
• Spikes propagated
y <= TRANSPORT NOT a AFTER 10 ns;
0 10 12 22 30 35 40 45
(C) P. R. Panda, I.I.T Delhi, 2017 30
Events and Transactions
• Event
– Signal assignment that causes change in
value
• Transaction
– Value scheduled for signal assignment
• may or may not cause change in value
a (1, 15)
Events b (1,5) c (0, 10)
and b (1,5)
Transaction Transaction
Transactions c (0, 10) Expires Expires
Transactions Event Created No Event
Scheduled
(C) P. R. Panda, I.I.T Delhi, 2017 33
Events and Transactions: Example
ARCHITECTURE demo OF
example IS a
SIGNAL a, b, c: BIT := ‘0’;
0
BEGIN
a <= ‘1’ AFTER 15 NS; b 0
b <= NOT a AFTER 5 NS;
c <= a AFTER 10 NS; c 0
END demo;
0 5 10 15 20 25
a (1, 10)
Events a (0, 15) b (1, 8)
and
b (1, 8) Transaction
Transactions
Transactions Expires
Scheduled Event Created
b (1,8)
Events
and Transaction
Transactions Expires
No Event
a (1, 10)
Events a (0, 15) b (1,8)
and
b (1,8) Transaction
Transactions
Transactions Expires
Scheduled Event Created
b (0,8) b (1,8)
Events
and
Transactions Transaction Transaction
Expires Expires
Event Created Event Created
a
0 10 20 30 40 50
a <= 0 c <= 0
b <= 1 d <= 0
(clock = 1) d <= 1
• Introduction
• Signal assignment
• Modelling delays
• Describing behaviour
• Structure, test benches, libraries,
parameterisation
• Standards
(C) P. R. Panda, I.I.T Delhi, 2017 43
Describing Behaviour: Processes
• Process is sensitive to
signals on Sensitivity List
• All processes executed Sensitivity List
once at time=0
• Suspended at end of PROCESS (a, b)
BEGIN
process c <= a AND b;
END PROCESS;
• Reactivated when event
occurs on any signal in
sensitivity list
ARCHITECTURE x of y IS
BEGIN
Identical
ARCHITECTURE x of y IS
PROCESS (a, b) BEGIN
BEGIN
c <= a AND b; c <= a AND b;
END PROCESS;
END x;
END x;
• Introduction
• Signal assignment
• Modelling delays
• Describing behaviour
• Structure, test benches, libraries,
parameterisation
• Standards
(C) P. R. Panda, I.I.T Delhi, 2017 55
Structural Description
• Instantiation
• Interconnection
z
Instance name p
r
x1 y1
Component name t
q
• Test bench a
separate VHDL
entity
• Ports are connected
to DUT’s ports Test
– i/p port DUT
Bench
corresponding to
DUT’s o/p port
– o/p port
corresponding to
DUT’s i/p port
(C) P. R. Panda, I.I.T Delhi, 2017 62
Test Bench Modelling - 2
• Test bench
instantiates the DUT
Test Bench
• Stimulus generation
and output
monitoring in Test
separate VHDL Bench DUT
process Process
• PACKAGE - collection of
– components
– data types
– functions/procedures
• LIBRARY - collection of PACKAGEs
Package
Library Name
All
PACKAGE util IS Name
Contents
COMPONENT c IS
PORT (a: IN BIT, b: OUT BIT);
END COMPONENT
TYPE my_int IS INTEGER RANGE -7 TO 7; USE WORK.UTIL.ALL;
FUNCTION comp (a: BIT_VECTOR) ...
RETURN BIT_VECTOR;
END util;
SIGNAL x: my_int;
... a <= comp (b);
• STD
– STANDARD
• types/utilities (BIT, TIME, INTEGER,...)
– TEXTIO
• interface to text files
• WORK
– default library for storing user designs
• STD_LOGIC_1164
– multi-valued logic
(C) P. R. Panda, I.I.T Delhi, 2017 67
TEXTIO Package
Generic
Parameters
Inp Outp
Clk
Inp Outp
Clk
Clk
• Introduction
• Signal assignment
• Modelling delays
• Describing behaviour
• Structure, test benches, libraries,
parameterisation
• Standards
(C) P. R. Panda, I.I.T Delhi, 2017 74
VHDL Standards