Correction
Exercice n°1 : Modélisation et styles en VHDL
Soit la description VHDL suivante:
entity exercice2
port( x1, x2, x3, sel: in std_logic;
y: out std_logic);
end entity exercice2;
architecture archi of exercice2 is
signal a, b, c, d, e, f: std_logic;
begin
a <= x1 or x3;
b <= x1 and x3;
c <= x2 and a;
d <= b or c;
e <= x1 xor x2;
f <= x3 xor e;
P1: process (d, f, sel)
begin
if sel=’0’ then
y <= d;
else
y <= f;
end if;
end process P1;
end architecture archi;
1) Tracez à partir d’éléments de base le schéma correspondant.(logigramme)
1
2) Cette description est-elle structurale ou comportementale? Justifiez.
Description comportementale car le système est décrit par des équations et des
comportements
3) Le processus P1 est-il combinatoire ou séquentiel? Justifiez.
Le processus P1 est-il combinatoire car il n’est pas par une horloge et ne contient pas des
bascules.
4) Quel est selon vous la fonction de ce circuit?
Additonneur complet 1 bit. Y=X1+X2+X3 si sel=0 et Y=Rentenu de X1+X2+X3 si sel=1
Exercice n°2 :
Soit le programme ci-contre.
Entity prog is
Port (
A: in std_logic_vector(7 downto 0);
B: in std_logic_vector(7 downto 0);
S: in std_logic_vector(1 downto 0);
R: out std_logic_vector(7 downto 0) );
End prog;
Architecture behv of prog is
process(A,B,S)
begin
case S is
when "00" =>
R <= A + B;
when "01" =>
R <= A - B;
when "10" =>
R <= A and B;
when "11" =>
R <= A or B;
when others =>
R <= "XXXXXXXX ";
end case;
End process;
End behv;
1) Dessiner un schéma synoptique pour ce circuit.
2
2) Quel est selon vous la fonction de ce circuit?
Unité Arithmétique et Logique (UAL)
Exercice n°3:
Pour le circuit ci-dessus compléter le programme VHDL correspondant ci-dessous?
Library ieee ;
Use ieee.std_logic_1164.all ;
Entity exercice4 is
port ( A: in std_logic;
B: in std_logic;
SEL: in std_logic;
CLK: in std_logic;
O: out std_logic);
End exercice4;
Architecture behv of exercice4 is
Signal S1,S2,S3 std_logic;
begin
S1<= A xor B;
S2<= A and B;
process(SEL)
begin
if SEL=’1’ then
S3=S1;
else
S3<=S2;
end if ;
end process;
process(CLK,S3)
begin
if (CLK'event and CLK=1 ) then
3
O<=S3;
end if;
end process;
end behv;
Exercice n°4 : Conception en VHDL
Soit l’entité suivante:
library ieee;
use ieee.std logic_1164.all;
use ieee.numeric_std.all;
entity compteur
port ( x: in std logic;
y: out std_logic_vector(7 downto 0));
end entity compteur; 1)
Dessiner un schéma synoptique pour ce circuit.
2) Ecrivez une description en VHDL comportemental à partir de cette entité qui compte
les transitions montantes sur x et présente en tout temps le compte courant sur 8 bits à la
sortie y.
library ieee;
use ieee.std logic_1164.all;
use ieee.numeric_std.all;
entity compteur
port ( x: in std logic;
y: out std_logic_vector(7 downto 0));
end entity compteur;
Architecture behv of compteur is
begin
process(x,y)
begin
if (x'event and x=1 ) then
y<=y+1;
4
if(y=256) then
y<=0;
end if;
end process;
end behv;
3) Si on rajoute le port suivant: d: out std_logic; Quelle modification apporteriez-vous
pour que d monte à ’1’ lorsqu’il y a débordement du compteur? (compteur > 255).
(réécrire le programme)
library ieee;
use ieee.std logic_1164.all;
use ieee.numeric_std.all;
entity compteur
port ( x: in std logic; d: out std_logic ; y: out std_logic_vector(7 downto 0));
end entity compteur;
Architecture behv of compteur is
begin
process(x,y,d)
begin
if (x'event and x=1 ) then
y<=y+1;
if(y>255) then
d<=1;
end if;
end process;
end behv;
Exercice 5:
Library ieee;
use ieee.std_logic_1164.all;
entity comparateur8bits is port
(A, B: in std_logic_vector (7 downto 0);
EQUA, SUPE, INFE: out std_logic);
end comparateur8bits;
architecture ARCH_comparateur8bits of comparateur8bits is
Begin
EQUA<='1' when A=B else '0';
SUPE<='1' when A>B else '0';
INFE<='1' when A<B else '0';
end ARCH_comparateur8bits;