Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction:
This subject will explore how to design implement and test hardware digital systems by
focussing on the required "behaviour" and the system architecture, to enable computer
based tools to then generate the actual implementation for you.
So far you may have experienced designing simple digital systems using either digital
logic gates, or written a program using assembler or 'C'.
A third approach to designing a digital system however is by describing the required
"behaviour" using a hardware description language called VHDL. (Which as an acronym
for Very High Speed Integrated Circuit - Hardware Description Language)
Most of the development will be done using a computer and many of the technical terms
and concepts will be similar to those found in other traditional computer languages - this
similarity might help at the start, but most of the time, to create VHDL modules that
translate into successful hardware that works as required, many of the concepts you will
meet, and how you will have to think, will be new.
From one view VHDL and Systems Design is easy - If you go about things in the right
way, if you follow a set of simple rules, if you keep an attention to detail - then things
should go smoothly. From another view VHDL and Systems Design may at first seem
difficult - there are many new "rules" and concepts to understand and remember - and
the way you need to think about and write VHDL is different from other computer
languages you will have met. Overall, however, there is nothing really complex to
master, and the rules are all relatively simple.
Aim of Studying this Subject:
Your aim in studying this subject is to reach a level of understanding that allows you to
design and implement digital systems through the use of VHDL behavioural modelling
targeted at a programmable logic implementation. The goal is for you to do some real
engineering development such that you have a skill for the future.
Preliminary design on paper to define input and output signals and overview of
the expected behaviour.
Create the VHDL behavioural model.
Run simulation and analyse results to prove correctness of expected behaviour.
Synthesize and Implement Design using computer based tools.
Download configuration file to the Programmable Logic Device.
When modelling the behaviour for hardware we are following an alternative route in the
design process in reaching a working solution.
Building Blocks:
Within digital systems, despite their overall complexity and functionality, there are in
reality a limited set of "standard" building blocks that make up such systems. The goal
in systems design therefore is to break a problem down into simpler sections to the
point where the lowest level blocks are the standard "Lego Bricks" that then easily fit
together to make up the system. Systems design is therefore a mix of top-down and
bottom-up approaches.
In VHDL we describe this transfer by the use of the "assignment operator" "<="
This gives a fixed assignment where B always feeds T; and C always feeds V.
Within any hardware system there is generally more than one thing happening at the same
time - called concurrency - which we therefore need some way of describing when we are
designing a hardware based system in VHDL. Given that the two wires we have just
described could have different values on them at any given instant - then the two
assignment statements if they were within a VHDL model would be concurrent - and could
therefore appear in any order.
Logic Functions
Often within a system, a set of input signals applied to a building block with particular
values causes the outputs to generate a known set of values. Such building blocks
normally implement Boolean logic functions through the use of combinational logic.
When using the traditional circuit design technique - there is normally a process of logic
minimisation that needs to take place by the application of Boolean algebra and Karnaugh
Maps to achieve the minimum of logic gates for implementation.
With VHDL any minimisation takes place later in the design process within the computer
based tools - so at the Behavioural level then one only needs to ensure that the logical
requirement is fully described without worrying about the actual implementation at this
stage.
The first step is to define the inputs and outputs for the building block to be modelled.
Here we describe the values that are assigned to the output W for each combination of the
inputs R and T. We are simply encoding the truth table using a conditional signal
assignment statement.
The example given here - explicitly shows the output for ALL possible input combinations.
It is possible to describe the required function however using less terms.
The three ways shown above of describing the required behaviour are all equivalent and
would result in the same implementation. The syntax for a conditional signal assignment is
as follows:
The key point to notice is the last value that is assigned if all the previous conditions are
NOT true - This is the "Default Value" and must appear at the end of the statement.
Because of this "rule" you will also notice that when specifying all input combinations as
shown in the first description for the output W with all four input combinations of R and T
above, five output values needed to given to fulfil the rule of having the unconditional
value at the end of the statement.
For a function with three inputs one simply includes more signals in each condition.
More complex building blocks can be described using a number of conditional signal
assignment statements - for example a 2 to 4 Decoder
where four concurrent statements describe the behaviour of each output where only one
output is high at any one time.
If an active low output is required then one simply changes the assignment values
Conditional Signal Assignment statements can be used to model other constructs found
in hardware. If one wanted control of the source of a signal that drives a particular
destination then
one can have:
where because these two actions take place at the same time - Then these statements
are concurrent
and because the statements are concurrent then they can be written in any order.
Within VHDL all signals must be given a data type to define the values that a signal can
be assigned. For the selector
then the signals could have the following data type - where "bit" tells us that these
signals can only be given values of '0' and '1' (Note Bit Values must be in single quotes)
If however the selector was required to switch a bundle of wires, often called a "bus", then
the following signal declaration for a vector would be required:
Notice that the actual statement remains the same - and it is only the data type that
defines what format the signal has - i.e. a single wire, or a vector.
The best way of introducing the required syntax is to show the complete entity below
and to then highlight the key points.
Entities must have a name - must start with a letter and then only contain letters,
numbers or underscore '_' (all declared items must follow this rule)
The entity name cannot be a keyword in VHDL and cannot be used for any other
purpose within the entity (e.g. signal name, label etc.)
The entity name appears in three places - after the keyword "entity" - at the "end" of the
entity declaration, and, within the architecture definition to link the architecture body to
the entity port list definition.
All input and output signals are declared in order within the port list.
Each signal declaration has a name, a mode (in, out, inout), and a type.
Signals of the same mode and type can be (as shown in the example) be declared one
signal at a time, or as a list e.g. R, T, S, V, Sel : in bit; k: out bit;
The architecture must have a name - not used elsewhere for other purposes.
Any internal signals (i.e. signals not previously declared in the entity port list) are
declared within the declarative area - between the "architecture" definition and the
"begin".
Behavioural statements appear between the "begin" and "end" and because they are
concurrent - can appear in any order.
Unless otherwise stated VHDL is insensitive to case where keywords and identifiers
may be in lower, upper or mixed case.
uninitialized
unknown
strong low and high
high impedance
weak unknown
weak low and high
i.e. low and high values that can be driven to a '0' or a '1'
Don't care
Complete Entity
Standard
Standardtypes
typeswithin
withinVHDL
VHDL
BIT
BIT('0','1')
('0','1')
BIT_VECTOR
BIT_VECTOR(0
(0to
to3)
3) -- BIT_VECTOR
BIT_VECTOR(3
(3downto
downto0)
0)
BOOLEAN
BOOLEAN(FALSE,TRUE)
(FALSE,TRUE)
INTEGER
INTEGER(-2147483647
(-2147483647to
to2147483647)
2147483647)
Enumerated
Enumeratede.g.
e.g. type
typecolour
colourisis (none,
(none,red,
red,blue,
blue,green);
green);
signal
signallamp
lamp::colour;
colour;
Other
Otheradditional
additionaltypes
typesare
areprovided
providedininpackages
packages
1076
10761993
1993defines
definestype
typeREAL
REAL--not
notsupported
supportedfor
forsynthesis
synthesis
entity example is
port ( A, B : in BIT;
F : out BIT);
end example;
architecture demo1 of example is
F <=
'1'
'1'
'1'
'0'
'0' ;
end demo1;
uninitialized
uninitialized
unknown
unknown
strong
stronglow
lowand
andhigh
high
high
highimpedance
impedance
weak
weakunknown
unknown
weak
weaklow
lowand
andhigh
high
Don't
(only
Don'tcare
care
(only'0','1','Z','-'
'0','1','Z','-'fully
fullysupported
supportedfor
forsynthesis)
synthesis)
std_logic_vector
std_logic_vector(range)
(range) e.g.
e.g.((77downto
downto00))or
or((00to
to7)
7)
signal
signalff::std_logic_vector
std_logic_vector((33downto
downto00););
gives
givesaa'bundle'
'bundle'of
of44'wires'
'wires'f(3),
f(3),f(2),
f(2),f(1)
f(1)&
&f(0)
f(0)
Value
Condition ( TRUE or FALSE )
F <= '1'
'1'
'1'
"Signal
Assignment
'0'
Operator"
'0' ;
example
Symbol
out
Modelling Behaviour
d
ul
co
t
en a
em in
at tten ......
t
S i
is wr rm
Th re- er fo
be pl
sim
Architecture Body
Alternative Value
else
else
else
else
entity example2 is
port ( A, B, C : in BIT;
S : out BIT);
end example2;
architecture demo of example2 is
begin
S <= '0' when A = '0' and B = '0' and C = '0' else
'1' when A = '0' and B = '0' and C = '1' else
'1' when A = '0' and B = '1' and C = '0' else
'0' when A = '0' and B = '1' and C = '1' else
'1' when A = '1' and B = '0' and C = '0' else
'0' when A = '1' and B = '0' and C = '1' else
'0' when A = '1' and B = '1' and C = '0' else
'1' when A = '1' and B = '1' and C = '1' else
'0' ;
end demo;
entity example is
port ( A, B : in BIT;
F : out BIT);
end example;
Entity Declaration
A
else
else
else
else
in
std_logic
std_logic (('U',
'U','X',
'X','0',
'0','1',
'1','Z',
'Z','W',
'W','L',
'L','H',
'H','-'
'-'))
'U'
'U'
'X'
'X'
'0',
'0', '1'
'1'
'Z'
'Z'
'W'
'W'
'L',
'L','H'
'H'
'-''-'
in
when
when
when
when
Truth Table
What is a
2 to 4 Decoder ?
A
B
K
L
M
N
VHDL Operators
2 to 4 Decoder ...
Describing the required behaviour.....
entity decoder is
port ( a,b : in bit; K,L,M,N : out bit );
end decoder;
architecture inside of decoder is
begin
N <= '1' when a='0' and b='0' else '0' ;
M <= '1' when a='0' and b='1' else '0' ;
L <= '1' when a='1' and b='0' else '0' ;
K <= '1' when a='1' and b='1' else '0' ;
end inside; This architecture has 4 concurrent statements
Logical:
Logical: And,
And, or,
or,nand,
nand, nor,
nor,xor,
xor,xnor,
xnor, not
not
=,
=, /=,
/=, <,
<, <=,
<=, >,
>, >=
>=
Relational:
Relational:
Arithmetic:
+,
Arithmetic:
+, -,-, *,
*, //
(('/'
'/'Synthesis
Synthesisrestriction
restriction--must
mustbe
bepower
powerof
of2)
2)
Other
Otheroperators
operatorsexist
existfor
forshift
shiftfunctions,
functions,MOD,
MOD,REM...
REM...
Extensions
Extensionsin
indata
datatypes
typesand
andoperators
operatorsmay
maybe
beincluded
included
in
inan
anentity
entityby
bythe
theuse
useof
oflibrary
librarypackages
packagese.g.
e.g.
Library
LibraryIEEE;
IEEE;
Use
UseIEEE.Std_logic_1164.
IEEE.Std_logic_1164.all;
all;
Use
IEEE.Std_logic_arith.all;
all;
UseIEEE.Std_logic_arith.