Partie 1 : Systèmes numériques
TD 2 : VHDL
Pr. Mohamed LAMHAMDI
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°1
Exercice N°1
Soit la description VHDL suivante
entity exo1 is
port (x1, x2, x3, sel: in s std_logic;
y: out std_logic);
end entity exo1;
architecture arch of exo1 is signal a, b, c, d, e, f: std_logic;
begin
a<=x1 xorx3;
b <= x1 and x3;
c<=x2and a;
d <= b or c;
e <=x1 xor x2;
f <=x3 xor e;
P: process (d, f, set)
begin
if sel= '0’ then
y<=d;
else
y<=f;
end if;
end process;
end arch;
1. Tracez à partir d'éléments de base le schéma correspondant.
2. Le processus P est-il combinatoire ou séquentiel ? Justifiez.
3. Quel est selon vous la fonction de ce circuit ?
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°1
Question N°1
Tracez à partir d'éléments de base le schéma correspondant.
entity exo1 is
port (x1, x2, x3, sel: in s std_logic;
y: out std_logic);
end entity exo1;
architecture arch of exo1 is signal a, b, c, d, e, f: std_logic;
begin
a<=x1 xorx3; X1
b <= x1 and x3;
X2
c<=x2and a;
d <= b or c; X3
e <=x1 xor x2; Y
f <=x3 xor e;
P: process (d, f, set)
begin
if sel= '0’ then Sel
y<=d;
else
y<=f;
end if;
end process;
end arch;
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°1
Question N°1
Tracez à partir d'éléments de base le schéma correspondant.
entity exo1 is
port (x1, x2, x3, sel: in s std_logic;
y: out std_logic);
end entity exo1;
architecture arch of exo1 is signal a, b, c, d, e, f: std_logic;
begin
a<=x1 xorx3;
b <= x1 and x3;
c<=x2and a; X1
d <= b or c;
e <=x1 xor x2; X2
f <=x3 xor e;
P: process (d, f, set) X3
begin
if sel= '0’ then
y<=d;
else
y<=f;
end if; Y
end process;
end arch; Sel
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°1
Question N°1
Tracez à partir d'éléments de base le schéma correspondant.
entity exo1 is
port (x1, x2, x3, sel: in s std_logic;
y: out std_logic);
end entity exo1;
architecture arch of exo1 is signal a, b, c, d, e, f: std_logic;
begin
a<=x1 xorx3;
b <= x1 and x3;
c<=x2and a; X1
d <= b or c;
e <=x1 xor x2;
X2
f <=x3 xor e;
X3
P: process (d, f, set)
begin
if sel= '0’ then
y<=d;
else
y<=f;
end if;
end process;
end arch;
Sel
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°1
Question N°2
Le processus P est-il combinatoire ou séquentiel ? Justifiez
enDty exo1 is
port (x1, x2, x3, sel: in s std_logic;
y: out std_logic);
end enDty exo1;
architecture arch of exo1 is signal a, b, c, d, e, f: std_logic;
begin
a<=x1 xorx3;
b <= x1 and x3;
c<=x2and a;
d <= b or c;
e <=x1 xor x2;
f <=x3 xor e;
P: process (d, f, set)
begin
if sel= '0’ then
y<=d;
else
y<=f;
end if;
end process;
end arch;
Le processus P est Combinatoire parce que
• Il n’y a pas d’horloge
• Pas de bascule non plus .
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°1
Question N°3
Quel est selon vous la fonction de ce circuit
Additionneur complet 1 bit
A B
Cout Cin
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°2
Exercice N°2
On considère la description VHDL suivante :
enDty Exo2 is
port ( hor, e : in bit ; s : out bit );
end Exo2 ;
architecture quasi_struct of Exo2 is
signal qa, qb : bit ;
begin
s <= qa xor qb ;
schem : process
begin
wait unDl hor = '1' ;
qa <= e ;
qb <= qa ;
end process schem ; e
end quasi_struct ;
1. Déduire de ce programme, par une construction méthodique, un schéma logique
(bascules et portes logiques).
2. Compléter le chronogramme ci-dessous
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°2
Exercice N°2
Déduire de ce programme, par une construction méthodique, un schéma logique
(bascules et portes logiques).
enDty Exo2 is
port ( hor, e : in bit ; s : out bit );
end Exo2 ;
architecture quasi_struct of Exo2 is hor
signal qa, qb : bit ;
begin
s <= qa xor qb ; S
schem : process
begin
e
wait unDl hor = '1' ;
qa <= e ;
qb <= qa ;
end process schem ; e
end quasi_struct ;
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°2
Exercice N°2
Déduire de ce programme, par une construction méthodique, un schéma logique
(bascules et portes logiques).
entity Exo2 is
port ( hor, e : in bit ; s : out bit );
end Exo2 ;
architecture quasi_struct of Exo2 is
signal qa, qb : bit ; qb
begin S
s <= qa xor qb ;
schem : process qa
begin
wait until hor = '1' ;
qa <= e ;
qb <= qa ;
end process schem ; e
end quasi_struct ;
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°2
Exercice N°2
Déduire de ce programme, par une construction méthodique, un schéma logique
(bascules et portes logiques).
enDty Exo2 is
port ( hor, e : in bit ; s : out bit );
end Exo2 ;
architecture quasi_struct of Exo2 is
signal qa, qb : bit ; hor
begin
s <= qa xor qb ;
schem : process
qb
begin
wait unDl hor = '1' ;
qa <= e ;
e
qb <= qa ;
end process schem ; e
qa
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°2
Exercice N°2
Déduire de ce programme, par une construction méthodique, un schéma logique
(bascules et portes logiques).
entity Exo2 is
port ( hor, e : in bit ; s : out bit );
end Exo2 ;
architecture quasi_struct of Exo2 is
signal qa, qb : bit ;
begin
s <= qa xor qb ;
schem : process
begin
wait until hor = '1' ;
qa <= e ;
qb <= qa ;
end process schem ;
end quasi_struct ;
hor
S
qb
e
qa
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°2
Exercice N°2
Compléter le chronogramme ci-dessous
entity Exo2 is
port ( hor, e : in bit ; s : out bit );
end Exo2 ;
architecture quasi_struct of Exo2 is
signal qa, qb : bit ; hor
begin
s <= qa xor qb ;
schem : process
qb S
begin
wait until hor = '1' ; e
qa <= e ;
qb <= qa ; qa
end process schem ;
end quasi_struct ;
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°3
Exercice N°3
Écrivez une description en VHDL à partir du circuit suivant
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°3
Exercice N°3
Écrivez une description en VHDL à partir du circuit suivant
entity Exo3 is
port ( A, B, Sel, CLK : in std_logic ;
OUT : out std_logic );
end Exo3 ;
Sel
A
B
Out
CLK
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°3
Exercice N°3
Écrivez une description en VHDL à partir du circuit suivant
entity Exo3 is
port ( A, B, Sel, CLK : in std_logic ;
OUT : out std_logic );
end Exo3 ;
architecture quasi_struct of Exo3 is
Sel
signal S1,S2,S3 std_logic ;
begin
s1 <= A xor B ; A S1
s2 <= A and B ;
B
Out
S2
CLK
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°3
Exercice N°3
Écrivez une description en VHDL à partir du circuit suivant
entity Exo3 is
port ( A, B, Sel, CLK : in std_logic ;
OUT : out std_logic );
end Exo3 ;
architecture quasi_struct of Exo3 is
signal S1,S2,S3 std_logic ;
Sel
begin
s1 <= A xor B ; A S1
s2 <= A and B ;
process (Mux) B
begin S3
if sel = '0’ then Out
S3 <=S1; S2
else
S3<=S2;
end if;
end process CLK
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°3
Exercice N°3
Écrivez une description en VHDL à partir du circuit suivant
enDty Exo3 is
port ( A, B, Sel, CLK : in std_logic ;
OUT : out std_logic );
end Exo3 ;
architecture circt of Exo3 is
signal S1,S2,S3 std_logic ;
begin Sel
s1 <= A xor B ;
s2 <= A and B ; A S1
process (Mux)
begin B
if sel = '0’ then S3
S3 <=S1; Out
else S2
S3<=S2;
end if;
end process
process (Clk , S3) CLK
begin
if (CLK’event and CLK=1) then
Out <=S3;
end if;
end process
end circt
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°4
Exercice N°4
Donner une description en langage VHDL pour :
1. Bascule D simple (sans mise à zéro ou mise un 1).
2. Bascule D simple avec remise à zéro (RAZ).
3. Bascule D simple avec remise à zéro (RAZ) prioritaire et remise à 1
(SET) synchrones.
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°4
Question 1
Bascule D simple (sans mise à zéro ou mise un 1).
Library ieee;
use ieee.std_logic_1164.all;
--------------------------------------------------------------
entity D simple is
port ( d, CLK : in std_logic ;
q : out std_logic );
end D simple ;
-------------------------------------------------------------
architecture behavior of D simple is
begin
process (clk)
begin
if Clk ’event AND Clk = ‘1’ then
q <=d;
end if;
end process;
end behavior;
------------------------------------------------------------
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°4
Question 2
Bascule D simple avec remise à zéro (RAZ).
Library ieee;
use ieee.std_logic_1164.all;
--------------------------------------------------------------
entity D avec RAZ is
port ( d, CLK rst : in std_logic ;
q : out std_logic );
end D avec RAZ ;
-------------------------------------------------------------
architecture behavior of D avec RAZ is
begin
process (clk, rst)
begin
if rst = ‘1’ then
q <= ‘0’;
Elsif Clk ’event AND Clk = ‘1’ then
q <=d;
end if;
end process;
end behavior;
------------------------------------------------------------
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°4
Question 3
Bascule D simple avec remise à zéro (RAZ) prioritaire et remise à 1
(SET) synchrones
Library ieee;
use ieee.std_logic_1164.all;
--------------------------------------------------------------
entity D avec RAZ is
port ( d, CLK rst : in std_logic ;
q : out std_logic );
end D avec RAZ ;
-------------------------------------------------------------
architecture behavior of D avec RAZ is
begin
process (clk)
begin
if Clk ’event AND Clk = ‘1’ then
if rst = ‘1’ then
q <= ‘0’;
Elsif set = ‘1’ then
q <= ‘1’;
Els q <= d;
end if;
end if;
end process;
end behavior;
------------------------------------------------------------
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
Exercice N°5
On souhaite écrire une description en VHDL décrivant le fonctionnement d'un
comparateur non signé sur 4 bits entre deux nombre A et B comme le montre la figure
suivante :
1. Donnez sa table de vérité.
2. Écrivez la description, en VHDL, correspondante en utilisant l'instruction
conditionnelle « if».
3. Donnez le circuit correspondant.
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
Question 1
Donnez sa table de vérité.
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
Question 2
Écrivez la description, en VHDL, correspondante en utilisant l'instruction
conditionnelle « if».
enDty comparateur 4 bit is
Port (a : in STD_LOGIC_VECTOR (3 downto 0);
b : in STD_LOGIC_VECTOR (3 downto 0);
egal : out STD_IOGIC;
sup : out STD_LOGIC;
inf : out STD_LOGIC );
end comparator_4bit;
Entité
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
Question 2
Écrivez la description, en VHDL, correspondante en utilisant l'instruction
conditionnelle « if».
architecture comparateur_arch of comparator_4bit is
begin
comparator: process(a,b) is
begin
If (a=b) then
egal<=‘1’;
sup <= '0’;
inf<= '0';
elsif (a<b) then
égal <= ‘0’
sup <= '0’; 1 4
inf<= ‘1’;
Else 2 5
égal <= ‘0’;
sup <= ‘1’;
inf<= ‘0’; 3 6
end if
end process
End comparateur_arch
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
iibrarylEEE;
Question 2 use IEEE.STD_LOGIC_1164.all;
Écrivez la description, en VHDL, --------------------------------------------------------------------------------
correspondante en utilisant l'instruction en<ty comparateur 4 bit is
conditionnelle « if». Port (a : in STD_LOGIC_VECTOR (3 downto 0);
b : in STD_LOGIC_VECTOR (3 downto 0);
egal : out STD_IOGIC;
sup : out STD_LOGIC;
inf : out STD_LOGIC );
end comparator_4bit;
--------------------------------------------------------------------------------
architecture comparateur_arch of comparator_4bit is
begin
comparator: process(a,b) is
begin
If (a=b) then
egal<='î’;
sup <= '0’;
inf<= '0';
elsif (a<b) then
égal <= ‘0
sup <= '0’;
inf<= ‘1’;
Else
égal <= ‘0’;
sup <= ‘1’;
inf<= ‘0’;
end if
end process
End comparateur_arch
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
Question 2
Donnez le circuit correspondant
Égal= 1 si Ai=Bi
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
Question 2 Donnez le circuit correspondant
Inf = 1 si Ai<Bi
Sup = 1 si Ai > Bi
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°5
Question 2 Donnez le circuit correspondant
Inf = 1 si Ai<Bi
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°6
Exercice N°6
Écrivez une description en VHDL à partir du circuit suivant
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°6
Exercice N°6
Écrivez une description en VHDL à partir du circuit suivant
A Q1
B
C Q2
enDty exo 5 bit is
Port (A,B, C : in STD_LOGIC;
Q1, Q2 : out STD_IOGIC;
end exo 5;
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°6
Exercice N°6
Écrivez une description en VHDL à partir du circuit suivant
architecture circuit_arch of exo 5 is
begin
process(C,A,B ) is
Varaible V: std_LOGIC;
begin
If V= ‘1’;
then Q2 <= C;
end if
If A ’event and A= ‘1’;
then Q1 <= B;
V:=not B;
end if;
end process;
end if circuit_arch;
--------------------------------------------------
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI
TD 2 : VHDL Exercice N°6
Exercice N°6
Écrivez une description en VHDL à partir du circuit suivant
Library ieee;
use ieee.std_logic_1164.all;
--------------------------------------------------------------
entity exo 5 bit is
Port (A,B, C : in std_LOGIC);
Q1, Q2 : out std_IOGIC;
end exo 5;
---------------------------------------------------------------
architecture circuit_arch of exo 5 is
begin
process(C,A,B ) is
Varaible V: std_LOGIC;
begin
If V= ‘1’;
then Q2 <= C;
end if
If A ’event and A= ‘1’;
then Q1 <= B;
V:=not B;
end if;
end process;
end if circuit_arch;
--------------------------------------------------------------------
Master - 2 : Automatique, Traitement du signal et Informatique industrielle Pr: Mohamed LAMHAMDI