Professional Documents
Culture Documents
VHDL 강좌 m10 - 23
VHDL 강좌 m10 - 23
Version 2.02
All rights reserved. This information is copyrighted by the RASSP E&F Program
and may only be used for non-commercial educational purposes. Any other use of
this information without the express written permission of the RASSP E&F Program
is prohibited. All information contained herein may be duplicated for non-
commercial educational use provided this copyright notice is included. No warranty
of any kind is provided or implied, nor is any liability accepted regardless of use.
FEEDBACK:
The RASSP E&F Program welcomes and encourages any feedback that you may have including
any changes that you may make to improve or update the material. You can contact us at
feedback@rassp.scra.org or
http://rassp.scra.org/module-request/FEEDBACK/feedback-on-modules.html
RASSP Roadmap RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
HW HW
DESIGN FAB
SYSTEM FUNCTION HW & INTEG.
DEF. DESIGN SW & TEST
PART.
SW SW
HW & SW
DESIGN CODE
CODESIGN
VHDL
VHDL
Copyright 1995-1998 RASSP E&F
Module Goals RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
Introduction
VHDL Design Example
VHDL Model Components
Entity Declarations
Architecture Descriptions
Timing Model
Examples
Summary
Introduction
VHDL Design Example
Examples
Summary
Architectural Structural
Behavioral
Algorithmic
Processor
Systems Functional Block
Hardware Modules
Algorithms Logic
ALUs, Registers
Register Transfer
Circuit Gates, FFs
Logic
Transfer Functions Transistors
Rectangles
Floor Plans
Clusters
Physical Partitions
Physical/Geometry
Copyright 1995-1998 RASSP E&F
Representation of a
RASSP System RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
High Res. Gate Clock Cycle Instr. Cycle System Event Low Res.
Propagation (pS) (10s of nS) (10s of uS) (10s of mS)
Data Value Resolution
High Res. Bit true Value True Composite Token Low Res.
(0b01101) (13) (13,req,(2.33, j89.2)) (Blue)
Functional Resolution
High Res. Structural Block diagram Single block box Low Res.
Gate netlist Major blocks (No implementation info)
Programming Level (Full implementation) (Some implementation info)
High Res. Micro- Assembly HLL (Ada,C) DSP primitive Major Low Res.
code code Statements Block-oriented modes
(fmul r1,r2) (i := i+1) (FFT(a,b,c)) (Search,Track)
(Note: Low resolution of details = High level of abstraction
High resolution of details = Low level of abstraction
Copyright 1995-1998 RASSP E&F [Hein97]
Graphical Representation of
the Model Levels using the RASSP
RASSP
RASSP Taxonomy
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
Symbol Key
Model resolves information at specific level
Temporal
A Virtual Prototype can be constructed at Data Value
any level of abstraction and may include a Functional
mixture of levels. It can be configured
Structural
quickly and cost-effectively, and, being a
computer simulation, provides non-
SW Programming Level
invasive observability of internal states.
Behavioral Level
Internal External
A behavioral model describes the function
and timing of a component without Temporal
describing a specific implementation Data Value
Functional
Structural
SW Programming Level
RTL Level
Internal External
An RTL model describes a system in terms
of registers, combinational circuitry, low- Temporal
level buses, and control circuits, usually Data Value
implemented as finite state machines
Functional
Structural
SW Programming Level
Algorithm Level
Internal External
The algorithm level of abstraction
describes a procedure for implementing a Temporal
function as a specific sequence of Data Value
arithmetic operations, conditions, and
Functional
loops
Structural
SW Programming Level
Performance Level
Internal External
Performance models may be written at any
level of abstraction and measure system Temporal
performance associated with response Data Value
time, throughput, and utilization
Functional
Structural
SW Programming Level
Structural Level
Internal External
A structural model represents a
component or system in terms of the Temporal
interconnections of its constituent Data Value
components.
Functional
Structural
SW Programming Level
Gate Level
Internal External
A gate-level model describes the function,
timing, and structure of a component in Temporal
terms of the structural interconnection of Data Value
boolean logic blocks
Functional
Structural
SW Programming Level
Package
Concurrent Process
Concurrent
Statements
Statements
Copyright 1995-1998 RASSP E&F
Sequential Statements
Module Outline RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
Introduction
Examples
Summary
x
carry
y Half Adder
result
enable
ENTITY half_adder IS
END half_adder;
x
Half carry
y
Adder result
enable
x
y carry
enable
result
COMPONENT and2
PORT (in0, in1 : IN BIT;
out0 : OUT BIT);
END COMPONENT;
COMPONENT and3
PORT (in0, in1, in2 : IN BIT;
out0 : OUT BIT);
END COMPONENT;
COMPONENT xor2
PORT (in0, in1 : IN BIT;
out0 : OUT BIT);
END COMPONENT;
BEGIN
END half_adder_c;
Introduction
Examples
Summary
Note port signals (i.e. ‘ports’) of the same mode and type or subtype may be
declared on the same line
PORT
PORT (( input
input :: IN
IN BIT_VECTOR(3
BIT_VECTOR(3 DOWNTO
DOWNTO 0);
0);
ready,
ready, output
output :: OUT
OUT BIT
BIT );
);
Start
StartSimulation
Simulation
Delay
Update
UpdateSignals
Signals Execute
ExecuteProcesses
Processes
End
EndSimulation
Simulation
Copyright 1995-1998 RASSP E&F
Delay Types RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
Input Output
delay
Input Output
Input
Output
0 5 10 15 20 25 30 35
Copyright 1995-1998 RASSP E&F
Inertial Delay RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
Output
0 5 10 15 20 25 30 35
Copyright 1995-1998 RASSP E&F
Inertial Delay (cont.) RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
Input
Output
0 5 10 15 20 25 30 35
B
1 AND
ANDgate
gateevaluated
evaluatedfirst:
first:
NAND
NANDgate
gateevaluated
evaluatedfirst:
first: IN:
IN:1->0
1->0
IN:
IN:1->0
1->0 A:
A: 0->1
0->1
A:
A: 0->1
0->1 C:
C: 0->1
0->1
B:
B: 1->0
1->0 B:
B: 1->0
1->0
C:
C: 0->0
0->0
Copyright 1995-1998 RASSP E&F
C:
C: 1->0
1->0
Delta Delay
An Example with Delta Delay RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
A
IN: 1->0
C
B
1
Using
Usingdelta
deltadelay
delayscheduling
scheduling
Time Delta Event
0 ns 1 IN: 1->0
eval INVERTER
2 A: 0->1
eval NAND, AND
3 B: 1->0
C: 0->1
eval AND
4 C: 1->0
1 ns
Copyright 1995-1998 RASSP E&F
Module Outline RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
Introduction
VHDL Design Example
VHDL Model Components
Examples
Summary
Access Composite
Array Record
Scalar
Integer
Minimum range for any implementation as defined by
standard: - 2,147,483,647 to 2,147,483,647
Example assignments to a variable of type integer :
ARCHITECTURE
ARCHITECTURE test_int
test_int OFOF test
test IS
IS
BEGIN
BEGIN
PROCESS
PROCESS (X)
(X)
VARIABLE
VARIABLE a:a: INTEGER;
INTEGER;
BEGIN
BEGIN
aa :=
:= 1;
1; --
-- OK
OK
aa :=
:= -1;
-1; --
-- OK
OK
aa :=
:= 1.0;
1.0; --
-- illegal
illegal
END
END PROCESS;
PROCESS;
END
END test_int;
test_int;
Real
Minimum range for any implementation as defined by
standard: -1.0E38 to 1.0E38
Example assignments to a variable of type real :
ARCHITECTURE
ARCHITECTURE test_real
test_real OF OF test
test IS
IS
BEGIN
BEGIN
PROCESS
PROCESS (X)
(X)
VARIABLE
VARIABLE a: a: REAL;
REAL;
BEGIN
BEGIN
aa :=
:= 1.3;
1.3; ---- OK
OK
aa :=
:= -7.5;
-7.5; -- -- OK
OK
aa :=
:= 1;
1; ---- illegal
illegal
aa :=
:= 1.7E13;
1.7E13; -- -- OKOK
aa :=
:= 5.3
5.3 ns;
ns; ---- illegal
illegal
END
END PROCESS;
PROCESS;
END
END test_real;
test_real;
Copyright 1995-1998 RASSP E&F
VHDL Data Types
Scalar Types (Cont.) RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
Enumerated
Userspecifies list of possible values
Example declaration and usage of enumerated data type :
TYPE
TYPE binary
binary ISIS (( ON,
ON, OFF
OFF );
);
...
... some
some statements
statements ... ...
ARCHITECTURE
ARCHITECTURE test_enum
test_enum OF OF test
test IS
IS
BEGIN
BEGIN
PROCESS
PROCESS (X)
(X)
VARIABLE
VARIABLE a:a: binary;
binary;
BEGIN
BEGIN
aa :=
:= ON;
ON; ---- OK
OK
...
... more
more statements
statements ... ...
aa := OFF; --
:= OFF; -- OK OK
...
... more
more statements
statements ... ...
END
END PROCESS;
PROCESS;
END
END test_enum;
test_enum;
Copyright 1995-1998 RASSP E&F
VHDL Data Types
Scalar Types (Cont.) RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
Physical
Require associated units
Range must be specified
Example of physical type declaration :
TYPE
TYPE resistance
resistance IS
IS RANGE
RANGE 00 TO
TO 10000000
10000000
UNITS
UNITS
ohm;
ohm; ---- ohm
ohm
Kohm
Kohm == 1000
1000 ohm;
ohm; --
-- i.e.
i.e. 11 K
K
Mohm
Mohm == 1000
1000 kohm;
kohm; --
-- i.e.
i.e. 11 M
M
END
END UNITS;
UNITS;
Array
Usedto group elements of the same type into a single
VHDL object
Range may be unconstrained in declaration
Range would then be constrained when array is used
Example declaration for one-dimensional array (vector) :
TYPE
TYPE data_bus
data_bus IS
IS ARRAY(0
ARRAY(0 TO
TO 31)
31) OF
OF BIT;
BIT;
0 ...element indices... 31
0 ...array values... 1
VARIABLE
VARIABLE XX :: data_bus;
data_bus;
VARIABLE
VARIABLE YY :: BIT;
BIT;
YY :=
:= X(12);
X(12); --
-- YY gets
gets value
value of
of element
element at
at index
index 12
12
Copyright 1995-1998 RASSP E&F
VHDL Data Types
Composite Types (Cont.) RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
DOWNTO keyword must be used if leftmost index is greater than rightmost index
e.g. ‘Big-Endian’ bit ordering
TYPE
TYPE reg_type
reg_type IS
IS ARRAY(15
ARRAY(15 DOWNTO
DOWNTO 0)
0) OF
OF BIT;
BIT;
15 ...element indices... 0
0 ...array values... 1
VARIABLE
VARIABLE XX :: reg_type;
reg_type;
VARIABLE
VARIABLE YY :: BIT;
BIT;
YY :=
:= X(4);
X(4); --
-- YY gets
gets value
value of
of element
element at
at index
index 44
Records
Used to group elements of possibly different types into
a single VHDL object
Elements are indexed via field names
Examples of record declaration and usage :
TYPE
TYPE binary
binary IS
IS (( ON,
ON, OFF
OFF );
);
TYPE
TYPE switch_info
switch_info IS IS
RECORD
RECORD
status
status :: BINARY;
BINARY;
IDnumber
IDnumber :: INTEGER;
INTEGER;
END
END RECORD;
RECORD;
VARIABLE
VARIABLE switch
switch :: switch_info;
switch_info;
switch.status
switch.status :=
:= ON;
ON; ---- status
status of
of the
the switch
switch
switch.IDnumber
switch.IDnumber :=:= 30;
30; --
-- e.g.
e.g. number
number ofof the
the switch
switch
Copyright 1995-1998 RASSP E&F
VHDL Data Types
Access Type RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
Access
Analogous to pointers in other languages
Allows for dynamic allocation of storage
Useful for implementing queues, fifos, etc.
Subtype
Allows for user defined constraints on a data type
e.g. a subtype based on an unconstrained VHDL type
May include entire range of base type
Assignments that are out of the subtype range are illegal
Range violation detected at run time rather than compile
time because only base type is checked at compile time
Subtype declaration syntax :
SUBTYPE
SUBTYPE name
name IS
IS base_type
base_type RANGE
RANGE <user
<user range>;
range>;
Subtype example :
SUBTYPE
SUBTYPE first_ten
first_ten IS
IS INTEGER
INTEGER RANGE
RANGE 00 TO
TO 9;
9;
Declaration examples :
CONSTANT
CONSTANT constant_name
constant_name :: type_name
type_name [:=
[:= value];
value];
CONSTANT
CONSTANT PI
PI :: REAL
REAL :=
:= 3.14;
3.14;
CONSTANT SPEED : INTEGER;
CONSTANT SPEED : INTEGER;
Copyright 1995-1998 RASSP E&F
VHDL Objects
Variables RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
Declaration examples :
VARIABLE
VARIABLE variable_name
variable_name :: type_name
type_name [:=
[:= value];
value];
VARIABLE
VARIABLE opcode
opcode :: BIT_VECTOR(3
BIT_VECTOR(3 DOWNTO
DOWNTO 0)
0) :=
:= "0000";
"0000";
VARIABLE
VARIABLE freq
freq :: INTEGER;
INTEGER;
Copyright 1995-1998 RASSP E&F
VHDL Objects
Signals RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
SIGNAL
SIGNAL signal_name
signal_name :: type_name
type_name [:=
[:= value];
value];
SIGNAL
SIGNAL brdy
brdy :: BIT;
BIT;
brdy
brdy <=
<= ‘0’
‘0’ AFTER
AFTER 5ns,
5ns, ‘1’
‘1’ AFTER
AFTER 10ns;
10ns;
0 0 1 1 1 0
1 1 1 1 1 0
1+d 1 1 1 0 0
1+2d 1 1 1 0 1
Copyright 1995-1998 RASSP E&F
VHDL Objects
Signals vs Variables (Cont.) RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
Raytheon
Raytheon
UVA
UCinc EIT
EIT ADL
ADL
ARCHITECTURE
ARCHITECTURE var_ex
var_ex OF OF test
test IS
IS
BEGIN
BEGIN
PROCESS
PROCESS (a,
(a, b,b, c)
c)
VARIABLE
VARIABLE out_3
out_3 :: BIT;
BIT;
BEGIN
BEGIN
out_3
out_3 :=
:= aa NAND
NAND b;b;
out_4
out_4 <=
<= out_3
out_3 XOR
XOR c;c;
END
END PROCESS;
PROCESS;
END
END var_ex;
var_ex;
0 0 1 1 1 0
1 1 1 1 0 0
1+d 1 1 1 0 1
ARCHITECTURE
ARCHITECTURE sequential
sequential OFOF test_mux
test_mux IS
IS
BEGIN
BEGIN
select_proc
select_proc :: PROCESS
PROCESS (x,y)
(x,y)
BEGIN
BEGIN
IF
IF (select_sig
(select_sig == '0')
'0') THEN
THEN
zz <=
<= x;
x;
ELSIF
ELSIF (select_sig
(select_sig == '1')
'1') THEN
THEN
zz <=
<= y;
y;
ELSE
ELSE
zz <=
<= "XXXX";
"XXXX";
END
END IF;
IF;
END
END PROCESS
PROCESS select_proc;
select_proc;
END
END sequential;
sequential;
PACKAGE
PACKAGE BODY
BODY my_stuff
my_stuff ISIS
CONSTANT
CONSTANT My_ID
My_ID :: INTEGER
INTEGER :=
:= 2;
2;
PROCEDURE
PROCEDURE add_bits3(SIGNAL
add_bits3(SIGNAL a, a, b,
b, en
en :: IN
IN BIT;
BIT;
SIGNAL
SIGNAL temp_result,
temp_result, temp_carry
temp_carry :: OUT OUT BIT)
BIT) IS
IS
BEGIN
BEGIN --
-- this
this function
function cancan return
return aa carry
carry
temp_result
temp_result <=
<= (a
(a XOR
XOR b)b) AND
AND en;
en;
temp_carry
temp_carry <=
<= aa AND
AND bb AND
AND en;
en;
END
END add_bits3;
add_bits3;
END
END my_stuff;
my_stuff;
ENTITY 8_bit_reg IS
GENERIC (x_setup, prop_delay : TIME);
PORT(enable, clk : IN qsim_state;
a : IN qsim_state_vector(7 DOWNTO 0);
b : OUT qsim_state_vector(7 DOWNTO 0));
END 8_bit_reg;
SHIFTED 0 0 1 0
Introduction
Examples
Summary
PACKAGE resources IS
END resources;
USE work.resources.all;
ENTITY and2 IS
END behav;
Copyright 1995-1998 RASSP E&F
And Gate Simulation Results RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
USE work.resources.all;
ENTITY tri_state IS
ARCHITECTURE behav OF tri_state IS
GENERIC(trise : delay := 6 ns;
tfall : delay := 5 ns; BEGIN
thiz : delay := 8 ns);
one : PROCESS (a,e)
PORT(a : IN level;
e : IN level; BEGIN
b : OUT level); IF (e = '1' AND a = '1') THEN
-- enabled and valid data
END tri_state; b <= '1' AFTER trise;
ELSIF (e = '1' AND a = '0') THEN
b <= '0' AFTER tfall;
ELSIF (e = '0') THEN -- disabled
b <= 'Z' AFTER thiz;
ELSE -- invalid data or enable
b <= 'X' AFTER (trise+tfall)/2;
END IF;
END behav;
Introduction
Examples
Summary
Package
Concurrent Process
Concurrent
Statements
Statements
Copyright 1995-1998 RASSP E&F
Sequential Statements
References RASSP
RASSP
SCRA
SCRAE&F
GT
GT UVA
E&F
UCinc
UVA
UCinc EIT
Raytheon
Raytheon EIT ADL
ADL
[Walker85] Walker, Robert A. and Thomas, Donald E., "A Model of Design Representation and Syntheses", 22nd
Design Automation Conference, pp. 453-459, IEEE, 1985
[Williams94] Williams, R. D., "Class Notes for EE 435: Computer Organization and Design", University of Virginia,
1994.