0% ont trouvé ce document utile (0 vote)
9 vues13 pages

A B C D: Entity Architecture en Utilisant Un Process

Le document contient une série d'exercices sur la conception de circuits numériques en VHDL, incluant des multiplexeurs, démultiplexeurs, fonctions de majorité, comparateurs de bus de données, et des bascules. Chaque exercice demande de rédiger des programmes VHDL en utilisant différentes approches de description, telles que flot de données et processus. Les exercices sont accompagnés d'instructions pour tracer des chronogrammes et modéliser des circuits à l'aide de diagrammes d'état.

Transféré par

chettouhmeriem93
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
9 vues13 pages

A B C D: Entity Architecture en Utilisant Un Process

Le document contient une série d'exercices sur la conception de circuits numériques en VHDL, incluant des multiplexeurs, démultiplexeurs, fonctions de majorité, comparateurs de bus de données, et des bascules. Chaque exercice demande de rédiger des programmes VHDL en utilisant différentes approches de description, telles que flot de données et processus. Les exercices sont accompagnés d'instructions pour tracer des chronogrammes et modéliser des circuits à l'aide de diagrammes d'état.

Transféré par

chettouhmeriem93
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

TD N° 01

Exercice 1 a
Ecrire un programme VHDL qui décrit un circuit multiplexeur à quatre entrées en utilisant : b y
a) une description de type « flot de données » c
b) une description qui utilise un process d

S(1) S(0)

a
Exercice 2
b
Ecrire un programme VHDL qui décrit un circuit démultiplexeur à quatre sorties en y
utilisant : c
a) une description de type « flot de données » d
b) une description qui utilise un process

S(1) S(0)

Exercice 3
Concevoir une fonction majorité à trois entrées. La déclaration d’entité est équivalente à : A
B Majorité S
Utiliser une description comportementale qui permet de décrire le comportement sans C
faire appel aux équations mais en passant par la table de vérité.
1) Réaliser la table de vérité de ce composant
2) Ecrire l’ensemble d’un fichier VHDL (Library, Entity, Architecture) qui décrit ce composant en utilisant un
process.

Exercice 4
On veut modéliser un circuit permettant de comparer 2 bus de données de 8 bits (A et B), et de générer 3 signaux de
sortie :
EQUA si les données sur les deux bus sont égales, SUPE si la donnée du bus A est supérieure à la donnée du bus B,
INFE si la donnée du bus A est inférieure à la donnée du bus B. A et B sont des entrées du type std_logic_vector,
EQUA, SUPE, INFE sont des sorties de type std_logic ;

Ecrire l’ensemble d’un fichier VHDL (Entity et Architecture) qui décrit ce circuit en utilisant un process.

Exercice 5
Ecrire un fichier VHDL (Entity et Architecture) qui décrit la même fonction du code VHDL suivant, en utilisant
l’instruction Case. Le circuit a deux entrées A et B, les sorties sont S et R.

if A = "00" then S <= ‘0’ ;


elsif B = ‘1’ then R <= "111" ;
else S <= ‘1’ ; R <= "000" ;

Pr. Mohamed Ould Zmirli 1 / 13 2022/2023


TD N° 02

Exercice 1
Ecrire un programme VHDL qui décrit une bascule de type D (figure ci-contre).
Utiliser une description à base d’un process.

Exercice 2
Ecrire l’ensemble d’un fichier VHDL qui décrit le circuit ci-dessous en utilisant deux processus.

Exercice 3
Soit la description VHDL suivante:
variable x : bit;
Entity exo3td2 is port ( begin
clk, a : in bit; if clk'event and clk='1' then
b, c : inout bit ; b <= a ;
d : out bit); c <= b ;
end exo3td2;
x := a ;
Architecture arch of exo3td2 is d <= x ;
begin end if;
end process;
process (clk) end arch;

Compléter le chronogramme ci-dessous.

Pr. Mohamed Ould Zmirli 2 / 13 2022/2023


Exercice 4
Soit la description VHDL suivante:

Entity exo4td2 is begin


port ( clk, e : in bit ; If rising_edge(clk) then
s : out bit ); qa <= e ;
End exo4td2; qb <= qa ;
end if;
Architecture arch of exo4td2 is end process;
signal qa, qb : bit ; s <= qa xor qb ;
begin end arch;
process (clk)

1. Tracer à partir de 02 Bascules D et une porte logique XOR le schéma du circuit.


2. Compléter le chronogramme ci-dessous.

Exercice 5
On considère le programme suivant :

Entity exo5td2 is begin


port ( T, clk, init : in bit; if rising_edge(clk) then
S : out bit); if ( init ='0') then
End exo5td2; etat <= '1';
elsif (T='0') then
Architecture arch of exo5td2 is etat <= not etat;
signal etat : bit; end if;
Begin end if;
S <= etat; end process;
process (clk) End arch;

Compléter le chronogramme ci-dessous.

Pr. Mohamed Ould Zmirli 3 / 13 2022/2023


TD N° 03

Exercice 1
Le système à concevoir : bascule JK, dispose de trois entrées (J, K et
Clk) et de deux sorties (S1 et S2).
Ecrire l’ensemble d’un fichier VHDL (Entity et Architecture) qui
décrit ce système en utilisant une description structurelle.

Exercice 2
Soit la description VHDL suivante:

Entity exercice2 is c <= x2 AND a ;


port ( d <= x2 OR b ;
x1 , x2 , x3 , sel : in bit ; P1: process (c , d , sel)
y : out bit) ; Begin
End exercice2; if sel=’0’ then
y <= c ;
Architecture archi of exercice 2 is else
Signal a, b, c, d : bit ; y <= d ;
Begin end if ;
a <= x1 OR x3 ; end process P1 ;
b <= x1 AND x3 ; End Architecture archi ;

1. Tracer à partir des composants de base le schéma du circuit correspondant à la description ci-dessus.
2. Ecrire l’ensemble d’un fichier VHDL (Entity et Architecture) qui décrit ce même circuit en utilisant une
description structurelle.

Exercice 3

1) Ecrire un programme VHDL (Entity et


Architecture) qui décrit le système ci-contre en
utilisant une description structurelle.

2) Récrire l’Architecture qui décrit ce même


système en utilisant une description
comportementale avec un seul process.

Pr. Mohamed Ould Zmirli 4 / 13 2022/2023


TD N° 04

Exercice 1
On veut concevoir une machine capable de détecter la séquence 0-1-1-0 sur son unique
entrée (x). Quand la séquence se produit, il devrait émettre un ‘1’ sur son unique sortie
(y).
Noter que dans la séquence 0-1-1-0-1-1-0, la séquence se produit deux fois.

Le diagramme d'états est comme le montre la figure suivante :

1) Ecrire un programme VHDL qui décrit cette machine.


2) Compléter le chronogramme suivant.

Exercice 2
Ci-contre la représentation schématique d’un système à 4
états (M0 à M3), 2 sorties (S1 et S2), 2 entrées X et Y, sans
oublier l’entrée d’horloge qui fait avancer le processus, et
celle de remise à zéro qui permet de l’initialiser :

L’état initial est M0. Les 2 sorties sont à 0. Au coup d’horloge


on passe inconditionnellement à l’état M1 sauf si la condition
Y=1 a été vérifiée, ce qui mène à l’état M3 ou si X=0 a été
validé ce qui mène à M2.
De M3 on revient au coup d’horloge à M0. De M1 on passe
à M2, et de M2 on passe à M3.
Dans chaque état on définit les niveaux des sorties.

Ecrire la description VHDL (Entité et Architecture) de ce système en se basant sur le diagramme d’état. Le système
est actif sur front montant.

Pr. Mohamed Ould Zmirli 5 / 13 2022/2023


Sol. Exo.1 TD 01

library ieee;
use ieee.std_logic_1164.all; architecture arch1 of exo1td1 is
begin
entity exo1td1 is port ( process(s,a,b,c,d)
y : out std_logic; begin
s: in std_logic_vector(1 downto if s="00" then y <= a ;
0); elsif s="01" then y <= b;
a,b,c,d : in std_logic); elsif s="10" then y <= c;
end exo1td1; else y <= d;
end if;
architecture flot1 of exo1td1 is end process;
begin end arch1;
y <= a when s="00" else
b when s="01" else architecture arch2 of exo1td1 is
c when s="10" else begin
d ; process(s,a,b,c,d)
end flot1; begin
case s is
architecture flot2 of exo1td1 is when "00" => y <= a ;
begin when "01" => y <= b ;
with s select when "10" => y <= c ;
y <= a when "00" , when others => y <= d ;
b when "01" , end case;
c when "10" , end process;
d when others; end arch2;
end flot2;

Sol. Exo.2 TD 01

library ieee; begin


use ieee.std_logic_1164.all; if s="00" then a <= y ;
elsif s="01" then b <= y;
entity exo2td1 is port ( elsif s="10" then c <= y;
y : in std_logic; else d <= y;
s: in std_logic_vector(1 downto end if;
0); end process;
a,b,c,d : out std_logic); end arch1;
end exo2;
architecture arch2 of exo2td1 is
architecture flot of exo2td1 is begin
begin process(s,y)
a<= y when s="00"; begin
b<= y when s="01"; case s is
c<= y when s="10"; when "00" => a <= y ;
d<= y when s="11"; when "01" => b <= y ;
end flot; when "10" => c <= y ;
when others => d <= y ;
architecture arch1 of exo2td1 is end case;
begin end process;
process(s,y) end arch2;

Pr. Mohamed Ould Zmirli 6 / 13 2022/2023


Sol. Exo.3 TD 01
library ieee;
use ieee.std_logic_1164.all;

entity exo3td3 is port (


A,B,C : in std_logic;
S : out std_logic);
end exo3td3;

architecture arch1 of exo3td3 is


begin
process (A,B,C)
begin
if A='0' and B='0' and C='0' then S <= '0';
elsif A='0' and B='0' and C='1' then S <= '0';
elsif A='0' and B='1' and C='0' then S <= '0';
elsif A='0' and B='1' and C='1' then S <= '1';
elsif A='1' and B='0' and C='0' then S <= '0';
elsif A='1' and B='0' and C='1' then S <= '1';
elsif A='1' and B='1' and C='0' then S <= '1';
else S <= '1';
end if;
end process;
end arch1;

architecture arch2 of exo3td3 is


signal D : std_logic_vector(2 downto 0);
begin
D <= A&B&C;
process (D)
begin
case D is
when "000" => S <= '0';
when "001" => S <= '0';
when "010" => S <= '0';
when "011" => S <= '1';
when "100" => S <= '0';
when "101" => S <= '1';
when "110" => S <= '1';
when others => S <= '1';
end case;
end process;
end arch2;

Sol. Exo.4 TD 01
library ieee;
use ieee.std_logic_1164.all;

entity exo4td1 is port (


A, B : in std_logic_vector(7 downto 0);
EQUA, SUPE, INFE : out std_logic);
end exo4td1;

architecture flot of exo4td1 is


begin
equa <= '1' when A = B else '0' ;
supe <= '1' when A > B else '0' ;
infe <= '1' when A < B else '0' ;
end architecture flot;

Pr. Mohamed Ould Zmirli 7 / 13 2022/2023


architecture comportementale of exo4td1 is
begin
process(A,B)
begin
if (A=B) then EQUA <= '1'; SUPE <= '0'; INFE <= '0';
elsif (A>B) then EQUA <= '0'; SUPE <= '1'; INFE <= '0';
else EQUA <= '0'; SUPE <= '0'; INFE <= '1';
end if;
end process;
end architecture comportementale;

Sol. Exo.5 TD 01

library ieee;
use ieee.std_logic_1164.all;

entity exo5td1 is port (


A : in std_logic_vector(1 downto 0);
B : in std_logic;
S : out std_logic;
R : out std_logic_vector(2 downto 0));
end exo5td1;

architecture arch of exo5td1 is


Signal C : std_logic_vector(2 downto 0);
Begin
C <= A&B;
Process(C)
Begin
case C is
when "000" | "001" => S <= '0';
when "011" | "101" | "111" => R <= "111";
when "010" | "100" | "110" => S <= '1'; R <= "000";
end case;
end process;
end arch;

Sol. Exo.1 TD 02
library ieee;
use ieee.std_logic_1164.all;

entity exo1td2 is port (


D, Clock, Reset : in std_logic;
Q : out std_logic);
end exo1td2;

architecture arch of exo1td2 is


begin
process (Clock, Reset)
begin
if Reset = '1' then Q <= '0';
elsif Clock'event and Clock = '1' then Q <= D;
end if;
end process;
end arch;

Pr. Mohamed Ould Zmirli 8 / 13 2022/2023


Sol. Exo.2 TD 02
Library ieee;
use ieee.std_logic_1164.all;

Entity exo2td2 is port (


A , B , SEL , CLK : in std_logic ;
OUT1 : out std_logic) ;
End exo2td2;

Architecture archi of exo2td2 is


Signal C, D, E : std_logic ;
Begin
C <= A XOR B ;
E <= A AND B ;
P1: process (C, E, SEL)
Begin
if SEL='0' then D <= C ;
else D <= E ; end if ;
end process P1 ;

P2: process (CLK)


Begin
if rising_edge(CLK) then OUT1 <= D; end if;
end process P2 ;
End archi ;

Sol. Exo.3 TD 02

Sol. Exo.4 TD 02

Sol. Exo.5 TD 02

Pr. Mohamed Ould Zmirli 9 / 13 2022/2023


Sol. Exo.1 TD 03
library ieee;
use ieee.std_logic_1164.all;

entity exo1td3 is port (


J, K, clk : in std_logic;
S1, S2 : inout std_logic);
signal a, b, c, d : std_logic;
end exo1td3;

architecture arch of exo1td3 is

component and2 port (


e1, e2 : in std_logic;
s : out std_logic);
end component;

component or2 port (


e1, e2 : in std_logic;
s : out std_logic);
end component;

component inverseur port (


e : in std_logic;
s : out std_logic);
end component;

component bascule_d port (


D,clk : in std_logic;
Q1, Q2 : out std_logic);
end component;

begin
a0 : and2 port map (S2,J,a);
a1 : and2 port map (c,S1,b);
a2 : or2 port map (a,b,d);
a3 : inverseur port map (K,c);
a4 : bascule_d port map (d,clk,S1,S2);
end arch;

Sol. Exo.2 TD 03

X1 a c
X3
Y
X2

b d

sel

Library ieee;
use ieee.std_logic_1164.all;

Entity exo2td3 is port (


x1 , x2 , x3 , sel : in std_logic;
y : out std_logic) ;
End exo2td3;

Pr. Mohamed Ould Zmirli 10 / 13 2022/2023


Architecture archi of exo2td3 is
Signal a, b, c, d : std_logic;

Component and2 port (


e1, e2 : in std_logic;
s : out std_logic);
end component;

Component or2 port (


e1, e2 : in std_logic;
s : out std_logic);
end component;

Component mux21 port (


e1, e2, sel : in std_logic;
s : out std_logic);
end component;

Begin
u0: or2 port map(x1,x3,a);
u1: and2 port map(x1,x3,b);
u2: and2 port map(x2,a,c);
u3: or2 port map(x2,b,d);
u4: mux21 port map(c,d,sel,y);
end archi ;

Sol. Exo.3 TD 03

library ieee;
use ieee.std_logic_1164.all;

entity exo3td3 is port (


A, clk, rst : in std_logic;
out1 : out std_logic);
end exo3td3;

architecture structurelle of exo3td3 is


Signal D1, D2, D3, Q1, Q2, Q3 : std_logic;

Component and2 port (


e1 , e2 : in std_logic;
s : out std_logic);
end component;

Component bascule_d port (


d, clk, rst : in std_logic;
q : out std_logic);
end component;

Begin
D2 <= A;
out1 <= Q3;
comp1: and2 port map (A,Q2,D1);
comp2: bascule_d port map (D1,clk,rst,Q1);
comp3: bascule_d port map (D2,clk,rst,Q2);
comp4: and2 port map (Q1,Q2,D3);
comp5: bascule_d port map (D3,clk,rst,Q3);
end structurelle;

Pr. Mohamed Ould Zmirli 11 / 13 2022/2023


architecture comportementale of exo3td3 is
Signal D1, D2, D3, Q1, Q2, Q3 : std_logic;

Begin
D1 <= A and Q2;
D2 <= A;
D3 <= Q1 and Q2;
out1 <= Q3;

process (clk, rst)


begin
if rst = '1' then Q1 <= '0'; Q2 <= '0'; Q3 <= '0';
elsif clk'event and clk = '1' then Q1 <= D1; Q2 <= D2; Q3 <= D3;
end if;
end process;
end structurelle;

Pr. Mohamed Ould Zmirli 12 / 13 2022/2023


Sol. Exo.1 TD 04

library ieee;
use ieee.std_logic_1164.all; when s1 => y <= '0';
if (x='1') then
entity exo1td04 is port ( next_state <= s2;
clk, x : in std_logic; else next_state <= s1;
y : out std_logic); end if;
end exo1td04;
when s2 => y <= '0';
architecture arch of exo1td04 is if (x='1') then
type state_type is (s0,s1,s2,s3,s4); next_state <= s3;
signal cur_state : state_type := s0; else next_state <= s1;
signal next_state: state_type; end if;
begin
process (clk) when s3 => y <= '0';
begin if (x='0') then
if rising_edge(clk) then next_state <= s4;
cur_state <= next_state; else next_state <= s0;
end if; end if;
end process;
when s4 => y <= '1';
process (cur_state, x) is if (x='1') then
begin next_state <= s2;
case cur_state is else next_state <= s1;
when s0 => y <= '0'; end if;
if (x='0') then end case;
next_state <= s1; end process;
else next_state <= s0; end arch;
end if;

Sol. Exo.2 TD 04

library ieee ; use ieee.std_logic_1164.all ;

ENTITY exo2td04 IS
PORT (raz, horl :IN STD_LOGIC ;
X, Y :IN STD_LOGIC ;
S1, S2 : OUT STD_LOGIC) ;
END exo2td04;

ARCHITECTURE arch OF exo2td04 IS


TYPE etat_4 IS (M0, M1, M2, M3)
SIGNAL etat,etat_suiv : etat_4 := M0;
BEGIN
PROCESS( raz, horl)
BEGIN
If raz = '1' THEN etat <= M0 ;
ELSIF rising_edge(horl) THEN etat <= etat_suiv ; END IF;
END PROCESS ;
PROCESS(etat, X, Y)
BEGIN
CASE etat IS
WHEN M0 => S1 <= '0'; S2<= '0';
IF Y='1' then etat_suiv <= M3;
ELSIF X='0' then etat_suiv <= M2;
ELSE etat_suiv <= M1; END IF;
WHEN M1 => S1 <= '1'; S2<= '0'; etat_suiv <= M2;
WHEN M2 => S1 <= '1'; S2<= '1'; etat_suiv <= M3;
WHEN M3 => S1 <= '0'; S2<= '1'; etat_suiv <= M0;
END CASE;
END PROCESS ; END arch ;

Pr. Mohamed Ould Zmirli 13 / 13 2022/2023

Vous aimerez peut-être aussi