Académique Documents
Professionnel Documents
Culture Documents
Un système électronique
numérique peut être Circuit Numérique
implémenté avec des
STANDARD (Conçu et SPECIFIQUE
circuits logiques de Réalisé par le Fabricant) à l'Application
divers types : Séquentiables
Configurables (Full Custom)
Une fonction (Semi Custom)
par circuit
MicroProcesseurs
PLA, PAL, EPLD MicroControleurs
à Mémoire ou CPLD, FPGA DSP
Spécialisés
RAM, ROM Mixtes : FPGA + Micro + RAM
Périphériques
PLDs standard, ASICs 2
SOC(System On Chip)
Connexions programmables
Introduction
Deux formes canoniques pour les équations logiques
Somme de produits S=a.b+ c.d
Produits de somme S=(z+f).(e +x)
Connexions programmables
ET cablé
Représentation standard
OU cablé
3
xPLD
4
FPGA
Exemple de référence
Famille Cyclone (FPGA
Low Cost d’ALTERA)
Concurrent: Spartan3 (chez 5
Xilinx)
REFERENCES DES CIRCUITS LOGIQUES PROGRAMMABLES
6
Kit de Développement : Cyclone III EDA/SOPC System Platform
7
FPGA : EP3C40F780C8
11
NIOSII32 bits processor demo experiment
●Hello experiment
●DIP seitch、key and LED experiment
●Key scan & 8 bits 7 segment display experiment
●Motor velocity measurement
●Timer experiment
●Sequence port communication experiment
●SPI interface audio Codec experiment
●High-speed AD and high-speed DA experiment
●SRAM&DMA experiment
●Flash ROM operation experiment
●Image point array LCD display experiment
●USB communication experiment(Include USB controller)
●Ethernet communication experiment(include Ethernet controller)
●Audio CODEC experiment
●PS2 key experiment
●Infrared communication experiment
●Wire digital temperature meter experiment
13
VHDL: Introduction
Programmation ou description?
Les objectifs du langage VHDL
Conception de circuits intégrés reconfigurable ou non (ASIC, FPGA…) : SYNTHESE
Mise au point de modèle de simulations numériques (circuits virtuels) : MODELISATION
14
VHDL: Concepts de base
Le fichier texte de description: xxx.vhd
Déclaration de l’architecture
15
de Démultiplexeur
Flot de conception
Un outils de développement: Quartus II d’Altera
Entrée schématique Entrée syntaxique Diagrammes d’états
Langages :VHDL
VHDL VHDL VHDL
Vérification des erreurs de Simulation
schémas et de syntaxe STIMULI ou
comportementale
VHDL TESTBENCH
SYNTHETISEURS CONNUS: SYNTHETISEUR
- FPGA Express (Synosys) Il convertit en fonction du circuit cible
-EXEMPLAR (ExemplAr) (CPLD ou FPGA: suivant le modèle
VITAL, VHDL
choisi) le projet en portes logiques et Simulation Après
-SYNPLICITY (Synplicity)
bascules de bases. synthèse
STIMULI ou
De plus, on peut lui spécifier des
contraintes technologiques tel que la TESTBENCH
vitesse de fonctionnement
EDIF, XNF
Outils de Placement et Routage au circuit interne: Optimisation VITAL, VHDL, SDF
Simulation
Chaque outil est propre à chaque fabricant Placement/Routage
temporelle
dans circuit choisi STIMULI ou
JEDEC TESTBENCH
La programmation du circuit se fait soit
-En utilisant un Programmateur CIRCUIT
CPLD
-En téléchargeant le code JEDEC directement FPGA 16
sur l’objet technique (JTAG ou ISP)
VHDL: Concepts de base
Méthodologie de conception
Guide pratique du débutant
Décomposition du cahier des charges en fonctions élémentaires
Classification de la fonction
• COMBINATOIRE: instructions dites concurrentes
• SEQUENTIELLE: utilisation d’un processus (PROCESS)
La sortie ne dépend pas de l’état passé La sortie dépend de son état passé
• Multiplexeurs • Compteurs
• Encodeurs de priorité 17
VHDL: Concepts de base
Les questions à se poser
On identifie les fonctions et on les dessine sur papier
On repère et on nomme les entrées de chaque blocs ( on évite d’utiliser
les mêmes noms)
On répertorie les signaux INTERNES (mot clé SIGNAL)
Le bloc est-il combinatoire ou séquentiel?
Si séquentiel alors description avec le mot clé PROCESS + instructions autorisées
X1 A
Il faut un SIGNAL
ET2 S
X2 B
Fil1 On créera 1 composant ET2
A
ET2 S (entity+architecture) Utilisé 3
B
Y fois pour décrire ET4
X3 A Fil2
ET2 S
X4 B ET4 ET4 est un composant
(entity+architecture) 18
VHDL: Concepts de base
Un autre exemple: Horloge BCD 2 digits
Blocs décodeurs 7 segments - combinatoire
Blocs compteurs – séquentiel
Les Blocs compteurs sont cascadé pour la propagation de la retenue
Après 9 on a 0 avec 1 de retenue! Donc Affichage 10
H U2 Q In U4 Out
Décodeur Seg2[6..0]
Compteur Fil2[3..0] 7 Segments
R
Sorties pilotant les Leds
En
de l’afficheur 2
port(
Ci : IN std_logic;
X,Y : IN std_logic;
S,Cout : OUT std_logic
);
ARCHITECTURE …..
L’ordre des instructions est SANS
IMPORTANCE ( car en parallèle) COMPONENT Truc
…
END COMPONENT
Déclaration de
Il est souhaite de scinder les projets en COMPONENT Machin composants
…
composants simples END COMPONENT
créés
APPROCHE METHODOLOGIQUE TOP-DOWN
SIGNAL: ……….
SIGNAL: ……..
Utilisation des bibliothèques IEEE
XX<=“1110”;
YY<= A AND B; Utilisation
U1: Truc PORT MAP( …….); des
Squelette de S<= “10” when (A=B) else
ressources
“00”;
description U2: Machin PORT MAP( …….); disponibles
VHDL With (Toto) select
G<= ……
END ARCHITECTURE
29
Logique combinatoire: Exemple
Décodeurs 7 segments ?
UTILISATION D’UNE TABLE (LUT) POUR DECRIRE LE SYSTEME
Création de nouveaux
library IEEE;
use IEEE.std_logic_1164.all; types: TYPE
Anode commune use IEEE.std_logic_unsigned.all; Tableau: ARRAY
Segment actif à ‘0’ --definition de l'architecture
architecture arch_dec_7seg of decod7seg is
-- definition d'un nouveau type
-- tableau de 16 elements de 7 bits
type MemROM is array(15 downto 0) of
std_logic_vector(6 downto 0);
--initialisaion du tableau
-- tableau vu comme une memoire(LUT)
signal Tableau : MemROM := (
"1000000","1111001","0100100","0110000","0011001",
"0010010","0000010","1111000","0000000","0011000","
0001000","0000011" ,"1000110","0100001","0000110","
0001110");
begin
entity decod7seg is -- pour indexer tableau il faut un entier
port( -- fonction de conversion conv_integer dans
InSeg : IN std_logic_vector(3 downto 0); IEEE.std_logic_unsigned.all
OutSeg : OUT std_logic_vector(6 downto 0) OutSeg <= Tableau(conv_integer(InSeg));
end arch_dec_7seg;
);
end decod7seg; 30
Logique combinatoire: Exemple
Additionneur « haut niveau »
Emploi des librairies IEEE;
On augmente la taille de 1 si l’on
souhaite conserver la retenue d’entrée architecture arch1_add4full of adddirect is
--création de TEMP pour résultat: extension de 1 bit
signal TEMP : std_logic_vector(LARG downto 0);
begin
library IEEE;
TEMP <= ('0'&A)+('0'&B)+Cin;
use IEEE.std_logic_1164.all;
--A et B étendu chacun de 1 bit.
use IEEE.std_logic_unsigned.all;
Res <= TEMP(TEMP'HIGH-1 downto 0);
Cout <= TEMP(TEMP'HIGH);
entity adddirect is
--TEMP'HIGH renvoi indice poids fort
generic (LARG:integer:=4);
end arch1_add4full;
-- paramètre générique
-- taille additionneur changer en 1 clic! Les attributs des signaux -Exemple S[5:0]
Buffers 3 états
LIBRARY ieee;
USE ieee.std_logic_1164.all;
----------------------------------------------
ENTITY tri_state IS
PORT (
ena : in std_logic; De manière générale il faut se poser la question:
input : in std_logic_vector (7 downto 0);
output : out std_logic_vector (7 downto 0) Le composant cible dispose t’il des ressources
); nécessaires pour synthétiser ma fonction
END tri_state;
---------------------------------------------- Pas de 3 états possibles si le composants n’en a pas!!
ARCHITECTURE tri_state OF tri_state IS
BEGIN
output <= input WHEN (ena='0') ELSE
(OTHERS => 'Z');
END tri_state;
33
Logique séquentielle: le process
Le mot clé PROCESS
Syntaxe:
MonEtiquette : process (signal1, signal2 etc)
-- zone déclarative
Signal sFIL1,sFIL2: xxxxxxxx
Begin
xxx
xxx
xxx
end process MonEtiquette;
Le PROCESS est activé lors d’un changement d’état d’un des signaux de la liste de sensibilité
Les instructions utilisables dans un PROCESS sont SPECIFIQUE ( pas de when/else par exemple)
Les signaux sont mis à jour uniquement à la fin du process
Réveil du process
Exemple: bascule D latch
Fonctionnement sur niveau architecture archi of seq1 is
begin
process (ena,d)
begin
IF ena = '1'
then q<=d;
else q<=q;
end if;
end process ;
end archi;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity seq1 IS
port ( d, ena : in std_logic;
q : buffer std_logic
);
end seq1; Processus activé 35
Logique séquentielle: le process
Rendre synchrone
Bascule D edge: fonctionnement sur front
architecture arch of Bascule_D is
begin
process(H)
begin
if rising_edge(H) then
q<=d;
end if;
end process;
end arch;
library ieee;
Use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity Bascule_D is
port (
H, d : in std_logic;
Autre façon:
q : out std_logic
process(CLK)
);
begin
end entity;
If (H=‘1’) and (H’event) then
q<=d;
end if;
36
end process;
Logique séquentielle: le process
CLK GCLK
ASTABLE CPLD
41
Logique séquentielle: les instructions
Assignations directes
Library ieee;
S<= signal;
Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;
Use ieee.std_logic_unsigned.all;
entity CMP4BITS is
PORT (
CLOCK : in std_logic;
Q : out std_logic_vector (3 downto 0)
);
Q est défini en sortie end CMP4BITS;
Syntaxe:
Case selecteur is
when condition1 => instructions ;
…….
when condition2 => instructions ;
----
when others => instructions ;
end case ;
2 LIBRARY ieee;
3 USE ieee.std_logic_1164.all;
4 --------------------------------------------------
ENTITY shiftreg IS
6 GENERIC (n: INTEGER := 4);
7 PORT (d, clk, rst: IN STD_LOGIC;
8 q: OUT STD_LOGIC
9 );
9 END shiftreg;
10 --------------------------------------------------
11 ARCHITECTURE behavior OF shiftreg IS
12 signal internal: std_logic_vector (n-1 downto 0);
13 begin
14 process (clk, rst)
15 begin
16 if (rst='1') then
17 internal <= (others => '0');
18 elsif(clk‘event and clk='1') then
19 internal <= d & internal(internal‘left downto 1);
20 End if;
21 end process;
22 q <= internal(0);
23 END behavior; 46
Logique séquentielle: des exemples
Registre à décalage
LIBRARY ieee;
Sortie parallèle USE ieee.std_logic_1164.all;
Choix du sens USE work.std_arith.all;
entity DECAL_DG is
port (H,R,SENS : in std_logic;
IN_OUT,OUT_IN : inout std_logic
);
end DECAL_DG;
architecture ARCH_DECAL_DG of DECAL_DG is
signal Q :std_logic_vector(3 downto 0);
begin
process(H,R)
Emploi de signaux et non de begin
variables if R='1' then Q <= "0000";
elsif (H'event and H='1') then
if SENS = '1' then
Q <= Q(2 downto 0) & OUT_IN;
Affectation en dehors du process else
Q <= IN_OUT & Q(3 downto 1);
end if;
end if;
end process;
OUT_IN <= Q(3) when SENS = '1' else 'Z';
IN_OUT <= Q(0) when SENS = '0' else 'Z';
end ARCH_DECAL_DG;
47
Logique séquentielle: des exemples
Une RAM
LIBRARY ieee;
USE ieee.std_logic_1164.all;
---------------------------------------------------
ENTITY ram IS
GENERIC ( bits: INTEGER := 8; -- # of bits per word
words: INTEGER := 16); -- # of words in the memory
PORT ( wr_ena, clk: IN STD_LOGIC;
addr: IN INTEGER RANGE 0 TO words-1;
data_in: IN STD_LOGIC_VECTOR (bits-1 DOWNTO 0);
data_out: OUT STD_LOGIC_VECTOR (bits-1 DOWNTO 0));
END ram;
---------------------------------------------------
ARCHITECTURE ram OF ram IS
TYPE vector_array IS ARRAY (0 TO words-1) OF STD_LOGIC_VECTOR (bits-1 DOWNTO 0);
SIGNAL memory: vector_array; -- Déclaration d’un signal du type créé précédemment
BEGIN
PROCESS (clk, wr_ena) Création d’un nouveau
BEGIN type: TYPE
IF (clk'EVENT AND clk='1') THEN
IF (wr_ena='1') THEN C’est un tableau de vecteurs
memory(addr) <= data_in;
END IF;
END IF;
END PROCESS;
data_out <= memory(addr);
END ram;
48
Logique séquentielle: des exemples
Diviseur de fréquence
Diviseur par comptable
Possibilité de faire par décomptage aussi
LIBRARY ieee;
USE ieee.std_logic_1164.all; Application et utilisation d’un diviseur de
USE ieee.std_arith.all; fréquence
entity DIV_FREQ1 is
port (H :in std_logic;
N :in std_logic_vector(3 downto 0); •On évitera de cascader la sortie du diviseur
DIV : out std_logic); sur l’horloge du bloc suivant
end DIV_FREQ1;
architecture ARCH_DIV_FREQ1 of DIV_FREQ1 is
signal Q :std_logic_vector(3 downto 0); •La bonne méthode:
begin Horloge du système la même pour
process(H) tous les blocs
begin
if (H'event and H='1') then
La sortie du diviseur est une entrée de
if Q = 15 then Q <= N; validation du bloc suivant
else Q <= Q + 1; Si En=‘1’ alors on compte
end if;
end if;
end process;
DIV <= '1' when Q = 15 else '0';
end ARCH_DIV_FREQ1;
49
Logique séquentielle: des exemples
Application et utilisation d’un diviseur de fréquence
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.all;
entity COMPTCAS is
port (H,R,EN :in std_logic;
LIBRARY ieee;
CO :out std_logic;
USE ieee.std_logic_1164.all; COMPOSANT HAUT NIVEAU
Q :out std_logic_vector(3 USE ieee.std_logic_unsigned.all;
downto 0)); entity COMPT12 is
end COMPTCAS; port (H,RAZ,EN : in std_logic;
architecture ARCH_COMPTCAS of CO : out std_logic;
COMPTCAS is Q :out std_logic_vector(11 downto 0));
signal X :std_logic_vector(3 downto end COMPT12;
0); architecture ARCH_COMPT12 of COMPT12 is
begin signal X :std_logic_vector(11 downto 0);
process(H,R) signal CO1,CO2,CO3,EN1 :std_logic;
begin component COMPTCAS
port (H,R,EN : in std_logic;
if R='1' then X <= "0000";
CO : out std_logic;
elsif (H'event and H='1') then
Q : out std_logic_vector(3 downto 0));
if EN = '1' then X <= X + 1; end component;
else X <= X; begin
end if; COMPTEUR1 : COMPTCAS port map(H,RAZ,EN,CO1,Q(3 downto 0));
end if; COMPTEUR2 : COMPTCAS port map(H,RAZ,CO1,CO2,Q(7 downto 4));
end process; EN1 <= CO1 and CO2;
Q <= X; COMPTEUR3 : COMPTCAS port map(H,RAZ,EN1,CO3,Q(11 downto 8));
CO <= '1' when X = 15 else '0'; CO <= CO1 and CO2 and CO3;
end ARCH_COMPTCAS; end ARCH_COMPT12; 50
Logique séquentielle: des exemples
51