---------------------------------------------------------------------------------- -- Company: -- Engineer: -- -- Create Date: 17:12:19 01/29/2011 -- Design Name: -- Module Name: tft_driver - 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.STD_LOGIC_ARITH.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 tft_driver is Port ( clock50 : in STD_LOGIC; led : out std_logic; tft_red : out STD_LOGIC; tft_green : out STD_LOGIC; tft_blue : out STD_LOGIC; tft_hsync : out STD_LOGIC; tft_vsync : out STD_LOGIC; tft_den : out STD_LOGIC; tft_clk : out STD_LOGIC); end tft_driver; architecture Behavioral of tft_driver is signal clk: std_logic; signal hctr: std_logic_vector(9 downto 0); signal vctr: std_logic_vector(9 downto 0); signal ictr: std_logic_vector(5 downto 0); signal ictr2: std_logic_vector(9 downto 0); begin tft_clk <= clk; led <= ictr(5); process (clock50) begin if clock50'event and clock50='1' then if clk='1' then clk <= '0'; else clk <= '1'; end if; end if; end process; process (clk) begin if clk'event and clk='1' then -- support counters -- -------------------------------------------------------------------- hctr <= hctr + 1; if (hctr = 800) then -- 0x320 = 800 hctr <= "0000000000"; vctr <= vctr + 1; end if; if (vctr = 521) then -- 0x209 = 521 vctr <= "0000000000"; ictr <= ictr + 1; ictr2 <= ictr2 + 1; end if; if (ictr = 60) then ictr <= "000000"; end if; if (ictr2 = 800) then ictr2 <= "0010100000"; -- 160 0xa0 end if; -- vsync -- -------------------------------------------------------------------- if (vctr >= 0 and vctr < 2) then tft_vsync <= '0'; else tft_vsync <= '1'; end if; -- hsync -- -------------------------------------------------------------------- if (hctr >= 0 and hctr < 130) then tft_hsync <= '0'; else tft_hsync <= '1'; end if; -- data enable -- -------------------------------------------------------------------- if (hctr >= 0 and hctr < 160) then tft_den <= '0'; else if ((vctr >= 0 and vctr < 34) or vctr >= 514) then tft_den <= '0'; else tft_den <= '1'; end if; end if; if (vctr = 34 or vctr = 513) then tft_red <= '1'; else tft_red <= '0'; end if; if (hctr = 160 or hctr = 799) then tft_green <= '1'; else tft_green <= '0'; end if; if (hctr = ictr2) then tft_blue <= '1'; else tft_blue <= '0'; end if; end if; end process; end Behavioral;