Prsentation
Electronique reprogrammable
Apparition des premiers circuits vers les annes 70: premiers PLD-> PAL, GAL Evolution vers composants plus complexes: CPLD, FPGA Diffrentes technologies pour la programmation des connexions
Permanents , Volatiles statiques, Volatiles Capacit de programmation In-Situ
composants dits ISP via interface JTAG
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
Reprsentation standard
OU cabl
xPLD
Simple Programme Logic Device
Composants simples
rseau ET/OU programmable ou fixe PAL (OTP en gnral), GAL reprogrammable
FPGA
Field Programmable Grid Array
Granularit plus fine que les CPLD ( macrocellules - complexes mais + nombreuses) Intgration matrielle de composants supplmentaires
RAM: appel LUT (Look-Up Table) Mutiplexeurs divers PLL Multiplieurs cbls (FPGA haut de gamme => concurrence avec les DSP) Rseau de routage rparti ( non centralis contrairement Rpartition des applications aux CPLD) Source Altera
Exemple de rfrence Famille Cyclone (FPGA Low Cost dALTERA) Concurrent: Spartan3 (chez Xilinx)
FPGA
La carte DE2 (utilis en TP)
Specifications FPGA Cyclone II EP2C35F672C6 FPGA and EPCS16 serial configuration device I/O Devices Built-in USB Blaster for FPGA configuration 10/100 Ethernet, RS-232, Infrared port Video Out (VGA 10-bit DAC) Video In (NTSC/PAL/Multi-format) USB 2.0 (type A and type B) PS/2 mouse or keyboard port Line-in, Line-out, microphone-in (24-bit audio CODEC) Expansion headers (76 signal pins) Memory 8-MB SDRAM, 512-KB SRAM, 4-MB Flash SD memory card slot Switches, LEDs, Displays, and Clocks 18 toggle switches 4 debounced pushbutton switches 18 red LEDs, 9 green LEDs Eight 7-segment displays 16 x 2 LCD display 27-MHz and 50-MHz oscillators, external SMA clock input6
VHDL introduction
Programmation ou description?
Les objectifs du langage VHDL
Conception de circuits intgrs reconfigurable ou non (ASIC, FPGA) : SYNTHESE Mise au point de modle de simulations numriques (circuits virtuels) : MODELISATION
Synthse ou modlisation
Nous nous focaliserons dans ce cours la synthse uniquement
entity
Flot de conception
Un outils de dveloppement: Quartus II dAltera
Logique combinatoire La sortie ne dpend pas de ltat pass Un vecteur dentre = un vecteur de sortie unique
Logique squentielle La sortie dpend de son tat pass Systme ncessitant une horloge (systmes dits synchrones)
11
12
La librairie IEEE
A mettre au dbut de votre description Pour rajouter les types tendues std_logic et std_logic_vector
use IEEE.STD_LOGIC_1164.all;
13
Alternative resize
A<=resize(signed(SW(LARG downto 1)),LARG+1);
14
Les oprateurs
Logiques (boolean, bit, std_ulogic)
AND, OR, NAND, NOR, XOR, NOT
Un bus (ou ensemble de fils lectrique) est reprsent sous forme dun vecteur de bits
Arithmtiques
+ * / ** MOD REM
STD_LOGIC_VECTOR (3 DOWNTO 0);
Exemple 2
library IEEE; use IEEE.std_logic_1164.all; entity example is port( E:IN std_logic_vector(2 downto 0); S1:OUT std_logic; --1 fil S2,S3:OUT std_logic_vector(3 downto 1); --3 fils S1[3:1] S4:OUT std_logic_vector(2 downto 0) ); end example; --definition de l'architecture architecture arch_example of example is begin S1<='0'; S2<='1'& E(1 downto 0);
-- operateur COLLER (ou CONCATENE) -- S2(3) S2(2) S2(1) -- '1' E(1) E(0)
&
S3<="101"; S4<= "111" XOR E; --manip sur les bus directement end arch_example;
16
signal <=
signal1 when expresion_boolnne else signal1xx when expresion_boolnne else signal par dfaut;
Exemple dapplication: encodeur clavier pour PIC Intrt: rduire le nombre dentre du PIC
17
Assignation slective
18
exemple: applicatif: Comment faire un additionneur 4 bits? etape 1: je cre un composant ADDITIONNEUR 1 bits
LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY fa IS PORT ( Ci, X, Y: IN STD_LOGIC; S, Cout: OUT STD_LOGIC); END fa; ARCHITECTURE Dataflow OF fa IS BEGIN Cout <= (X AND Y) OR (Ci AND (X XOR Y)); S <= X XOR Y XOR Ci; END Dataflow;
Full Adder
19
20
END ET4;
STD_LOGIC; STD_LOGIC
21
XX<=1110; YY<= A AND B; U1: Truc PORT MAP( .); S<= 10 when (A=B) else 00; U2: Machin PORT MAP( .); With (Toto) select G<= END ARCHITECTURE
22
--definition de l'architecture architecture arch_dec_7seg_v1 of decod7seg is -- definition d'un nouveau type -- tableau de 16 elements de 7 bits type ROM is array(15 downto 0) of std_logic_vector(6 downto 0); --initialisaion du tableau -- tableau vu comme une memoire(LUT) signal LUT:ROM:=( "1000000","1111001","0100100","0110000","0011001","0010010","000 0010", "1111000","0000000","0011000","0001000","0000011","1000110","010 0001",
Carte DE2: Anode commune Segment actif 0 Brochage: voir p31 du manuel
"0000110","0001110"); begin -- pour indexer tableau il faut un entier -- fonction de conversion conv_integer dans IEEE.std_logic_unsigned.all oSeg<=LUT(conv_integer(iDigit));
23
Utilisation de GENERIC lors du PORT MAP U1: generic(10) adddirect PORT MAP(xxxxxx);
24
Slection Op 2 LIBRARY ieee; arithmtique/logique 3 USE ieee.std_logic_1164.all; 4 USE ieee.std_logic_unsigned.all; 5 ---------------------------------------------6 ENTITY ALU IS 7 PORT (a, b: IN STD_LOGIC_VECTOR (7 DOWNTO 0); 8 sel: IN STD_LOGIC_VECTOR (3 DOWNTO 0); 9 cin: IN STD_LOGIC; 10 y: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)); 11 END ALU; 12 ---------------------------------------------13 ARCHITECTURE dataflow OF ALU IS 14 SIGNAL arith, logic: STD_LOGIC_VECTOR (7 DOWNTO 0); 15 BEGIN 16 ----- Arithmetic unit: -----17 WITH sel(2 DOWNTO 0) SELECT 18 arith <= a WHEN "000", 19 a+1 WHEN "001", 20 a-1 WHEN "010", 21 b WHEN "011", 22 b+1 WHEN "100", b-1 WHEN "101", 24 a+b WHEN "110", 25 a+b+cin WHEN OTHERS;
Code Opratoire (mot de commande sur 3 bits) 26 ----- Logic unit: ----------27 WITH sel(2 DOWNTO 0) SELECT 28 logic <= NOT a WHEN "000", 29 NOT b WHEN "001", 30 a AND b WHEN "010", 31 a OR b WHEN "011", 32 a NAND b WHEN "100", 33 a NOR b WHEN "101", 34 a XOR b WHEN "110", 35 NOT (a XOR b) WHEN OTHERS; 36 -------- Mux: --------------37 WITH sel(3) SELECT 38 y <= arith WHEN '0', 39 logic WHEN OTHERS; 40 END dataflow; 41 ----------------------------------------------
25
De manire gnrale il faut se poser la question: Le composant cible dispose til des ressources ncessaires pour synthtiser ma fonction
1 LIBRARY ieee; 2 USE ieee.std_logic_1164.all; 3 ---------------------------------------------4 ENTITY tri_state IS 5 PORT ( ena: IN STD_LOGIC; 6 input: IN STD_LOGIC_VECTOR (7 DOWNTO 0); 7 output: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)); 8 END tri_state; 9 ---------------------------------------------10 ARCHITECTURE tri_state OF tri_state IS 11 BEGIN 12 output <= input WHEN (ena='0') ELSE 13 (OTHERS => 'Z'); 14 END tri_state; 15 ----------------------------------------------
26
Le PROCESS est activ lors dun changement dtat dun des signaux de la liste de sensibilit Une fois dans le PROCESS le droulement est SEQUENTIELLE Les instructions utilisables dans un PROCESS sont SPECIFIQUE ( pas de when/else par exemple) Les signaux sont mis jour uniquement la fin du process
process begin q <= d; wait until Reloj = 1; end process; Process begin c <= a and b; wait on a, b; end process; Process(a,b) begin c <= a and b; end process;
critures alternatives
27
Processus activ
28
Autre faon: Process(CLK) Begin If (CLK=1) then Q<=D; End if; End process;
29
process(horl) if (horlevent and horl = 1) then if (ena = 1 ) then contenu_registre <= valeur_in; end if; end if; end process;
Ce quil faut faire! En pratique le FPGA (ou CPLD) possde une ou des broches spcifiques pour le signal dhorloge 30
31
32
architecture DESCRIPTION of CMP4BITSRET is signal CMP: std_logic_vector (3 downto 0); begin process (RESET,CLOCK) begin if RESET ='1' then CMP <= "0000"; elsif (CLOCK ='1' and CLOCK'event) then CMP <= CMP + 1; if (CMP = "1111") then RET <= '1'; else RET <= '0'; end if; end if; end process; Q <= CMP; end DESCRIPTION; 1110+1=1111 oui mais la fin du process Conclusion: etat 1111 et pas de retenue! Prochain front: 1111+1=0 je detecte 1111 , lancienne valeur et RET passe 1 Oui mais trop tard!!
Library ieee; Use ieee.std_logic_1164.all; Use ieee.numeric_std.all; Use ieee.std_logic_unsigned.all; entity CMP4BITSRET is PORT ( RESET, CLOCK : in std_logic; RET : out std_logic; Q : out std_logic_vector (3 downto 0)); end CMP4BITSRET;
33
34
Library ieee; 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)); end CMP4BITS; architecture DESCRIPTION of CMP4BITS is signal Q_BUS_INTERNE : std_logic_vector(3 downto 0)); begin process (CLOCK) begin if (CLOCK ='1' and CLOCK'event) then Q_BUS_INTERNE <= Q_BUS_INTERNE + 1; end if; end process; Q <= Q_BUS_INTERNE; -- affectation du bus interne au -- signal de sortie Q end DESCRIPTION;
Q est dfini en sortie OR Q<=Q+1 signifie Relire tat courant et incrmente Solution 1: dfinir BUFFER au lieu de OUT Solution 2: couramment utilise: passer par un signal
35
Structure SI/SINON SI
36
CAS possibles de lexpression EST LORSQUE signal = valeur1 => instructions squentielles; LORSQUE signal = valeur2 =>instructions squentielles; LORSQUE signal = valeur3 =>instructions squentielles; LORSQUE signal = AUTRES =>instructions squentielles; FIN DE CAS;
37
Reg_dec: PROCESS (h) VARIABLE stmp: std_logic_vector(3 DOWNTO 0); BEGIN If (h=1 and hevent) then CASE selection IS WHEN 11=> stmp := d_entree; --chargement paralelle WHEN 10=>stmp:= stmp(2 DOWNTO 0) & edg; --gauche WHEN 01=>stmp:= edd &stmp(3 DOWNTO 1); --droite WHEN OTHERS => ; --mmorisation END CASE; la sortie est SYNCHRONE sortie <= stmp; END PROCESS Reg_dec; Pas de retard supplmentaire car utilisation dune variable
On peut utiliser une variable la place dun signal Affecttation dune variable Mavariable:= ma valeur; CONTRAIREMENT AU SIGNAUX LA VALEUR EST MISE A JOUR DE SUITE Rappel: & colle les signaux ensemble
Si emploi dun signal la place dune variable affectation EN DEHORS DU PROCESS ( voir chapitre Mise jour des signaux et page suivante pour un exemple)
38
39
LIBRARY ieee; USE ieee.std_logic_1164.all; 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) begin if R='1' then Q <= "0000"; elsif (H'event and H='1') then if SENS = '1' then Q <= Q(2 downto 0) & IN_OUT; else Q <= OUT_IN & 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;
40
41
dun
On vitera de cascader la sortie du diviseur sur lhorloge du bloc suivant La bonne mthode:
Horloge du systme LA mme pour tous les blocs La sortie du diviseur est une entre de validation du bloc suivant Si En=1 alors je compte
42
LIBRARY ieee; USE ieee.std_logic_1164.all; USE work.std_arith.all; entity COMPTCAS is port (H,R,EN :in std_logic; CO :out std_logic; Q :out std_logic_vector(3 downto 0)); end COMPTCAS; architecture ARCH_COMPTCAS of COMPTCAS is signal X :std_logic_vector(3 downto 0); begin process(H,R) begin if R='1' then X <= "0000"; elsif (H'event and H='1') then if EN = '1' then X <= X + 1; else X <= X; end if; end if; end process; Q <= X; CO <= '1' when Q = 15 else '0'; end ARCH_COMPTCAS;
44
Bibliographie
Certaines illustrations et exemples proviennent de cours ou douvrages prsents cidessous
Introduction la Synthse logique Philippe LECARDONNEL & Philippe LETENNEUR Le langage de description VHDL T. B LOTIN VHDl J.maillefert Circuit Design with VHDL Volnei A. Pedroni
45