Processeur/Processeur.srcs/sources_1/new/VGAControler.vhd
2021-06-30 16:36:19 +02:00

114 lines
3.5 KiB
VHDL

----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 28.06.2021 09:20:00
-- Design Name:
-- Module Name: VGAControler - 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;
-- 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 leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity VGAControler is
Generic ( HEIGHT : Natural;
WIDTH : Natural;
X_PulseWidth : Natural;
X_FrontPorch : Natural;
X_BackPorch : Natural;
Y_PulseWidth : Natural;
Y_FrontPorch : Natural;
Y_BackPorch : Natural
);
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 Natural;
Y : out Natural;
PIXEL_ON : in STD_LOGIC;
CLK : in STD_LOGIC;
RST : in STD_LOGIC);
end VGAControler;
architecture Behavioral of VGAControler is
component Compteur is
Generic (Min : Natural;
Max : Natural
);
Port (CLK : in STD_LOGIC;
RST : in STD_LOGIC;
Value : out Natural;
Carry : out STD_LOGIC);
end component;
signal X_pos : Natural := 0;
signal Y_pos : Natural := 0;
signal Y_CLK : STD_LOGIC := '0';
signal Screen_CLK : STD_LOGIC := '0';
signal active : BOOLEAN := false;
begin
X_Compteur : Compteur
generic map (Min => 0,
Max => WIDTH + X_PulseWidth + X_FrontPorch + X_BackPorch - 1)
port map (CLK => CLK,
RST => RST,
Value => X_pos,
Carry => Y_CLK);
Y_Compteur : Compteur
generic map (Min => 0,
Max => HEIGHT + Y_PulseWidth + Y_FrontPorch + Y_BackPorch - 1)
port map (CLK => Y_CLK,
RST => RST,
Value => Y_pos,
Carry => Screen_CLK);
active <= ((X_pos < WIDTH) and (Y_pos < HEIGHT));
VGA_RED <= "0000" when (RST = '0') else
"1000" when ((PIXEL_ON = '0') or (not active)) else
"1111";
VGA_BLUE <= "0000" when (RST = '0') else
"1000" when ((PIXEL_ON = '0') or (not active)) else
"1111";
VGA_GREEN <= "0000" when (RST = '0') else
"1000" when ((PIXEL_ON = '0') or (not active)) else
"1111";
VGA_HS <= '0' when ((RST = '0') or (X_pos < WIDTH + X_FrontPorch) or (X_pos >= WIDTH + X_FrontPorch + X_PulseWidth)) else
'1';
VGA_VS <= '0' when ((RST = '0') or (Y_pos < HEIGHT + Y_FrontPorch) or (Y_pos >= HEIGHT + Y_FrontPorch + Y_PulseWidth)) else
'1';
X <= X_pos;
Y <= Y_pos;
end Behavioral;