realisation de controlleur vga(vhdl)
Embed Size (px)
DESCRIPTION
this is my first step of realisation of one VHDL design project (VGA )TRANSCRIPT

1
Rapport : Contrôleur d’affichage vidéo VGARéaliser par :
AYARI YAHIA & DAHMANI MOHAMED
2010/2011

Sommaire
But :
Introduction : Description des machines à état :
Décoder : Générateur de synchronisation :
Synchro ligne : Synchro trame :
Afficher : Description matérielle :
Schéma RTL : Description en VHDL (code source) :
MUX1 : ROM : RAM : MUX2 : Séquenceurs :
Générateur de décodage : Gestionnaire d’affichage : Générateur de synchronisation :
Générateur trame Générateur ligne :
Top module VGA : Les scenarios de test (TEST BENCH):
Test MUX Test ROM: Test decoder: Test afficher : Test ligne : Test trame : Test VGA:
2

Simulation: Fichier texte:
Exemple de simulation: Rapport technique : Outils de développement : Conclusion :
3

BUT :
Notre projet sert à réaliser une propriété intellectuelle d’affichage vidéo VGA destiné au
débogage hardware en environnement FPGA. Dans ce TP on va se familiariser avec un outil
de développement hard trop connu XILINX, puis on va implémenter notre application sur
une FPGA adéquate.
I. Introduction :
Il existe plusieurs modes pour la norme VGA, et nous allons utiliser celle dont la définition de
l’image est de 640×480 dont les informations sont codées chacune sur un ensemble de bit.
Le protocole VGA consiste à utiliser deux signaux de synchronisation horizontale
SL et verticale ST pour pouvoir guider la manière d’afficher. Pour une qui parvient à tous les
pixels de l’écran à une fréquence de 25 MHz (soit à une période de 40 ns).
Le module d’affichage VGA lit une image à partir d’une mémoire et l’affiche sur un écran. Les
contraintes à prendre en compte sont les contraintes de temps d’accès aux données des
pixels et leur transmission sur un câble VGA dans les délais requis. D’autres difficultés se
présentent aussi, surtout lorsque l’image en question stockée dans la mémoire est lue à
partir d’un PC à travers un câble série.
Dans ce cas, il faut gérer et organiser l’accès en lecture et en écriture à la mémoire par les
différentes unités et en utilisant des autres modules de traitement et de gestion qui seront
des extensions pour notre application et notre IP ;
Cette IP étant intégré dans des applications matérielles sur FPGA permet de visualiser sur
écran SVGA une ligne de 8 caractère des valeurs hexadécimaux à partir de 8 signaux en entré
U0-U7 codés sur 4 bits.
4

25MHZ
U<0>
U<7>
SPECIFICATION EXTERNE D’IP
En sortie : cette IP fournira des signaux de contrôle d’affichage vidéo :
ST : Synchronisation de début d’une image (trame) affichée en temps réels.
SL : Synchronisation de début d’une ligne.
SP : Synchronisation de Transfer d’un pixel<<point image>>.
RVB(Final) : signal résultat validé à chaque front montant d’horloge.
La fréquence de rafraichissement doit être suffisante pour tromper la persistance de l’œil
humaine, les pixels sont affichés séquentiellement par succession de lignes horizontaux de
haut en bas, le balayage de ligne s’effectue de droite à gauche.
Pour cette IP on choisie l’affichage SVGA SP=25 MHZ, SL=31.25 KHZ, ST=62. HZ
On distingue les modules suivants :
Chemin de données :
Mux1 : multiplexeur des signaux Ui.
ROM : permet de garder la police des caractères en mémorisant les fonts de ces caractères
hexadécimaux de 0 à F.
RAM : une mémoire en double port pour mémoriser le plan image dit bitmap.
Mux2 : pour la sérialisation des mots binaire vers les signaux d’affichage.
5
Module d’affichage de 16
Mots binaires à 4 bits
ST
SL
SP
RVB

Séquenceurs :
Gestion de décodage binaire : ce module ce module séquentielle à chaque début de trame
il sert à indexer la Rom et la Ram pour pouvoir savoir d’où et où en va écrire.
Gestion d’affichage : ce module génère le signal sortie et gère le nombre de colonne et de
ligne de la trame lors de la l’écriture il est dirigé par le générateur de synchronisation.
Gestion de synchronisation : ce module génère les synchro trame ST et les synchro ligne SL.
C’est lui qui indique le début d’une trame ou celle d’une ligne.
6

Description des machines à états :
a) Décoder :
b) Générateur de synchronisation :
Synchro ligne :
7

Synchro trame :
8

c) Afficher :
9

I. Description matérielle: 1. Schema RTL
10

II. Description en VHDL (code source):
1. MUX1
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity MUX_8_1 is port(
u0 : in STD_LOGIC_vector(3 downto 0); ----les données à afficher----
u1 : in STD_LOGIC_vector(3 downto 0);
u2 : in STD_LOGIC_vector(3 downto 0);
u3 : in STD_LOGIC_vector(3 downto 0);
u4 : in STD_LOGIC_vector(3 downto 0);
u5 : in STD_LOGIC_vector(3 downto 0);
u6 : in STD_LOGIC_vector(3 downto 0);
u7 : in STD_LOGIC_vector(3 downto 0);
11

se : in STD_LOGIC_vector(2 downto 0); -----entrée selective-----
ds : out STD_LOGIC_vector(3 downto 0)); -----sortie de MUX------
end MUX_8_1;
architecture MUX_8_1 of MUX_8_1 is
begin
process(se,u0,u1,u2,u3,u4,u5,u6,u7)
begin
Case se is
when "000" => ds <= u0;
when "001" => ds <= u1;
when "010" => ds <= u2;
when "011" => ds <= u3;
when "100" => ds <= u4;
when "101" => ds <= u5;
when "110" => ds <= u6;
when "111" => ds <= u7;
when others => ds <= "0000" ;
end case ;
end process;
end MUX_8_1;
12

2. ROM
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 15:43:06 03/14/2011
-- Design Name:
-- Module Name: ROM - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
13

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity ROM is port(
A: in std_logic_vector(9 downto 0);
data:out std_logic);
end ROM;
architecture Behavioral of ROM is
signal inter :std_logic_vector(63 downto 0):=(others => '0');
signal i:integer range 127 downto 0 :=0;
signal j:integer range 63 downto 0 :=0;
type police is array(127 downto 0) of std_logic_vector(7 downto 0);
constant D : police := (
0 => "01110000", --0--
1 => "10001000",
2 => "10001000",
3 => "10001000",
4 => "10001000",
5 => "10001000",
6 => "10001000",
7 => "01110000",
8 => "00100000", --1--
9 => "01100000",
10 => "10100000",
11 => "00100000",
12 => "00100000",
14

13 => "00100000",
14 => "00100000",
15 => "11111000",
16 => "01110000", --2--
17 => "10001000",
18 => "10001000",
19 => "00010000",
20 => "00100000",
21 => "01000000",
22 => "11111000",
23 => "11111000", --3--
24 => "00001000",
25 => "00001000",
26 => "01111000",
27 => "01111000",
28 => "00001000",
29 => "00001000",
30 => "11111000",
31 => "10000000", --4--
32 => "10000000",
33 => "10010000",
34 => "10010000",
35 => "11111000",
36 => "00010000",
37 => "00010000",
38 => "00010000",
39 => "11111000", --5--
40 => "10000000",
41 => "10000000",
42 => "10000000",
15

43 => "11111000",
44 => "00001000",
45 => "00001000",
46 => "11111000",
47 => "11111000", --6--
48 => "00001000",
49 => "00001000",
50 => "11111000",
51 => "10001000",
52 => "10001000",
53 => "10001000",
54 => "11111000",
55 => "11111000", --7--
56 => "10001000",
57 => "00001000",
58 => "00001000",
59 => "00010000",
60 => "00100000",
61 => "01000000",
62 => "10000000",
63 => "11111000", --8--
64 => "10001000",
65 => "10001000",
66 => "11111000",
67 => "10001000",
68 => "10001000",
69 => "10001000",
70 => "11111000",
71 => "11111000", --9--
72 => "10001000",
16

73 => "10001000",
74 => "11111000",
75 => "00001000",
76 => "00001000",
77 => "10001000",
78 => "11111000",
79 => "01110000", --A--
80 => "10001000",
81 => "10001000",
82 => "10001000",
83 => "11111000",
84 => "10001000",
85 => "10001000",
86 => "10001000",
87 => "11111000", --B--
88 => "10001000",
89 => "10001000",
90 => "11111000",
91 => "10001000",
92 => "10001000",
93 => "10001000",
94 => "11111000",
95 => "11111000", --C--
96 => "10001000",
97 => "10000000",
98 => "10000000",
99 => "10000000",
100=> "10000000",
101=> "10000000",
102=> "10000000",
17

103=> "11111000",
104=> "11110000", --D--
105=> "10001000",
106=> "10001000",
107=> "10001000",
108=> "10001000",
109=> "10001000",
110=> "10001000",
111=> "11110000",
112=> "11111000", --E--
113=> "10001000",
114=> "10000000",
115=> "10000000",
116=> "11110000",
117=> "10000000",
118=> "10001000",
119=> "11111000",
120=> "11111000", --F--
121=> "10001000",
122=> "10000000",
123=> "11110000",
124=> "10000000",
125=> "10000000",
126=> "10000000",
127=> "10000000");
begin
i <= 8*(to_integer ( unsigned (A(3 downto 0))));
18

j <= (to_integer ( unsigned (A(9 downto 4))));
inter(7 downto 0) <= D(i); inter(39 downto 32) <= D(i+4);
inter(15 downto 8) <= D(i+1); inter(47 downto 40) <= D(i+5);
inter(23 downto 16) <= D(i+2); inter(55 downto 48) <= D(i+6);
inter(31 downto 24) <= D(i+3); inter(63 downto 56) <= D(i+7);
data <= inter(j);
end Behavioral;
3. RAM
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 14:40:18 03/15/2011
-- Design Name:
-- Module Name: RAM - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
19

----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity RAM_VGA is port(
A: in std_logic_vector(8 downto 0);
R: in std_logic_vector(8 downto 0);
Din,clk,WR:in std_logic;
Dout:out std_logic);
end RAM_VGA;
architecture Behavioral of RAM_VGA is
signal RAM_MEM:std_logic_vector(511 downto 0);
begin
write_process: Process(clk,WR)
begin
if(clk' event and clk='1') then
20

if WR='1' then
(RAM_MEM(to_integer(unsigned(A)))) <= Din;
end if;
end if;
end process;
read_process: process(R,wr,RAM_MEM)
begin
if(wr='0')then
Dout <= (RAM_MEM(to_integer(unsigned(R))));
end if;
end process;
end Behavioral;
4. MUX2
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity MUX_2_1 is port(
enter : in STD_LOGIC; ----les données à afficher----
mass : in STD_LOGIC;
se : in std_logic; -----entrée selective-----
21

final : out STD_LOGIC); -----sortie de MUX------
end MUX_2_1;
architecture Behavioral of MUX_2_1 is
begin
process (se,enter,mass)
begin
Case se is
when '0' => final <= mass;
when '1' => final <= enter;
when others => final <= '0' ;
end case ;
end process;
end Behavioral;
5. Sequenceurs a) Gestionneur de decodage
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
22

use IEEE.STD_LOGIC_unsigned.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity decoder is port(
st,clk:in std_logic;
wr:out std_logic;
sortie:out std_logic_vector(8 downto 0));
end decoder;
architecture Behavioral of decoder is
type state is(repot,copier,fin_t);
signal etat:state;
signal inter:std_logic_vector(8 downto 0):=(others => '0');
begin
process(clk)
begin
if(clk'event and clk='1') then
case etat is
when repot => ---repot--
23

inter<="000000000";
wr<='0';
if st='0' then
etat<= copier;
end if;
when copier =>
sortie<=inter; ---copier --
inter<=inter+"000000001";
wr<='1';
if inter="111111111" then
etat<= fin_t;
end if;
when fin_t => ---fin_t--
wr<='0';
if st='1' then
etat<= repot;
end if;
end case;
end if;
end process;
end Behavioral;
24

b) Gestionnaire d’affichage
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity affichage is port(
clk,ft,fl:in std_logic;
nl:out std_logic_vector( 2 downto 0);
nc:out std_logic_vector( 5 downto 0);
noir:out std_logic);
end affichage;
architecture Behavioral of affichage is
type state is(repot,attendre_fl,ligne,incrementation,fin_ligne,fin_trame);
signal etat:state;
signal nc1:std_logic_vector( 5 downto 0):=(others => '0');
signal nl1:std_logic_vector( 3 downto 0):=(others => '0');
25

begin
process(clk)
begin
if (clk' event and clk='1') then
case etat is
when repot => ---repot--
noir<='0';
nc1<="000000";
nl1<="0000";
if ft='1' then
etat<= attendre_fl;
end if;
when attendre_fl => ---attendre fenetre ligne--
noir<='0';
nc1<="000000";
if fl='1' then
etat<= ligne;
end if;
when ligne =>
---affichage d'une ligne---
noir<='1';
nc<=nc1;
nc1<=nc1+"000001";
if nc1="111111" then
etat<= incrementation;
end if;
26

when incrementation => ---incrementation de nombre de ligne----
noir<='0';
nc1<="000000";
nl1<=nl1+"0001";
nl<=nl1(2 downto 0);
if nl1="1000" then
--etat<=fin_ligne;
etat<=fin_trame;
end if;
if nl1/="1000" then
etat<= fin_ligne;
end if;
when fin_ligne => ----fin ligne-------------
noir<='0';
if fl='0' then
etat<= attendre_fl;
end if;
when fin_trame => ----fin trame----
noir<='0';
if ft='0' then
etat<= repot;
end if;
end case;
end if;
27

end process;
end Behavioral;
c) Générateur de synchronisation i. Générateur ligne
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 19:32:25 03/17/2011
-- Design Name:
-- Module Name: generateur_ligne - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
28

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity generateur_ligne is port(
clk: in std_logic;
sl,fl:out std_logic );
end generateur_ligne;
architecture Behavioral of generateur_ligne is
type state is(deb,tsl,gap1,gap2,ligne);
signal etat : state;
signal n : integer range 0 to 800;
begin
process(clk)
begin
if (clk' event and clk='1') then
case etat is
when deb => ---debut--
n<= 800;
sl<='1';
fl<='0';
etat<= tsl;
29

when tsl => ---retour en ligne--
n<= n-1;
sl<='0';
fl<='0';
if n=740 then
etat<= gap1;
end if;
when gap1 => ---debut d'une fenetre ligne---
n<=n-1;
sl<='1';
fl<='0';
if n=690 then
etat<= ligne;
end if;
when ligne => ---ligne à écrire ----
n<=n-1;
sl<='1';
fl<='1';
if n=50 then
etat<= gap2;
end if;
when gap2 => ----fenetre ligne (blanc aprés ligne)----
n<=n-1;
sl<='0';
fl<='0';
if n=0 then
etat<= deb;
end if;
30

end case;
end if;
end process;
end Behavioral;
ii. Générateur trame
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 13:11:39 03/29/2011
-- Design Name:
-- Module Name: generateur_trame - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
31

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity generateur_trame is port(
sl:in std_logic;
st,ft:out std_logic);
end generateur_trame;
architecture Behavioral of generateur_trame is
type state is(deb,tst,gapt1,page,gapt2);
signal etat:state;
signal n : integer range 0 to 503;
begin
process(sl)
begin
if (sl='0') then
32

case etat is
when deb => ---debut-----
n<=503;
st<='1';
ft<='0';
etat<= tst;
when tst => ---nouvelle trame--
n<= n-1;
st<='0';
ft<='0';
if n=495 then
etat<= gapt1;
end if;
when gapt1 => ---debut d'une fenetre trame---
n<=n-1;
st<='1';
ft<='0';
if n=490 then
etat<= page;
end if;
when page => ---trame à écrire ----
n<=n-1;
st<='1';
ft<='1';
if n=10 then
etat<= gapt2;
end if;
when gapt2 => ----fenetre trame (blanc aprés les lignes)----
n<=n-1;
st<='1';
33

ft<='0';
if n=0 then
etat<= deb;
end if;
end case;
end if;
end process;
end Behavioral;
6. Top module VGA
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 13:13:09 04/09/2011
-- Design Name:
-- Module Name: top - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
34

-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity top is port(
uu0 : in std_logic_vector(3 downto 0);
uu1 : in std_logic_vector(3 downto 0);
uu2 : in std_logic_vector(3 downto 0);
uu3 : in std_logic_vector(3 downto 0);
uu4 : in std_logic_vector(3 downto 0);
uu5 : in std_logic_vector(3 downto 0);
uu6 : in std_logic_vector(3 downto 0);
uu7 : in std_logic_vector(3 downto 0);
clk_25MHZ: in std_logic;
sl,st:out std_logic;
final:out std_logic
35

);
end top;
architecture top of top is
COMPONENT ROM
PORT(
A : IN std_logic_vector(9 downto 0);
data : OUT std_logic
);
END COMPONENT;
COMPONENT RAM_VGA
port(
A: in std_logic_vector(8 downto 0);
R: in std_logic_vector(8 downto 0);
Din,clk,WR:in std_logic;
Dout:out std_logic
);
END COMPONENT;
COMPONENT MUX_8_1
PORT(
u0 : in STD_LOGIC_vector(3 downto 0);
u1 : in STD_LOGIC_vector(3 downto 0);
u2 : in STD_LOGIC_vector(3 downto 0);
u3 : in STD_LOGIC_vector(3 downto 0);
u4 : in STD_LOGIC_vector(3 downto 0);
u5 : in STD_LOGIC_vector(3 downto 0);
36

u6 : in STD_LOGIC_vector(3 downto 0);
u7 : in STD_LOGIC_vector(3 downto 0);
se : in STD_LOGIC_vector(2 downto 0);
ds : out STD_LOGIC_vector(3 downto 0));
END COMPONENT;
COMPONENT MUX_2_1
PORT(
enter : in STD_LOGIC;
mass : in STD_LOGIC;
se : in std_logic;
final : out STD_LOGIC);
END COMPONENT;
COMPONENT affichage
PORT(
clk : IN std_logic;
ft : IN std_logic;
fl : IN std_logic;
nl : OUT std_logic_vector(2 downto 0);
nc : OUT std_logic_vector(5 downto 0);
noir : OUT std_logic
);
END COMPONENT;
COMPONENT decoder
PORT(
st : IN std_logic;
clk : IN std_logic;
wr : OUT std_logic;
37

sortie : OUT std_logic_vector(8 downto 0)
);
END COMPONENT;
COMPONENT generateur_trame
PORT(
sl : IN std_logic;
st : OUT std_logic;
ft : OUT std_logic
);
END COMPONENT;
COMPONENT generateur_ligne
PORT(
clk : IN std_logic;
sl : OUT std_logic;
fl : OUT std_logic
);
END COMPONENT;
signal ds1:std_logic_vector(3 downto 0);
signal sortie1:std_logic_vector(8 downto 0);
signal data1:std_logic;
signal WR1:std_logic;
signal DOUT1:std_logic;
signal noir1:std_logic;
signal nc1:std_logic_vector( 5 downto 0);
signal nl1:std_logic_vector( 2 downto 0);
38

signal ft1:std_logic;
signal fl1:std_logic;
signal st1:std_logic;
signal sl1:std_logic;
signal mass:std_logic;
begin
mass<='0';
a1:MUX_8_1 PORT MAP(
u0=>uu0,
u1=>uu1,
u2=>uu2,
u3=>uu3,
u4=>uu4,
u5=>uu5,
u6=>uu6,
u7=>uu7,
se=>sortie1(8 downto 6),
ds=>ds1
);
a11: MUX_2_1 PORT MAP (
enter =>DOUT1,
mass => mass,
se => noir1,
final=> final
39

);
a2:ROM PORT MAP (
A(3 downto 0)=> ds1,
A(9 downto 4)=>sortie1(5 downto 0),
data => data1
);
a3:RAM_VGA port MAP(
A=>sortie1,
R(8 downto 6)=>nc1(5 downto 3),
R(5 downto 3)=>nl1,
R(2 downto 0)=>nc1(2 downto 0),
Din=>data1,
clk=>clk_25MHZ,
WR=>WR1,
Dout=>DOUT1
);
a4:affichage PORT MAP (
clk => clk_25MHZ,
ft => ft1,
fl => fl1,
nl => nl1,
nc => nc1,
noir => noir1
);
a5:decoder PORT MAP (
40

st => st1,
clk => clk_25MHZ,
wr => WR1,
sortie => sortie1
);
a6:generateur_trame PORT MAP (
sl => sl1,
st => st1,
ft => ft1
);
a7:generateur_ligne PORT MAP (
clk => clk_25MHZ,
sl => sl1,
fl => fl1
);
sl<=sl1;
st<=st1;
end top;
41

III. Les scenarios de test (les tests bench): 1. Test MUX :
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 20:31:03 03/30/2011
-- Design Name:
-- Module Name: C:/Users/yahya/Desktop/project hard/VGA/test_MUX.vhd
-- Project Name: VGA
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: MUX_8_1
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
42

-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY test_MUX IS
END test_MUX;
ARCHITECTURE behavior OF test_MUX IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT MUX_8_1
PORT(
u0 : IN std_logic_vector(3 downto 0);
u1 : IN std_logic_vector(3 downto 0);
u2 : IN std_logic_vector(3 downto 0);
u3 : IN std_logic_vector(3 downto 0);
u4 : IN std_logic_vector(3 downto 0);
u5 : IN std_logic_vector(3 downto 0);
u6 : IN std_logic_vector(3 downto 0);
u7 : IN std_logic_vector(3 downto 0);
se : IN std_logic_vector(2 downto 0);
ds : OUT std_logic_vector(3 downto 0)
);
43

END COMPONENT;
--Inputs
signal u0 : std_logic_vector(3 downto 0) := "1011";
signal u1 : std_logic_vector(3 downto 0) := (others => '0');
signal u2 : std_logic_vector(3 downto 0) := (others => '0');
signal u3 : std_logic_vector(3 downto 0) := (others => '0');
signal u4 : std_logic_vector(3 downto 0) := (others => '0');
signal u5 : std_logic_vector(3 downto 0) := (others => '0');
signal u6 : std_logic_vector(3 downto 0) := (others => '0');
signal u7 : std_logic_vector(3 downto 0) := (others => '0');
signal se : std_logic_vector(2 downto 0) := "000";
--Outputs
signal ds : std_logic_vector(3 downto 0);
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: MUX_8_1 PORT MAP (
u0 => u0,
u1 => u1,
u2 => u2,
u3 => u3,
u4 => u4,
44

u5 => u5,
u6 => u6,
u7 => u7,
se => se,
ds => ds
);
END;
2. Test ROM :
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 12:49:36 03/15/2011
-- Design Name:
-- Module Name: C:/Users/yahya/Desktop/project hard/VGA/ROM_TEST.vhd
-- Project Name: VGA
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: ROM
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
45

--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use IEEE.numeric_std.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY ROM_TEST IS
END ROM_TEST;
ARCHITECTURE behavior OF ROM_TEST IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT ROM
PORT(
A : IN std_logic_vector(9 downto 0);
data : OUT std_logic
);
END COMPONENT;
46

--Inputs
signal A : std_logic_vector(9 downto 0) := "1111101111";
--Outputs
signal data : std_logic;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: ROM PORT MAP (
A => A,
data => data
);
END;
3. Test decoder
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 22:19:06 03/30/2011
-- Design Name:
-- Module Name: C:/Users/yahya/Desktop/project hard/VGA/test_decoder.vhd
-- Project Name: VGA
47

-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: decoder
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY test_decoder IS
48

END test_decoder;
ARCHITECTURE behavior OF test_decoder IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT decoder
PORT(
st : IN std_logic;
clk : IN std_logic;
wr : OUT std_logic;
sortie : OUT std_logic_vector(8 downto 0)
);
END COMPONENT;
--Inputs
signal st : std_logic := '0';
signal clk : std_logic := '0';
--Outputs
signal wr : std_logic;
signal sortie : std_logic_vector(8 downto 0);
-- Clock period definitions
constant clk_period : time := 0.002 ns;
49

BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: decoder PORT MAP (
st => st,
clk => clk,
wr => wr,
sortie => sortie
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
50

-- insert stimulus here
wait;
end process;
END;
Test afficher
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 22:26:36 03/29/2011
-- Design Name:
-- Module Name: C:/Users/yahya/Desktop/project hard/VGA/test_affichage.vhd
-- Project Name: VGA
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: affichage
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
51

-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY test_affichage IS
END test_affichage;
ARCHITECTURE behavior OF test_affichage IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT affichage
PORT(
clk : IN std_logic;
ft : IN std_logic;
fl : IN std_logic;
nl : OUT std_logic_vector(2 downto 0);
nc : OUT std_logic_vector(5 downto 0);
noir : OUT std_logic
);
END COMPONENT;
52

--Inputs
signal clk : std_logic := '0';
signal ft : std_logic := '1';
signal fl : std_logic := '1';
--Outputs
signal nl : std_logic_vector(2 downto 0);
signal nc : std_logic_vector(5 downto 0);
signal noir : std_logic;
-- Clock period definitions
constant clk_period : time := 0.002 ns;
signal n:integer range 0 to 100;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: affichage PORT MAP (
clk => clk,
ft => ft,
fl => fl,
nl => nl,
nc => nc,
noir => noir
);
-- Clock process definitions
clk_process :process
53

begin
fl<='1';
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
fl<='0'after 0.137 ns;
end process;
END;
4. Test_ligne
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 22:51:19 03/17/2011
-- Design Name:
-- Module Name: C:/Users/yahya/Desktop/project hard/VGA/tester_ligne.vhd
-- Project Name: VGA
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: generateur_ligne
--
-- Dependencies:
--
54

-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY tester_ligne IS
END tester_ligne;
ARCHITECTURE behavior OF tester_ligne IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT generateur_ligne
PORT(
clk : IN std_logic;
sl : OUT std_logic;
fl : OUT std_logic
55

);
END COMPONENT;
--Inputs
signal clk : std_logic := '0';
--Outputs
signal sl : std_logic;
signal fl : std_logic;
-- Clock period definitions
constant clk_period : time := 0.002 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: generateur_ligne PORT MAP (
clk => clk,
sl => sl,
fl => fl
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
56

end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
-- insert stimulus here
wait;
end process;
END;
Test_trame
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 14:19:18 03/29/2011
-- Design Name:
-- Module Name: C:/Users/yahya/Desktop/project hard/VGA/test_trame.vhd
-- Project Name: VGA
-- Target Device:
-- Tool versions:
-- Description:
57

--
-- VHDL Test Bench Created by ISE for module: generateur_trame
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY test_trame IS
END test_trame;
ARCHITECTURE behavior OF test_trame IS
-- Component Declaration for the Unit Under Test (UUT)
58

COMPONENT generateur_trame
PORT(
sl : IN std_logic;
st : OUT std_logic;
ft : OUT std_logic
);
END COMPONENT;
--Inputs
signal sl : std_logic := '0';
--Outputs
signal st : std_logic;
signal ft : std_logic;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
constant clk : time := 0.002 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: generateur_trame PORT MAP (
sl => sl,
st => st,
ft => ft
);
-- Clock process definitions
59

process
begin
sl <= '0';
wait for clk/2;
sl <= '1';
wait for clk/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk*10;
-- insert stimulus here
wait;
end process;
END
60

5. Test_VGA --------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 14:42:38 04/10/2011
-- Design Name:
-- Module Name: C:/Users/yahya/Desktop/project hard/VGA/test_top.vhd
-- Project Name: VGA
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: top
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee ;
61

use std.textio.all;
USE ieee.std_logic_1164.all ;
LIBRARY std;
use IEEE.std_logic_textio.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY test_top IS
END test_top;
ARCHITECTURE behavior OF test_top IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT top
PORT(
uu0 : IN std_logic_vector(3 downto 0);
uu1 : IN std_logic_vector(3 downto 0);
uu2 : IN std_logic_vector(3 downto 0);
uu3 : IN std_logic_vector(3 downto 0);
uu4 : IN std_logic_vector(3 downto 0);
uu5 : IN std_logic_vector(3 downto 0);
uu6 : IN std_logic_vector(3 downto 0);
uu7 : IN std_logic_vector(3 downto 0);
clk_25MHZ : IN std_logic;
sl : OUT std_logic;
st : OUT std_logic;
final : OUT std_logic
62

);
END COMPONENT;
--Inputs
signal uu0 : std_logic_vector(3 downto 0) := "1111";
signal uu1 : std_logic_vector(3 downto 0) := "0001";
signal uu2 : std_logic_vector(3 downto 0) := "0000";
signal uu3 : std_logic_vector(3 downto 0) := "0000";
signal uu4 : std_logic_vector(3 downto 0) := "0000";
signal uu5 : std_logic_vector(3 downto 0) := "0000";
signal uu6 : std_logic_vector(3 downto 0) := "0000";
signal uu7 : std_logic_vector(3 downto 0) := "0000";
signal clk_25MHZ : std_logic := '0';
--Outputs
signal sl : std_logic;
signal st : std_logic;
signal final : std_logic;
-- Clock period definitions
constant clk_25MHZ_period : time := 40 ps;
signal a:integer range 66 downto 0 :=0;
signal b:integer range 2 downto 0 :=0;
signal deb1:integer range 1 downto 0 :=0;
signal deb2:integer range 1 downto 0 :=0;
signal deb3:integer range 1 downto 0 :=0;
signal deb4:integer range 1 downto 0 :=0;
signal deb5:integer range 1 downto 0 :=0;
63

signal deb6:integer range 1 downto 0 :=0;
signal deb7:integer range 1 downto 0 :=0;
signal deb8:integer range 1 downto 0 :=0;
signal d:integer range 8 downto 0 :=1;
type TAB is array(0 to 161) of bit;
signal T : TAB;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: top PORT MAP (
uu0 => uu0,
uu1 => uu1,
uu2 => uu2,
uu3 => uu3,
uu4 => uu4,
uu5 => uu5,
uu6 => uu6,
uu7 => uu7,
clk_25MHZ => clk_25MHZ,
sl => sl,
st => st,
final => final
);
-- Clock process definitions
clk_25MHZ_process :process
begin
64

clk_25MHZ <= '0';
wait for clk_25MHZ_period/2;
clk_25MHZ <= '1';
wait for clk_25MHZ_period/2;
--fixer les debut des ligne pour l'affichage dans notre fichier texte---
deb1<=1 after 293.280 ns;
deb2<=1 after 325.380 ns;
deb3<=1 after 357.460 ns;
deb4<=1 after 389.540 ns;
deb5<=1 after 421.620 ns;
deb6<=1 after 453.700 ns;
deb7<=1 after 485.780 ns;
deb8<=1 after 517.860 ns;
end process;
--ecriture de resultat de notre controleur VGA dans une fichier TXT-----
ECRITURE: process(clk_25MHZ,d,deb1,deb2,deb3,deb4,deb5,deb6,deb7,deb8)
variable L: line;
file SORTIES: text open WRITE_MODE is "C:\Users\yahya\Desktop\res\res.txt";
begin
if(clk_25MHZ' event and clk_25MHZ='1') then
if(deb1=1 and d=1)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
T(a)<='1';
a<=a+1;
b<=1;
65

end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
for i in 0 to 66 loop
write(L, T(i));
end loop;
writeline(SORTIES, L); -- écriture de la ligne dans le fichier
d<=2;
end if;
end if;
end if;
if(deb2=1 and d=2)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
T(a)<='1';
a<=a+1;
b<=1;
end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
for i in 0 to 66 loop
write(L, T(i));
66

end loop;
writeline(SORTIES, L); -- écriture de la ligne dans le fichier
d<=3;
end if;
end if;
end if;
if(deb3=1 and d=3)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
T(a)<='1';
a<=a+1;
b<=1;
end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
for i in 0 to 66 loop
write(L, T(i));
end loop;
writeline(SORTIES, L); -- écriture de la ligne dans le fichier
d<=4;
end if;
end if;
end if;
67

if(deb4=1 and d=4)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
T(a)<='1';
a<=a+1;
b<=1;
end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
for i in 0 to 66 loop
write(L, T(i));
end loop;
writeline(SORTIES, L); -- écriture de la ligne dans le fichier
d<=5;
end if;
end if;
end if;
if(deb5=1 and d=5)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
68

T(a)<='1';
a<=a+1;
b<=1;
end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
for i in 0 to 66 loop
write(L, T(i));
end loop;
writeline(SORTIES, L); -- écriture de la ligne dans le fichier
d<=6;
end if;
end if;
end if;
if(deb6=1 and d=6)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
T(a)<='1';
a<=a+1;
b<=1;
end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
69

for i in 0 to 66 loop
write(L, T(i));
end loop;
writeline(SORTIES, L); -- écriture de la ligne dans le fichier
d<=7;
end if;
end if;
end if;
if(deb7=1 and d=7)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
T(a)<='1';
a<=a+1;
b<=1;
end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
for i in 0 to 66 loop
write(L, T(i));
end loop;
writeline(SORTIES, L); -- écriture de la ligne dans le fichier
d<=8;
end if;
70

end if;
end if;
if(deb8=1 and d=8)then
if(final='0') then
T(a)<='0';
a<=a+1;
end if;
if(final='1') then
T(a)<='1';
a<=a+1;
b<=1;
end if;
if(a=66)then
a<=0;
if(b=1)then
b<=0;
for i in 0 to 66 loop
write(L, T(i));
end loop;
writeline(SORTIES, L);
end if;
end if;
end if;
end if;
end process ECRITURE;
END;
71

IV. Simulation
72

1. Fichier: i. Simulation (0, 0, 0, 0, 0, 0, 0, 0):
ii. Simulation (F, 1, 0, 0, 0, 0, 0, 0):
73

Rapport technique:
Outil de développement utilisé:
Logiciel :
Xilinx est une entreprise américaine de semi-conducteurs. Inventeur du FPGA, Xilinx fait
partie des plus grandes entreprises spécialisées dans le développement et la
commercialisation de composants logiques programmables, et des services associés tels que
les logiciels de CAO électroniques ; blocs de propriété intellectuelle réutilisables et
formation.
74

Langage :
VHDL est un langage de description matériel destiné à représenter le comportement ainsi
que l'architecture d’un système électronique numérique. Son nom complet est VHSIC
Hardware Description Langage.
L'intérêt d'une telle description réside dans son caractère exécutable : une spécification
décrite en VHDL peut être vérifiée par simulation, avant que la conception détaillée ne soit
terminée. En outre, les outils de conception assistée par ordinateur permettant de passer
directement d'une description fonctionnelle en VHDL à un schéma en porte logique ont
révolutionné les méthodes de conception des circuits numériques, ASIC ou FPGA.
Conclusion:
Le but de ce projet est d’exploiter le FPGA Spartan 3 de Xilinx pour faire des applications
basiques d’entrée sortie pour passer par la suite à des architectures relativement
complexes rassemblant plusieurs composants qu’il faut synchroniser et gérer l’accès à la
mémoire.
Au cours de ce projet, nous avons fait l’implantation en VHDL de circuits basiques, à savoir le
module VGA et ces spécifications. Cependant, nous avons pu valider l’architecture de
l’affichage sur écran VGA en utilisant des méthodes de simulations qui peuvent réaliser le
même résultat qu’implémenter notre application sur carte. Mais nous sommes familiarisés
avec les outils de développement hard.
Notre ROM ne contient pas tous les caractères que l'utilisateur peut saisir (restriction sur les
HEXA) donc on peut penser à des modules intermédiaires de traitements qui peuvent jouer
le rôle de constructeur de nouveaux caractères à partir de notre ROM suite à un nouveau
codage que l'on peut définir également.
75

76