Académique Documents
Professionnel Documents
Culture Documents
VHDL
2018-2019
Introduction – Qu’est ce que VHDL
2
Introduction – Qu’est ce que VHDL
Système matériel:
3
Introduction – Qu’est ce que VHDL
• Langage puissant
(Il supporte plusieurs niveaux d’abstraction et autorise des
descriptions
hiérarchiques: descriptions comportementales (fonctionnelles) aussi
bien
que structurelles.
VHDL favorise une approche hiérarchique pour la description d’un
circuit complexe)
• Standard IEEE.
(Standardisation afin d’assurer une portabilité des programmes tant en
synthèse qu’en simulation)
4
Introduction – Qu’est ce que VHDL
5
VHDL - Historique et évolution..
8
VHDL – Simulation et synthèse
Algorithme de la simulation logique
9
VHDL – Simulation et synthèse
Synthèse logique
10
Flot de synthèse logique
VHDL – Simulation et synthèse
Synthèse logique
11
VHDL – Simulation et synthèse
Synthèse architecturale
13
VHDL – Simulation et synthèse
Synthèse physique
14
VHDL – Simulation et synthèse
Synthèse physique
Synthèse physique
16
VHDL – Structure du langage
Bibliothèques
17
VHDL – Structure du langage
Bibliothèques
Bibliothèques
• Les bibliothèques sont déclarée avec le mot clé library, elle dépendent
des outils utilisés.
• Elle contiennent des paquetages que l’on déclare vouloir utiliser avec le
mot clé use:
use BIBLIOTHEQUE.PAQUETAGE.all;
19
VHDL – Structure du langage
Bibliothèques
• Par défaut, les outils considère que l’on utilise les bibliothèques STD et
WORK, il y a donc implicitement:
library STD;
library WORK;
20
VHDL – Structure du langage
Bibliothèques
STD_LOGIC_1164.
library ieee;
entity ... is
port (...
p: in ieee.std_logic_1164.std_logic); -- sans clause use
end entity;
library ieee;
use ieee.std_logic_1164.all;
entity ... is
port (...
p: in std_logic); -- avec clause use
end entity;
Toute unité de conception possède une clause de contexte (déclaration de bibliothèque + clause
use) implicite.
library std, work;
use std.standard.all;
21
VHDL – Structure du langage
Unités de conception
22
VHDL – Structure du langage
Entité (Entity)
library ieee;
A
use ieee.std_logic_1164.all; S
B Add
23
VHDL – Structure du langage
Architecture
24
VHDL – Structure du langage
Modèle comportementale
25
VHDL – Structure du langage
Architecture comportementale Nom de l’architecture
27
VHDL – Structure du langage
Architecture structurelle
begin
u0 : porteET
port map ( A, B, S2);
Chaque instance de composant
u1 : porteXOR définit les associations entre
port map ( A, B, S1); ses ports formels et ses ports
effectifs
u2 : porteET
port map ( S1, Cin, S3);
Etiquette (label):
u3 : porteXOR
port map ( S1, Cin, S); obligatoire pour nommer
chaque instance de manière
u4 : porteOU unique.
port map ( S2, S1, Cout);
end structurelle1;
29
VHDL – Structure du langage
Environnement de test
Add_tb
30
VHDL – Structure du langage
Environnement de test
Testbench de l’aditionneur:
-- Bibliothèques
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--Entity
ENTITY Add_tb IS
END Add_tb;
--Architecture
ARCHITECTURE test OF Add_tb IS
31
VHDL – Structure du langage
Environnement de test
Testbench de l’aditionneur:
COMPONENT Add_1
PORT(A0 : in std_logic;
B0 : in std_logic;
Cin0 : in std_logic;
S0 : out std_logic;
Cout0 : out std_logic);
END COMPONENT;
BEGIN
-- Instanciation du composant à tester -- DUT : Design
Under Test
DUT: Add_1 PORT MAP (A0=>A_tb,B0=>B_tb,Cin0=>Cin_tb,
S0=>S_tb,Cout0=>Cout_tb);
32
VHDL – Structure du langage
Environnement de test
Testbench de l’aditionneur:
33
VHDL – Structure du langage
Configuration
library GATES;
configuration add_tb_cfg_str of add_tb is
for bench
for DUT: add_1 use entity WORK.add(str)
port map (A0, B0, Cin0, S0, Cout0);
for str
for all: U0 use entity GATES.AND(bhv);
port map (A => i1, B => i2, S2 <= z);
end for;
for all: U1 use entity GATES.XOR(bhv)
port map (S1 => i1, Cin => i2, S3 <= z);
end for; -- XOR U1
……
end for; -- str
end for; -- DUT
end for; -- bench 35
end configuration add_tb_cfg_str;
VHDL – Structure du langage
Exemple
36
VHDL – Structure du langage
Exemple : Registre 4bits
entity reg4 is
port (
d0, d1, d2, d3: in bit; -- données d’entrée
en, clk: in bit; -- signal de contrôle et
horloge
q0, q1, q2, q3: out bit -- données de sortie
);
end entity reg4;
37
VHDL – Structure du langage
Exemple : Registre 4bits
Architecture comportementale du registre 4 bits.
architecture bhv of reg4 is
begin
process is
variable d0_reg, d1_reg, d2_reg, d3_reg: bit;
begin
if en = ’1’ and clk = ’1’ then
-- mémorisation des entrées
d0_reg := d0;
d1_reg := d1;
d2_reg := d2;
d3_reg := d3;
end if;
-- modification des signaux de sortie
q0 <= d0_reg after 5 ns;
q1 <= d1_reg after 5 ns;
q2 <= d2_reg after 5 ns;
q3 <= d3_reg after 5 ns;
-- attente du prochain événement sur l’un des
signaux d’entrée
wait on d0, d1, d2, d3, en, clk;
end process;
end architecture bhv;
38
VHDL – Structure du langage
Exemple : Registre 4bits
begin
-- instances de latches
bit0: dlatch port map (d => d0, clk => int_clk, q => q0);
bit1: dlatch port map (d => d1, clk => int_clk, q => q1);
bit2: dlatch port map (d => d2, clk => int_clk, q => q2);
bit3: dlatch port map (d => d3, clk => int_clk, q => q3);
-- génération de l’horloge interne
gate: and2 port map (en, clk, int_clk);
40
VHDL – Structure du langage
Exemple : Registre 4bits
entity reg4_tb is
end entity reg4_tb;
begin
-- composant à tester
UUT: c_reg4 port map (p_d0 => s_d0, p_d1 => s_d1, p_d2 =>
s_d2, p_d3 => s_d3,
p_en => s_en, p_clk => s_clk,
p_q0 => s_q0, p_q1 => s_q1, p_q2 => s_q2, p_q3 => s_q3);
-- stimulis
s_clk <= not s_clk after 20 ns; -- période de 40 ns
process
begin
s_en <= ’0’;
s_d0 <= ’1’; s_d1 <= ’1’; s_d2 <= ’1’; s_d3 <= ’1’;
wait for 40 ns;
s_en <= ’1’;
wait for 40 ns; 42
VHDL – Structure du langage
Exemple : Registre 4bits
43
VHDL – Structure du langage
Exemple : Registre 4bits
library GATES;
configuration reg4_tb_cfg_str of reg4_tb is
for bench
for UUT: c_reg4 use entity WORK.reg4(str)
port map (p_d0, p_d1, p_d2, p_d3, p_en, p_clk,
p_q0, p_q1, p_q2, p_q3);
for str
for all: dlatch use entity GATES.dlatch(bhv);
end for;
for all: and2 use entity GATES.and2(bhv)
port map (a => i1, b => i2, z => z);
end for; -- and2
end for; -- str
end for; -- UUT
end for; -- bench
end configuration reg4_tb_cfg_str;
45
VHDL – Structure du langage
Instanciation directe
46
VHDL – Structure du langage
Instanciation directe
library GATES;
architecture str2 of reg4 is
signal int_clk: bit; -- signal interne
begin
-- instanciations directes des latches
bit0: entity GATES.dlatch(bhv)
port map (d => d0, clk => int_clk, q => q0);
bit1: entity GATES.dlatch(bhv)
port map (d => d1, clk => int_clk, q => q1);
bit2: entity GATES.dlatch(bhv)
port map (d => d2, clk => int_clk, q => q2);
bit3: entity GATES.dlatch(bhv)
port map (d => d3, clk => int_clk, q => q3);
-- instanciation directe de la porte and2
gate: entity GATES.and2(bhv)
port map (en, clk, int_clk);
end architecture str2; 47
VHDL – Structure du langage
Spécification de configuration
48
VHDL – Structure du langage
Spécification de configuration
library GATES;
architecture str2 of reg4 is
component and2 is
port (i1, i2: in bit; z: out BIT);
end component and2;
for all: and2 use entity GATES.and2(bhv) port map (i1, i2, z);
component dlatch is
port (d, clk: in BIT; q: out BIT);
end component dlatch;
for all: dlatch use entity GATES.dlatch(bhv);
...
begin
...
end architecture str2; 49
VHDL – Structure du langage
Processus
50
VHDL – Structure du langage
Processus
entity demi_add is
port (A, B: in bit; S, CO: bit);
end entity demi_add;
Carry: process
begin
CO <= A and B;
wait on A, B; Demi additionneur 1bit
end process Carry;
end architecture bhv;
51
VHDL – Structure du langage
Synchronisation de processus
La forme:
wait on liste-de-signaux;
-- p. ex.
wait on S1, S2, S3;
active un processus dès qu’un événement survient sur l’un des signaux de
la liste. La liste des signaux forme une liste de sensibilité (sensitivity list).
52
VHDL – Structure du langage
Synchronisation de processus
La forme:
wait until condition;
-- p. ex.
wait until CLK = ’1’; -- activation sur le flanc montant du signal CLK
wait on CLK until CLK = ’1’; -- forme équivalente
active un processus dès que la condition est vraie. Les signaux impliqués
dans la condition forment une liste de sensibilité. Si la liste est vide,
l’instruction wait stoppe le processus de manière définitive.
53
VHDL – Structure du langage
Synchronisation de processus
La forme:
wait for délai;
-- p. ex.
wait for 10 ns;
La forme générale:
55
VHDL – Généricité
56
VHDL – Généricité
Paramètres génériques :
Temps de maintien
Temps de
prépositionnement
Temps de propagation
57
VHDL – Généricité
entity dff is
generic (
Tpd_clk_q, -- temps de propagation
Tsu_d_clk, -- temps de pré-positionnement
Th_d_clk: delay_length -- temps de
maintien
);
port (clk, d: in bit; q: out bit);
end entity dff;
58
VHDL – Généricité
59
VHDL – Généricité
Le corps d’architecture est composé de trois processus concurrents.
check_setup: process is
begin
wait until clk = ’1’;
assert d’last_event => Tsu_d_clk report "Setup violation";
end process check_setup;
check_hold: process is
begin
wait until clk’delayed(Th_d_clk) = ’1’;
assert d’delayed’last_event => Th_d_clk report "Hold
violation";
end process check_hold;
60
end architecture bhv;
VHDL – Généricité
61
VHDL – Généricité
Objets d’interface non contraints :
entity reg is
port (clk, rst: in bit;
d: in bit_vector;
q: out bit_vector);
begin
assert d’length = q’length;
end entity reg;
63
VHDL – Généricité
Instruction generate :
entity shiftreg is
generic (nbits: positive := 8);
port (clk, rst, d: in bit; q: out bit);
end entity shiftreg;
component dff is
port (clk, rst, d: in bit; q: out bit);
end component dff;
64
VHDL – Généricité
Instruction generate :
entity Et_N is
generic ( N : Natural )
port ( Entrees : in std_logic_vector ( 1 to N ) ;
sortie : out std_logic );
end Et_N ;
66
VHDL – Généricité
Exemple : ET n bits
entity AdditionneurN is
generic (N : Natural);
port (
X, Y : in std_logic_vector ( N-1 downto 0) ;
Cin : in std_logic;
S : out std_logic_vector (N-1 downto 0);
Cout : out std_logic);
end AdditionneurN ;
component Add
port (
A, B, Cin : in std_logic;
S, Cout : out std_logic);
end component;
67
VHDL – Généricité
Exemple : ET n bits
entity AdditionneurN is
..
end AdditionneurN ;
begin
for I in 0 to N-1 generate
Instance : Add
port map (X(I), Y(I), C(I), S(I), C(i+1));
end generate;
C(0) <= Cin;
Cout <= C(N);
end structurelle ;
68
69