Академический Документы
Профессиональный Документы
Культура Документы
Département d’Elécronique
Module : VHDL-FPGA
Préparer par :
Lamri yasmine
EXERCICES PLD-FPGA
26/09/2020
Le 15/05/2020
Chapitre 1 et 2
I. EXERCICE N°1
le schéma d’un PLA (Programmable Logic Array) à 3 entrées A , B , C et deux sorties X et Y permettant
de réaliser les fonctions suivantes : A B C
Compte Microsoft
[Nom de la société]
[Date]
X Y
X Y
2
III. EXERCICE N°3
le schéma d’un PLA (Programmable Logic Array) à 3 entrées A , B , C et deux sorties X et Y permettant
de réaliser les fonctions suivantes : A B C
X Y
1. Les PAL
3
Ce sont les circuits logiques programmables les plus anciens. Les PAL sont
programmés par destruction de fusibles. Ils ne sont donc programmables
qu’une fois, ce qui peut être gênant en phase de développement. Un PAL
permet de remplacer jusqu’à 10 boîtiers SSI ou 2 à 3 boîtiers MSI.
2. Les GAL
Historiquement, les premiers EPLD étaient des GAL effaçables aux U.V. Il
existe maintenant des EPLD effaçables électriquement.
Les pLSI et ispLSI de LATTICE sont à mi-chemin entre les EPLD et les FPGA.
4.Les FPGA
V. EXERCICE N°5
Les technologies à fusibles :
- Son principe est d’appliquer une tension de 12 à 25v (tension de claquage) aux bornes du fusible.
5
PLD : programmable logic device.
SPLD : Simple programmable logic device.
CPLD : complexe programmable logic device.
FPGA : field programmable gate array.
PROR : programmable read only memory.
PAL : programme array logic.
PLA : programme logic array.
6
les équations logiques des sorties S0, S1,S2 et S3 en fonction des entrées A,B,C et D du circuit PAL :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo1_a is
7
7 port( A,B,C :in std_logic ;
8 S : out std_logic );
9
10 end exo1_a ;
11 - - Description comportementale
12 architecteure flot_de_données of exo1_a is
13 begin
14 S <= (A and not (B)) or (B and not (C));
15 end flot de données ;
la table de vérité :
8
11 - - Description comportementale
12 architecteure comp_ sans_ process of exo1_b1 is
13 begin
14 S <= ‘1’when(A=’1’and B=’0’) or (B=’1’and C=’0’)
15 else ’0’ ;
16 end comp_ sans_ process ;
9
14 process (A B C)
15 begin
16 case A B C is
17 when “000”=> S <=’0’ ;
18 when “001”=> S <=’0’ ;
19 when “010”=> S <=’1’ ;
20 when “011”=> S <=’0’ ;
21 when “100”=> S <=’1’ ;
22 when “101”=> S <=’1’ ;
23 when “110”=> S <=’1’ ;
24 when others=> S <=’0’ ;
25 end case ;
26 end process ;
27 end comp_ avec_ process ;
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
10
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo2_a is
7 port( A,B,C :in std_logic ;
8 S : out std_logic );
9
10 end exo2_a ;
11 - - Description comportementale
12 architecteure flot de données of exo2_a is
13 begin
14 S <= (A xor B) xor (B xor C);
15 end flot de données ;
la table de vérité :
A B C A xor B B xor C S
0 0 0 0 0 0
0 0 1 0 1 1
0 1 0 1 1 0
0 1 1 1 0 1
1 0 0 1 0 1
1 0 1 1 1 0
1 1 0 0 1 1
1 1 1 0 0 0
S= Á B́C+ Á BC +A B́ Ć +ABĆ = Á C(B+ B́)+AĆ (B+ B́)
B+ B́=1 donc
S= Á C+AĆ =A⨁ C
Le programme
CODE : VHDL
11
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo2_b1 is
7 port( A,B,C :in std_logic ;
8 S : out std_logic );
9
10 end exo2_b1 ;
11 - - Description comportementale
12 architecteure comp_ sans_ process of exo2_b1 is
13 begin
14 S <= ‘1’when(A=’0’and C=’1’) or (A=’1’and C=’0’)
15 else ’0’ ;
16 end comp_ sans_ process ;
12
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo2_c1 is
7 port( A,B,C :in std_logic_vector ( 2 downto 0 );
8 S : out std_logic );
9
10 end exo2_c1 ;
11 - - Description comportementale
12 architecteure comp_ avec_ process of exo2_c1 is
13 begin
14 process (A B C)
15 begin
16 case A B C is
17 when “000”=> S <=’0’ ;
18 when “001”=> S <=’1’ ;
19 when “010”=> S <=’0’ ;
20 when “011”=> S <=’1’ ;
21 when “100”=> S <=’1’ ;
22 when “101”=> S <=’0’ ;
23 when “110”=> S <=’1’ ;
24 when others=> S <=’0’ ;
25 end case ;
26 end process ;
27 end comp_ avec_ process ;
sum= a + b si sel= 0
sum = c + d si sel = 1
Le programme
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4 Use ieee.std_logic_unsigned.all ;
5
6 - - Description externe
7 entity exo3 is
8 port( a,b,c,d :in std_logic_vector ( 7 downto 0 ) ;
9 sel :in std_logic ;
10 sum: out std_logic_vector ( 7 downto 0 ) ) ;
11
12 end exo3 ;
13 - - Description comportementale
14 architecteure comportementale of exo3 is
15 signal S1,S2: std_logic_vector ( 7 downto 0 ) ;
16 begin
17 process (a,b,c,d,sel)
18 begin
19 if SEl ='0' then
20 S1<=a ;
21 S2<=b ;
22 else
23 S1<=c ;
24 S2<=d ;
25 end if ;
26 end process ;
27 sum<=S1=S2 ;
28 end comportementale ;
14
IV. EXERCICE N°4
la description VHDL(description comportementale) d’un décodeur trois entrées et huit sorties :
Le programme :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity decodeur_3V8 is
7 port(E :in std_logic_vector ( 2 downto 0 ) ;
8 S: out std_logic_vector ( 7 downto 0 ) ) ;
9
10 End decodeur_3V8 ;
11 - - Description comportementale
12 architecteure comportementale of decodeur_3V8 is
13 begin
14 process (E)
15 begin
16 case E is
17 when “000”=> S <=”00000001” ;
18 when “001”=> S <=”00000010” ;
19 when “010”=> S <=”00000100” ;
20 when “011”=> S <=”00001000” ;
21 when “100”=> S <=”00010000” ;
22 when “101”=> S <=”00100000” ;
23 when “110”=> S <=”01000000” ;
24 when others=> S <=”10000000” ;
end case ;
15
25 end process ;
26 end comportementale ;
27
V. EXERCICE N°5
le circuit suivant constitué de deux bascules D activant sur le front montant de l’horloge.
Le programme :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo5 is
7 port( E ,CLK :in std_logic ;
8 A , B : out std_logic );
9
10 end exo5 ;
11 - - Description comportementale
12 architecteure description of exo5 is
13
14 signal S1,S2 : std_logic ;
15
16 begin
17 process (CLK)
18 begin
19 if CLK ='1' and CLK'event then
20 -- Ou if rising_edge(clk) then
21
22
16
23 S1<=E ;
24 S2<=S1 ;
25 end if ;
26 end process ;
27 A<=E xor S2 ;
28 B<=S2 xor S1 xor E ;
end description ;
Le programme :
CODE : VHDL
17
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo6 is
7 port( E :in std_logic_ vector ( 7 downto 0 ) ;
8 S : out std_logic_vector ( 2 downto 0 )) ;
9
10 end exo6 ;
11 - - Description comportementale
12 architecteure comp_avec_case of exo6 is
13 begin
14
15 process (E)
16 begin
17 case E is
18 when "00000001"=> S <="000" ;
19 when "00000010"=> S <="001" ;
20 when "00000100"=> S <="010" ;
21 when "00001000"=> S <="011" ;
22 when "00010000"=> S <="100" ;
23 when "00100000"=> S <="101" ;
24 when "01000000"=> S <="110" ;
25 when "10000000"=> S <="111" ;
26 -- Ou when others => S <="111" ;
27 end case ;
28 end process ;
29 end comp_avec_case ;
18
a. Le schéma correspondant (logigramme) :
b. C’est description comportementale car le système est décrit par des équations et des
comportements.
c. Le processus P1 est-il combinatoire car il n’est pas par une horloge et ne contient
pas des bascules.
d. La fonction de ce circuit : Additionneur complet 1 bit. Y=X1+X2+X3 si sel=0 et
Y=Rentenu de X1+X2+X3 si sel=1
19
VIII. EXERCICE N°8
La description VHDL du circuit suivant constitué d’un multiplexeur à deux entrées et d’une bascule D.
Tous les signaux mis en jeu sont du type « standard logique ».
Le programme :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo8 is
7 port( A,B,CLK,SEL :in std_logic ;
8 S1 , S2 : out std_logic );
9
10 end exo8 ;
11 - - Description comportementale
12 architecteure description of exo8 is
13
14 signal SG1,SG2,SG3 : std_logic ;
15
16 begin
17 SG1<=A xor B ;
18 SG2<=A and B ;
19 process (SEL)
20 begin
21 if SEL=’1’ then
22 SG3<=SG1 ;
23 else
24 SG3<=SG2 ;
25 end if ;
26 end process ;
27 process (CLK, SG3)
28 begin
if CLK ='1' and CLK'event then
-- Ou if rising_edge(clk) then
S1<=SG3 ;
S2<=not(SG3) ;
end if ;
20
end process ;
S1<=Q ;
S2<=not Q ;
end description ;
Le programme :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4 Use ieee.numeric_std.all ;
5 use ieee . std_logic_unsigned.all ;
6
- - Description externe
7
8 entity compteur is
port( RESET ,CLK :in std_logic ;
9
10 S : out std_logic_vector ( 4 downto 0 ));
11
12 end compteur ;
- - Description comportementale
13
14 architecteure description of compteur is
15
16 begin
process (RESET,CLK)
17
18 begin
if RESET=’1’ then
19
20 comp<= "00000" ;
elseif comp > 23 then
21
22 comp<="00000" ;
elseif (CLK ='1' and CLK'event ) then
23
24 -- Ou if rising_edge(clk) then
25 comp<= comp+1 ;
26 end if ;
27 end process ;
21
28 A<=comp ;
29 end description ;
X. EXERCICE N°10
XI. EXERCICE N°11
Le programme :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity CLK_gen is
7 port (CLK :in std_logic ;
8 S : out std_logic);
9
10 end CLK_gen ;
11 - - Description comportementale
12 architecteure description of CLK_gen is
13 signal cmp :integer range 0 to 1000000
14 begin
15 process (CLK)
16 begin
17 if (CLK ='1' and CLK'event ) then
18 -- Ou if rising_edge(clk) then
19 cmp<= cmp+1 ;
20 S<=’0’ ;
21 if cmp=999999 then
22 cmp<=0 ;
23 S<=’1’ ;
24 end if ;
25 end if ;
26 end process ;
27 end description ;
22
XII. EXERCICE N°12
a. la description VHDL d’un compteur 3 bits avec remise à zéro(RESET) asynchrone :
Le programme :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4 Use ieee.std_logic_arith.all ;
5 use ieee . std_logic_unsigned.all ;
6
- - Description externe
7
8 entity compteur is
port( RESET ,CLK :in std_logic ;
9
10 q : out std_logic_vector ( 2 downto 0 ));
11
12 end compteur ;
- - Description comportementale
13
14 architecteure description of compteur is
begin
15
16 process (CLK, RESET)
begin
17
18 if RESET=’1’ then
q<= (others=>’0’) ;- - ou q<= "000" ;
19
20 elsif CLK’event and CLK=’1’ then
q<=q+1 ;
21
22 end if ;
end if ;
23
24 end process ;
end description ;
25
23
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4 Use ieee.std_logic_arith.all ;
5 use ieee . std_logic_unsigned.all ;
6
- - Description externe
7
8 entity compteur is
port( RESET ,CLK :in std_logic ;
9
10 q : out std_logic_vector ( 2 downto 0 ));
11
12 end compteur ;
- - Description comportementale
13
14 architecteure description of compteur is
begin
15
16 process (CLK)
begin
17
18 if CLK’event and CLK=’1’ then
if RESET=’1’ then
19
20 q<= (others=>’0’) ;- - ou q<= "000" ;
else
21
22 q<=q+1 ;
end if ;
23
24 end if ;
end process ;
25
26 end description ;
24
Le programme
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4 Use ieee.numeric_std.all ;
5 Use ieee.std_logic_unsigned.all ;
6 - - Description externe
7 entity CMP4BITS is
8 port( LOAD,RESET,CLK :in std_logic ;
9 DATA :in std_logic_vector ( 3 downto 0 ) ;
10 Q : out std_logic_vector ( 3 downto 0 ) ) ;
11
12 end CMP4BITS ;
13 - - Description comportementale
14 architecteure description of CMP4BITS is
15 signal Q: std_logic_vector ( 3 downto 0 ) ;
16 begin
17 process (RESET,CLK)
18 begin
19 if RESET ='1' then
20 Q <=(others=>'0') ; -- Remise à zero asynchrone du compteur
21 elsif (CLK ='1' and CLK'event) then
22 -- Ou elsif (rising_edge(clk)) then
23 if (LOAD ='1') then
24 Q <= DATA ; -- Préchargement synchrone
25 end if ;
26 end if ;
27 end process ;
28 end description ;
Le programme
25
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 - - description de la bascule D
3 library ieee ;
4 use ieee . std_logic_1164.all ;
5 - - Description externe
6 entity FFD is
7 port( DATA_D :in std_logic ;
8 CLK_D :in std_logic ;
9 Q_D : out std_logic ) ;
10
11 end FFD ;
12 - - Description comportementale
13 architecteure description of FFD is
14 signal Sig: std_logic=’0’;
15 begin
16 process (CLK_D)
17 begin
18 if rising_edge(CLK_D) then
19 Sig_D<=DATA_D ;
20 Else
21 Sig_D<=Sig_D ;
22 end if ;
23 end process ;
24 Q_D <=Sig_D;
25 end description ;
26 - - description structurel
27 library ieee ;
28 use ieee . std_logic_1164.all ;
29 - - Description externe
30 entity registre is
31 port( DATA :in std_logic ;
32 CLK :in std_logic ;
33 Q : out std_logic_vector ( 2 downto 0 )) ;
34
35 end registre ;
36 - - Description comportementale
37 architecteure RTL_Registre of component FFD is
38 port(CLK_D :in std_logic ;
39 DATA_D :in std_logic ;
40 Q_D :in std_logic ) ;
41
42 end component FFD ;
43 signal Q0,Q1,Q2 : std_logic ;
44 begin
45 B1 :FFD port map(CLK,DATA,Q0) ;
46 B2 :FFD port map(CLK,DATA,Q1) ;
47 B3 :FFD port map(CLK,DATA,Q2) ;
48
49 end RTL_registre ;
26
b. La description comportementale en VHDL du registre à décalage à droit :
Le programme
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 - - Description comportementale
3 library ieee ;
4 use ieee . std_logic_1164.all ;
5 - - Description externe
6 entity exo14 is
7 port( DATA :in std_logic ;
8 CLK :in std_logic ;
9 Q : out std_logic_vector ( 2 downto 0 )) ;
10
11 end exo14 ;
12 - - Description comportementale
13 architecteure comportementale of exo14 is
14 signal q_reg : std_logic_vector ( 2 downto 0 ):”000”;
15 begin
16 process (CLK)
17 begin
18 if CLK ='1' and CLK'event then
19 -- Ou if rising_edge(clk) then
20 Q_reg<=DATA q_reg( 2 downto 0 );
21 else q_reg<=q_reg ;
22 end if ;
23 end process ;
24 Q<=q_reg ;
25 end comportementale ;
27
XV. EXERCICE N°15
Soit la description VHDL suivante :
a. le schéma :
A 00
01 D
10
11 CLK
H
b. C’est description comportementale décrit par des équations et des comportemets.
c.
Le processus P1 est combinatoire car il n’y a pas d’horloge ou de bascules.
28
Le processus P2 est séquentiel car il contient une horloge H dans sa liste de sensibilité, il
sera a donc décrit par une bascule.
Le programme :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity mux_4v1 is
7 port( A ,B,C,D :in std_logic ;
8 SEL: in std_logic_vector ( 1 downto 0 )
9 S: out std_logic) ;
10
11 end mux_4v1 ;
12 - - Description comportementale
13 architecteure description of mux4v1 is
14 begin
15 S<=A when SEL="00" else
16 B when SEL="00" else
17 C when SEL="00" else
18 D when SEL="00" else
19 0 ;
20
21 end description ;
Le programme :
CODE : VHDL
29
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity mux_4v1 is
7 port( A ,B,C,D :in std_logic ;
8 SEL: in std_logic_vector ( 1 downto 0 )
9 S: out std_logic) ;
10
11 end mux_4v1 ;
12 - - Description comportementale
13 architecteure description of mux4v1 is
14 begin
15 with SEL select
16 S<=A when "00"
17 B when "00"
18 C when "00"
19 D when "00"
20 0 when others ;
21
22 end description ;
Le programme :
30
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity exo18 is
7 port( E ,H :in std_logic ;
8 S1, S2 : out std_logic );
9
10 end exo18 ;
11 - - Description comportementale
12 architecteure description of exo18 is
13
14 signal SG1,SG2 : std_logic ;
15
16 begin
17 process (H)
18 begin
19 if H ='1' and H'event then
20 -- Ou if rising_edge(H) then
21
22 SG1<=E ;
23 SG2<=SG1 ;
24 end if ;
25 end process ;
26 S1<=E xor S2 ;
27 S1<=SG2 or SG1 or E ;
28 end description ;
31
La description du XOR :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity XOR is
7 port( I1,I2 :in std_logic ;
8 out : out std_logic );
9
10 end XOR ;
11 - - Description comportementale
12 architecteure description of XOR is
13 begin
14 out<= I1 xor I2 ;
15 end description ;
La description de l’inversseur :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity inversseur is
7 port( I :in std_logic ;
8 out : out std_logic );
9
10 end inversseur ;
11 - - Description comportementale
12 architecteure description of inversseur is
13 begin
14 out<= not I ;
15 end description ;
32
La description structurelle :
CODE : VHDL
1 - - Déclaration des paquetages utiles pour le module
2 library ieee ;
3 use ieee . std_logic_1164.all ;
4
5 - - Description externe
6 entity description_struct is
7 port( A ,B ,C :in std_logic ;
8 S : out std_logic );
9
10 end description_struct ;
11 - - Description comportementale
12 architecteure description of description_struct is
13
14 component xor
15 port (I1 ,I2 : in std_logic ;
16 out : out std_logic );
17 end component ;
18
19 component inversseur
20 port (I : in std_logic ;
21 out : out std_logic );
22 end component ;
23
24 signal S1,S2 : std_logic ;
25
26 begin
27
28 XOR1 : xor port map (A ,B,S1) ;
29 XOR2 : xor port map (S1 ,B,S2) ;
30 INV : inversseur port map (S2,S) ;
31
32 end description ;
33
34