Beruflich Dokumente
Kultur Dokumente
Support de cours
D.Chillet
Daniel.Chillet@enssat.fr
http://r2d2.enssat.fr
VHDL
Plan
1 ) Introduction : motivations, historique
2 ) Mthode de conception: modles de description
3 ) Units de conception :
entit, architecture, configuration, paquetage, corps de paquetage
Introduction
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
1) Introduction
q
C1
C2
C4
C3
1) Introduction
niveau logique
niveau transfert de registres
niveau systme
B
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
1) Introduction
q
Un HDL, doit :
formalisation du problme
partir de briques de base
viter les descriptions ambigu
1) Introduction
la validation du systme :
C1
C2
C4
C3
1) Introduction
Systme
Architecture
Registres
Portes
Circuit
Silicium
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
1) Introduction
Schmas
Systme
Architecture
Registres
Portes
Outils de synthse
de haut niveau
Description HDL
Equations
boolennes
Circuit
Objets
gomtriques
Structurel
Silicium
???
Comportemental 10
1) Introduction
VHDL
Schmas
Objets
gomtriques
Structurel
Systme
Architecture
Registres
Portes
Outils de synthse
de haut niveau
Description HDL
Equations
boolennes
Circuit
Silicium
???
Comportemental
11
1) Introduction
q
besoin de standardisation
12
1) Introduction
q
Rapide historique :
rfrences constantes
ADA a t normalis dfinitivement en 83
Nouvelle norme en 93
Nouvelle normalisation autour de VHDL analogique :
VHDL AMS
pourquoi ?
demande en simulation analogique et en simulation mixte
13
1) Introduction
VHDL :
Langage de
simulation
la simulation
la synthse
la spcification
la documentation
Langage de
synthse
VHDL
Langage de
documentation
Langage de
modlisation
14
1) Introduction
main()
{
...
resultat = Factorielle(x)
Factorielle
resultat
15
1) Introduction
s1
s2
C2
notion de signal :
s3
C3
C4
e1
e2
2 ns
s
16
1) Introduction
q
indpendant du constructeur
indpendant de la technologie
indpendant de la dmarche
indpendant du niveau de conception
Standard
Portabilit
IEEE :
nombreux outils :
compilateur, simulateur
mais aussi des outils de synthse et de spcification
17
1) Introduction
Dfinition du langage :
- version 1076-87
- version 1076-93
1076.1
1076
1076.2
1076.3
VHDL
Dans le langage :
dfinition du type bit :
bit ('0' , '1')
un peu juste
1076.4
1076.5
1164
STD LOGIC
18
1) Introduction
q
VHDL :
travail dquipe :
Simulation du systme :
1) Introduction
1 re anne :
- modlisation
- simulation
Description
informelle
Spcification
en VHDL
2 me anne :
- modlisation
- simulation
- synthse
Synthse
20
Mthodes de
conception
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
21
2) Mthodes de conception
q
Descendante :
d'oprateurs logiques
d'oprateurs arithmtiques
d'oprateurs plus complexes
Ascendante :
oprateurs logiques
oprateurs arithmtiques
oprateurs plus complexes
22
2) Mthodes de conception
q
Mthode en 3 temps :
description comportementale
simulation et validation
description structurelle (architecture)
Simulations
Corrections
Spcification
de niveau N
Ce que fait le systme
(cahier des charges)
Etape N
Modle
Comment il le fait
(ralisation)
Spcification
de niveau N-1
23
2) Mthodes de conception
q
Mathmatique
Etape
Application
Comportemental
Etape
Formule
N-1
Structurel
Etape
Algorithme
N-2
Architecture
Conception descendante
Conception ascendante
24
2) Mthodes de conception
Langage naturel
Etape 1
Modle
mathmatique
Simulateur
comportemental
Etape 2
Modle
comportemental
(algorithmique)
Simulateur
matriel
Etape 3
Modle
structurel
Simulateur
physique
Etape 4
Modle
physique
Math lab
25
2) Mthodes de conception
Langage naturel
Etape 1
Modle
mathmatique
Etape 2
Modle
comportemental
(algorithmique)
Etape 3
Modle
structurel
Etape 4
Modle
physique
Simulateur
VHDL
26
2) Mthodes de conception
q
Primitives
Reprsentations
Systme
fonctions
Spcif de performances
Module hard
Machine squentielle
Logique
Portes
Equations boolennes
Circuit
Transistors, R, L, C
Equations diffrentielles
Silicium
Objets gomtriques
27
2) Mthodes de conception
q
Structurel
Comportemental
algorithme
le temps peut intervenir
Flot de donnes
28
2) Mthodes de conception
Intrt de VHDL dans la conception descendante
SANS VHDL
Description
informelle
Equations
boolennes
Schmas
AVEC VHDL
Description
informelle
Spcification
en VHDL
Synthse
Synthse
Le temps,
c'est de l'argent !!!
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
29
2) Mthodes de conception
q
Organisation de la conception :
Bibliothque
de Robert
Bibliothque
de Paul
Bibliothque
commune
30
2) Mthodes de conception
q Bibliothques
et librairies
bit
vector de bit
string
integer
time
etc
31
Units de
conception
VHDL
32
3) Units de conception
q
Boite noire
Nom
paramtres
connections
Description
interne
33
3) Units de conception
q
Exemples :
A
Additionneur
vue interne
Cout
Cout
Cin
Cin
vue interne
description du corps de toutes
les fonctions (y compris les
fonctions non visible de lextrieur)
34
3) Units de conception
q
spcification dentits
architecture
Liens entre
les entits et
les composants
utiliss
spcification de paquetage
Composant
(intrieur de la boite)
configuration
Paquetage
corps de paquetage
35
3) Units de conception
q
Spcification dentit :
nom
entres sorties :
nombre
sens
type de donnes transportes
entity Additionneur is
port ( A, B, Cin : in bit;
S, Cout : out bit)
end Additionneur ;
(paramtres gnriques)
Cin
S
Additionneur
B
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
Cout
36
3) Units de conception
q
Spcification darchitecture :
comportemental
structurel
flot de donnes
Fonction
s = a.b + a.b
Structurel
Etape 1
Etape 2
process
if (not a and b)
s <=
else
s <=
end if;
wait
end process;
a
b
a
b
0;
on a, b;
37
3) Units de conception
q
Modle comportemental :
38
3) Units de conception
q
Modle comportemental
Additionneur
A
B
Cin
architecture comportementale of
begin
process
if (A = '0' AND
S <= '0
end if;
if (A = '0' AND
S <= '1
end if;
if (A = '0' AND
S <= '1
end if;
wait on A, B;
end process;
end comportementale;
Additionneur is
Cout
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
Cin
0
1
0
1
0
1
0
1
S
0
1
1
0
1
0
0
1
Cout
0
0
0
1
0
1
1
1
39
3) Units de conception
q
Modle comportemental
A
B
Cin
algorithme
architecture comportementale2 of Additionneur is
begin
process (A, B, Cin)
begin
if (A = '0' AND B = '0' AND Cin = '0') then
S <= '0 after 5 ns; Cout <= '0 after 5 ns;
end if;
if (A = '0' AND B = '0' AND Cin = '1') then
S <= '1 after 5 ns; Cout <= '0 after 5 ns;
end if;
if (A = '0' AND B = '1' AND Cin = '0') then
S <= '1 after 5 ns; Cout <= '0 after 5 ns;
end if;
end process;
end comportementale2 ;
40
3) Units de conception
q
Modle structurel
liste dlments
interconnexions
connexions permanentes
41
3) Units de conception
q
Modle structurel
Additionneur
A
B
S2
u0
u1
Cin
u4
S1
S3
u2
u3
Cout
42
3) Units de conception
architecture
structurelle1 of Additionneur is
component porteOU
port (
e1 : in
e2 : in
s : out
end component;
component porteET
port (
e1 : in
e2 : in
s : out
end component;
component porteXOR
port (
e1 : in
e2 : in
s : out
end component;
bit;
bit;
bit );
bit;
bit;
bit );
bit;
bit;
bit );
begin
u0 : porteET
port map ( A, B, S2);
u1 : porteXOR
port map ( A, B, S1);
u2 : porteET
port map ( S1, Cin, S3);
u3 : porteXOR
port map ( S1, Cin, S);
u4 : porteOU
port map ( S2, S1, Cout);
end structurelle1;
43
3) Units de conception
q
demi_add
Additionneur
demi_add
A
B
S2
u2
Cout
u0
u0
S1
Cin
S3
u1
u1
demi_add
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
44
3) Units de conception
architecture
structurelle2 of Additionneur is
component porteOU
port (
end component;
component DemiADD
port (
e1 : in bit;
e2 : in bit;
s : out bit );
e1
e2
s1
s2
:
:
:
:
in bit;
in bit;
out bit ;
out bit);
end component;
signal S1, S2, S3 : bit;
begin
u0 : DemiADD
port map ( A, B, S2, S1);
u1 : DemiADD
port map ( S1, Cin, S3, S);
u2 : porteOU
port map ( S2, S3, Cout);
end structurelle2;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
45
3) Units de conception
q
Avec DemiAdd :
Entity DemiAdd is
port (
e1
e2
s1
s2
:
:
:
:
in bit;
in bit;
out bit ;
out bit);
end DemiAdd;
architecture
structurelle of DemiAdd is
component porteET
port (
e1 : in bit;
e2 : in bit;
s : out bit );
end component;
component porteXOR
port (
e1 : in bit;
e2 : in bit;
s : out bit );
end component;
begin
u0 : PorteET
port map ( e1, e2, s1);
u1 : porteXOR
port map ( e1, e2, s2);
end structurelle;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
46
3) Units de conception
q
S2
Cout
B
S1
S3
Cin
S
47
3) Units de conception
q
Spcification de configuration :
48
3) Units de conception
Soit un systme utilisant un composant Add1 :
Entity Additionneur
Architecture
comportement
Architecture
structurelle1
Architecture
flot
Configuration 1
Configuration 2
Configuration 3
end -conf1;
conf1;
ENSSAT
Universit de Rennes 1 - France - Anne universitaire 2003end
- 2004
end conf1;
49
3) Units de conception
q
Spcification de package :
package nom
is
constant PI : real ;
return integer;
.....
end nom;
50
3) Units de conception
q
Corps du package :
package body nom
is
return integer is
end nom ;
51
Les objets
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
52
4) Les objets
q
Constantes :
Variables :
Signaux :
10 ns
20 ns
30 ns
60 ns
S <= '1', '0' after 10 ns, '1' after 20 ns, '0' after 30 ns,
53
4) Les objets
q
Les signaux :
54
4) Les objets
q
Affectation de signaux :
2 modes de fonctionnement :
mode inertiel :
filtre les impulsions de longueur insuffisante
mode transmission :
transmission de toutes les impulsions
< 10 ns
< 10 ns
S
S1 <= S after 10 ns;
S2 <= transport S after 10 ns
55
4) Les objets
Mode inertiel
pour les composants dont le temps de travers est non nul (tous les
composants dcrits de faon raliste)
Impulsion infrieure 5 ns
1
0
a
ET
Logique
(5 ns)
1
0
1
0
56
4) Les objets
Mode transport
Bus 1
Bus 2
57
4) Les objets
q
le contrleur doit s'assurer que les deux sorties de registres ne sont pas
l'tat basse impdance simultanment
R1
cs1
R2
cs2
58
4) Les objets
Les types
Scalaires :
entiers
flottants
types physiques
numrs
integer
real
time
(bleu, rouge, jaune, ...)
Composites :
tableaux
articles
Accs:
pointeurs
Fichiers (accs
squentiel, typ
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
array
record
access (new, deallocate)
file (read, write, endfile)
59
4) Les objets
q
Le type scalaire :
type numr :
type physique :
60
son unit
par des sous units
on peut effectuer des calculs sur ces types
Co
rre
sp
on
da
nc
e
4) Les objets
61
4) Les objets
q
Les tableaux :
dimensions multiples
les indices sont de type discret (numr ou entier)
2 sortes de tableaux :
contraint : on spcifie le sens de variation des indices
1 to 15
15 downto 1
62
4) Les objets
63
4) Les objets
q
Les articles :
64
4) Les objets
q
65
4) Les objets
association mixte :
doit commencer par la partie "nominative"
A: tableau := (4=>9, 0=> 5, others => 0);
B : article := (champs2=>1, others => 0);
quivalents
A := (5, 0, 0, 0, 9);
B := (0, 1, 0);
...
signal BusData : bus (7 downto 0);
signal BusAddress : bus (15 downto 0);
....
BusData <= (Others => 'Z') ;
BusAddress <= (Others => '0') ;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
4) Les objets
q
Le type accs :
new
deallocate
Peu utilis !
deallocate(p);
-- Initialisation
67
4) Les objets
q
Le type fichier :
utilis pour :
fichiers de stimuli
charger le contenu dune ROM (par exemple)
lecture ;
68
4) Les objets
q
69
Les lments
du langage
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
70
Oprations classiques :
q
q
q
caractre : X
chanes de caractres : .........
chanes de bits :
XAB08
O037
B001101
: hexadcimale
: octale
: binaire
71
72
73
exemples
74
x := MAX ( var, 5) ;
x := MAX ( b=> 5, a=> var) ;
75
Surcharge doprateurs :
-- oprateur unaire
76
Instructions squentielles :
wait :
77
assert :
A, B : in bit;
S : out bit)
end Additionneur;
architecture comportement of Additionneur i s
begin
process (A, B)
begin
assert ((A AND B) = '0') report "Additionneur : Probleme de debordement" severity warning;
S <= A and B after 4 ns;
end process;
end comportement;
78
Affectation de signaux :
79
Temps vu par :
le simulateur
le concepteur
2 delta
80
81
Instructions conditionnelles :
if condition_boolenne then
sequence dinstructions 1 ;
else
sequence dinstructions 2 ;
end if;
if condition_1 then
sequence dinstructions 1 ;
end if;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
82
Structure case
case expression is
when valeur1
when valeur2 | valeur3
when valeur4 to valeur5
when others
end case;
83
Instructions de boucles :
boucle infinie :
loop
squence dinstructions ;
end loop;
boucle while :
while condition loop
squence dinstructions ;
end loop ;
boucle for :
for i in 1 to 10 loop
squence dinstructions ;
end loop;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
Les attributs :
des signaux
des tableaux
des types
85
Attributs de signaux :
Sevent :
boolean
true si un vnement vient darriver sur S pendant le cycle de simulation en
cours
Sactive :
boolean
true si il y a eu une transaction (affectation) sur le signal dans le cycle de
simulation en cours
Squiet(T) :
boolean
true si le signal a eu ni transaction ni vnement pendant un temps T
Sstable(T) :
boolean
true si il ny a pas eu d'vnement sur le signal pendant le temps T
Stransaction :
signal
cest un signal de type bit qui change dtats pour chaque transaction du
signal
86
Sdelayed :
signal
cest un signal identique S mais retard de T
Slast_event :
time
rend le temps coul depuis le dernier vnement sur le signal
Slast_active :
time
rend le temps coul depuis la dernire transaction
Slast_value :
type du signal
rend la valeur du signal immdiatement avant le dernier changement de S
87
40 ns
55 ns 60 ns 70 ns 80 ns
S
Sevent
Sactive
T F T
Squiet(T)
Sstable(5 ns)
Sdelayed(2 ns)
88
Logique synchrone
89
positif'base :
BitBus'high ===> 15
BitBus'low ===> 0
BitBus'left ===> 15
NewBits'left ===> '0'
NewBits'right ===> 'Z'
etat'pos(Marche) ===> 1
etat'val(2) ===> Monter
etat'succ(Marche) ===> Monter
90
chane de caractres
du type tat
91
Attributs de tableaux :
A'left ===> 1
Aright ===> 37
Ahigh ===> 37
A'low ===> 1
Alength ===> 37
A'range ===> 1 to 37
A'reverse_range ===> 37 downto 1 A'ascending ===> true
Bleft(1) ===> 6
B'right(1) ===> 2
Blow(1) ===> 2
Blow(2) ===> 1
Blength(1) ===> 5
B'range(1) ===> 16 downto 2
B'range(2) ===> 1 to 7
B'ascending(1)
===>
ENSSAT - Universit de Rennes1 - France
- Anne universitaire 2003
- 2004 false
B'left(2) ===> 1
Bright(2) ===> 7
B'high(1) ===> 6
B'high(2) ===> 7
B'length(2) ===> 7
B'reverse_range(1) ==> 2 to 6
B'reverse_range(2) ==> 7 downto 1
B'ascending(2) ===> true
92
if (A'left = 1) then
93
Instructions
concurrentes
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
94
6) Instructions concurrentes
q
Les processus :
liste de sensibilit
utilisation de linstruction wait
95
6) Instructions concurrentes
label : process (liste signaux)
dclarations
begin
instructions squentielles
label : process
dclarations
begin
instructions squentielles
....
wait on liste signaux ;
Transformation de ce processus
label : process
dclarations
begin
wait on liste signaux ;
....
instructions squentielles
end process label ;
96
6) Instructions concurrentes
Systme
Composant 2
Composant 1
Processus 2
1
Processus 1
Composant 3
Composant 4
Processus 4
Processus 3
Processus 2
Processus 3
Simulation
Processus 4
Processus 1
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
97
6) Instructions concurrentes
P2 : process
begin
P3 : process
begin
98
6) Instructions concurrentes
q
Les blocs :
partage de dclarations
garde daffectation :
affectations soumises une condition
t0+40 ns
99
La gnricit
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
100
7) La gnricit
q
Intrts :
exemples :
registre N bits
additionneur N entres
101
7) La gnricit
Intrts de la gnricit :
Bibliothque
Conception 1
Conception 2
Conception 3
Bibliothque
Bibliothque
Bibliothque
Conception N
102
7) La gnricit
q
generic ( ;
. ;
. );
port (;
;
...);
end .. ;
de tableaux
de types
de signaux
7) La gnricit
q
8, 16, 32 ???
D
Registre
Load
8, 16, 32 ???
NbBits
Enable
Clock
104
7) La gnricit
Description de l'entit
entity registre is
generic (NbBits : INTEGER := 8);
port (D : in std_logic_vector (NbBits-1 downto 0);
Load : in std_logic ;
Enable : in std_logic ;
Clock : in std_logic ;
Q : out std_logic_vector (NbBits-1 downto 0)
);
end registre ;
105
7) La gnricit
Reg j
Reg i
106
7) La gnricit
Regi : Registre
generic map (16)
port map (BusData, SLoadi, SEnablei, SClock, BusData);
Regj : Registre
generic map (32)
port map (BusAddress, SLoadj, SEnablej, SClock, BusAddress);
end structure;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
107
7) La gnricit
Entrees
ET
Sortie
entity Et_N is
generic ( N : Natural )
port (
Entrees : in std_logic_vector ( 1 to N ) ;
sortie : out std_logic );
end Et_N ;
7) La gnricit
Utilisation du ET gnrique :
Entree : in std_logic ;
sortie : out std_logic );
end component ;
signal Entrees : std_logic_vector(2 downto 0);
signal Sortie : std_logic;
signal E0, E1, E2 : std_logic;
begin
U0 : Et_N
generic map(3)
port map (Entrees, Sortie);
U1 : OU port map( , E1);
U2 : OU port map( , E2);
U3 : OU port map( , E3);
Entrees(0) <= E1;
Entrees(1) <= E2;
Entrees(2) <= E3;
end comportement;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
OU
OU
ET
Sortie
OU
109
7) La gnricit
x(0)
y(0)
ADD
ADD
C(0)
s(0)
x(1)
C(1)
y(1)
ADD
ADD
s(1)
x(N-1)
C(2)
C(N-1)
y(N-1)
ADD
ADD
C(N)
s(N-1)
110
7) La gnricit
entity Add is
port (
A, B, Cin : in std_logic;
S, Cout : out std_logic);
end Add ;
entity AdditionneurN is
generic (N : Natural := 8);
port (
X, Y : in std_logic_vector ( N-1 downto 0) ;
Cin : in std_logic;
S : out std_logic_vector (N-1 downto 0);
Cout : out std_logic);
end AdditionneurN ;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
111
7) La gnricit
q
7) La gnricit
Sortie1
Sortie2
Demux
Entree
NbBits
NbSorties
SortieN
Selection
113
7) La gnricit
description de l'entit
entity Demux is
generic (NbBits : Natural := 8;
NbCmd : Natural := 4;
NbSorties : Natural := 16);
port (
Entree : in std_logic_vector(NbBits -1 downto 0) ;
Selection : in std_logic_vector(NbCmd -1 downto 0);
Sorties : out std_logic_vector (NbSorties*NbBits -1 downto 0)
);
end Demux ;
architecture comportement of Demux is
begin
affectations : for i in
Selection'range
generate
for i in 0 to 7 generate
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
114
La fonction
de
rsolution
115
8) La fonction de rsolution
q
Mmoire
R1
R3
Mult
R2
Add
R4
Signal multi-sources
Plusieurs driver pour le mme signal
PROBLEME
116
8) La fonction de rsolution
q
q
q
117
8) La fonction de rsolution
q
Exemple :
8) La fonction de rsolution
q
Exemple:
----Extrait du package std_logic_1164.vhd-------------TYPE std_ulogic IS ( 'U','X','0', '1', 'Z', 'W', 'L', 'H', '-' );
TYPE std_ulogic_vector IS ARRAY ( NATURAL RANGE <> ) OF std_ulogic;
CONSTANT resolution_table : stdlogic_table := (
--------------------------------------------------------| U X 0 1 Z W L H | |
--------------------------------------------------------( 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U' ), -- | U |
( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ), -- | X |
( 'U', 'X', '0', 'X', '0', '0', '0', '0', 'X' ),
-- | 0 |
( 'U', 'X', 'X', '1', '1', '1', '1', '1', 'X' ),
-- | 1 |
( 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', 'X' ), -- | Z |
( 'U', 'X', '0', '1', 'W', 'W', 'W', 'W', 'X' ), -- | W |
( 'U', 'X', '0', '1', 'L', 'W', 'L', 'W', 'X' ), -- | L |
( 'U', 'X', '0', '1', 'H', 'W', 'W', 'H', 'X' ), -- | H |
( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ) -- | - |
);
FUNCTION resolved ( s : std_ulogic_vector ) RETURN std_ulogic IS
VARIABLE result : std_ulogic := 'Z'; -- weakest state default
BEGIN
IF (s'LENGTH = 1) THEN RETURN s(s'LOW);
ELSE
FOR i IN s'RANGE LOOP
result := resolution_table(result, s(i));
END LOOP;
END IF;
RETURN result;
END resolved;
SUBTYPE std_logic IS resolved std_ulogic
----
0
0
0
1
X
X
0
119
Simulations
et validations
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
120
9) Simulation et validation
q
Spcification
de niveau N
Ce que fait le systme
(cahier des charges)
SIMULATIONS
simulation comportementale :
REFERENCE
simulation structurelle :
COMPARAISON AVEC LA
REFERENCE
Simulations
Corrections
Etape N
SIMULATIONS
Comment il le fait
(ralisation)
Spcification
de niveau N-1
121
9) Simulation et validation
q
Simulations
Etape 1
Modle
mathmatique
Etape 2
Modle
comportemental
(algorithmique)
Etape 3
Modle
structurel
Etape 4
Modle
physique
122
9) Simulation et validation
q
123
9) Simulation et validation
Processus
Systme
Comparaisons
Entit de test
Stimuli
(et rsultats
attendus)
Messages :
- simulation correcte
- erreur de simulation
124
9) Simulation et validation
q
entity Additionneur is
port (
A, B, Cin : in std_logic ;
S, Cout : out std_logic );
end Additionneur ;
architecture comportement of Additionneur is
...
end comportement;;
Cin
S
Additionneur
B
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
Cout
125
9) Simulation et validation
entity Test_Add is
end Test_Add ;
Additionneur
Test_Add
Processus
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
126
9) Simulation et validation
-- configuration
for U1 : Add use entity Additionneur(comportement);
constant TempsCycle : time := 10 ns ;
begin
-- Instanciation du composant
U1 : Additionneur port map (
A => SA ,
B => SB,
S => SOut,
Cin => SCin ,
Cout => SCout
);
Simulation : process
begin
...
end process;
end comportement;
127
9) Simulation et validation
128
9) Simulation et validation
...
constant TempsCycle : time := 10 ns ;
type TableauEntrees is array (0 to 2) of std_logic;
type TableauVecteur is array (0 to 7) of TableauEntrees;
constant Vecteur : TableauVecteur :=
(
(0, 0, 0),
(0, 0, 1),
(0, 1, 0),
(0, 1, 1),
(1, 0, 0),
(1, 0, 1),
(1, 1, 0),
(1, 1, 1)
);
-- Instanciation du composant
U1 : Additionneur port map ();
Simulation : process
begin
wait for TempsCycle ;
for i in Vecteur'range(1) loop
SA <= Vecteur(i)(0);
SB <= Vecteur(i)(1);
SCin <= Vecteur(i)(2);
wait for TempsCycle;
end loop;
wait ;
end process;
begin
129
9) Simulation et validation
...
constant TempsCycle : time := 10 ns ;
type TableauEntrees is array (0 to 4) of std_logic;
type TableauVecteur is array (0 to 7) of TableauEntrees;
constant Vecteur : TableauVecteur :=
(
(0, 0, 0, 0, 0),
(0, 0, 1, 0, 1),
(0, 1, 0, 0, 1),
(0, 1, 1, 1, 0),
(1, 0, 0, 0, 1),
(1, 0, 1, 1, 0),
(1, 1, 0, 1, 0),
(1, 1, 1, 1, 1)
);
signal SA, SB, SOut, SCin, SCout : std_logic ;
-- Instanciation du composant
U1 : Additionneur port map ();
Simulation : process
begin
wait for TempsCycle ;
for i in Vecteur'range(1) loop
SA <= Vecteur(i)(0);
SB <= Vecteur(i)(1);
SCIn <= Vecteur(i)(2);
wait for TempsCycle;
assert (SCout = Vecteur(i)(3))
report "Probleme sur la sortie Cout"
severity warning;
assert (SOut = Vecteur(i)(4))
report "Probleme sur la sortie S"
severity warning;
end loop;
wait ;
end process;
begin
130
9) Simulation et validation
...
signal SA, SB, SOut, SCin, SCout : std_logic ;
begin
-- Instanciation du composant
U1 : Additionneur port map ();
Simulation : process
file VecteursIN : integer is in "VecteursIN ";
file VecteursOut : integer is in "VecteursOUT";
variable ligne : line;
variable VA, VB, VCin, VCout, VOut : integer;
variable Tps : integer;
variable TempsCycle : time := 10 ns;
begin
wait for TempsCycle ;
readline(VecteursIN , ligne);
read(ligne, Tps);
TempsCycle = Tps ns;
while not endfile(VecteursIn ) loop
read(ligne, VA);
read(ligne, VB);
read(ligne, VCin);
read(ligne, VCout);
read(ligne, VOut);
SA <= Integer2Bit(VA);
SB <= Integer2Bit((VB);
SCIn <= Integer2Bit(VCin);
wait for TempsCycle;
assert (SCout = Integer2Bit(VCout))
report "Probleme sur la sortie Cout"
severity warning;
assert (SOut = Integer2Bit(VOut)
report "Probleme sur la sortie S"
severity warning;
end loop;
wait ;
end process;
131
9) Simulation et validation
q
entity Test_Registre
end Test_Registre;
begin
-- Instanciation du composant
U1 : Registre port map (
SD, SClock, SQ
);
Simulation : process
begin
...
end process Simulation;
-- configuration
for U1 : Registre use entity Registre(comportement );
Horloge : process
begin
SClock <= '0' ;
wait for 50 ns;
SClock <= '1' ;
wait for 50 ns;
end process Horloge ;
end comportement;
132
Exemples :
- logique combinatoire
- logique squentielle
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
133
Exemple simple :
soit la fonction :
a
b
s1
s2
ENTITY Fonc IS
PORT ( a : IN std_logic;
b : IN std_logic;
c : IN std_logic;
d : IN std_logic;
s1 : OUT std_logic;
s2 : OUT std_logic) ) ;
END Fonc ;
134
Autre description :
a
b
c
x1
s1
x2
s2
d
ARCHITECTURE flot3 OF Fonc IS
BEGIN
s1 <= (x1 and x2) after Tand;
s2 <= (x1 or x2) after Tor;
x1 <= (a and b) after tand;
x2 <= (c xor d) after Txor;
END flot3 ;
135
x1
x2
s1
s2
136
Additionneur :
gnricit sur :
le nombre de bits
le temps de calcul
NbBits
entree1
BEGIN
NbBits
NbBits
entree2
ENTITY Additionneur IS
GENERIC (Tadd : TIME ;
NbBits : INTEGER );
PORT (
entree1 : IN std_logic_vector(NbBits-1 DOWNTO 0) ;
entree2 : IN std_logic_vector(NbBits-1 DOWNTO 0)
;
sortie : OUT std_logic_vector(NbBits-1 DOWNTO 0) ) ;
END Additionneur ;
Additionneur
Additionneur
ProcessAdditionneur : PROCESS
VARIABLE e1, e2, s : INTEGER;
sortie
BEGIN
e1 := Conv_Integer (entree1) ;
e2 := Conv_Integer (entree2) ;
s := e1 + e2 ;
sortie <= Conv_Std_Logic_Vector (s, NbBits) After Tadd ;
wait on entree1, entree2;
END PROCESS ProcessAdditionneur ;
END comportementale ;
137
Multiplieur :
gnricit sur :
le nombre de bits
le temps de calcul
ENTITY Multiplieur IS
GENERIC (Tmult : TIME ;
NbBits : INTEGER );
PORT (
entree1 : IN std_logic_vector(NbBits-1 DOWNTO 0) ;
entree2 : IN std_logic_vector(NbBits-1 DOWNTO 0)
;
sortie : OUT std_logic_vector(2*NbBits-1 DOWNTO 0) ) ;
END Multiplieur ;
NbBits
entree1
entree2
Multiplieur
Multiplieur
BEGIN
sortie
ProcessMultiplieur : PROCESS
VARIABLE e1, e2, s : INTEGER;
BEGIN
e1 := Conv_Integer (entree1) ;
e2 := Conv_Integer (entree2) ;
s := e1 * e2 ;
sortie <= Conv_Std_Logic_Vector (s, 2*NbBits) After Tmult ;
wait on entree1, entree2;
END PROCESS ProcessMultiplieur ;
END comportementale ;
138
Exemple du multiplexeur :
ENTITY Multiplexeur IS
GENERIC (Tmux : TIME ;
NbBits : INTEGER );
PORT (
A : IN std_logic_vector(NbBits-1 DOWNTO 0) ;
B : IN std_logic_vector(NbBits-1 DOWNTO 0)
C : IN std_logic_vector(NbBits-1 DOWNTO 0)
D : IN std_logic_vector(NbBits-1 DOWNTO 0)
cmd : IN std_logic_vector(1 DOWNTO 0)
;
S : OUT std_logic_vector(NbBits-1 DOWNTO 0)
END Multiplexeur ;
;
;
;
);
Cmd
BEGIN
S <=
END flotdedonnees ;
C
D
139
Cmd
END flotdedonnees ;
A
B
C
D
140
Cmd
A
B
C
D
141
Le dcodeur :
entity decodeur is
generic (
NbSorties : integer;
Log2NbSorties : integer
);
port (
sorties : out std_logic_vector (NbSorties - 1 downto 0) ;
cmd : in std_logic_vector (log2NbSorties -1 downto 0)
);
end decodeur;
architecture flot of decodeur is
begin
affectations : for i in sorties'range generate
sorties(i) <= '1' when conv_positif(cmd) = i
else '0';
end generate affectations;
end flot ;
142
B
0
0
0
0
1
1
1
1
0
0
0
0
..
..
C
0
0
1
1
0
0
1
1
0
0
1
1
..
..
D
0
1
0
1
0
1
0
1
0
1
0
1
..
..
S
1
1
1
0
0
0
0
1
0
0
..
);
V:= 8 * conv_integer (A) + 4 * conv_integer (B)
+ 2 * conv_integer (C) + 1 * conv_integer (D) ;
S <= codage1 (V) ;
143
entity tristate is
port (
e : in std_logic;
oe : in std_logic;
s : out std_logic
);
end tristate ;
oe
architecture flot of tristate is
begin
s <= e when oe = '1' else 'Z';
end flot ;
144
Bascule D Latch
ena
entity BasculeD is
port (
Q <= test;
end comp;
d, ena : in std_logic;
Q : out std_logic);
end BasculeD ;
ena
D
Q
145
clock
entity BasculeD is
port (
Q <= test;
end comp;
d, clock : in std_logic;
Q : out std_logic);
end BasculeD ;
clock
D
Q
146
raz
up
clk
147
end BDA;
architecture comp of BDA is
begin
process
begin
if (raz = 0) then
Q <= 0 ;
elsif clkevent and clk = 1 then
Q <= D ;
end if;
wait on clk, raz;
end process;
end comp;
Asynchrone
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
entity BDS is
port (
end BDS;
architecture comp of BDS is
begin
process
begin
if clkevent and clk = 1 then
if raz = 0 then
Q <= 0 ;
else
Q <= D;
end if;
end if;
wait on clk;
end process;
end comp;
Synchrone
148
end BDA;
entity BDS is
port (
end BDS;
Asynchrone
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
Synchrone
149
Ralisation du contrleur
dun ascenseur :
il sagit de commander :
le moteur douverture et de
fermeture des portes
le moteur de monter et de
descente de lascenseur
dassurer une temporisation
entre louverture et la fermeture
des portes
Etage 2
Monte
Etage 1
on dispose :
Rdc
Ouverture
fermeture
Descente
150
Monte
Etage = Appel
Etage = Appel
Ouverture
porte
Descente
Etage = Appel
porte
ferme
Temporisation
Fermeture
porte
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
151
Logique
combinatoire
LC2
Sorties
state
LC1
REGISTRE
Logique
combinatoire
nextstate
Entres
clk
raz
Modlisations envisageables :
1) 1processus : (LC1 + REGISTRE + LC2)
2) 2 processus : (LC1 + REGISTRE) et LC2
ou LC1 et (REGISTRE + LC2)
3) 3 processus : LC1, REGISTRE et LC2
entity Controleur is
port (
Vue externe
end Controleur ;
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
152
153
154
155
Packages
ENSSAT - Universit de Rennes 1 - France - Anne universitaire 2003 - 2004
156
standard :
textio :
157
158
end standard ;
chane : string (1 to N) ;
V : bit_vector ( 15 downto 0) ;
159
160
16 procdures read :
8 procdures write :
end textio ;
Belles surcharges !!
161
11 ) Paquetages IEEE
q
package std_logic_1164 :
package std_logic_arith :
162
11 ) Paquetages IEEE
package std_logic_signed :
package std_logic_unsigned :
163
11 ) Paquetages IEEE
q
Attention :
164
11 ) Paquetages IEEE
-- ---------------------------------------------------------------------- Title : std_logic_1164 multi-value logic system
-- Library : This package shall be compiled into a library
-: symbolically named IEEE.
-:
-- Developers: IEEE model standards group (par 1164)
-- Purpose : This packages defines a standard for designers
-: to use in describing the interconnection data types
-: used in vhdl modeling.
-:
-- Limitation: The logic system defined in this package may
-: be insufficient for modeling switched transistors,
-: since such a requirement is out of the scope of this
-: effort. Furthermore, mathematics , primitives,
-: timing standards, etc. are considered orthogonal
-: issues as it relates to this package and are therefore
-: beyond the scope of this effort.
-:
-- Note
: No declarations or definitions shall be included in,
-: or excluded from this package. The "package declaration"
-: defines the types, subtypes and declarations of
-: std_logic_1164. The std_logic_1164 package body shall be
-: considered the formal definition of the semantics of
-: this package. Tool developers may choose to implement
-: the package body in the most efficient manner available
-: to them.
-:
-- --------------------------------------------------------------------- modification history :
-- --------------------------------------------------------------------- version | mod. date:|
-- v4.200 | 01/02/92 |
-- -------------------------------------------------------------------PACKAGE std_logic_1164 IS
-------------------------------------------------------------------- logic state system (unresolved)
-------------------------------------------------------------------
165
11 ) Paquetages IEEE
FUNCTION "or" ( l : std_ulogic; r : std_ulogic ) RETURN UX01;
FUNCTION "nor" ( l : std_ulogic; r : std_ulogic ) RETURN UX01;
FUNCTION "xor" ( l : std_ulogic; r : std_ulogic ) RETURN UX01;
function "xnor" ( l : std_ulogic; r : std_ulogic ) return ux01;
FUNCTION "not" ( l : std_ulogic
) RETURN UX01;
-------------------------------------------------------------------- vectorized overloaded logical operators
------------------------------------------------------------------FUNCTION "and" ( l, r : std_logic_vector ) RETURN std_logic_vector;
FUNCTION "and" ( l, r : std_ulogic_vector ) RETURN std_ulogic_vector;
FUNCTION "nand" ( l, r : std_logic_vector ) RETURN std_logic_vector;
FUNCTION "nand" ( l, r : std_ulogic_vector ) RETURN std_ulogic_vector;
FUNCTION "or" ( l, r : std_logic_vector ) RETURN std_logic_vector;
FUNCTION "or" ( l, r : std_ulogic_vector ) RETURN std_ulogic_vector;
FUNCTION "nor" ( l, r : std_logic_vector ) RETURN std_logic_vector;
FUNCTION "nor" ( l, r : std_ulogic_vector ) RETURN std_ulogic_vector;
FUNCTION "xor" ( l, r : std_logic_vector ) RETURN std_logic_vector;
FUNCTION "xor" ( l, r : std_ulogic_vector ) RETURN std_ulogic_vector;
function "xnor" ( l, r : std_logic_vector ) return std_logic_vector;
function "xnor" ( l, r : std_ulogic_vector ) return std_ulogic_vector;
FUNCTION "not" ( l : std_logic_vector ) RETURN std_logic_vector;
FUNCTION "not" ( l : std_ulogic_vector ) RETURN std_ulogic_vector;
166
11 ) Paquetages IEEE
-------------------------------------------------------------------------function "+"(L: UNSIGNED; R: SIGNED) return SIGNED;
--attribute builtin_subprogram of
-- Copyright (c) 1990,1991,1992 by Synopsys , Inc. All rights reserved. -"+"[UNSIGNED, SIGNED return SIGNED]: function is "stdarith_plus_uss";
---- This source file may be used and distributed without restriction -function "+"(L: SIGNED; R: UNSIGNED) return SIGNED;
-- provided that this copyright statement is not removed from the file -attribute builtin_subprogram of
-- and that any derivative work contains this copyright notice.
-"+"[SIGNED, UNSIGNED return SIGNED]: function is "stdarith_plus_sus ";
---- Package name: STD_LOGIC_ARITH
-function "+"(L: UNSIGNED; R: INTEGER) return UNSIGNED;
--attribute builtin_subprogram of
-- Purpose:
-"+"[UNSIGNED, INTEGER return UNSIGNED]: function is "stdarith_plus_uiu";
-- A set of arithemtic, conversion, and comparison functions
--- for SIGNED, UNSIGNED, SMALL_INT, INTEGER,
-- function "+"(L: INTEGER; R: UNSIGNED) return UNSIGNED;
-- STD_ULOGIC, STD_LOGIC, and STD_LOGIC_VECTOR.
attribute
-builtin_subprogram of
--"+"[INTEGER, UNSIGNED return UNSIGNED]: function is "stdarith_plus_iuu";
-------------------------------------------------------------------------function "+"(L: SIGNED; R: INTEGER) return SIGNED;
--------------------------------------------------attribute builtin_subprogram of
-- Attributes added to invoke MTI builtin functions
"+"[SIGNED, INTEGER return SIGNED]: function is "stdarith_plus_sis ";
--------------------------------------------------function "+"(L: INTEGER; R: SIGNED) return SIGNED;
library IEEE;
attribute builtin_subprogram of
use IEEE.std_logic_1164.all;
"+"[INTEGER, SIGNED return SIGNED]: function is "stdarith_plus_iss";
package std_logic_arith is
type UNSIGNED is array (NATURAL range <>) of STD_LOGIC;
type SIGNED is array (NATURAL range <>) of STD_LOGIC;
subtype SMALL_INT is INTEGER range 0 to 1;
attribute builtin_subprogram : string;
167
11 ) Paquetages IEEE
function "+"(L: UNSIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[UNSIGNED, UNSIGNED return STD_LOGIC_VECTOR]: function is "stdarith_plus_uuu";
function "+"(L: SIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[SIGNED, SIGNED return STD_LOGIC_VECTOR]: function is "stdarith_plus_sss";
function "+"(L: UNSIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[UNSIGNED, SIGNED return STD_LOGIC_VECTOR]: function is "stdarith_plus_uss";
function "+"(L: SIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[SIGNED, UNSIGNED return STD_LOGIC_VECTOR]: function is "stdarith_plus_sus ";
function "+"(L: UNSIGNED; R: INTEGER) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[UNSIGNED, INTEGER return STD_LOGIC_VECTOR]: function is "stdarith_plus_uiu";
function "+"(L: INTEGER; R: UNSIGNED) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[INTEGER, UNSIGNED return STD_LOGIC_VECTOR]: function is "stdarith_plus_iuu";
function "+"(L: SIGNED; R: INTEGER) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[SIGNED, INTEGER return STD_LOGIC_VECTOR]: function is "stdarith_plus_sis ";
function "+"(L: INTEGER; R: SIGNED) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[INTEGER, SIGNED return STD_LOGIC_VECTOR]: function is "stdarith_plus_iss";
function "+"(L: UNSIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[UNSIGNED, STD_ULOGIC return STD_LOGIC_VECTOR]: function is "stdarith_plus_uxu";
function "+"(L: STD_ULOGIC; R: UNSIGNED) return STD_LOGIC_VECTOR;
attribute builtin_subprogram of
"+"[STD_ULOGIC, UNSIGNED return STD_LOGIC_VECTOR]: function is "stdarith_plus_xuu";
168