Académique Documents
Professionnel Documents
Culture Documents
Circuits combinatoires
Description VHDL
E. Amouri
Plan
❑ Process
❑ Simulateur VHDL
❑ Circuits arithmétiques
2
PROCESS
Process
4
Process
REGLE FONDAMENTALE
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
❑ Mise à jour des sorties des process à la fin de l’exécution de tous les
process
8
Process et Simulation
9
Exemple 1
entity Exemple is
Port (clk,e: in std_logic;
s: out std_logic);
End entity Exemple;
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
❑ Décodeur
❑ Codeur
❑ Multiplexeur
❑ Démultiplexeur
16
17 Décodeur
Décodeur
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
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
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
❑ 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;
If
end if;
end process ;
end if;
end process ;
❑ Circuits arithmétiques
❑ Comparateur
❑ Additionneur
32
COMPARATEUR
Comparateur
B A
N N
Circuit de décision
1 1 1
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;
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
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
GÉNÉRICITÉ
Généricité
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.
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é
44