Académique Documents
Professionnel Documents
Culture Documents
Cours VHDL
Cours VHDL
http://www.unilim.fr/pages_perso/vahid/
Notation
– Exam théorique
– Evaluation TP
– Exam pratique
Formation VHDL Vahid MEGHDADI
1
Introduction aux
conceptions
numériques
Une partie de ce cours a été emprunté de DSPedia développé par Dr. Bob Stewart à steepest ascent, Glasgow. 2
Chapitre : Introduction
PLD : Programmable Logic Device, CPLD : Complex PLD, PAL: Programmable Array Logic, GAL: Generic Array Logic,
FPGA : Field Programmable Gate Array, ASIC : application-specific integrated circuit
Formation VHDL Introduction Vahid MEGHDADI
3
Circuit avec des éléments discrets
•Circuit figé
•Circuit imprimé difficile à
modifier
•Intégration limitée
•Coût élevé
•Justifié pour de petits
circuits
4
Circuit à fonctionnement programmable
5
Circuit à architecture programmable
6
Les ASIC
7
ASIC ou FPGA ?
ASICs FPGAs
High performance
8
Evolution : Méthodes de CAO
Conception logique
Synthèse comportemental
Formation VHDL Introduction Vahid MEGHDADI
9
Démonstrateurs
10
Exemple
Connecteur
d’extension
VGA
11
Logique (FPGA) ou software (µP et DSP) ?
• Vitesse
• Possibilité de parallélisme (calcul dans l’espace ou dans le temps)
• Exemple y=Ax²+Bx+C
DSP FPGA
12
Intérêt de la logique par rapport à µP
13
Architecture des FPGA
Feild Programmable Gate Array
14
FPGA architecture interne
Clock
Programmable Programmable
IO Logic (CLB)
BLE
#1
N
N
I Outputs
I
Inputs BLE
#N
Clock
Programmable
Routing
15
Architecture simplifiée de CLB
Inputs Look-Up
Out
Table
(LUT)
Out = f (in0, in1, in2, in3)
State
Clock
Enable
16
FPGA Xilinx
17
Remarque
Spartan (depuis 1998)
18
Remarque
Spartan II
Ajout de la RAM
19
Remarque
La famille Spartan II
20
Remarque
Spartan 3
21
Remarque
La famille Virtex
•Plus de I/O
•DSP slices
22
Remarque
La famille Virtex
23
Remarque
La famille Virtex-II pro
24
Remarque
Virtex 5 et le LUT
25
Remarque
Virtex 5 et les blocs DSP
26
Remarque
Série 7 (depuis 2010)
27
Outil de développement
28
Conception circuit
29
Design flow
Netlist
Map
o which is then mapped to the FPGA technology,
Place o the inferred components are placed on the chip,
Route o and the connecting signals are routed through the
interconnection network.
Bitstream
30
Synthèse HDL
HDL
(VHDL / process(clk, reset)
Verilog)
begin
if reset = ‚1‘ then
Synthesize output <= ‚0‘;
elsif rising_edge(clk) then
output <= a XOR b;
Netlist end if;
end process;
Map
Place Register
a
Route ⊕ D Q output
b
clk
clear
Bitstream
reset
Formation VHDL Introduction Vahid MEGHDADI
31
Technology Mapping
Register
HDL
a
(VHDL / ⊕ D Q output
Verilog) b
clk
clear
Synthesize
reset
Netlist
Map
Place
Route
Bitstream
32
Placement & Routage
HDL
(VHDL /
Verilog)
Synthesize
Netlist
Map
Place
Route
Bitstream
33
Système embarqué traditionnel
Power Supply
Ethernet Audio CLK
CLK
MAC Codec
GP I/O Interrupt
Controller
Timer
Address
Decode
Unit
CPU UART
L
(uP / DSP) Co- C
Memory Proc. custom
CLK Controller IF-logic
Images by H.Walder
Formation VHDL Introduction Vahid MEGHDADI
34
Système embarqué traditionnel
Power Supply
Ethernet Audio CLK
CLK
MAC FPGA Codec
GP I/O Interrupt
Controller
Timer
Address
Decode
Unit
CPU UART
L
(uP / DSP) Co- C
Memory Proc. custom
CLK Controller IF-logic
Images by H.Walder
Formation VHDL Introduction Vahid MEGHDADI
35
System on Chip Configurable (CSoC)
Audio
Codec EPROM
Power Supply
L
C
36
Avantages
37
Chapitre : Introduction A VHDL
Introduction au langage
VHDL
38
VHDL
V VHSIC
(Very High Speed Integradted Circuit)
H Hardware
D Description
L Language
39
Remarque
Un peu d’histoire
40
Qu’est ce que on attend de VHDL
41
Qu’est ce que on attend des outils de synthèse
42
Niveau d’abstraction
Synthèse Comportemental
comportemental
RTL VHDL
Synthèse
logique
Logique
Placement
routage
Layout
43
Chapitre : Structure du VHDL
44
Minimum design en VHDL
Déclaration d’entité
Architecture
45
Exemple simple: entité
entity AOI is
Port(
A,B,C,D: in std_logic; AOI
F : out std_logic);
end AOI;
46
Entité décortiquée
ENTITY nand_gate IS
PORT(
a : IN STD_LOGIC; No Semicolon
b : IN STD_LOGIC; after last port
z : OUT STD_LOGIC
);
END nand_gate;
Reserved words
Port modes (data flow directions)
47
Remarque
48
Exemple simple: architecture
architecture v1 of AOI is
-- les déclarations
begin
F <= not((A and B) or (C and D));
end v1;
49
Remarque
50
Exemple simple: architecture bis
architecture v2 of AOIis
signal I1,I2,I3: std_logic;
begin
I1, I2 et I3 sont des
I1 <= A and B;
I2 <= C and D; signaux internes.
I3 <= I1 or I2;
F <= not I3;
end v2;
51
Principe de concurrence
architecture v3 of AOI is
signal I1,I2,I3: std_logic;
begin
I1 <= A and B;
I2 <= C and D;
I3 <= I1 or I2;
F <= not I3;
end v3;
Tous les mêmes !
architecture v2 of AOI is architecture v4 of AOI is
signal I1,I2,I3: std_logic; signal I1,I2,I3: std_logic;
begin begin
I1 <= A and B; F <= not I3;
F <= not I3; I3 <= I1 or I2;
I2 <= C and D; I2 <= C and D;
I3 <= I1 or I2; I1 <= A and B;
end v2; end v4;
52
Remarque
53
Décrire des délais
Dans des circuits réels, les portes logiques présentent des délais.
54
Délai dans les affectations
55
TRES IMPORTANT
56
Résultat obtenu en simulation
57
Exemple
A SUM
Demi-
additionneur
B C
A SUM
A B SUM C
B 0 0 0 0
C 0 1 1 0
1 0 1 0
1 1 0 1
58
Programme VHDL correspondant
entity DEMI_ADD is
port (A,B: in std_logic;
SUM,C: out std_logic);
end DEMI_ADD;
59
Hiérarchisation en VHDL
60
Hiérarchie in VHDL
61
Exemple : multiplexeur 2 voies
62
Déclaration de component
Déclaration du component
63
Déclaration de signaux
64
Instanciation du component
Instanciation du component
65
Instructions Concurrentes / séquentielles
66
Instructions concurrentes ou séquentielles
67
Exemple
A
B I S
C
68
Instruction concurrente conditionnelle
69
Instruction concurrente sélective
70
Remarque
L’affectation sélective produit très souvent un circuit plus simple (par rapport à l’affectation
conditionnelle) parce qu’il n’y a pas de priorité dans différentes branches. De plus, la
condition est à tester sur un seul objet.
Exemple
71
Exemple instruction « with-select »
Codeur sept-segment
72
Remarque
Exemple ALU
entity ADDER is
port (A,B :in std_logic_vector(7 downto 0);
SEL : in std_logic;
S : out std_logic_vector(7 downto 0));
end ADDER;
architecture COMPORT of ADDER is
Begin
with SEL select
S <= A+B when '0',
A-B when others;
-- ou on peut utiliser when-else
-- S <= A+B when SEL=‘0’ else A-B;
end COMPORT;
73
Process
74
Process
75
Syntaxe de process
•Syntaxe de process :
label : -- optionnel
process (liste de sensibilité)
{partie déclarative}
begin
suite d’instructions séquentielles
end process;
•Notion très importante : Un process s'exécute (se
réveille) quand un des signaux de la liste de sensibilité
change de valeur.
•Un fois on arrive à la fin du process, celui-ci rendort jusqu’à
l’arrivée d’un évènement sur un des signaux de sa liste de
sensibilité,
76
Instructions séquentielles
77
Instructions wait
•Wait
• wait on signal;
•wait on A , B
Formation VHDL Process Vahid MEGHDADI
78
Remarque
79
Instructions conditionnelle
if condition then
sequential statements
[elsif condition then
sequential statements ]
[elsif condition then
sequential statements ]
[else
sequential statements ]
end if;
80
Instruction sélective
case EXPRESSION is
when VAL1 => suite d’instructions séquentielles
when VAL2|VAL3|VAL4 => suite d’instr séquentielles
when VAL5 to VAL7 => suite d’instr séquentielles
when others => suite d’instr séquentielles
end case;
81
Remarque
Exemple
Multiplexeur 4 voies
S1 S0
A
M
B Z
U
C X
4
D
82
Remarque
Exemple (avec if)
entity MUX_4 is
port (S1, S0, A, B, C, D: in std_logic;
Z: out std_logic);
end MUX_4;
end behav_MUX_4;
83
Remarque
Exemple (avec case)
entity MUX_4 is
port ( S : in std_logic_vector(1 downto 0);
A, B, C, D: in std_logic; Z: out std_logic );
end MUX_4;
end behav_MUX_4;
Formation VHDL Process Vahid MEGHDADI
84
Affectation séquentielle
85
Remarque
Attention !
Le process ci-dessous ne
produira pas le signal ci-
contre
SIG
Process (x)
begin
SIG <= '0';
SIG <= '1'; SIG
SIG <= '0';
end process;
86
Circuits séquentiels
87
process combinatoire
88
Exemple: Verrou ou Latch
Bascule à verrouillage
entity L is
port (D,EN : in std_logic;
Q : out std_logic);
end L;
architecture A of L is architecture A of L is
Ce qu’on préfère !
begin begin
process process (D,EN)
begin begin
wait on D,EN; if EN='1' then
if EN='1' then Q <= D; Q <= D;
end if; end if;
end process; end process;
end A; end A;
Formation VHDL Circuits séquentiels Vahid MEGHDADI
89
Registre (latch synchrone)
process (CLK)
begin D
if CLK'event and CLK='1' then Q
Q <= D; CLK
end if
end process; Bascule D
process (CLK) 8
begin D 8
if rising_edge(CLK) then Q
Q <= D; CLK
end if
Registre de taille 8 dépendant
end process; du type de Q et D
90
Registre avec SET ou RESET
entity R is
port (D,CLK,SET: in std_logic;
Q: out std_logic);
end R;
architecture A of R is
architecture A of R is
begin -- set synchrone
begin -- set asynchrone
process (CLK)
process (SET,CLK)
begin
begin
if CLK'event and CLK='1' then
if SET = '1' then Q <= '1';
if SET = '1' then Q <= '1';
elsif CLK'event and CLK='1'
else Q <= D;
then Q <= D;
end if;
end if;
end if;
end process;
end process;
end A;
end A;
Formation VHDL Circuits séquentiels Vahid MEGHDADI
91
Exemple : compteur
process(CLK)
begin
if CLK’event and CLK=‘1’ then
cmp <= cmp+1;
end if;
end process;
92
Exemple
process(CLK)
begin
if CLK’event and CLK=‘1’ then
trig <= ‘0’; cmp <= cmp + 1;
if cmp = ? Then
cmp <= 0; trig <= ‘1’;
end if;
end if;
end process;
Formation VHDL Vahid MEGHDADI
93
Objets en VHDL
94
Objets en VHDL
95
Constants
Exemple:
C’est une
valeur explicite
96
Variable
Initialisation
optionnelle
• Les variables sont utilisées uniquement dans les process.
• Elles sont déclarées dans le process avant le mot clé « begin » (c’est
le begin du process).
• Contrairement aux signaux, les variables sont affectées tout de suite,
on n’a pas besoin d’attendre la suspension du process.
• Affectation se fait par ":=" et non pas par "<=" :
• current_bit := not current_bit;
Formation VHDL Vahid MEGHDADI
97
Signal
98
Signaux et variables
99
Remarque
Variables:
- Peuvent être utilisées dans le process où ils sont déclarées
- Ne peuvent pas apparaitre dans la liste des sensibilités
- Ne peuvent pas être retardées
- affectation immédiate
Signaux
- Peuvent être utilisés pour relier des process
- Peuvent apparaitre dans la liste des sensibilités des process
- Peuvent être retardés
100
Types en VHDL
101
Types en VHDL
4 catégories de types
- Type scalaire : integer, reals, physique, énuméré
- Type composite: array, records
- Type accès: comme des pointeurs
- Type File
Formation VHDL Vahid MEGHDADI
102
Type scalaire
•énuméré
type T_FEU is (ROUGE, ORANGE, VERT);
signal FEU : T_FEU;
•entier
signal COMPT : integer range 0 to 15;
•flottante
signal MASSE : REAL; -- de -1e38 à 1e38
103
Remarque
104
Type énuméré
105
Type entier (scalaire)
106
Logique à valeurs multiples (scalaire)
107
Le type std_logic
‘L’
VDD
Le type std_logic : ‘0’
‘U’ non initialisé
‘X’ non connu ‘H’ ‘1’
‘0’ logique 0 Strong drive
‘1’ logique 1
‘Z’ haute impédance
‘W’ non connu
‘L’ logique 0 weak drive
‘H’ logique 1
‘-’ don’t care ‘0’
108
Haute impédance un type résolu
109
Type composite
110
Accès aux éléments
•Déclaration:
A,B: std_logic_vector(15 downto 0);
•Accès direct :
A(3) <= ‘1’;
B(15) <= ‘0’;
111
Accès aux éléments de tableaux
• Par agrégat
• Notation positionnelle
A(3 downto 1) <= ('0', '1', B(15));
B <= ('1','1',others => '0');
• Par concaténation
signal A,B,C,D : std_logic;
signal BYTE : std_logic_vector(7 downto 0);
signal Z_BUS,A_BUS : std_logic_vector(3 downto 0);
Z_BUS <= A & C & D & B;
BYTE <= Z_BUS & A_BUS;
112
Remarque
Exemples
SIGNAL a: STD_LOGIC;
SIGNAL b: STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL c: STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL d: STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL e: STD_LOGIC_VECTOR(15 DOWNTO 0);
SIGNAL f: STD_LOGIC_VECTOR(8 DOWNTO 0);
……….
a <= ‘1’;
b <= ”0000”; -- Base Binaire par défaut
c <= B”0000”; -- Base Binaire explicite
d <= ”0110_0111”; -- Utiliser ‘_’ pour augmenter la lisibilité
e <= X”AF67”; -- Base Hexadecimale
f <= O”723”; -- Base Octale
113
Remarque
Exemples
114
Déclaration d’un objet de type array
115
Enregistrement (record)
type PAQUET is
record
mot_unique : std_logic_vector (7 downto 0);
data : std_logic_vector (23 downto 0);
CRC : std_logic_vector( 5 downto 0);
num : integer range 0 to 1023;
end record;
signal paq_rec : PAQUET;
paq_rec.CRC <= "111000";
Formation VHDL Types en VHDL Vahid MEGHDADI
116
Opérateurs en VHDL
117
Les opérateurs
118
Circuits combinatoires
119
Process combinatoire
120
Circuits combinatoires : équation logique
121
Exemple
122
Affectation conditionnelle
end if;
end process;
end AVEC_IF;
123
Affectation sélective séquentielle
124
Remarque
Affectation sélective concurrente
125
Remarque
Affectation non conditionnelle
126
Remarque
Affectation conditionnelle concurrente
127
Remarque
Exemple : ALU
entity ALU is
port(A : in std_logic_vector(7 downto 0);
B : in std_logic_vector(7 downto 0);
Sel: in std_logic_vector(1 downto 0);
Res: out std_logic_vector(7 downto 0));
end ALU;
-- Sel="00" => Addition
-- Sel="01" => Soustraction
-- Sel="00" => et logique bit à bit
-- Sel="00" => ou logique bit à bit
architecture behv of ALU is
begin
process(A,B,Sel)
….
end process;
end behv;
128
Remarque
Exemple : ALU (suite)
process(A,B,Sel)
begin
case Sel is
when "00" =>
Res <= A + B;
when "01" =>
Res <= A + (not B) + 1; -- ou A - B
when "10" =>
Res <= A and B;
when "11" =>
Res <= A or B;
when others =>
Res <= "--";
end case;
end process;
129
Remarque
Exemple : Multiplieur
+0100 1000
res(1) (4 downto 1) 5
----------
0111 0101 res(2) (4 downto 1)
res(7 downto 3)
130
Remarque
Exemple : Multiplieur (suite)
entity main is
Port ( A : in std_logic_vector(3 downto 0);
B : in std_logic_vector(3 downto 0);
RES : out std_logic_vector(7 downto 0));
end main;
131
Chapitre : Machine à états finis
•L’état interne est préservé dans des registres (bascules). Une machine à
états comporte au moins log bascules.
•Machine de Mealy : les sorties dépendent de l’état courant mais aussi des
entrées
132
Présentation graphique
E1E2= "1-"
Formation VHDL Vahid MEGHDADI
133
Séparation des logiques
134
Implantation par un seul process
État courant
type T_ETAT is (E1, E2, E3);
signal etat : T_ETAT;
... Logique D Q
Process(CLK) ENTREE combinatoire CLK
begin CLK Registre
if CLK'event and CLK='1‘ then
d’états
case etat is
when E1 => -- mise à jour des sorties pour état E1
if <cond> then ETAT <= E3; end if;
when E2 => -- mise à jour des sorties pour état E2 • Process n’est pas
ETAT <= E3 combinatoire
when E3 => -- mise à jour des sorties pour état E3
if <cond> then ETAT <= E1; • Très simple à écrire
elsif <cond> then ETAT <= E2;
end if; • Ne convient pas aux
end case; machines complexes
end if;
end process;
135
Implantation par des process séparés (plus robuste)
Moore Mealy
E1
Fonction
combin- S1
atoire
E2
S2
F
Fonction
combin-
ETAT_COUR
atoire ETAT_FUTUR Registre
d'états
G H
RAZ
136
Programmation logique séparée
137
Programmation de la partie combinatoire G
138
Programmation de la partie combinatoire F
139
Remarque
Rappels généraux (1)
140
Remarque
Rappels généraux (2)
141
Remarque
Exemple de la partie combinatoire F
142
Remarque
Exemple écran VGA
CLK HS
fclk=25MHz
143
Remarque
Ecran VGA: Conception RTL
144
Remarque
Ecran VGA Programme VHDL
FSM: process(etat_cour, count) when others => type t_etat is (PW, BP, DISP, FP);
begin if count = 0 then
case etat_cour is signal etat_cour, etat_futur : t_etat:=PW;
etat_futur <= PW;
when PW => else
if count = 96 then etat_futur <= FP;
etat_futur <= BP; end if;
else end case;
etat_futur <= PW; end process;
end if;
when BP =>
if count = 144 then
etat_futur <= DISP;
else
etat_futur <= BP;
end if;
when DISP =>
if count = 784 then
etat_futur <= FP;
else
etat_futur <= DISP;
end if;
145
Techniques de programmation
146
Utilisation de « Clock Enable »
E
S
• Tous les évènements sont
EN
synchronisés sur le front (montant) de
l’horloge. CLK
147
Periodic Clock Enable Generation
CLK T=10 ns
EN1 T=80 ns
EN2 T=210 ns
process (CLK)
begin
if rising_edge(CLK) then
EN1 <= ‘0’; EN2<=‘0’;
EN1 cmp1 <= cmp1 + 1;cmp2 <= cmp2 + 1;
CLK Timing if cmp1 = 7 then EN1 <= ‘1’;
generator EN2 cmp1 <= 0;
end if;
if cmp2 = 20 then EN2 <= ‘1’;
cmp2 <= 0;
end if;
end if;
end process;
Enable usage
CLK T=10 ns
EN T=80 ns
To execute some lines at EN rate, use general CLK in conjunction with EN.
process (CLK)
begin
CLK if rising_edge(CLK) then
A process if EN = ‘1’ then
EN repeated every --
80 ns -- write the code here
--
end if;
end if;
end process;
Example : Two-digit timer
CLK
CLK Event that should make
2-digit 8 the counter to
CLK Timing en counter en increment.
generator
process (CLK)
process (CLK) Begin
begin
if rising_edge(CLK) then if rising_edge(CLK) then
en <= '0'; if en = '1' then
cmp <= cmp + 1;
if cmp = 999_999 then counter <= counter + 1;
en <= ‘1’; end if;
cmp <= 0; end if;
end if; end process;
end if;
end process;
Example : Traffic light
Create a traffic light with Red: 14 sec, Green: 12 sec, and yellow 2 sec.
0 1 2 13 14 15 25 26 27
process(CLK)
begin
if CLK’event and CLK=‘1’ then
REG <= REG(0) & REG(7 downto 1); -- rotate right
REG <= ‘0’ & REG(7 downto 1); -- shift right logical
REG <= REG(7) & REG(7 downto 1);
end if;
end process
154
Exemple 4, affichage multiplexé
155
Préparation de l’horloge
156
Machine à états
157
Circuit complet
158
Remarque
Exemple 7- CNA AD5541A
159
Remarque
Exemple 7- AD5541A Timing Diagram
Génération de LDAC
160
Remarque
Exemple 7- AD5541A contraintes de Timing
Fclk=25MHz
On fixe à 1/25MHz=40ns
161
Remarque
Exemple 7- Interface CNA
162
Remarque
Exemple 7- Conception
163
Remarque
Exemple 7- Programmation un seul process
164
Remarque
Exemple 7- Conception robuste
165
Remarque
Exemple 7- Programme
process(CLK)
entity AD5541A is begin
Port ( CLK : in STD_LOGIC; if CLK'event and CLK='1' then
DATA : in STD_LOGIC_VECTOR (15 downto 0); if STRB = '1' then
STRB : in STD_LOGIC; reg <= DATA;
CS : out STD_LOGIC; end if;
DIN : out STD_LOGIC; end if;
LDAC : out STD_LOGIC; end process;
SCLK : out STD_LOGIC);
end AD5541A; process(CLK)
begin
architecture Behavioral of AD5541A is if CLK'event and CLK='1' then
type t_etat is (repos, e_cs, envoie, tempo, e_ldac); etat_cour <= etat_futur;
signal etat_cour, etat_futur : t_etat:= repos; end if;
signal count : integer range 0 to 31:=0; end process;
signal raz : std_logic;
signal reg : std_logic_vector(15 downto 0); process(CLK)
Begin begin
if CLK'event and CLK='1' then
SCLK <= not CLK; if raz = '1' then
DIN <= reg(16-count) when etat_cour = envoie else 'Z'; count <= 0;
CS <= '1' when etat_cour = e_CS else '0'; else
LDAC <= '0' when etat_cour=e_ldac else '1'; count <= count + 1;
end if;
end if;
end process;
Formation VHDL Vahid MEGHDADI
166
Remarque
Exemple 7- Programme
167
Remarque
Exemple 7- Résultat de simulation
168
Technique de
programmation
169
Attention !
Architecture x of y is
Begin +1
A <= not A;
CMPT <= CMPT + 1;
REG <= REG (0) & REG(7 downto 1);
…...
end x;
170
Correction
On utilise un process D Q
171
Process synchrones!
172
Les sous-programmes
173
Procédure
174
Fonction
175
Ecriture des sous-programmes
Syntaxe de la déclaration
•procedure <nom> (liste des paramètre);
•function <nom> (liste des paramètre) return type_du_résultat;
176
Déclaration des sous-programmes
Liste_des_paramètre :
{classe_d'objet} PARAM1 :{mode} type{:=valeur_par_défaut}
•class_d'objet : signal, variable, constant
•mode : in, out, inout
Restriction
•pas de paramètres out ou inout dans la déclaration d'une
fonction
•pas de variable transmise à une fonction
•classe d'objet par défaut est "constant" pour les "in" et
"variable" pour les "out" et "inout"
Formation VHDL Les sous-programmes Vahid MEGHDADI
177
Corps de sous-programme
Exemple
function MIN (signal A,B : integer) return integer is
begin
if A < B then return A
else return B
end if;
end MIN;
178
Appel de sous-programme
179
Exemple
-- HEX-to-seven-segment decoder
-- HEX: in STD_LOGIC_VECTOR (3 downto 0);
-- LED: out STD_LOGIC_VECTOR (6 downto 0);
--
-- segment encoding
-- 0
-- ---
-- 5 | | 1
-- --- <- 6
-- 4 | | 2
-- ---
-- 3
180
Programmation concurrente
181
Utilisation de fonction
182
Paquetage
Il donne la possibilité de
•Regrouper des codes communs dans un travail en équipe
•Déclarer des types et des sous-types
•Déclarer des objets (signaux, constants)
•Déclarer des sous-programmes
•Déclarer des alias
183
Syntaxe de Paquetage
Package <nom_de_paquetage> is
<suite de déclarations>
end {<nom_de_paquetage>};
package pak_test is
184
Paquetage de composants
185
Corps de Paquetage
186
Exemple de Corps de Paquetage
end pak_test;
Formation VHDL Paquetage Vahid MEGHDADI
187
Utilisation de paquetage
188
Configuration
189
Choix de l'architecture
190
Exemple de Configuration
191
Exemple de Configuration "à la volée"
192
Les Attributs
193
Alias
Intérêt
•Donne un nom différent (plus lisible) à un objet
•l'ancien nom reste utilisable
Syntaxe
•alias nouveau_nom : type_ou_sous_type is ancien_nom
Exemple
variable V32 : std_logic_vector (0 to 31);
alias P_8 : std_logic_vector (0 to 7) is V32(0 to 7);
alias D_8 : std_logic_vector (0 to 7) is V32(24 to 31);
alias SIGNE : std_logic is V32(0);
...
SIGNE := '1'; -- identique que V32(0) <= ‘1’;
Formation VHDL Alias Vahid MEGHDADI
194
Encodage d'état dans une machine à état
Formation VHDL Encodage d'état dans une machine à état Vahid MEGHDADI
195
Codage one-hot
Remarque:
Ne pas oublier d'initialiser l'état avec un signal RESET
Formation VHDL Encodage d'état dans une machine à état Vahid MEGHDADI
196
for Generate
197
Généricité
Syntaxe :
generic (param1 : type de param1 := valeur par défaut;
param2 : type de param2 := valeur par défaut;
...);
198
Exemple
Porte ET à N entrées :
entity PORTE_ET is
generic(N : integer := 2);
port(ENTREE : in std_logic_vector(1 to N);
SORTIE : out std_logic);
end entity;
…
process (ENTREE)
variable V : std_logic;
begin
V := '1';
for I in 1 to N loop
V := V and ENTREE(I);
end loop;
SORTIE <= V;
end process;
199
Appel d’un bloc paramétrable
component PORTE_ET
generic(N :integer := 2);
port(ENTREES : in std_logic_vector(1 to N);
SORTIE : out std_logic);
end component;
…
architecture A of B is
begin
200
If Generate
end A;
Formation VHDL If generate Vahid MEGHDADI
201
Conseils de synthèse
202
Conseils (2)
203
Conseils (3)
204
Ordre des opérations
A1
A2 ADD
A3 Un circuit plus rapide
A4
Formation VHDL Conseils de synthèse Vahid MEGHDADI
205
"if" ou "case", la différence
206
Circuit résultant
207
Utilisant "case"
208
Circuit résultant
209
Génération des latch
210
Partage des ressources
211
Validation d'horloge
212
Validation d'horloge (suite)
213
Occupation sur le FPGA
CLB CLB
Chaîne de
Spartan-II, Virtex retenue
Spartan-III, Virtex-II
SET
I3 CE
I2 O D Q
I1 RST
I0
LUT
I3 SET
I2 O CE
I1 D Q
I0 RST
214
Registre à décalage
4
Z-1 Z-1 Z-1 Z-1 Z-1 Z-1
215
Utilisation des LUT
Multiplexeur
A SEL1 I3
B SEL2 I2 O
A I1
B I0
SEL1 SEL2
Un seul slice.
Formation VHDL Occupation sur le FPGA Vahid MEGHDADI
216
Additionneur complet
Cout
A I3
B + sum I2 O Cout
I1
Cin
I0
I3
A
Sum=f(A,B,Cin) I2 O Sum
B I1
Cout=g(A,B,Cin) Cin I0
Un slice.
Formation VHDL Occupation sur le FPGA Vahid MEGHDADI
217
Additionneur complet Xilinx
LUT Cout
A
0 1
B Sum
Cin
218
La chaîne de retenu
Connexion rapide
SET
I3 CE
I2 O D Q
I1 RST
I0
LUT
I3 SET
I2 O CE
I1 D Q
I0 RST
219
Addition 8 bits
S8
B7
A7 S7
B6
S6
A6
B5
A5 S5
Il suffit 4 slices pour une B4
S4
A4
addition sur 8 bits
B3 S3
A3
B2 S2
A2
B1
A1 S1
B0
A0 S0
220