97 lines
3.1 KiB
VHDL
97 lines
3.1 KiB
VHDL
----------------------------------------------------------------------------------
|
|
-- Company: INSA-Toulouse
|
|
-- Engineer: Paul Faure
|
|
--
|
|
-- Create Date: 28.06.2021 09:20:00
|
|
-- Module Name: VGAControler - Behavioral
|
|
-- Project Name: Processeur sécurisé
|
|
-- Target Devices: Basys 3 ARTIX7
|
|
-- Tool Versions: Vivado 2016.4
|
|
--
|
|
-- Description: Controleur du VGA
|
|
-- - Crée les signaux VGA
|
|
-- - Demande si le pixel (X,Y) doit être allumé
|
|
--
|
|
-- Dependencies: Compteur_X et Compteur_Y
|
|
----------------------------------------------------------------------------------
|
|
|
|
|
|
library IEEE;
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
|
|
use work.ScreenProperties.all;
|
|
|
|
entity VGAControler is
|
|
Port ( VGA_RED : out STD_LOGIC_VECTOR (3 downto 0);
|
|
VGA_BLUE : out STD_LOGIC_VECTOR (3 downto 0);
|
|
VGA_GREEN : out STD_LOGIC_VECTOR (3 downto 0);
|
|
VGA_HS : out STD_LOGIC;
|
|
VGA_VS : out STD_LOGIC;
|
|
|
|
X : out X_T;
|
|
Y : out Y_T;
|
|
PIXEL_ON : in STD_LOGIC;
|
|
|
|
CLK : in STD_LOGIC;
|
|
RST : in STD_LOGIC);
|
|
end VGAControler;
|
|
|
|
architecture Behavioral of VGAControler is
|
|
|
|
component Compteur_X is
|
|
Port ( CLK : in STD_LOGIC;
|
|
RST : in STD_LOGIC;
|
|
Value : out X_T;
|
|
Carry : out STD_LOGIC);
|
|
end component;
|
|
|
|
component Compteur_Y is
|
|
Port ( CLK : in STD_LOGIC;
|
|
RST : in STD_LOGIC;
|
|
Value : out Y_T);
|
|
end component;
|
|
|
|
|
|
signal X_pos : X_T := 0;
|
|
signal Y_pos : Y_T := 0;
|
|
signal Y_CLK : STD_LOGIC := '0';
|
|
signal active : BOOLEAN := false;
|
|
|
|
begin
|
|
|
|
X_Compteur : Compteur_X
|
|
port map (CLK => CLK,
|
|
RST => RST,
|
|
Value => X_pos,
|
|
Carry => Y_CLK);
|
|
|
|
Y_Compteur : Compteur_Y
|
|
port map (CLK => Y_CLK,
|
|
RST => RST,
|
|
Value => Y_pos);
|
|
|
|
-- Test si on est dans l'écran et non dans les zones de FP, BP, SP
|
|
active <= ((X_pos < screen_width) and (Y_pos < screen_height));
|
|
|
|
|
|
-- Affectation des couleurs et fonction du pixel (0 hors champs, gris si inactif, blanc si actif)
|
|
VGA_RED <= "0000" when ((RST = '0') or (not active)) else
|
|
"1000" when (PIXEL_ON = '0') else
|
|
"1111";
|
|
VGA_BLUE <= "0000" when ((RST = '0') or (not active)) else
|
|
"1000" when (PIXEL_ON = '0') else
|
|
"1111";
|
|
VGA_GREEN <= "0000" when ((RST = '0') or (not active)) else
|
|
"1000" when (PIXEL_ON = '0') else
|
|
"1111";
|
|
|
|
-- Création des signaux de synchronisation
|
|
VGA_HS <= '0' when ((RST = '0') or (X_pos < screen_width + X_FrontPorch) or (X_pos >= screen_width + X_FrontPorch + X_PulseWidth)) else
|
|
'1';
|
|
VGA_VS <= '0' when ((RST = '0') or (Y_pos < screen_height + Y_FrontPorch) or (Y_pos >= screen_height + Y_FrontPorch + Y_PulseWidth)) else
|
|
'1';
|
|
|
|
X <= X_pos;
|
|
Y <= Y_pos;
|
|
|
|
end Behavioral;
|