then - 123SeminarsOnly.com

publicité
Du Software au Hardware
Introduction aux composants
programmables FPGA
Grégory ESTRADE
http://torlus.com/
Introduction aux FPGA - Plan
• Electronique numérique
• Logique programmable
• Conception hardware sur FPGA
–
–
–
–
Langages et outils
Bases
Exemples simples
Projets avancés
• En pratique
Introduction aux FPGA – Electronique numérique
• Bases
– Portes logiques
– Latches, Flip-flops
– Horloge, Bus...
• Série 7400 et 4000
–
–
–
–
Premiers circuits intégrés déployés dans les 70s
Familles TTL et CMOS
Accessible aux hobbyistes
Applications : « glue logic », systèmes complets
( http://www.homebrewcpu.com/ )
Source : Wikipedia
Introduction aux FPGA – Electronique numérique
• Circuits avancés
– ROM, RAM
– CPU, DSP (audio, vidéo, télécoms… ), MCU
(Microcontrôleurs)
– Contrôleurs USB, Ethernet…
– ASIC
– DAC, ADC, capteurs, servo-moteurs…
• Logique programmable
– PAL, GAL
– CPLD, FPGA
Logique programmable
• Synthèse combinatoire
• Circuits séquentiels
• Composants
Synthèse combinatoire
A
S
B
Ci
Co
Ci
0
1
0
1
0
1
0
1
A
0
0
1
1
0
0
1
1
B
0
0
0
0
1
1
1
1
S
0
1
1
0
1
0
0
1
S = Ci./A./B + /Ci.A./B + /Ci./A.B + Ci.A.B
Co = Ci.A./B + Ci./A.B + /Ci.A.B + Ci.A.B
Co
0
0
0
1
0
1
1
1
PAL = Programmable Array Logic
Source : Wikipedia
Introduction aux FPGA – Logique programmable
Synthèse combinatoire
• Gate Array (PAL, PLA, GAL)
• ROM
• Microcontrôleur ( http://www.schells.com/intellicart.shtml )
Circuits séquentiels
• Horloge, bascules
• Finite State Machine
Horloge
Fonction de
Transition
Etat futur
Mémoire
d'Etat
Etat courant
Fonction de
Sortie
Référence : « Du Binaire au Processeur » - Emmanuel Mesnard
Introduction aux FPGA – Logique programmable
Composants : CPLD
– Apparition dans les 80s.
– Capacité : 10000 portes (500 macrocells).
– Configuration stockée « on-chip ».
– Langages de haut niveau (HDLs).
Introduction aux FPGA – Logique programmable
Composants : FPGA
– Extension des CPLD, architecture plus flexible
– Capacité : millions de portes
– Configuration stockée sur EEPROM externe
– Éléments dédiés : RAM, multiplicateurs, CPU
cores...
Source : http://www.chrec.ufl.edu/
Introduction aux FPGA – Logique programmable
Composants : FPGA (suite)
– Remplacement des ASICs, DSP...
– Constructeurs : Xilinx, Altera, Lattice, Actel...
– Développement combiné software/hardware
– Runtime reconfiguration
Conception hardware sur FPGA
•
•
•
•
Langages et outils
Bases du langage VHDL
Exemple simple
Projets avancés
Introduction aux FPGA – Conception
Outils (Xilinx)
• Spartan-3 Starter Board
• ISE WebPack
• ModelSim
Source : Diligent
Introduction aux FPGA – Conception
Etapes
• Edition des sources
• Edition du fichier UCF : « User Constraints File »
– Répartition des signaux de l’entité principale sur des pins
– Contraintes de timing
– IO Standards (LVTTL, LVCMOS33, LVCMOS25…)
• Synthèse et génération du fichier programme
• Génération de l’image EEPROM
• Flashage de l’EEPROM
Introduction aux FPGA – Conception
Langages
• VHDL
– Origine : DoD américain
– Syntaxe ADA
– Meilleure abstraction
• Verilog
– Origine : industrie
– Syntaxe proche du C
– Plus simple d’apprentissage, plus concret
• Saisie de schémas
Introduction aux FPGA – Conception
Langages (suite)
• Software Programming Language
– Compilation en langage machine
– Exécution séquentielle
• Hardware Description Language
– Synthèse en « portes et câbles »
– Exécution concurrente
– Exécution séquentielle en simulation (Test benchs)
Introduction aux FPGA – Conception
Langages (suite)
• Pièges
–
–
–
–
Exécution concurrente
« Optimisations »
Synthèse (guidage, asynchronisme…)
Problèmes hardware (Routage, clock skew, SSO…)
• Remèdes
– Simulation
– Rapports de synthèse
– Visualisation à l’oscilloscope, analyseur logique
VHDL - Porte ET à 2 entrées
-- imports
library IEEE;
use IEEE.std_logic_1164.all;
-- entité
entity porte_et is
port( a,b : in std_logic; s : out std_logic );
end porte_et;
-- architecture
architecture rtl of porte_et is
begin
s <= a and b;
end rtl;
VHDL - Utilisation de la porte ET à 2 entrées
library IEEE;
use IEEE.std_logic_1164.all;
entity mon_systeme is
… …
end mon_systeme;
architecture arch of mon_systeme is
-- déclaration de porte_et pour utilisation
component porte_et is
port( a,b : in std_logic; s : out std_logic );
end component;
-- déclaration de « registres » 8 bits
signal op1 : std_logic_vector(7 downto 0);
signal op2 : std_logic_vector(7 downto 0);
signal res : std_logic_vector(7 downto 0);
begin
-- instanciation de 8 portes_et
et8 : for i in op1’range generate
et8_0 : porte_et port map
(a => op1(i),
b => op2(i),
s => res(i));
end generate et8;
end arch;
Autres exemples : représentation d’un MUX
-- template 1:
X <= A when S = '1' else B;
-- template 2:
with S select X <= A when '1' else B;
-- template 3:
process(A,B,S)
begin
case S is
when '1' => X <= A;
when others => X <= B;
end case;
end process;
-- template 4:
process(A,B,S)
begin
if S = '1' then
X <= A;
else
X <= B;
end if;
end process;
Source : Wikipedia
Autres exemples (suite)
-- logique 3 états et « don’t care » :
B <= A when CE = ‘0’,
‘Z’ when OE = ‘1’
else ‘X’;
-- horloge et reset asynchrone
process(clk, reset)
if (reset = ‘0’) then
… …
elsif clk’event and clk = ‘1’ then
… …
end if;
begin
end process;
-- simulation : génération d’une horloge
process
begin
clk <= ‘0’;
wait for 20ns;
clk <= ‘1’;
wait for 20ns;
end process;
Introduction aux FPGA – Conception
Exemple : Communication RS-232
Utilisation d’un convertisseur (MAX232)
Introduction aux FPGA – Conception
Exemple : Communication RS-232
• Caractéristiques
– Fonctionnement à 16Mhz
– Communication à 9600 bps, format 8N1
• Exemple d’interface
–
–
–
–
–
–
Caractères à lire et à écrire
Signal de demande d’écriture
Signal « busy » en écriture
Signal de demande de lecture
Signal « avail » en lecture
Reset
Exemple : Communication RS-232
entity UART is
port(
clk : in std_logic;
reset : in std_logic;
tx : out std_logic;
rx : in std_logic;
rd : in std_logic;
rd_data : out std_logic_vector(7 downto 0);
avail : out std_logic;
wr : in std_logic;
wr_data : in std_logic_vector(7 downto 0);
busy : out std_logic
);
end UART;
Introduction aux FPGA – Conception
Exemple : Communication RS-232
• Fonctionnement
– Suréchantillonage x16 (utile en réception uniquement)
– Compteur serclk_cnt (adapté au baudrate)
• 16 000 000 / 9600 / 16 = 103
– Compteurs rx_cnt et tx_cnt sur 8 bits
• 4 bits de poids faible : suréchantillonage
• 4 bits de poids fort : compteur des bits à transmettre/recevoir
– Bit de start
– Bits de données
– Bit de stop
Architecture de l’UART – Vue d’ensemble
architecture rtl of UART is
-- signaux de contrôle (non détaillés)
signal serclk_cnt : std_logic_vector(6 downto 0);
signal tx_data : std_logic_vector(7 downto 0);
signal tx_cnt : std_logic_vector(7 downto 0);
signal rx_data : std_logic_vector(7 downto 0);
signal rx_cnt : std_logic_vector(7 downto 0);
begin
process(clk, reset)
begin
if reset = ‘0’ then
-- réinitalisation (non détaillée)
elsif rising_edge(clk) then
-- gestion des signaux de contrôle (non détaillée)
serclk_cnt <= serclk_cnt + 1;
if serclk_cnt = 103 then
serclk_cnt <= (others => '0');
-- unité de réception
-- unité d’émission
end if;
end if;
end process;
end rtl;
Architecture de l’UART – Emission
-- un ordre d’écriture positionne tx_cnt à ‘00010000’ et
busy à ‘1’
if tx_cnt(7 downto 4) = "0000" then
tx <= '1';
elsif tx_cnt(7 downto 4) = "0001" then -- start bit
tx <= '0';
tx_cnt <= tx_cnt + 1;
elsif tx_cnt(7 downto 4) < "1010" then -- data bits
tx <= tx_data(0);
if tx_cnt(3 downto 0) = "1111" then
tx_data <= "0" & tx_data(7 downto 1);
end if;
tx_cnt <= tx_cnt + 1;
elsif tx_cnt(7 downto 4) = "1010" then -- stop bit
tx <= '1';
tx_cnt <= tx_cnt + 1;
else
busy <= ‘0’;
tx_cnt <= "00000000";
end if;
Architecture de l’UART – Réception
if rx_cnt(7 downto 4) = "0000" then
if rx = '0' then -- start bit
rx_cnt <= rx_cnt + 1;
if rx_cnt(3 downto 0) = "1000" then
rx_cnt <= "00010000";
end if;
else
rx_cnt <= "00000000";
end if;
elsif rx_cnt(7 downto 4) < "1001" then -- data bits
rx_cnt <= rx_cnt + 1;
if rx_cnt(3 downto 0) = "1111" then
rx_data <= rx & rx_data(7 downto 1);
end if;
else
rx_cnt <= "00000000";
end if;
Introduction aux FPGA – Conception
Projets avancés
• http://www.opencores.org/
– CPU Cores : T65, T80, 6809, 8051…
– Contrôleurs Ethernet, USB, LCD, SPI, I²C…
• Emulation de machines anciennes
– http://zxgate.sourceforge.net/ (ZX81, ZX Spectrum, Jupiter ACE,
TRS80)
– http://www.fpgaarcade.com/ (Hardware arcade, VIC-20)
– Minimig (Amiga 500 sur base 68k + FPGA)
– http://www.experiment-s.de/ (Atari STE)
Introduction aux FPGA – Conception
Projets avancés (suite)
– http://c64upgra.de/c-one/ (Commodore ONE)
– http://www.bazix.nl/onechipmsx.html (MSX)
• Divers
– http://jeanfrancoisdelnero.free.fr/floppy_drive_emulator/index.html
Emulation de lecteur de disquette avec interface USB
– Custom CPUs
– http://www.tripoint.org/kevtris/ (le site de Kevin Horton : NES,
Intellivision, SID…)
– http://torlus.com/ (Blog dédié au développement)
En pratique
• Outils et composants
• Interfaçage avec d’autres systèmes
• Réalisation de PCB
Introduction aux FPGA – En pratique
Equipement
• Pour commencer
–
–
–
–
–
Breadboard, cartes pastillées, fil.
Composants passifs : résistances, condensateurs.
Fer à souder <18W, soudure 0.5mm.
Tresse ou pompe à dessouder.
Multimètre
• Pour aller plus loin
– Oscilloscope (analogique, numérique, USB)
– Analyseur logique
Introduction aux FPGA – En pratique
Interfaçage - Problématiques
• Evolution des standards
– 5V TTL / CMOS
– 3.3V CMOS (2.5V, 1.8V, 1.2V…)
• Evolution des composants
– Packages « thru-hole »
– Packages « SMT » (CMS, Composants Montés en Surface)
Introduction aux FPGA – En pratique
Interfaçage - Circuits intégrés : Packages
• Packages « Thru-hole »
– DIP : 2,54mm
– PLCC, PGA : 2,54mm – 1,27mm
• Packages « SMT » (CMS)
– SOIC : 1,27mm
– *QFP, *SOP : 0,8mm – 0,5mm
– *BGA
Introduction aux FPGA – En pratique
Interfaçage - Solutions
• Conversion 5V / 3.3V : circuits d’adaptation
• Utilisation des CMS
– Adaptateurs
– Utilisation de PCB
• Fabriqués par un tiers (ex : http://www.pcbfabexpress.com/ )
• Fabriqués soi-même
Introduction aux FPGA – En pratique
•
•
•
•
•
•
Réalisation de PCB – Processus
Utilisation de plaques photosensibles
Conception du circuit – EAGLE, Proteus, OrCAD…
Edition d’un typon – Impression laser sur transparent
Insolation – Kit insoleuse à néons UV
Révélation – Bac et révélateur en poudre
Gravure – Kit graveuse verticale (bac, chauffage et bulleur) et perchlorure
de fer
• Etamage – Solution d’étamage à froid
Graveuse et Insoleuse KF – photo Selectronic
Introduction aux FPGA – En pratique
Réalisation de PCB – Matériel additionnel
• Meuleuse et support (Dremel 300 et Dremel Workstation 220)
• Soudure
– Fer 11W avec panne CMS
– Station de soudage thermo-régulée
– Flux de soudure (flux pen Kester solder)
– Loupe
• Divers
– Plaques de cuivre simples
– Feutres pour CI
– Gomme abrasive
Du Software au Hardware – Pour conclure
• Ouvre de nouvelles perspectives
• Investissement non négligeable
– Initial
– Récurrent
• Demande du temps
• Demande méthode et patience
Du Software au Hardware – Bibliographie
• « Du binaire au processeur » - Emmanuel Mesnard (Théorique)
• « Design your own video game console » eBook – André LaMothe
http://www.xgamestation.com/
• « Understanding the Apple II » - Jim Sather
• « Tracé des circuits imprimés » - Philippe Dunand
Merci pour votre
attention
Grégory ESTRADE
http://torlus.com/
Téléchargement