Top Banner
Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE http:// torlus.com/
44

Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Apr 03, 2015

Download

Documents

Juliet Jacob
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Du Software au Hardware

Introduction aux composants programmables FPGA

Grégory ESTRADE http://torlus.com/

Page 2: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Introduction aux FPGA - Plan

• Electronique numérique• Logique programmable • Conception hardware sur FPGA

– Langages et outils– Bases– Exemples simples– Projets avancés

• En pratique

Page 3: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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/ )

Page 4: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Source : Wikipedia

Page 5: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 6: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Logique programmable

• Synthèse combinatoire

• Circuits séquentiels

• Composants

Page 7: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

A

B

Ci

Co

S Ci A B S Co0 0 0 0 01 0 0 1 00 1 0 1 01 1 0 0 10 0 1 1 01 0 1 0 10 1 1 0 11 1 1 1 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

Synthèse combinatoire

Page 8: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Source : Wikipedia

PAL = Programmable Array Logic

Page 9: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Introduction aux FPGA – Logique programmable

Synthèse combinatoire

• Gate Array (PAL, PLA, GAL)

• ROM• Microcontrôleur ( http://www.schells.com/intellicart.shtml )

Page 10: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Circuits séquentiels

• Horloge, bascules• Finite State Machine

Fonction de Transition

Mémoired'Etat

Fonction deSortie

Etat futur Etat courant

Horloge

Référence : « Du Binaire au Processeur » - Emmanuel Mesnard

Page 11: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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).

Page 12: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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...

Page 13: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Source : http://www.chrec.ufl.edu/

Page 14: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Introduction aux FPGA – Logique programmable

Composants : FPGA (suite)

– Remplacement des ASICs, DSP...– Constructeurs : Xilinx, Altera, Lattice, Actel...– Développement combiné software/hardware– Runtime reconfiguration

Page 15: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Conception hardware sur FPGA

• Langages et outils• Bases du langage VHDL• Exemple simple• Projets avancés

Page 16: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Introduction aux FPGA – Conception

Outils (Xilinx)

• Spartan-3 Starter Board

• ISE WebPack

• ModelSim

Source : Diligent

Page 17: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 18: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 19: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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)

Page 20: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 21: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

VHDL - Porte ET à 2 entrées

-- importslibrary 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;

-- architecturearchitecture rtl of porte_et isbegin

s <= a and b;end rtl;

Page 22: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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;

Page 23: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 24: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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;beginend process;

-- simulation : génération d’une horlogeprocessbegin clk <= ‘0’; wait for 20ns; clk <= ‘1’; wait for 20ns;end process;

Page 25: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Introduction aux FPGA – Conception

Exemple : Communication RS-232

Utilisation d’un convertisseur (MAX232)

Page 26: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 27: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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;

Page 28: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 29: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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);

beginprocess(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;

Page 30: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Architecture de l’UART – Emission

-- un ordre d’écriture positionne tx_cnt à ‘00010000’ et busy à ‘1’

if tx_cnt(7 downto 4) = "0000" thentx <= '1';

elsif tx_cnt(7 downto 4) = "0001" then -- start bittx <= '0';tx_cnt <= tx_cnt + 1;

elsif tx_cnt(7 downto 4) < "1010" then -- data bitstx <= 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 bittx <= '1';tx_cnt <= tx_cnt + 1;

elsebusy <= ‘0’;tx_cnt <= "00000000";

end if;

Page 31: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Architecture de l’UART – Réception

if rx_cnt(7 downto 4) = "0000" thenif rx = '0' then -- start bit

rx_cnt <= rx_cnt + 1;if rx_cnt(3 downto 0) = "1000" then

rx_cnt <= "00010000";end if;

elserx_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;

elserx_cnt <= "00000000";

end if;

Page 32: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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)

Page 33: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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.htm

l 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)

Page 34: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

En pratique

• Outils et composants

• Interfaçage avec d’autres systèmes

• Réalisation de PCB

Page 35: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 36: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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)

Page 37: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 38: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 39: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 40: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Graveuse et Insoleuse KF – photo Selectronic

Page 41: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 42: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 43: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

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

Page 44: Du Software au Hardware Introduction aux composants programmables FPGA Grégory ESTRADE

Merci pour votre attention

Grégory ESTRADE http://torlus.com/