Académique Documents
Professionnel Documents
Culture Documents
VHDL
Exercices:
1 Fonctions logiques combinatoires . ................................................3
1.1 Exercice 1 : Décodage d’adresses . ..............................................3
1.2 Exercice 2 : Multiplexeur . .....................................................5
1.3 Exercice 3 : Décodeur Hexadécimal / 7 segments . ................................7
1.4 Exercice 4 : Démultiplexeur 1→ 8 . ..............................................9
2
Introduction au langage VHDL
/libre =
/I_O =
/RAM =
entity Decod_Add is
end flot_Decod_Add;
3
Introduction au langage VHDL
entity Decod_Add1 is
port(
BusAdd: in std_logic_vector (15 downto 13) ;
ROM1: out std_logic );
end Decod_Add1 ;
Exemple: B &
A
C <= B when A=’1’ ; ≥1 C
est interprété comme signifiant :
&
C <= B when A=’1’ else C;
Si le but est d’exprimer « C prend la valeur de B quand A = ‘1’, sinon n’importe quoi » il
faut écrire :
4
Introduction au langage VHDL
S = -------------------------------------------
entity mux4_1 is
end mux4_1
end comporte_mux4_1;
5
Introduction au langage VHDL
entity mux4_1 is
end mux4_1 ;
begin begin
6
Introduction au langage VHDL
"0" a "1" a
Caractères à afficher
MSB q3 a
Décodeur b
q2 c
Hexadécimal d
q1 / e
f
7 segments g
LSB q0
Fonctionnement attendu
Les entrées q3, q2, q1 et q0 peuvent prendre l'état logique « 0 » ou « 1 ».
Pour chacune des combinaisons possibles du mot binaire Q = q3q2q1q0, on doit
afficher le caractère hexadécimal correspondant.
7
Introduction au langage VHDL
q3 q2 q1 q0 a b c d e f g Affichage
0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 1 1 0 0 1 1 1 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
1 0 0 0 8
1 0 0 1 9
1 0 1 0 A
1 0 1 1 b
1 1 0 0 c
1 1 0 1 d
1 1 1 0 E
1 1 1 1 F
a /q1./q0 /q1.q0 q1.q0 q1./q0
/q3./q2
a = ------------------------------------------------------ /q3.q2
q3.q2
q3./q2
begin
end Hex7seg;
8
Introduction au langage VHDL
→ 8
1.4 Exercice 4 : Démultiplexeur 1→
→ 8 ci-dessous.
Ecrire le fichier .VHD correspondant au démultiplexeur 1→
S0
S1
I
S6
S7
3
SEL
end Demux1_8;
end Demux1_8;
begin
9
Introduction au langage VHDL
OE
8 8
D_OUT
D_IN
begin
end comporte_Buff_3;
end Buff_Trois_Etat ;
OEAB
8 8 D_OUT
D_IN
OEBA
begin
end comporte_Trans;
end Transceiver;
10
Introduction au langage VHDL
8
D 8
Q
LE
begin
11
Introduction au langage VHDL
8 Fonctionnement
D 8
Q Q <= D si ↑CLK
CLK
begin
end comporte_Reg;
end Reg;
clk
rst
12
Introduction au langage VHDL
Remarque: Etant asynchrone, le signal rst peut déclencher le processus. Il doit donc
se situer dans la liste de sensibilité.
set
8
8
D Q
clk
begin
end RegSync;
end comporteRegSync;
13
Introduction au langage VHDL
CPTR 8
Q
clk
rst
begin
end Reg_Sync;
end comporteCPTR;
8
CMPL 8
D
Q
clk
load
rst
begin
end CMPL;
end comporteCMPL;
Remarque: Le type unsigned est associé à des vecteurs de bits considérés comme
représentant des nombres non signés.
14
Introduction au langage VHDL
module testcptl
// input
clk, rst, load pin;
D_7_,D_6_,D_5_,D_4_,D_3_,D_2_,D_1_,D_0_ pin ;
// output
Q_7_,Q_6_,Q_5_,Q_4_,Q_3_,Q_2_,Q_1_,Q_0_ pin istype 'reg_d,buffer';
// Vectors
Q = [Q_7_,Q_6_,Q_5_,Q_4_,Q_3_,Q_2_,Q_1_,Q_0_];
D = [D_7_,D_6_,D_5_,D_4_,D_3_,D_2_,D_1_,D_0_];
// constantes
c = .c.;
x = .x.;
X = [x,x,x,x,x,x,x,x];
equations
test_vectors
([clk,rst, load, D] -> [Q])
[c,1,0,0] -> [X];
@repeat 5 {[c,0,0,X] -> [X];}
[c,0,1,8] -> [X];
@repeat 20 {[c,0,0,X] -> [X];}
end
Simulation fonctionnelle
15
Introduction au langage VHDL
UP DOWN___Comportement_______
load 0 0 Rien
1 0 compte
rst 0 1 décompte
1 1 Rien
down
up
begin
end CMP_DEC;
end comporte_CMP_DEC;
module testcpde
// input
clk, rst, load,up,down pin;
D_7_,D_6_,D_5_,D_4_,D_3_,D_2_,D_1_,D_0_ pin ;
// output
Q_7_,Q_6_,Q_5_,Q_4_,Q_3_,Q_2_,Q_1_,Q_0_ pin istype 'reg_d,buffer';
// Vectors
Q = [Q_7_,Q_6_,Q_5_,Q_4_,Q_3_,Q_2_,Q_1_,Q_0_];
D = [D_7_,D_6_,D_5_,D_4_,D_3_,D_2_,D_1_,D_0_];
// constantes
c = .c.;
x = .x.;
X = [x,x,x,x,x,x,x,x];
equations
test_vectors
([clk,rst,load,up,down,D] -> [Q])
[c,1,0,0,0,0] -> [X];
@repeat 10 {[c,0,0,1,0,X] -> [X];}
[c,0,1,0,0,20] -> [X];
@repeat 10 {[c,0,0,0,1,X] -> [X];}
end
16
Introduction au langage VHDL
« Fichier .vhd »
Simulation fonctionnelle