Vous êtes sur la page 1sur 25

Chapitre 5 : Description structurelle

Chapitre 5 : Description structurelle


Sommaire
Introduction
1. Déclaration des composants
2. Instanciation des composants
3. Déclaration GENERIC
4. Organisation physique des composants
5. Applications

Par M. JAROU 1|Pa g e


Chapitre 5 : Description structurelle

Introduction
Dans ce type de description, on utilise des composants (component)
étant des blocs logiques qui existent déjà dans une libraire de travail
(WORK) sous forme d’entité de conception.

La description structurelle en VHDL, se contente de d’instancier


les composants nécessaires et de décrire leurs interconnexions.

Les composants sont des modèles déjà développés et réutilisés dans


le nouveau modèle.

Le composant doit être déclaré au niveau du nouveau modèle :


– dans la partie déclarative de l'architecture
– ou dans un package auquel l'architecture doit faire référence

Règles de structuration des composants


 Un composant peut être constitué lui-même d'autres composants
 Dans une architecture utilisatrice, les composants sont reliés entre
eux par l'intermédiaire de signaux internes.
 On n’affecte pas de sens à un signal interne comme on le fait pour
un signal d’entité.

La description structurelle au sens VHDL:


 Description de type hiérarchique par liste de connexions et le
nombre de niveaux de hiérarchie est quelconque
 Permet de construire une description à partir de couples entité-
architecture
 comporte un ou plusieurs composants (component)

Exemple :

Par M. JAROU 2|Pa g e


Chapitre 5 : Description structurelle

Par M. JAROU 3|Pa g e


Chapitre 5 : Description structurelle

1. Déclaration des composants


La déclaration d'un composant spécifie :
– le nom
– le nom des ports
– la direction des données (in, out, inout, buffer)
– le type de ses ports
– les valeurs par défaut (optionnel)

Syntaxe : Déclaration d’un composant


component nom_composant
port (
identificateur:mode type_signal;
[identificateur:mode type_signal);
end component nom_composant;

Syntaxe : Entité d’un composant


entity nom_composant is
port (
identificateur:mode type_signal;
[identificateur:mode type_signal);
end component nom_composant;

La déclaration est faite :


 soit dans la zone de déclaration d'une architecture de
l’utilisateur. Le composant est décrit dans un fichier séparé sans
paquetage.
 soit dans un paquetage visible depuis cette architecture. Le
composant est décrit dans un fichier séparé avec paquetage rangé
dans une bibliothèque.

Par M. JAROU 4|Pa g e


Chapitre 5 : Description structurelle

2. Instanciation des composants


Chaque instance est une copie unique du composant avec un nom
(étiquette ou label) et une liste de ports.

Syntaxe : Instanciation d’un composant


Etiquette : nom_composant
port map (
nom_de_signal | nom_de_variable | expression |
open
[,nom_de_signal | nom_de_variable | expression |
open]
);
Pour chaque instance, il convient de lister les signaux dans l'ordre
défini dans la déclaration du composant.

Exemple 1: Multiplexeur à 2 voies


entity multiplexeur2_1 is
port( e0, e1 : in std_logic;
sel : in std_logic;
s : out std_logic);
end;

--Description par flot de données


architecture flot of multiplexeur2_1 is
signal sel0, sel1: bit_logic
begin
sel0 <= e0 and not sel;
sel1 <= e1 and sel;
s <= sel0 or sel1;
end flot;

Par M. JAROU 5|Pa g e


Chapitre 5 : Description structurelle

--Description structurelle
architecture struct of multiplexeur2_1 is

component inverseur
port ( a : in std_logic ;
s : out std_logic );
end component;

component et
port ( a, b : in std_logic ;
s : out std_logic );
end component;

component ou
port ( a, b : in std_logic;
s : out std_logic );
end component;

Signal nonsel, sel0, sel1: bit_logic

begin
complem : inverseur port map (sel, nonsel);
choix0 : et port map (nonsel, e0, sel0);
choix1 : et port map (sel, e1, sel1);
result : OU port map (sel0, sel1, s);

end struct;

Par M. JAROU 6|Pa g e


Chapitre 5 : Description structurelle

-- Définition de l’architecture des composants


entity inverseur is
port (a : in std_logic;
s : out std_logic);
end inverseur;

architecture A_ inverseur of inverseur is


begin
s <= not a;
end A_ inverseur;

entity OU is
port (E1, E2 : in std_logic;
S1 : out std_logic);
end OU;

architecture A_OU of OU is
begin
S1 <= E1 OR E2;
end A_OU;

entity ET is
port (E3, E4 : in std_logic;
S2 : out std_logic);
end ET;

architecture A_ET of ET is
begin
S2 <= E3 AND E4;
end A_ET;

Par M. JAROU 7|Pa g e


Chapitre 5 : Description structurelle

Exemple 2: Additionneur de 1bit


-- Définition du package XOUET
package XOUET is
component XOU
port (E1, E2 : in std_logic; S : out std_logic);
end component;

component ET
port (E1, E2 : in std_logic; S : out std_logic);
end component;
end XOUET;

-- Définition de l’architecture des composants

entity XOU is
port (E1, E2 : in std_logic;
S1 : out std_logic);
end XOU;

architecture A_XOU of XOU is


begin
S1 <= E1 XOR E2;
end A_XOU;

entity ET is
port (E3, E4 : in std_logic;
S2 : out std_logic);
end ET;

architecture A_ET of ET is
begin
S2 <= E3 AND E4;
end A_ET;

Par M. JAROU 8|Pa g e


Chapitre 5 : Description structurelle

-- Définition de l’entité et l’architecture de l’additionneur

entity add is
port (A, B : in bit; Som, Ret : out std_logic);
end add;

use work.XOUET.all ; -- rend visible le contenu de


-- XOUET

architecture Arch_structurelle of add is

component XOU
port (E1, E2 : in std_logic; S : out std_logic);
end component;

component ET
port (E1, E2 : in std_logic; S : out std_logic);
end component;

begin
U1 : XOU port map (A, B, Som);
U2 : ET port map (A, B, Ret);
end arch_structurelle;

Par M. JAROU 9|Pa g e


Chapitre 5 : Description structurelle

Exemple 3: Porte Ou Exclusive


Ayant défini les opérateurs élémentaires ET, OU et NON, il est
possible de les utiliser dans une construction comme le OU
EXCLUSIF.

entity ouex is -- operateur ou exlusif


port ( a, b : in std_logic;
s : out std_logic );
end ouex;

use work.portelem.all ; -- rend visible le contenu de


-- portelem

architecture struct of ouex is

component inverseur
port ( e : in std_logic; -- les entrees
s : out std_logic); -- les sorties
end component;

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

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

signal abar,bbar,abbar,abarb : std_logic;

begin -- les differents composants sont instancies ici


i1 : inverseur port map (a,abar);
i2 : inverseur port map (b,bbar);
et1 : et port map (a,bbar,abbar);
et2 : et port map (b,abar,abarb);
ou1 : ou port map (abbar,abarb,s);
end struct;

Pour que le programme précédent soit compilé correctement, il faut au


préalable créer et compiler le paquetage portelem et la description des
opérateurs élémentaires qui y sont décrits comme suit :

Par M. JAROU 10 | P a g e
Chapitre 5 : Description structurelle

-- Définition du package portelem


package portelem is
component inverseur
port ( e : in std_logic ; -- les entrees
s : out bit ); -- les sorties
end component;

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

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

end portelem;

-- Définition de l’entité et l’architecture des composants

-- operateur inverseur
entity inverseur is
port ( e : in std_logic ;
s : out std_logic );
end inverseur;

architecture arch_inverseur of inverseur is


begin
s <= not e;
end arch_inverseur;

-- operateur et
entity et is
port ( e1, e2 : in std_logic ;
s : out std_logic );
end et;

architecture arch_et of et is
begin
s <= e1 and e2;
end arch_et;

-- operateur ou
entity ou is
port ( e1, e2 : in std_logic ;
s : out std_logic );
end ou;

architecture arch_ou of ou is
begin
s <= e1 or e2;
end arch_ou;

Par M. JAROU 11 | P a g e
Chapitre 5 : Description structurelle

Autres implémentations de OU Exclusif


L’opérateur OU EXCLUSIF n’est autre que Si deux opérandes binaires sont différents le
l’opérateur d’addition en base deux, le résultat de l’opérateur OU EXCLUSIF est
programme suivant en est la conséquence directe '1' :
:

-- operateur ou exlusif -- operateur ou exlusif


entity ouex is entity ouex is
port (a,b :in integer range 0 to 1 ; port ( a, b : in bit ;
s : out integer range 0 to 1 s : out bit );
); end ouex;
end ouex;
architecture compare of ouex is
architecture arith of ouex is begin
begin s <= '0' when a = b
s <= a + b; else '1';
end arith; end compare;

Par M. JAROU 12 | P a g e
Chapitre 5 : Description structurelle

Exemple 4: Indicateur de parité impaire


Nous terminerons cette découverte du OU EXCLUSIF par sa
généralisation comme contrôleur de parité d’un mot d’entrée de 16
bits:
-- Opérateur ou exlusif generalize

-- Contrôleur de parité de 4bits


entity ouex4 is

port (a : in std_logic_vector(0 to 3) ;
s : out std_logic );
end ouex4;

architecture parite of ouex4 is


begin
process(a)
variable parite : bit ;
begin
parite := '0' ;
for i in 0 to 3 loop
if a(i) = '1' then
parite := not parite;
end if;
end loop;
s <= parite;
end process;
end parite;

-- Contrôleur de parité de 16bits


entity ouex16 is
port (e : in std_logic_vector(0 to 15);
s : out std_logic_vector (0 to 3);
-- force la conservation des signaux intermédiaires
s16 : out bit); -- le résultat complet
end ouex16;

architecture struct of ouex16 is

component ouex4
port ( a : in std_logic_vector(0 to 3) ;
s : out bit );
end component;

signal inter : std_logic_vector(0 to 3);

begin
par16 : for i in 0 to 3 generate
g1 : ouex4 port map (e(4*i to 4*i + 3),inter(i));
end generate;
g2 : ouex4 port map (inter,s16);
s <= inter;
end struct;

Par M. JAROU 13 | P a g e
Chapitre 5 : Description structurelle

On notera l’intérêt des boucles « generate» pour créer des motifs


répétitifs.
Exercice d’application :
- Réaliser un additionneur de 4 bits à partir d’un additionneur de 1bit
- Réaliser un soustracteur de 4 bits à partir d’un soustracteur de 1bit
- Réaliser un comparateur de 4 bits à partir d’un comparateur de 1bit
- Réaliser un compteur de 8 bits à partir d’un compteur de 4bit

Par M. JAROU 14 | P a g e
Chapitre 5 : Description structurelle

3. Déclaration GENERIC
Au sein de la description VHDL d’une structure logique, il est
possible de rajouter une déclaration GENERIC pour déclarer des
paramètres.

Typiquement, on utilise une déclaration de GENERIC pour spécifier


des temps de propagation et autres délais de portes logiques.

Ces temps seront alors modifiables lors de l'utilisation de ces portes


logiques dans une description structurelle (Description avec les
composants).

Exemple 1 :
--Porte OU
entity OU is
generic (TP : time := 20 ns);
port (E1, E2 : in std_logic;
S1 : out std_logic);
end OU;

architecture OU of OU is
begin
S1 <= E1 or E2 after TP;
end OU;

--Porte ET
entity ET is
GENERIC (TP : time := 0 ns);
port (E1, E2 : in std_logic;
S1 : out std_logic);
end ET;

architecture ET of ET is
begin
S1 <= E1 and E2 after TP;
end ET;

Par M. JAROU 15 | P a g e
Chapitre 5 : Description structurelle

--Porte ET_OU

Entity ET_OU is
port (A, B : in std_logic;
X, Y : out std_logic);
end ET_OU;

architecture ET_OU of ET_OU is

component OU
generic (TP : time);
port (E1, E2 : in std_logic;
S1 : out std_logic);
end component;

component ET
generic (TP : time);
port (E1, E2 : in std_logic;
S1 : out std_logic);
end component;

begin
U1 : OU generic map ( TP => 5 ns )port map(A, B, X);
U2 : ET generic map ( TP => 15 ns )port map(A, B, Y);
end ET_OU;

Exemple 2:
entity UAL_generique is
generic ( width : integer := 4);
port (op : in std_logic_vector (1 downto 0);
a : in std_logic_vector (width-1 downto 0);
b : in std_logic_vector (width-1 downto 0);
...
end UAL_generique;

Par M. JAROU 16 | P a g e
Chapitre 5 : Description structurelle

Exemple 3:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all; -- for the unsigned type

entity COUNTER is
generic (
WIDTH : in natural := 32);
port (
RST : in std_logic;
CLK : in std_logic;
LOAD : in std_logic;
DATA : in std_logic_vector(WIDTH-1 downto 0);
Q : out std_logic_vector(WIDTH-1 downto 0));
end entity COUNTER;

architecture RTL of COUNTER is


signal CNT : unsigned(WIDTH-1 downto 0);
begin
process(RST, CLK) is
begin
if RST = '1' then
CNT <= (others => '0');
elsif rising_edge(CLK) then
if LOAD = '1' then
CNT <= unsigned(DATA); -- type is converted to
unsigned
else
CNT <= CNT + 1;
end if;
end if;
end process;

Q <= std_logic_vector(CNT); -- type is converted back to


std_logic_vector
end architecture RTL;

Par M. JAROU 17 | P a g e
Chapitre 5 : Description structurelle

4. Organisation physique des composants


- Description dans un seul fichier, rangé dans la bibliothèque
prédéfinie work, contenant :
 l’entité/architecture du composant
 l’entité/architecture utilisatrice
o l’architecture utilisatrice comporte la déclaration du
composant (component)
o l’architecture utilisatrice comporte les instances du composant

- Description dans deux fichiers rangés tous deux dans la


bibliothèque work :
 un fichier contenant l’entité/architecture du composant
 un fichier contenant l’entité/architecture utilisatrice
o l’architecture utilisatrice comporte la déclaration du
composant
o l’architecture utilisatrice comporte les instances du composant

- Description dans deux fichiers avec une bibliothèque spécifique


:
 un fichier, rangé dans bibliothèque spécifique créée par le
concepteur, contenant
o un paquetage incluant la déclaration de composant
o l’entité/architecture du composant
 un fichier, rangé dans la bibliothèque work, contenant :
o la déclaration d’usage de la bibliothèque (library et use)
o l’entité/architecture utilisatrice

Peuvent être compilées séparément -(Un seul fichier *.vhd ou


plusieurs)

Par M. JAROU 18 | P a g e
Chapitre 5 : Description structurelle

5. Application:
Concevoir un compteur BCD 4 bits comme bloc logique cntbcd et
le définir comme un composant.

Instancier le composant deux fois pour créer un compteur BCD 2


digits counter.
--Description VHDL dans un seul fichier
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- Entité/architecture du composant
entity c_cntbcd is port (
rst, clk, en : in std_logic;
co : out std_logic;
q : out std_logic_vector(3 downto 0) );
end c_cntbcd;

architecture Behavioral of c_cntbcd is


begin
-- Description du comportement du composant
end Behavioral;

Par M. JAROU 19 | P a g e
Chapitre 5 : Description structurelle

-- Entité/architecture utilisatrice

entity counter is port(


rst, clk : in std_logic;
q0, q1 : out std_logic_vector(3 downto 0)
);
end counter;

architecture archcounter of counter is


-- Déclaration de composants et de signaux
auxiliaires
signal co0, co1 : std_logic;
signal sq0, sq1 : std_logic_vector (3 downto 0);
signal en0, en1 : std_logic;

component c_cntbcd port (


rst, clk, en : in std_logic;
co : out std_logic;
q : out std_logic_vector(3 downto 0) );
end component;

begin
en0 <= '1';
bcd0: c_cntbcd port map (rst, clk, en0, co0, sq0);
en1 <= co0;
bcd1: c_cntbcd port map (rst, clk, en1, co1, sq1);
q0 <= sq0;
q1 <= sq1;
end archcounter;

Par M. JAROU 20 | P a g e
Chapitre 5 : Description structurelle

--Description VHDL dans deux fichiers de la bibliothèque work


-- Entité/architecture du composant (1er fichier)
package pack_cnt is

component c_cntbcd port (


rst, clk, en : in std_logic;
co : out std_logic;
q : out std_logic_vector(3 downto 0) );
end component;

end pack_cnt;

entity c_cntbcd is
Port(
…);
end c_cntbcd;

architecture Behavioral of c_cntbcd is


begin
-- Description du comportement du composant
end Behavioral;

-- Entité/architecture utilisatrice (2ème fichier)


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

use work.pack_cnt.all

entity counter is port(


…);
end counter;

architecture archcounter of counter is


-- Déclaration de composants et de signaux auxiliaires
signal co0, co1 : std_logic;
signal sq0, sq1 : std_logic_vector (3 downto 0);
signal en0, en1 : std_logic;

component c_cntbcd port (


rst, clk, en : in std_logic;
co : out std_logic;
q : out std_logic_vector(3 downto 0) );
end component;

begin
en0 <= '1';
bcd0: c_cntbcd port map (rst, clk, en0, co0, sq0);
en1 <= co0;
bcd1: c_cntbcd port map (rst, clk, en1, co1, sq1);
q0 <= sq0;
q1 <= sq1;
end archcounter;

Par M. JAROU 21 | P a g e
Chapitre 5 : Description structurelle

--Description VHDL dans deux fichiers avec paquetage dans une


bibliothèque spécifique

-- 1er Fichier Package rangé ds une bibliothèque Lib_cnt


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- Déclaration de paquetage et de composant


package pack_cnt is

component c_cntbcd port (


rst, clk, en : in std_logic;
co : out std_logic;
q : out std_logic_vector(3 downto 0) );
end component;

end pack_cnt;

-- Entité/architecture du composant
entity c_cntbcd is
Port ( rst, clk, en : in std_logic;
co : out std_logic;
q : out std_logic_vector (3 downto 0));
end c_cntbcd;

architecture Behavioral of c_cntbcd is


-- Description du comportement du composant
begin
-- Description du comportement du composant
end Behavioral;

Par M. JAROU 22 | P a g e
Chapitre 5 : Description structurelle

-- 2ème Fichier rangé dans la bibliothèque stadard work


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

--Déclaration d’accès au paquetage pack_cnt rangé à la


bibliothèque Lib_cnt

library Lib_cnt
use Lib_cnt.pack_cnt.all;

-- Entité/architecture utilisatrice
entity counter is port(
clk, rst : in std_logic;
q0, q1 : out std_logic_vector(3 downto 0));
end counter;

architecture archcounter of counter is


signal co0, co1 : std_logic;
signal sq0, sq1 : std_logic_vector (3 downto 0);
signal en0, en1 : std_logic;

component c_cntbcd port (


rst, clk, en : in std_logic;
co : out std_logic;
q : out std_logic_vector(3 downto 0) );
end component;

begin
en0 <= '1';
bcd0: c_cntbcd port map (rst, clk, en0, co0, sq0);
en1 <= co0;
bcd1: c_cntbcd port map (rst, clk, en1, co1, sq1);
q0 <= sq0;
q1 <= sq1;
end archcounter;

Par M. JAROU 23 | P a g e
Chapitre 5 : Description structurelle

Exemple :

Déclaration des composants

Package SN_COMPONENTS is component NOR2


port (E1 : in bit;
component INV E2 : in bit;
port (E : in bit; S : out bit);
S : out bit); end component;
end component; component RS
port (R : in bit;
component AND2 S : in bit;
port (E1 : in bit; CK : in bit;
E2 : in bit; Q : out bit;
S : out bit); QB: out bit);
end component; end component;
End SN_COMPONENTS;
component OR2
port (E1 : in bit;
E2 : in bit;
S : out bit);
end component;

Description de l'architecture

entity SN_95 is
port ( SERIAL : in bit;
D : in bit_vector (1 to 4) ;
MODE : in bit;
SHIFT : in bit;
LOAD : in bit;
Q : inout bit_vector (1 to 4 )) ;
end SN_95 ;

architecture structurelle of SN_95 is

use WORK.SN_COMPONENTS.all;

signal W1,W2,W3,W4,CK : bit;


signal W6,W7,R,S : bit_vector (1 to 4);

begin
G1 : INV port map (MODE,W1);
G2 : INV port map (W1,W2);
G3 : AND2 port map (SHIFT,W1,W3);
G4 : AND2 port map (LOAD,MODE,W4);
G5 : OR2 port map (W3,W4,CK);
REG : for i in 1 to 4 generate
PREM : if i = 1 generate
G6 : AND2 port map (SERIAL, W1,W6(i));
G7 : AND2 port map (D(i), W2,W7(i));
G8 : NOR2 port map (W6(i), W7(i),R(i));
G9 : INV port map (R(i),S(i));
GRS : RS port map (R(i),S(i),CK,Q(i),open);
end generate;
autre : if i/= 1 generate
G6 : AND2 port map (Q(i-1), W1,W6(i));
G7 : AND2 port map (D(i), W2,W7(i));

Par M. JAROU 24 | P a g e
Chapitre 5 : Description structurelle

G8 : NOR2 port map (W6(i), W7(i),R(i));


G9 : INV port map (R(i),S(i));
GRS : RS port map (R(i),S(i),CK,Q(i),open);
end generate
end generate
end structurelle;

Configuration du système : permet d'associer à chaque instance, une entité et


une architecture

library TTL;
configuration config_1 of SN_95 is
for structurelle
for all : AND2 use entity TTL.AND2(FAST); end for;
for all : OR2 use entity TTL.OR2(FAST); end for;
for G1,G2 : INV use entity TTL.INVERTER(MU07); end for;
for REG
for all : NOR2 use entity TTL.NOR2(FAST); end for;
for all : RS use entity TTL.BASC_RS(BEH); end for;
for PREM
for G9 : INV use entity TTL.INVERTER(FAST); end for;
end for;
for AUTRE
for G9 : INV use entity WORK.INVERSEUR(le_mien); end
for;
end for;
end for;
end structurelle;

Par M. JAROU 25 | P a g e

Vous aimerez peut-être aussi