La présentation est en train de télécharger. S'il vous plaît, attendez

La présentation est en train de télécharger. S'il vous plaît, attendez

Introduction au VHDL - R.WEBER - Polytech'Orleans

Présentations similaires


Présentation au sujet: "Introduction au VHDL - R.WEBER - Polytech'Orleans"— Transcription de la présentation:

1 Introduction au VHDL - R.WEBER - Polytech'Orleans
Polytech'Orléans Filière ESI MODULE Processeurs du traitement du signal Introduction au VHDL FASCICULE DE COURS ANNÉE SPE 3 Option “ESI” Rodolphe WEBER Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

2 Introduction au VHDL - R.WEBER - Polytech'Orleans
FORMATION VHDL Introduction Premiers pas Les Objets VHDL Les Opérateurs VHDL Assignation concurrente Assignation séquentielle Les Testbenchs Les Compléments Les machines d'états Les règles de conception Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

3 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les circuits logiques programmables Source: Dataquest Logic Standard Logic ASIC Programmable Logic Devices (PLDs) Gate Arrays Cell-Based ICs Full Custom ICs SPLDs (PALs) CPLDs FPGAs Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

4 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les circuits logiques programmables Les CPLD (complex programmable logic devices) association de plusieurs blocs logiques chaque bloc logique contient des macro-cellules (qq10 à qq100) une macro-cellule réalise une fonction logique combinatoire + bascule matrice de connexions centrale temps de propagation prévisible horloge rapide technologie eeprom ou flash, ISP Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

5 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les circuits logiques programmables Les FPGA (Field programmable gate arrays) matrice de blocs logiques (fonctions logiques, multiplexeurs, LUT) densité plus grande réseau d’interconnexions temps de propagation variable deux technos SRAM ou antifusible Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

6 Introduction au VHDL - R.WEBER - Polytech'Orleans
Détail extrait de l'architecture d'un FPGA Xilinx Exemple d'une single-slice d'un CLB (Configurable Logic Block) d'un Virtex ou Spartan II F5IN CIN CLK CE COUT D Q CK S R EC O G4 G3 G2 G1 Look-Up Table Carry & Control Logic YB Y F4 F3 F2 F1 XB X BY SR SLICE + éventuellement des fonctions spécialisées implantées en dur : + entrees/sorties + Blockram + DLL + registre à décalage + multiplieurs + communications + …. Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

7 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les ASICs (Application Specific Integrated Circuit) Conçus pour des applications particulières : réduction des coûts pour les grandes productions meilleures performances (vitesse, consommation,…) confidentialité, durcissement. Différentes technologies : Pré-caractérisés (standard cells) : à partir d'un wafer nu Pré-diffusé (gate array) et mer de portes (sea of gates) : les transistors sont déjà sur le wafer, il reste à déposer les interconnexions Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

8 Introduction au VHDL - R.WEBER - Polytech'Orleans
Comparaison ASIC/FPGA Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

9 Vision comportementale
VHDL Introduction Rappels d’électronique numérique Système combinatoire (asynchrone) : [b2,b1,b0]=f(a3,a2,a1,a0) [b2,b1,b0] [a3,a2,a1,a0] mémoire f(a3,a2,a1,a0) Fonctionnellement Vision comportementale Niveaux logiques 1 2 3 a0 and b0 a1 delay or mult b1 a2 a3 xor not b2 Mais temporellement : a b si niveaux logiques  alors delay  Mauvaise performance en temps Difficultés pour mettre au point Difficultés pour tester tous les cas Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

10 Design Synchrone Améliore les performances en vitesse
VHDL Introduction Design Synchrone clk1 (Registre = flip-flop = bascule D = Z-1) « Q=D au front de clk1, sinon Q=Q » registre D Q Feed-back combinatoire logique combinatoire logique combinatoire logique combinatoire a b c d e f g logique combinatoire clk2 a(n-1) b(n-1) c(n)=b(n-1) d(n) e(n+1)=d(n)) f(n+1) g(n+2)) ^ Améliore les performances en vitesse Simplifie la vérification fonctionnelle  Autorise des analyses statiques du timing Assure une parfaite testabilité Architectures des composants calquent cette vision (cf. architecture virtex) Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

11 Introduction au VHDL - R.WEBER - Polytech'Orleans
Qu'est-ce que le VHDL ? VHSIC Hardware Description Language VHDL est un langage de modélisation et/ou de synthèse de systèmes électroniques C'est un langage normalisé au niveau international, il est sensé être indépendant de tout compilateur ou simulateur (actuellement version 93, la version 2000 existe mais les modifications sont spécifiques). Il peut cibler des CPLDs, des FPGAs ou des Asics. Conception de haut niveau d'abstraction : Modification rapide de la conception, réduction cycle, réduction risques… Meilleur management du projet, développement de grosses conception (structure de programmation hiérarchisée) Adéquation entre le style d'écriture et les compilateurs : les résultats en terme de vitesse ou de compacité peuvent être notablement différents. Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

12 Introduction au VHDL - R.WEBER - Polytech'Orleans
Flux de conception VHDL et Niveaux d'abstraction Simulation rapide Faible précision Simulation VHDL : VHDL Synthèse comportementale validation Editeur VHDL fonctionnelle rtl Synthèse VHDL structurelle validation timing logique Fichier de contrainte Placement/Routage Simulation lente(x100) Grande précision librairies (VITAL,UNISIM…) VHDL Générique Testbench génération de stimuli comportementale rtl : Register Transfert level : ensemble de registres (synchro.), interconnectés par de la logique combinatoire Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

13 Introduction au VHDL - R.WEBER - Polytech'Orleans
Procédure de développement d'un composant programmable Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

14 Introduction au VHDL - R.WEBER - Polytech'Orleans
Premiers pas I ) Structure d’un fichier VHDL Permet d’accéder à d’autres descriptions définies dans des diverses librairies. Rem. : Plusieurs couples entity/architecture sont possibles au sein d ’un même fichier. Les clauses library et use ne sont pas globales. Leur effet s’arrête dès la déclaration d’une nouvelle entity. D'office il y a Standard et Work library ieee; use ieee.std_logic_1164.all; entity essai is port (a,b : in std_logic; c : out integer); end essai; architecture archi1 of essai is Signal s1, s2 : std_logic; begin . end archi1; Description de l’interface Description du comportement de l’entité. Pour une même entité plusieurs architectures sont possibles. a c s1 s2 b Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

15 Introduction au VHDL - R.WEBER - Polytech'Orleans
Premiers pas Exemple de projet avec l’outil Xilinx et Modelsim Simulation : (Ouvrir le webpack) Ecrire le composant en VHDL Ecrire le testbench associé en VHDL Ecrire le batch (*. do) qui va compiler tous les fichiers dont vous avez besoin pour la simulation Ouvrir Modelsim, lancer le fichier batch puis la simulation Synthèse : Ouvrir le webpack Ouvrir ou créer un projet (pas de chemin avec des espaces) Insérer tous les fichiers nécessaires dans ce projet (facultatif) Définir un fichier de contraintes (*.ucf) Lancer les différentes étapes de la synthèse. Chaque étape peut générer un fichier VHDL pour la simulation qu'il suffit de préciser ensuite dans le fichier batch de simulation. rst a rst c D b clk en en Intro.vhd Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

16 Introduction au VHDL - R.WEBER - Polytech'Orleans
Premiers pas Exemple de projet avec le webpack et ModelSim intro_tb.vhd intro.vhd library ieee; use ieee.std_logic_1164.all; entity intro_tb is end intro_tb; architecture vhd of intro_tb is component intro port ( rst : in std_logic; clk : in std_logic; en : in std_logic; a : in std_logic; b : in std_logic; c : out std_logic); end component ; signal rst : std_logic :='1'; signal clk : std_logic := '0'; signal en : std_logic:= '0'; signal a : std_logic:= '0'; signal b : std_logic:= '0'; signal c : std_logic; constant periode : time := 20 ns; begin clk <= not clk after periode/2; rst <= '1', '0' after 45 ns; --generateur pseudoaleatoire pour a et b et du en process variable m_a : std_logic_vector(6 downto 1):= "000001"; variable m_b : std_logic_vector(6 downto 1):= "011001"; variable m_en : std_logic_vector(6 downto 1):= "110001"; begin wait until clk='1'; a <= m_a(6) after periode/7; m_a(6 downto 2) := m_a(5 downto 1); m_a(1) := m_a(1) xor m_a(6); b <= m_b(6) after periode/5; m_b(6 downto 2) := m_b(5 downto 1); m_b(1) := m_b(1) xor m_b(6); en <= m_en(6) after periode/3; m_en(6 downto 2) := m_en(5 downto 1); m_en(1) := m_en(1) xor m_en(6); end process; -- instantiation du composant tester test : intro port map (rst => rst, en => en, a => a, b => b, c => c ); end vhd; library ieee; use ieee.std_logic_1164.all; entity intro is port ( rst : in std_logic; clk : in std_logic; en : in std_logic; a : in std_logic; b : in std_logic; c : out std_logic); end intro ; architecture vhd of intro is begin process (clk, rst) if rst='1' then c <= '0'; elsif rising_edge(clk) then if en='1' then c <= a and b; end if; end process; end vhd; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

17 Introduction au VHDL - R.WEBER - Polytech'Orleans
Premiers pas Exemple de projet avec le webpack et ModelSim intro.do vlib work vcom -93 intro.vhd vcom -93 intro_tb.vhd vsim intro_tb view structure view signals view wave do wave_intro.do run 1000 ns Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

18 Le Design Flow Xilinx 1) Synthesis HDL
VHDL Premiers pas Le Design Flow Xilinx 1) Synthesis Conversion VHDL => netlist HDL Machine d’états : très éfficaces pour décrire des process HDL Parsing Identification of language syntax errors Une description Bien précise = Une fonction connue Et donc optimisée HDL Synthesis Macro recognition, FSM extraction, resource sharing Soft Hard Low Level Optimization Macro implementation, timing optimization, LUT mapping, register replication Constraints .NGC .LOG Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

19 Introduction au VHDL - R.WEBER - Polytech'Orleans
Premiers pas Le Design Flow Xilinx Implement 2) Implementation includes many phases Translate: Merge multiple design files into a single netlist Map: Group logical symbols from the netlist (gates) into physical components (CLBs and IOBs) Place & Route: Place components onto the chip, connect them, and extract timing data into reports . . . Constraints Translate Map simulation Place & Route Modèle vhdl . 3) Download Fichier binaire => composants Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

20 Introduction au VHDL - R.WEBER - Polytech'Orleans
Premiers pas 1ères Règles d’écriture du VHDL VHDL 87 (obsolète), VHDL 93 ( en cours) , VHDL 2000 (très peu de changement) La simulation comportementale est indépendante du style d'écriture et du compilateur utilisée et de la cible , pas la synthèse Les commentaires commencent par deux tirets et se prolongent jusqu’à la fin de la ligne -- ceci est un commentaire En général, les commandes VHDL se terminent par ';' Aucune distinction entre les minuscules et les majuscules Règles de dénomination : 26 lettres de l ’alphabet + les 10 chiffres + ‘ _ ’ le premier caractère est une lettre interdit : v__hdl, vhdl_ et les noms réservés Valeurs explicites : entiers : 123, 1_2_3, 2#11#  3, 16#0F#  15, 2#11#e3  24 caractère ASCII: ‘ a ’ , bit : '0', '1', 'Z', '-',... chaîne de caractère : "composant programmable" bus : "0010", "001-", "0Z1"... X"F6"  " " boolean : true, false Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

21 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL II) Les objets VHDL Les objets manipulés en VHDL sont : les ports E/S (PORT) les signaux (SIGNAL) les constantes (CONSTANT) les variables (VARIABLE) (cf. les PROCESS) les paramètres (GENERIC) (cf. compléments) Ces objets représentent une valeur Ils doivent être typés vhdl standard (integer, bit, bit_vector, boolean, time, array, énumération…) librairie IEEE Standard 1164 : ieee.std_logic_1164 (std_logic, std_logic_vector,…) librairie IEEE Numeric_std (signed, unsigned,…) type défini par l'utilisateur Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

22 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Les ports E/S Exemple : Ils sont définis dans la section entity Ils listent les signaux d'interface avec l'extérieur du composant Il y a 4 modes possibles : L'affection se fait avec "<=" (sauf pour le mode IN) library ieee; use ieee.std_logic_1164.all; entity essai is port (a,b : in std_logic; c : out std_logic); end essai; architecture vhd of essai is begin c <= a and b; end vhd; essai a c b Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

23 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Les signaux Ils représentent une équipotentielle (virtuelle ou non) Ils doivent être déclarés avant utilisation Ils peuvent être déclarés : Dans un package, ils sont alors globaux Dans une entity, ils sont communs à toutes les architectures de l'entity Dans l'architecture, ils sont locaux L'affectation se fait avec "<=" L'initialisation se fait avec ":=" (attention danger car OK pour la simu mais pas pour la synthèse !) architecture rtl of essai is signal carry : std_logic :='0'; begin : carry <= a and b end rtl; entity essai is port (a,b : in std_logic; c : out integer); signal rst : std_logic; end essai; package essai is signal clk : std_logic; signal rst : std_logic :='1'; end essai; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

24 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Les ports E/S vs. les signaux essai b sigout library ieee; use ieee.std_logic_1164.all; entity essai is port (a,b : in std_logic; sigout,c : out std_logic); end essai; architecture vhd of essai is begin sigout <= a and b; c <= sigout or a; -- ne fonctionne pas end vhd; a sigbuf c La solution : utiliser un signal intermédiaire architecture vhd of essai is signal sigbuf : std_logic; begin sigbuf <= a and b; sigout <= sigbuf; c <= sigbuf or a; end vhd; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

25 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Les constantes Ils doivent être déclarés avant utilisation Ils peuvent être déclarés : Dans un package, ils sont alors globaux Dans une entity, ils sont communs à toutes les architectures de l'entity Dans l'architecture, ils sont locaux L'affectation se fait avec ":=" architecture rtl of essai is constant VCC : std_logic :='1'; constant GND : std_logic:='0'; constant periode : time := 20 ns; begin : end rtl; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

26 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Le typage des objets VHDL Types scalaires prédéfinis integer : par défaut 32bits mais limites paramétrables. ex.: signal val integer range 0 to 15 implique que val ne peut prendre que les 16 valeurs de 0 à 15. Il sera donc codé sur 4 bits natural : sous-type de integer, limité aux nombres >=0 positive : sous-type de integer, limité aux nombres >0 real : (non synthétisable pour les simus seulement) time : (non synthétisable pour les simus seulement) x := 20 ns; Types énumérations prédéfinis character, string : (ex: 'a', "bonjour") bit, bit_vector : seulement 0 ou 1 (ex. : '0', '1', "0101") type peu ou pas utilisé boolean : false ou true Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

27 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Le typage des objets VHDL (suite) std_logic et std_logic_vector( package std_logic_1164) : 9 états possibles dont 4 synthétisables 0 : bas : haut Z : haute impédance : indifférent Ex.: signal s :std_logic; -- représente 1 bit signal bus : std_logic_vector( 7 downto 0); -- représente un vecteur (un bus) de 8 bits bus(7) représente le bit de poids fort et bus(0) le bit du poids faible signal toto : std_logic_vector( 0 to 3); -- représente un vecteur (un bus) de 4 bits toto(0) représente le bit de poids fort et toto(3) le bit du poids faible s <= ‘1’; -- notez le simple cote bus <= "01-10ZZZ" ; -- notez le double cote bus(1) <= s and bus(2) ; toto <= bus (7 downto 4); affectation rapide d'un vecteur : bus <= (others => '0')  bus <= " " Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

28 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Le typage des objets VHDL (suite) Type personnalisé Tableaux d'éléments type etat is (debut, fin, stop); signal x : etat; -- idéal pour une machine d'états x<=debut; type table is array (0 to 3, 0 downto 7) of bit; signal x :table; x(2,4)<='1'; -- voilà comment est défini std_logic_vector dans la librairie 1164 type std_logic_vector is array ( natural range <>) of std_logic; signal x : std_logic_vector (5 downto 0); x<="101010"; type vs. subtype type montype is integer range 0 to 31; subtype int5b is integer range 0 to 31; signal vala : montype; signal valb : int5b; signal valc : integer range 0 to 31; vala <= valc ; --erreur !!! valb <=valc ; -- voilà comment est défini une ROM 16 x 8bits Type romtype is array ( 0 to 15) of std_logic_vector (7 downto 0); constant my_rom : romtype := ( X"FF", X"00",…,X"11"); Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

29 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL La Librairie NUMERIC_STD Elle permet de faire de l'arithmétique cc2 avec des vecteurs : use ieee.numeric_std.all; C'est aussi un vecteur, mais il représente un nombre signé ou non signé possibilités d'opérations arithmétiques ou relationnelles entre eux, mais aussi avec des integer Elle définit deux types vecteurs : SIGNED et UNSIGNED : signal u: unsigned ( 3 downto 0); -- "1010" représentent 10 signal s: signed (3 downto 0); -- "1010" représentent -6 Changement de type : to_integer(s) Type signed std_logic_vector(s) to_signed(i,nbits) signed(v) Type std_logic_vector Type integer unsigned(v) to_unsigned(i,nbits) Type unsigned std_logic_vector(u) to_integer(u) Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

30 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les opérateurs VHDL III) Les opérateurs VHDL Opérateurs logiques (sur booléens, bits et dérivés) Opérateurs relationnels (sur types scalaires ou dérivés (signed et unsigned) ) Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

31 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les opérateurs VHDL Les opérateurs VHDL (suite) Opérateurs bits (sur vecteurs de bits et types numériques) : "01" & "00" = "0100" Opérateurs arithmétiques (sur les types numériques : entiers, signés, non signés, flottant) : Opérateurs de décalage (sur les tableaux de bits, std_logic_vector, signed et unsigned) : sll, srl, sla, sra, rol, ror Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

32 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode concurrent IV) Assignation concurrente La description de la fonctionnalité se fait dans l'architecture Toutes les déclarations sont exécutées simultanément et en permanence L'ordre des déclarations dans le code source n'a pas d'importance Les déclarations possibles sont : assignation continue : "<=" instantiation d'un composant port map (déclaration préalable du composant par component) assignation conditionnelle when…else assignation sélective with…select…when…when appel d'un process instruction generate appel d'une fonction assert cf. compléments 5ème année Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

33 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode concurrent Assignation continue "<=" library ieee; use ieee.std_logic_1164.all; entity essai is port (a,b,c : in std_logic; d : out std_logic); end essai; architecture archi1 of essai is signal e: std_logic; begin d <= e and c after 5 ns; e <= a xor b after 6 ns; end archi1; xor and b a c e d en simulation uniquement pour simuler des délais Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

34 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode concurrent Instantiation d'un composant tutu essai ina a c outc inb b Le composant à instantier peut être déclaré de 3 façons : Toutes les paires entity/architecture sont déclarées dans le même fichier La paire entity/architecture est déclarée dans un autre fichier La structure component est déclarée dans une library via un package comp1 c essai a c outa a b architecture rtl of principal is component mux port (sel :in std_logic; a,b : in std_logic_vector (width-1downto 0); c : out std_logic_vector (width-1 downto 0)); end component; begin end rtl; comp2 package mon_package is component mux ...end component; end mon_package; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

35 Introduction au VHDL - R.WEBER - Polytech'Orleans
Les objets VHDL Instantiation (suite) library ieee; use ieee.std_logic_1164.all; entity tutu is port (ina,inb,a,c : in std_logic; outc,outa : out std_logic); end tut; architecture vhd of tutu is component essai is port (a,b : in std_logic; c : out std_logic); end component; begin comp1 : essai – instantiation par position port map ( ina,inb,outc); comp2 : essai – instantiation par nomination port map (b=>a, c=>outa, a=>c); end vhd; L'instantiation se fait avec "port map(…)" tutu essai ina a c outc inb b comp1 c essai a c outa a b comp2 Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

36 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode concurrent Assignation conditionnelle Forme générale : signal <= valeur when condition else autre_valeur when autre condition…; Une seule cible peut être assignée Les conditions sont sous-entendues exclusives Mémorisation implicite lorsque toutes les conditions ne sont pas listées S<= "a" when (sel="00") else "b" when (sel="01") else "c"; A <= B when c='0' else D when e='1' else  D when e='1' and c='1' else F; S<= '1' when sel="00" else '0' when sel="01" (else S); Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

37 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode concurrent Assignation sélective Forme générale : with selecteur select signal <= valeur when valeur_sel, valeur when valeur_sel ...; Importance de la clause when others qui permet de préciser tous les cas non définis. Possibilité de regrouper plusieurs valeurs du sélécteur pour une même assignation : " | ". with selecteur select x<= a when "00", b when "01", c when "10", d when others; with selecteur select x<= a when "00", b when "01" | "10", d when others; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

38 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode concurrent 1ers Exemples - Un buffer 3 états un décodeur d'adresse un latch avec reset Buffer 3 états : Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

39 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode séquentiel V) Assignation séquentielle ATTENTION, ce mode concerne uniquement les function, procedure et les process Les function et procedure ne manipulent que des variable (cf. complément 5ème année) les process manipulent variable et signal Au sein de ces descriptions, les déclarations sont exécutées de manière séquentielle L'ordre des déclarations est donc important Les déclarations possibles sont : assignation continue : "<=" pour les signal et ":=" pour les variable assignation conditionnelle if…then…elsif ... then ... else …end if; assignation sélective case… is … when… => … when … =>… end case; boucles for …. in … loop… end loop; boucles while … loop … end loop; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

40 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode séquentiel Process(liste de sensibilité) --Déclaration de constantes et variables Begin --Description séquentielle End process Les process Dans un process, l'interprétation des instructions est séquentielle MAIS l'ensemble de leur réalisation est instantanée (le temps extérieur est suspendu) : les signal sont assignés en sortie du process : '<='  "va prendre la valeur en sortie" les variable sont assignées immédiatement : ':='  "prend la valeur" les variables ne sont pas visibles à l'extérieur du process Lors d'affectation multiple, c'est la dernière qui est prise en compte. Le process n'est activé que lorsque les signal de sa liste de sensibilité ont subi un changement (attention à l’interprétation des listes incomplètes) Absence de liste de sensibilité : le process se réactive en permanence process(a,b,c, d) variable e,f,g,h : std_logic; begin a <= b; a <= c and a ; d <= a and b ; e := f ; e := g and e; h := e and f ; end process; process(a) begin c<=b and a; end process; Règle : tout signal qui modifie un autre signal ou variable doit être dans la liste de sensibilité Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

41 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode séquentiel assignation conditionnelle Forme générale : if condition then ….. elsif conditons then ….else…; Mise en oeuvre de process clockés : if clk='1' and clk'event ou if rising_edge(clk) if clk='0' and clk'event ou if falling_edge(clk) Absence de liste de sensibilité+ wait until (clk='1') placé en tête de la partie déclarative du process Attention aux mémorisations implicite et aux listes incomplètes: Structure d'un process clocké process(clk,rst) variable éventuelle begin if rst='1' then mise à zeros de c elsif rising_edge(clk) then if en='1' then description du bloc combinatoire end if end if; end process; process(a,b) -- process (a,b,c) begin if (a=b) then c<='1'; else c<='0'; end if; d<=c; end process; process(d,en) begin if en='1' then q<=d; -- else q<=q end if; end process; rst, en registre logique combinatoire a b c clk Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

42 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode séquentiel Assignation sélective Forme générale : case sélecteur is when val_select => instructiuons;... end case; Possibilité de grouper des valeurs de sélections par 'val1_select | val2_select ' par val1_select to val2_select Attention aux clauses incomplètes pouvant générer des registres ou des latches : utilisation de la clause when others process begin wait until (clk='1'); case en is when "00" | "11" => q<='1'; c<='0'; when "10" => q<='0'; c<='1'; when others => null; -- ou when others => q<= ' - '; c <= ' - '; end case; end process; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

43 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode séquentiel Les boucles loop Forme générale : for i in val_deb to val_fin loop…end loop; L'indice i de boucle n'a pas besoin d'être déclaré mais il n'est ni visible de l'extérieur ni modifiable Les bornes doivent être statiques while condition loop … end loop; process begin for i in 0 to 3 loop y(i) <= a(3-i); end loop; end process; Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

44 Introduction au VHDL - R.WEBER - Polytech'Orleans
Le mode séquentiel 1ers Exemples - Un buffer 3 états un décodeur d'adresse une rom synchrone une bascule D avec reset un compteur un registre à décalage Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

45 Introduction au VHDL - R.WEBER - Polytech'Orleans
Testbench VI) Les Testbenchs stimuli Vhdl à tester Pour générer des stimulis et valider le design vhdl. la durée s'exprime avec un type physique : fs, ps, ns, us, ms Possibilité ( nécessité) d'utiliser des ressources VHDL non synthétisable label : wait on liste_signal until condition for durée; -- dans des process wait on : attente sur évènements wait until : attente de conditions (s’il a eu un événement sinon la condition n’est pas testée) wait for : attente pour un certains temps constant Period: TIME := 25 NS; ... Stimulus: process begin A <= "0000"; B <= "0000"; wait for Period; A <= "1111"; B <= "1111"; wait; end process; wait on clk until now=1ms ; --attente synchrone d’une durée de simulation wait until now=1ms ; wait for 10 ns ; wait until clk=‘1’ ; -- attente d’un front montant Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

46 Introduction au VHDL - R.WEBER - Polytech'Orleans
Testbench Les Testbenchs signal <= valeur after durée absolue, valeur after durée absolue ,… ; H <= "00", "01" after 10 NS, "10" after 20 NS; clk<= not clk after 50 ns; -- génération d’une horloge à 10 MHz Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

47 Introduction au VHDL - R.WEBER - Polytech'Orleans
Complément VII) Les Compléments Les Paramètres Génériques Les Fonctions Les Procédures Les Packages La boucle Generate Package Textio Les Attributs Les assertions Les Configurations cf. compléments 5ème année Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO

48 Introduction au VHDL - R.WEBER - Polytech'Orleans
Complément Les paramètres génériques Ils sont déclarés dans l'entity Ils permettent de paramétrer des composants une valeur par défaut peut être définie (":=") l'instanciation se fait grâce à "generic map(…)" entity mux is generic (width : integer :=8); port (sel :in std_logic; a,b : in std_logic_vector (width-1 downto 0); c : out std_logic_vector (width-1 downto 0)); end mux; architecture behav of mux is begin c<=a when sel='0' else b; end behav; comp1 : mux generic map ( 4) port map(sel=>seldata, a=> dataa, b=> datab, c=>data); comp2 : mux port map (sel=>seladr, a=>adra, b=> adrb, c=>adr); Introduction au VHDL - R.WEBER - Polytech'Orleans ESPEO


Télécharger ppt "Introduction au VHDL - R.WEBER - Polytech'Orleans"

Présentations similaires


Annonces Google