Sie sind auf Seite 1von 11

ESSAT GABES

GE 2èmme Année
FPGA
ING_GE TP 3 ESSAT GABES

conceptions de systèmes numériques


ENSEIGNANT : M. TAYARI LASSAAD
Initiation à VHDL avec ISE de Xilinx (V14.4)

T P N°2
I. Objectif
L’objectif de ce module de TP est, au travers de la réalisation de différents petits projets,
d’apprendre à utiliser les outils de la suite logicielle ISE design sofware de la société Xilinx
pour configurer des composants logiques programmables à partir d’une description en VHDL.
Pré Requis : connaître les fonctions logiques de base.

II. Déroulement
La conduite d’un projet simple comporte les étapes suivantes :
1. Description du projet avec le module ISE qui comporte différents modes d’entrée tels
que :
• Texte VHDL ou Verilog HDL
• Schéma bloc
• Machine d’états
2. Simulation fonctionnelle avec le module ModelSim
Cette étape permet d’entrer des stimuli, de simuler le comportement des éléments du projet
et de visualiser les résultats sous forme de chronogrammes ou de listes d’états.
3. Synthèse
L’outil de synthèse XST (Xilinx Synthesis Technology) crée, à partir des fichiers texte
VHDL, un fichier du type « netlist » de très bas niveau qui décrit les fonctions à implémenter
dans le composant.
4. Implémentation dans un CPLD (XCRP) ou FPGA (sapartanIII) ou (ARTIX7) carte
NEXYS4.
Elle comporte deux étapes :
• Traduction (Translation) du modèle logique du composant en une autre forme qui
tient compte de l’architecture du composant, et vérification de la validité des
contraintes imposées par l’utilisateur (temps de propagation, brochage).
• Adaptation du modèle précédant (Fitting) aux ressources du composant en tenant
compte des contraintes.
5. Simulation post-implémentation
Elle consiste à simuler le fonctionnement du composant en tenant compte du chemin suivi
par les signaux et donc des temps de propagation (simulateur ModelSim).
6. Programmation du composant
Elle commence par la création d’un fichier de programmation au format standard JEDEC
puis la configuration du composant sur l’application cible avec le logiciel iMPACT

7. Test électrique du projet


Nous utilisons comme application cible une carte d’évaluation Digilab XCRP ou
Spartan III de la société Digilent.
Cette carte est équipée d’un circuit CPLD CoolRunner XCR3064PC44 ou FPGA
XC3S200.
FPGA ESSAT GABES

III. Projets proposés


Le tableau de la figure 1 donne la liste des projets proposés.
Exemple n° Fichier.vhd Mode Type Instructions
d’instructions
1 Basic_gates combinatoire concourantes équations logiques
2 Comparateur combinatoire concourantes when-else
3 Hex27seg combinatoire concourantes when-else
4 Bcd27seg combinatoire concourantes with-select
5 Dec3v8 combinatoire process case
6 Demux1v8 combinatoire process case
7 Com_mot_2v séquentiel process machine d’état sorties
combinatoire
8 Com_mot_2s séquentiel process machine d’état sorties
synchronisées

Figure 1

Compte rendu
Les résultats obtenus à chaque étape de chaque projet seront analysés et consignés dans
un compte rendu sur l’ensemble des projets.
Pour chaque projet il sera présenté :
- La fonction du composant réalisé
- Une analyse du fichier source expliquant les nouvelles instructions utilisées
- Les tests proposés pour la simulation en justifiant leur choix.
- Les résultats de la simulation et leur interprétation.
- Les ressources utilisées après implémentation dans le composant
- Les équations logiques synthétisées
- Les résultats de tests effectués avec la carte d’évaluation
FPGA ESSAT
GABES

-- Exemple 1 Fonctions logiques de base (équations booléennes)

-- mode concourant
-- Le système est purement combinatoire
-- Il utilise le symbole d'affectation <=
-- La mise jour est effective à la dernière instruction
-- fichier Basic_gates.vhd

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- le standard IEEE 1164 définit des signaux std_logic à 9 niveaux :


-- 0, 1, Z(haute impédance), - (indifférent), etc

-- Description externe du système


entity Basic_Gates is
Port ( a : in std_logic; -- SW1
b : in std_logic; -- SW2
y1 : out std_logic; -- LED1
y2 : out std_logic; -- LED2
y3 : out std_logic; -- LED3
y4 : out std_logic; -- LED4
y5 : out std_logic; -- LED5
y6 : out std_logic; -- LED6
y7 : out std_logic); -- LED7
end Basic_Gates;

-- Description du fonctionnement interne


architecture Behavioral of Basic_Gates is
begin

-- liste d'instructions concourantes


y1 <= a and b;
y2 <= a or b;
y3 <= a xor b;
y4 <= not a;
y5 <= a nand b;
y6 <= a nor b;
y7 <= not(a xor b);

-- mise a jour des sorties


end Behavioral;
FPGA ESSAT
GABES
-- Exemple 2 : comparateur 4 bits

-- Fichier Comparateur.vhd
-- mode concourant
-- utilise l''assignation conditionnelle WHEN ... ELSE

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

-- Description externe du système


entity Comparateur is
Port ( A : in std_logic_vector(3 downto 0); -- SW1 ..SW4
B : in std_logic_vector(3 downto 0); -- SW5 ..SW8
SUP : out std_logic; -- LED3
INF : out std_logic; -- LED1
EGAL : out std_logic); -- LED2
end Comparateur;

-- Description du fonctionnement interne


architecture Behavioral of Comparateur is

begin
SUP <= '1' WHEN A>B ELSE '0';
INF <= '1' WHEN A<B ELSE '0';
EGAL <='1' WHEN A=B ELSE '0';

end Behavioral;
FPGA ESSAT
GABES
-- Exemple 3 : décodeur hexadecimal 7 segments

-- fichier Hex2seg.vhd
-- mode concourant
-- utilise un signal interne

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity HEX27SEG is
Port ( i : in std_logic_vector(3 downto 0); -- SW1,SW2,SW3,SW4
a : out std_logic; -- AA
b : out std_logic; -- AB
c : out std_logic; -- AC
d : out std_logic; -- AD
e : out std_logic; -- AE
f : out std_logic; -- AF
g : out std_logic; -- AG
cat1 : out std_logic; -- CAT1
cat2 : out std_logic); -- CAT2
end HEX27SEG;

architecture Behavioral of HEX27SEG is

SIGNAL seg :std_logic_vector(0 to 6);


BEGIN

seg <= "1111110" when i=0


ELSE "0110000" when i=1
ELSE "1101101" when i=2
ELSE "1111001" when i=3
ELSE "0110011" when i=4
ELSE "1011011" when i=5
ELSE "1011111" when i=6
ELSE "1110000" when i=7
ELSE "1111111" when i=8
ELSE "1111011" when i=9
ELSE "1110111" when i=10
ELSE "0011111" when i=11
ELSE "0001101" when i=12
ELSE "0111101" when i=13
ELSE "1001111" when i=14
ELSE "1000111" when i=15;

a <= seg(0);
b <= seg(1);
c <= seg(2);
d <= seg(3);
e <= seg(4);
f <= seg(5);
g <= seg(6);
cat1 <= '0';
cat2 <= '1';
end Behavioral;
FPGA ESSAT
GABES
-- exemple 4 :décodeur BCD 7 segments

-- fichier BCD27SEG.vhd
-- mode concourant
-- utilise l'assignation conditionnelle WITH SELECT <= WHEN

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity BCD27SEG is
Port ( i : in std_logic_vector(3 downto 0); -- SW1,SW2,SW3,SW4
a : out std_logic; -- AA
b : out std_logic; -- AB
c : out std_logic; -- AC
d : out std_logic; -- AD
e : out std_logic; -- AE
f : out std_logic; -- AF
g : out std_logic; -- AG
cat1 : out std_logic; -- CAT1
cat2 : out std_logic); -- CAT2
end BCD27SEG;

architecture Behavioral of BCD27SEG is

SIGNAL seg :std_logic_vector(0 to 6);


BEGIN
WITH i SELECT
seg <="1111110" WHEN "0000",
"0110000" WHEN "0001",
"1101101" WHEN "0010",
"1111001" WHEN "0011",
"0110011" WHEN "0100",
"1011011" WHEN "0101",
"1011111" WHEN "0110",
"1110000" WHEN "0111",
"1111111" WHEN "1000",
"1111011" WHEN "1001",
"-------" WHEN OTHERS ;

a <= seg(0);
b <= seg(1);
c <= seg(2);
d <= seg(3);
e <= seg(4);
f <= seg(5);
g <= seg(6);
cat1 <= '0';
cat2 <= '1';
end Behavioral;
FPGA ESSAT
GABES
-- Exemple 5 : décodeur octal

-- fichier Decodeur_octal.vhd
-- mode combinatoire
-- utilise l'assignation conditionnelle IF THEN ELSE dans un process

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Decodeur_Octal is
Port ( E : in std_logic_vector(2 downto 0); -- SW1,SW2,SW3
S0 : out std_logic; -- LED1
S1 : out std_logic; -- LED2
S2 : out std_logic; -- LED3
S3 : out std_logic; -- LED4
S4 : out std_logic; -- LED5
S5 : out std_logic; -- LED6
S6 : out std_logic; -- LED7
S7 : out std_logic); -- LED8
end Decodeur_Octal;

architecture Behavioral of Decodeur_Octal is

BEGIN
PROCESS(E) BEGIN
IF E="0000" THEN S0 <='1'; ELSE S0 <='0';END IF;
IF E="0001" THEN S1 <='1'; ELSE S1 <='0';END IF;
IF E="0010" THEN S2 <='1'; ELSE S2 <='0';END IF;
IF E="0011" THEN S3 <='1'; ELSE S3 <='0';END IF;
IF E="0100" THEN S4 <='1'; ELSE S4 <='0';END IF;
IF E="0101" THEN S5 <='1'; ELSE S5 <='0';END IF;
IF E="0110" THEN S6 <='1'; ELSE S6 <='0';END IF;
IF E="0111" THEN S7 <='1'; ELSE S7 <='0';END IF;

END PROCESS;

end Behavioral;

-- Exemple 6 : Décodeur 3 vers 8

-- fichier Dec3V8.vhd
-- mode combinatoire
-- utilise l'assignation conditionnelle CASE dans un process

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Decodeur3V8 is
Port ( SEL : in std_logic_vector(2 downto 0);-- SW1,SW2,SW3
S : out std_logic_vector(7 downto 0));-- LEDs 1 a 8
end Decodeur3V8;

architecture Behavioral of Decodeur3V8 is


FPGA ESSAT
GABES
begin
PROCESS(SEL )BEGIN
CASE SEL IS
WHEN "000" => S <= "00000001";
WHEN "001" => S <= "00000010";
WHEN "010" => S <= "00000100";
WHEN "011" => S <= "00001000";
WHEN "100" => S <= "00010000";
WHEN "101" => S <= "00100000";
WHEN "110" => S <= "01000000";
WHEN OTHERS =>S <= "10000000";
END CASE;
END PROCESS;

end Behavioral;

-- Exemple 7 : Démultiplexeur 1 vers 8

-- fichier demux1V8
-- mode combinatoire
-- utilise l'assignation conditionnelle CASE dans un process
-- utilise le mot clé OTHERS

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Demux1V8 is
Port ( E : in std_logic; -- BTN1
SEL : in std_logic_vector(2 downto 0); -- SW1,SW2,SW3
S : out std_logic_vector(7 downto 0)); -- LEDS 1 à 8
end Demux1V8;

architecture Behavioral of Demux1V8 is

BEGIN
PROCESS(SEL,E) BEGIN
CASE SEL IS
WHEN "000" => S <= (0=>E,OTHERS=>'0');
WHEN "001" => S <= (1=>E,OTHERS=>'0');
WHEN "010" => S <= (2=>E,OTHERS=>'0');
WHEN "011" => S <= (3=>E,OTHERS=>'0');
WHEN "100" => S <= (4=>E,OTHERS=>'0');
WHEN "101" => S <= (5=>E,OTHERS=>'0');
WHEN "110" => S <= (6=>E,OTHERS=>'0');
WHEN OTHERS => S <=(7=>E,OTHERS=>'0');
END CASE;
END PROCESS;

end Behavioral;
FPGA ESSAT
GABES

-- Exemple 8 :Commande d'un moteur 2 vitesses

-- Machine d'état à sortie combinatoire


-- la grande vitesse passe obligatoirement par la petite vitesse
-- fichier com_mot_2_v.vhd

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity Com_Mot_2V is
Port ( Clk : in std_logic; -- MCLK
Rst : in std_logic; -- BTN1
Ma_PV : in std_logic; -- BTN2
MA_GV : in std_logic; -- BTN3
At : in std_logic; -- BTN4
K_PV : out std_logic; -- LED1
K_GV : out std_logic); -- LED2
end Com_Mot_2V;

architecture Behavioral of Com_Mot_2V is

type type_etat is (arret, p_vitesse,g_vitesse);


signal etat: type_etat;
begin
process (clk, rst)
begin
if rst='1' then
etat <= arret;
elsif (clk'event and clk='1') then
case etat is
when arret =>
if Ma_PV='1' then
etat <= p_vitesse;
end if;
when p_vitesse =>
if At = '1' then
etat <= arret;
elsif Ma_GV ='1'then
etat <= g_vitesse;
end if;
when g_vitesse =>
if At='1' then
etat <= arret;
elsif Ma_PV='1'then
etat <= p_vitesse;
end if;
end case;
end if;
end process;
-- assignation des sorties
K_PV <='1'when etat=p_vitesse else '0';
K_GV <='1'when etat=g_vitesse else '0';
end Behavioral;
FPGA ESSAT
GABES

Exemple 9 : Commande d’un moteur à 2 sens de rotation

Description comportementale par une machine d’états

Le fichier VHDL est obtenu par compilation du diagramme EX_14

Arriere
av <='0';
ar <='1';

mar = '1' and mav='0' at= '1'

rst = '1' Arret


av = '0';
ar = '0';

at = '1' mav = '1' and mar ='0'

Avant
av <= '1';
ar <= '0';

Machine d’états Ex_14

-- C:\JOB\XILINX_JOB\EXEMPLE_14\EX_14.vhd
-- VHDL code created by Xilinx's StateCAD 5.03
-- Sun Oct 17 10:53:40 2004

-- This VHDL code (for use with Xilinx XST) was generated using:
-- enumerated state assignment with structured code format.
-- Minimization is enabled, implied else is enabled,
-- and outputs are area optimized.
LIBRARY ieee;
USE ieee.std_logic_1164.all;

ENTITY EX_14 IS
PORT (CLK,at,mar,mav,rst: IN std_logic; --MCLK,BTN2,BTN1,BTN3,BTN4
ar,av : OUT std_logic);
END;

ARCHITECTURE BEHAVIOR OF EX_14 IS


TYPE type_sreg IS (Arret,Arriere,Avant);
SIGNAL sreg, next_sreg : type_sreg;
BEGIN
PROCESS (CLK, rst)
BEGIN
FPGA ESSAT
GABES
IF ( rst='1' ) THEN
sreg <= Arret;
ELSIF CLK='1' AND CLK'event THEN
sreg <= next_sreg;
END IF;
END PROCESS;

PROCESS (sreg,at,mar,mav)
BEGIN
ar <= '0'; av <= '0';

next_sreg<=Arret;

CASE sreg IS
WHEN Arret =>
av<='0';
ar<='0';
IF ( mav='0' AND mar='0' ) OR ( mar='1' AND mav='1'
THEN
next_sreg<=Arret;
END IF;
IF ( mav='1' AND mar='0' ) THEN
next_sreg<=Avant;
END IF;
IF ( mar='1' AND mav='0' ) THEN
next_sreg<=Arriere;
END IF;
WHEN Arriere =>
av<='0';
ar<='1';
IF ( at='1' ) THEN
next_sreg<=Arret;
ELSE
next_sreg<=Arriere;
END IF;
WHEN Avant =>
av<='1';
ar<='0';
IF ( at='1' ) THEN
next_sreg<=Arret;
ELSE
next_sreg<=Avant;
END IF;
WHEN OTHERS =>
END CASE;
END PROCESS;
END BEHAVIOR

Das könnte Ihnen auch gefallen