Académique Documents
Professionnel Documents
Culture Documents
Mini-Projet en VHDL Mini-Projet en VHDL
Mini-Projet en VHDL Mini-Projet en VHDL
Mini-projet en VHDL
I. Conception de l’UAL
- Conception du comparateur 4 bits …………………………………………...4
- Conception de l’UAL …………………………………………………………..8
2
Conception d’un mini-calculateur
R0
A 4
CE
UAL
R1
B 4 CE
R2 Res
3
CE
R3
Contrôleur CE
clk
Instructon
8
3
I. Conception de l’Unité arithmétique et logique :
1. Conception du comparateur 4 bits :
a. Table de vérité
Entrées Sorties
A3, B3 A2, B2 A1, B1 A0, B0 A_SUP_B A_INF_B A_EGAL_B
A3>B3 x x x 1 0 0
A3<B3 x x x 0 1 0
A3=B3 A2>B2 x x 1 0 0
A3=B3 A2<B2 x x 0 1 0
A3=B3 A2=B2 A1>B1 x 1 0 0
A3=B3 A2=B2 A1<B1 x 0 1 0
A3=B3 A2=B2 A1=B1 A0>B0 1 0 0
A3=B3 A2=B2 A1=B1 A0<B0 0 1 0
A3=B3 A2=B2 A1=B1 A0=B0 0 0 1
b. Fichier « compar_4b » :
4
c. Fichier « compar_4b_TB » :
5
6
La simulation donne les résultats suivants:
2. Conception de l’UAL :
4
Enntree_A
4 resultat
S_A_SUP_B
S_A_INF_B
S_A_EGAL_B
4 S_OVFL
Enntree_B S_ZERO
3 S_NEG
CodeOP
a. Fichier « Opérations.vhd » :
7
Le champ CodeOp sert à indiquer la nature de l’opération à
réaliser :
b. Fichier « Indications.vhd » :
8
S_NEG : sortie permettant d’indiquer sur le résultat est
négatif.
9
c. Fichier « Unite.vhd » : description complète de l’UAL :
10
force CodeOp 000 0,001 40,010 80,011 120,100 160,101 200,110 240,111 360
run 400
La simulation donne les resultats suivants :
11
12
La simulation donne les résultats suivants :
13
II. Conception des registres :
(Registre de mémorisation : Il s'agit en fait d'un ensemble de bascules
D flip-flop formant un mot binaire de 4 bits)
D
Clock_enable Q
CE
CLR
1. Fichier « Registre.vhd » :
Commentaire : Si CE=1,l’entrée de registre sera recopié dans la sortie ,si non la sortie est un
état inconnu fort
14
2. Fichier « REGISTRE_TB » :
15
16
- La simulation donne les résultats suivants :
18
b. Fichier « MUX1_TB.vhd » :
19
La simulation donne les résultats suivants :
2
a. Fichier « MUX2.vhd »:
Sc2e
s
20
- On tape les lignes de commande suivantes dans la fenêtre transcript :
force S_R0 0000 0,0001 20
force S_R1 0010 0,0011 10
force S_R2 0100 0,0101 15
force S_R3 0111 0,1000 10
force Sc2 00 0,01 5,10 10,11 15
run 20
21
b. Fichier « MUX2_TB » :
22
La simulation donne les résultats suivants :
23
2. Conception de démultiplexeur :
E_R0
Sc3 E_R0 E_R1 E_R2 E_R3
E_R1 00 1 0 0 0
S_UAL DEMUX 01 0 1 0 0
E_R2
1→4 10 0 0 1 0
11 0 0 0 1
E_R3
2
Sc3e
s
a. Fichier « DEMUX.vhd » :
24
b. Fichier « DEMUX_TB » :
25
La simulation donne les résultats suivants :
Sc1
Sc2
Sc3
Instr 8 Contrôleur CE1
CE2
CE3
CE4
Code_OP
Fichier « CONTROL1.vhd » :
26
27
- On tape les lignes de commande dans le transcript :
force Instr 01011111 0,01010000 10,11111010 20,10101010 30,01100110
40,11111111 50,00000000 60
run 70
- La simulation donne les résultats suivants :
28
- Fichier « mini_calcul.vhd » :
29
30
Exercices en VHDL
31
I. Modélisation d’un décodeur 7 segments :
1. Table de vérité :
2. Fichier « dec7seg.vhd »
LIBRARY ieee;
USE ieee.std_logic_1164.all;
entity dec7seg is
port( BCD: in std_logic_vector (3 downto 0);
SEGS: out std_logic_vector(6 downto 0));
end dec7seg;
architecture bhv of dec7seg is
begin
with BCD select
SEGS <= "1111110" when "0000",
"0110000" when "0001",
"1101101" when "0010",
"1111001" when "0011",
"0110011" when "0100",
"1011011" when "0101",
"1011111" when "0110",
"1110000" when "0111",
"1111111" when "1000",
"1111011" when "1001",
"-------" when others;
end bhv;
32
On tape les lignes de commande suivantes dans la fenêtre transcript :
- force bcd 0000 0,0001 20,0010 40,0011 60,0100 80,0101 100,0110 120,0111
140,1000 160,1001 180,1010 200,1011 220
- run 240
La simulation donne les résultats suivants :
library ieee;
use ieee.std_logic_1164.all;
entity dec7seg_TB is
end dec7seg_TB;
33
--case 3
BCD <= "0010";
wait for 2 ns;
assert(SEGS = "1101101")
report "SEGS error!" severity error;
if ( SEGS /= "1101101") then
C:= C +1;
end if;
--case 4
BCD <= "0011";
wait for 2 ns;
assert(SEGS = "1111001")
report "SEGS error!" severity error;
if ( SEGS /= "1111001") then
C:= C +1;
end if;
--case 5
BCD <= "0100";
wait for 2 ns;
assert(SEGS = "0110011")
report "SEGS error!" severity error;
if ( SEGS /= "0110011") then
C:= C +1;
end if;
--case 6
BCD <= "0101";
wait for 2 ns;
assert(SEGS = "1011011")
report "SEGS error!" severity error;
if ( SEGS /= "1011011") then
C:= C +1;
end if;
--case 7
BCD <= "0110";
wait for 2 ns;
assert(SEGS = "1011111")
report "SEGS error!" severity error;
if ( SEGS /= "1011111") then
C:= C +1;
end if;
--case 8
BCD <= "0111";
wait for 2 ns;
assert(SEGS = "1110000")
report "SEGS error!" severity error;
if ( SEGS /= "1110000") then
C:= C +1;
end if;
--case 9
BCD <= "1000";
wait for 2 ns;
assert(SEGS = "1111111")
report "SEGS error!" severity error;
if ( SEGS /= "1111111") then
34
C:= C +1;
end if;
--case 10
BCD <= "1001";
wait for 2 ns;
assert(SEGS = "1111011")
report "SEGS error!" severity error;
if ( SEGS /= "1111011") then
C:= C +1;
End if;
-- lorsque l'entree BCD dépasse 9
--case 11
BCD <= "1010";
wait for 2 ns;
assert(SEGS = "-------")
report "SEGS error!" severity error;
if ( SEGS /= "-------") then
C:= C +1;
end if;
--case 12
BCD <= "1011";
wait for 2 ns;
assert(SEGS = "-------")
report "SEGS error!" severity error;
if ( SEGS /= "-------") then
C:= C +1;
end if;
--case 13
BCD <= "1100";
wait for 2 ns;
assert(SEGS = "-------")
report "SEGS error!" severity error;
if ( SEGS /= "-------") then
C:= C +1;
end if;
--case 14
BCD <= "1101";
wait for 2 ns;
assert(SEGS = "-------")
report "SEGS error!" severity error;
if ( SEGS /= "-------") then
C:= C +1;
end if;
--case 15
BCD <= "1110";
wait for 2 ns;
assert(SEGS = "-------")
report "SEGS error!" severity error;
if ( SEGS /= "-------") then
C:= C +1;
end if;
--case 16
BCD <= "1111";
wait for 2 ns;
assert(SEGS = "-------")
report "SEGS error!" severity error;
35
if ( SEGS /= "-------") then
C:= C +1;
end if;
-- summury of test bench
if (C=0) then
assert false
report"Testbench of compara_4b completed successfully!"
severity note;
else
assert true
report " Something wrong,try again"
severity error;
end if;
wait;
end process;
end TB2;
36
II. Modélisation d’un compteur synchrone :
1. Fichier « compteur.vhd » :
37
On change la valeur du N, et on lui donne cette fois la valeur 12 ,( generic(n:
natural := 12);)
Le résultat de la simulation est le suivant :
2. Fichier « compteur_TB.vhd » :
38
Remarque : le testbench est fait pour N = 3
39
III. Modélisation d’une bascule D flip flop:
D
Q
Clk
1. Fichier « bascD.vhd » :
2. Fichier « bascD_TB.vhd » :
40
Simulation :
J
Q
CLK JK
Qbar
K
reset
1. Fichier « JK.vhd » :
41
- On tape les lignes de commande suivante dans le transcript :
Force clk 1 0, 0 {50 ns} -r 100
force reset 1 0,0 20
force j 0 0,1 110
force k 0 0,1 40,0 110,1 210
run 300
- La simulation donne les résultats suivants :
2. Fichier « JK_TB.vhd » :
42
43
44
Simulation :
45