Vous êtes sur la page 1sur 44

Chap III:

Circuits combinatoires
Description VHDL

E. Amouri
Plan

❑ Process

❑ Simulateur VHDL

❑ Exemples de circuits combinatoires

❑ Circuits logiques de conversion et de sélection de données

❑ Circuits arithmétiques

2
PROCESS
Process

❑ Un process peut être vu comme une fonction dont l’exécution dépend de la


variation de signaux/ports à observer

❑ Les signaux/ports que l’on souhaite observer font partie de la liste de


sensibilité du process

❑ Si un des signaux de la liste est modifié, le process s’exécute


❑ Si aucun des signaux n’est modifié, le process reste en veille

4
Process

REGLE FONDAMENTALE

❑ Lorsque l’on décrit dans un process un système électronique combinatoire, la


liste de sensibilité doit comporter TOUTES LES ENTREES du système

❑ Lorsque l’on décrit dans un process un système électronique séquentiel, la


liste de sensibilité doit comporter L’HORLOGE et les ENTREES DE FORCAGE
ASYNCHRONE (reset, preset)

5
Exemple
library ieee;
use ieee.std_logic_1164.all;
❑ Description d’une bascule D
use ieee.std_logic_unsigned.all;

entity Bascule is
Port (h,raz,d: in std_logic;
q: out std_logic);
End entity Bascule;
architecture archi of Bascule is
begin
Process (h,raz)
Liste de sensibilité
Process s’execute si begin
evolution des signaux if raz=‘0’ then q<=‘0’;
elsif rising_edge(h) then q<=d;
end if;
Test du front montant end process;
end architecture archi;

6
SIMULATEUR VHDL
Simulateur VHDL

Simulation à Evénements Discrets

❑ A chaque pas de simulation

❑ Evolution des valeurs des entrées


❑ Ces changements activent les listes de sensibilités de certains process

❑ Exécution de ces process

❑ Mise à jour des sorties des process à la fin de l’exécution de tous les
process

8
Process et Simulation

❑ Pour garantir l’aspect concurrent d’un programme VHDL et la bonne


synchronisation des instructions, un process possède les caractéristiques suivantes:

❑ Pour le simulateur, le temps d’exécution d’un process est nul


❑ Lors de la simulation du programme, l’ensemble des instructions d’un process
est vu comme une grosse instruction concurrente
❑ Pour le simulateur, deux process ayant la même liste de sensibilité seront
activés aux mêmes pas de simulation.
❑ Un signal/port dont la valeur est modifiée au cours d’un process n’est remis à
jour QU’APRES L’EXECUTION DE TOUS LES PROCESS

9
Exemple 1
entity Exemple is
Port (clk,e: in std_logic;
s: out std_logic);
End entity Exemple;

architecture archi of Exemple is


signal t: std_logic;
begin
process (clk)
begin
if rising_edge(clk) then t<=e; end if;
end process;
process (clk)
❑ Quel est le comportement des
begin
signaux T et S et e ?
if rising_edge(clk) then s<=t; end if;
end process;
End architecture archi;

10
Exemple 1

11
Exemple 2
entity compteur is
Port (h,raz: in std_logic;
sortie: out std_logic);
end entity compteur;
architecture archi of compteur is
signal cpt: std_logic_vector(2 downto 0);
begin
Process (h,raz)
begin
If raz=‘0’ then cpt<="000"; sortie<=‘0’;
elsif rising_edge(h) then
cpt<=cpt+1;
if cpt="110" then sortie<=‘1’; else sortie<=‘0’; end if;
if cpt = “111” then cpt <=“000”;
end if;
end process;
end architecture archi;
12
Exemple 2

Process (h,raz)
begin
If raz=‘0’ then cpt<="000"; sortie<=‘0’;
elsif rising_edge(h) then
cpt<=cpt+1;
if cpt="110" then sortie<=‘1’; else sortie<=‘0’; end if;
if cpt = “111” then cpt <=“000”;
end if;
end process; 13
Exemple 2

14
CIRCUITS LOGIQUES DE
CONVERSION ET DE
SÉLECTION DE DONNÉES
Circuits logiques

❑ Circuits logiques de conversion et de sélection de données

❑ Décodeur

❑ Codeur

❑ Multiplexeur

❑ Démultiplexeur

16
17 Décodeur
Décodeur

❑ Un décodeur a N lignes d’entrée et 2N


lignes de sorties au maximum. N entrées
❑ Il peut avoir une entrée
supplémentaire: signal de validation E0 E1 Ej EN-1
❑ Il établit la correspondance entre un
code d’entré binaire de N-bits et M
sorties.
❑ A une combinaison du signal
d’entrée correspond une unique Décodeur
sortie

1 seule sortie
valide pour un code
d’entrée

S0 S1 Sj SM-1

M sorties
18
Décodeur

❑ Table de vérité

c b a y0 y1 y2 y3 y4 y5 y6 y7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1

19
Décodeur / VHDL

Library ieee; With A select


Use ieee.std_logic_1164.all; Y <=”00000001” when “000”,
”00000010” when “001”,
Entity decodeur is ”00000100” when “010”,
port ( ”00001000” when “011”,
A : in std_logic_vector(2 downto 0); ”00010000” when “100”,
Y : out std_logic_vector (7 downto 0) ”00100000” when “101”,
); ”01000000” when “110”,
End entity decodeur; ”10000000” when “111”,
“00000000” when others;
Architecture vhdl of decodeur is End architecture behav;
Begin

20
21 Codeur
Codeur 4 vers 2
❑ Table de vérité library IEEE;

x3 x2 x1 x0 y1 y0 use IEEE.std_logic_1164.all;
0 0 0 1 0 0 entity encoder42 is
0 0 1 0 0 1 port (X: in std_logic_vector(3 downto 0);
0 1 0 0 1 0
Y: out std_logic_vector(1 downto 0));
1 0 0 0 1 1
End entity encoder42;
architecture csel of encoder42 is
begin
with X select

End architecture csel; 22


Multiplexeur
Multiplexeur 4->1

❑ Multiplexeur 4 vers 1 de 1 bits


❑ comm : entrée de contrôle sur 2 bits

A,B,C,D : entrées de données


S : sortie

comm
comm s
0 0 A A
B MUX S
0 1 B C 4:1
D
1 0 C
1 1 D

24
Multiplexeur 4->1: 1bit
Library ieee;
Use ieee.std_logic_1164.all;

Entity multiplexeur41_1bits is
port (
A,B,C,D : in std_logic;
comm : in std_logic_vector(1 downto 0);
sortie : out std_logic
);
End entity multiplexeur41_1bits;

Architecture truthtable of multiplexeur41_1bits is


Begin
With select
sortie<=

End architecture truthtable;


25
Démultiplexeur
Demux 1->4

❑ Architecture
❑ a et b : entrées de contrôles

❑ E : entrée de données
❑ s0…s3 : sorties de données

a b
a b S0 S1 S2 S3
0 0 E 0 0 0 S0
E DEMUX S1
0 1 0 E 0 0 1:4 S2
S3
1 0 0 0 E 0
1 1 0 0 0 E

27
Démultiplexeur 1->4 : 1 bit
Library ieee;
Use ieee.std_logic_1164.all;

Entity demultiplexeur14_1bits is
port (
E : in std_logic;
a, b : in std_logic ;
S0, S1, S2, S3 : out std_logic
);
End entity demultiplexeur14_1bits;

Architecture dataflow of demultiplexeur14_1bits


Begin
S0 <= E and (not a) and (not b) ;

End architecture dataflow; 28


Démultiplexeur 1->4: 1 bit
Library ieee; Architecture algo of demultiplexeur14_1bit
Use ieee.std_logic_1164.all; Signal ……………..
Begin
Entity demultiplexeur14_1bit is ………………………….
port ( Process (…………………………………… )
E : in std_logic; Begin
a, b : in std_logic ; S0 <= ‘0’ ;
S0, S1, S2, S3 : out std_logic S1 <= ‘0’ ;
); S2 <= ‘0’ ;
End entity demultiplexeur14_1bit; S3 <= ‘0’ ;

If

end if;
end process ;

End architecture algo; 29


Démultiplexeur 1->4: 4 bits
Library ieee; Architecture algo of demultiplexeur14_4bits
Use ieee.std_logic_1164.all; Signal ………………………………………….
Begin
Entity demultiplexeur14_4bits is Process ( ……………………………………….. )
port ( Begin
E : in std_logic_vector(3 downto 0); S0 <= “0000” ;
a, b : in std_logic; S1 <= “0000” ;
S0 : out std_logic_vector(3 downto 0); S2 <= “0000” ;
S1 : out std_logic_vector(3 downto 0); S3 <= “0000” ;
S2 : out std_logic_vector(3 downto 0);
S3 : out std_logic_vector(3 downto 0) If
);
End entity demultiplexeur14_4bits;

end if;
end process ;

End architecture algo; 30


CIRCUITS DES OPERATIONS
ARITHMETIQUES
Circuits arithmétiques

❑ Circuits arithmétiques

❑ Comparateur

❑ Additionneur

32
COMPARATEUR
Comparateur

❑ Un comparateur est un circuit permettant de connaître si deux opérandes


de N bits sont entres elles :
❑ Egales
❑ Inférieurs
❑ Supérieurs

B A
N N

Circuit de décision

1 1 1

A<B A=B A>B

34
Comparateur 4 bits en VHDL
Architecture sequentiel of comparateur_4bit
Begin
Library ieee;
Use ieee.std_logic_1164.all;

Entity comparateur_4bits is
port (
A : in std_logic_vector (3 downto 0);
B : in std_logic_vector (3 downto 0);
Egal : out std_logic;
Sup : out std_logic;
Inf : out std_logic
);
End entity comparateur_4bits;

End architecture sequentiel; 35


ADDITIONNEUR
Additionneur 1 bit
Half Adder - HA
Library ieee;
Use ieee.std_logic_1164.all;

Entity half_adder is si = a i  bi
port (
ci+1 = a i bi
A : in std_logic;
B : in std_logic;
S : out std_logic;
C : out std_logic
);
End entity half_adder; Génération d’une retenue

Architecture dataflow of half_adder ai si


Begin bi
S <= A xor B;
C <= A and B;
ci+1
End architecture dataflow;
37
Additionneur complet (FA)
s i = a i  bi  ci = HAsi ( HAsi (a i , b i ), ci )
ci +1 = a i b i + ci (a i  b i )
ci +1 = HAci+1 (a i , b i ) + HAci+1 ( HAsi (a i , b i ), ci )

ai ai si ai si si ai
si
HA HA bi FA
bi bi ci+1 bi ci+1
ci+1 ci ci+1
ci
38
Additionneur 1 bit
Full Adder - FA
Library ieee;
Use ieee.std_logic_1164.all;

Entity full_adder is
port (
A, B, Cin : in std_logic; ai ai si ai si si
HA HA
S, Cout : out std_logic );
bi bi ci+1 bi ci+1
ci+1
End entity full_adder;
Architecture struct of full_adder ci

Begin

End architecture struct; 39


40

GÉNÉRICITÉ
Généricité

❑ La généricité permet de décrire des blocs paramétrés


❑ Ces blocs seront plus tard instanciés avec la valeur des paramètres pour
créer un composant
❑ On dispose ainsi de modèle de composant
❑ Déclaration d’entité d’un composant générique:

entity nom_composant is
generic ( paramètre1 : type [:= valeur_par_défaut];
paramètre2 : type[:= valeur_par_défaut] );

Port
( …… );
End entity nom_composant;
41
Généricité
❑ On peut spécifier des valeurs par défaut pour les paramètres génériques
❑ La valeur par défaut sera utilisée lors de l’instanciation du bloc si le
paramètre correspondant est omis.

❑ Exemple: Porte ET à n entrées

entity porte_ET is
generic ( N natural := 2);

Port(
entrees: in Bit_vector ( 0 to N-1 ) ;
sortie: out bit
);
end entity porte_ET;

42
Généricité
❑ L’entité est générique, mais pas l’architecture.
❑ L’architecture doit supporter cette généricité

❑ Exemple: Porte ET à n entrées

Architecture arch of porte_ET is


Begin
process (entrees)
variable V : std_logic := ‘1’ ;
begin
for i in 0 to N-1 loop
V := V and entrees (i) ;
end loop ;
sortie <= V ;
end process ;
end Architecture arch; 43
Instanciation d’un composant générique
❑ L'instanciation d'un composant se fait dans le corps de l'architecture avec la
clause generic map :
Architecture arc of circuit is
entity circuit is component porte_ET
generic ( N : natural );
port (
Port(
entrees: in Bit_vector (0 to N-1 ) ;
A: in Bit_vector ( 0 to 3 ) ;
Sout: out bit sortie: out bit
);
);
end component;
end circuit ;
signal S : std_logic;
…..
begin
inst_ET : porte_ET
generic map (N=>4);
port map (entrees=>A, sortie=>S);
...
end arc;

44

Vous aimerez peut-être aussi