📄 vga_module.vhd
字号:
------------------------------------------------------------------------------------ Company: -- Engineer: Likee000-- -- Create Date: 08:51:13 05/03/2008 -- Design Name: -- Module Name: VGA_Module - Behavioral -- Project Name: -- Target Devices: -- Tool versions: xilinx SPARTAN-3-- 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;entity VGA_Module is Port ( clk50_in : in std_logic; Red_out : out std_logic; Green_out : out std_logic; Blue_out : out std_logic; hs_out : out std_logic; vs_out : out std_logic);end VGA_Module;architecture Behavioral of VGA_Module is signal Clk25 : std_logic; signal Horizontal_Counter : std_logic_vector (9 downto 0); signal Vertical_Counter : std_logic_vector (9 downto 0);begin--Generate 25Mhz Clockprocess (clk50_in)begin if clk50_in'event and clk50_in='1' then if (Clk25 = '0')then Clk25 <= '1' after 2 ns; else Clk25 <= '0' after 2 ns; end if; end if;end process; process (Clk25)TYPE Screen_Line1 is ARRAY(0 to 15, 0 to 47) OF std_logic; --CONSTANT char_L1 : Screen_Line1 := (( '0','1','1','1','0','0','0','0','0','0','0','1','0','0','1','0','0','0','0','0','0','1','1','1','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),-- ( '1','0','0','0','0','1','0','0','1','0','0','1','0','0','1','0','0','0','0','0','0','1','0','0','1','0','0','1','0','0','0','0','0','0','0','0','1','1','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),-- ( '1','0','0','0','0','1','0','1','0','0','0','1','0','0','1','0','0','0','0','0','0','1','0','0','1','0','0','1','0','1','0','0','1','0','0','1','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),-- ( '0','1','1','0','0','1','1','0','0','0','0','0','1','1','1','0','0','0','0','0','0','1','0','0','1','0','0','1','0','1','0','0','1','0','0','1','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),-- ( '0','0','0','1','0','1','1','0','0','0','0','0','0','0','1','0','0','0','0','0','0','1','1','1','1','0','0','1','0','1','0','0','1','0','0','1','1','1','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),-- ( '0','0','0','1','0','1','0','1','0','0','0','0','0','0','1','0','0','0','0','0','0','1','0','0','0','1','0','1','0','1','0','0','1','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),-- ( '0','0','0','1','0','1','0','0','1','0','0','0','0','1','0','0','0','0','0','0','0','1','0','0','0','1','0','1','0','0','1','1','1','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),-- ( '1','1','1','0','0','1','0','0','0','1','0','1','1','0','0','0','0','0','0','0','0','1','1','1','1','0','0','1','0','0','0','0','0','1','0','0','0','1','1','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0') ); CONSTANT char_L1 : Screen_Line1 :=(('0','0','0','0','1','0','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','1','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0',
'1','0','0','0','0','0','0','0','0'),('0','1','1','1','1','1','1','1','0','0','1','1','0','0','0','0','0','0','0','0','0','0','0','1','0','0','1','1','0','0','0','0','0','0','0','0','0','0','0',
'1','0','0','0','1','1','0','0','0'),('0','0','0','0','1','0','0','0','0','0','1','0','1','0','0','0','0','0','0','0','0','0','0','1','0','0','0','1','0','0','0','0','0','0','1','1','1','1','0',
'1','1','0','1','0','0','0','0','0'),('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','0','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','0','0','0','0','0','0','1','0',
'1','0','1','0','0','0','0','0','0'),('0','0','0','0','0','0','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','1','0','0',
'1','0','0','1','1','0','0','0','0'),('0','1','1','1','1','1','1','1','0','0','1','0','0','0','0','0','0','0','1','0','0','0','0','1','0','0','0','1','1','0','0','0','0','0','1','1','0','1','0',
'1','0','0','0','0','1','1','1','0'),('0','1','0','0','1','0','0','1','0','0','1','0','1','0','0','0','0','0','0','1','0','0','0','1','0','0','1','0','0','0','0','0','0','0','0','0','0','0','1',
'0','0','0','0','0','0','1','0','0'),('0','1','1','1','1','1','1','1','0','0','1','0','1','1','0','0','0','0','0','0','1','0','0','1','0','1','0','0','0','0','0','0','0','0','0','0','1','0','0',
'0','0','0','1','0','0','0','0','0'),('0','1','0','0','1','0','0','1','0','0','1','0','1','0','0','0','0','0','0','0','0','1','0','1','1','1','0','0','0','0','0','0','1','1','1','0','1','0','1',
'1','1','0','1','0','1','1','0','0'),('0','1','1','1','1','1','1','1','0','0','0','1','1','0','0','0','0','0','0','0','1','0','0','1','0','0','1','0','0','0','0','0','0','0','1','0','1','1','0',
'0','1','0','1','1','0','0','0','0'),('0','0','0','1','0','0','1','0','0','0','0','1','0','0','0','0','0','0','0','1','0','0','0','1','0','0','0','1','1','0','0','0','0','0','1','0','1','1','0',
'0','1','0','1','0','1','0','0','0'),('0','1','1','1','1','1','1','1','1','0','0','1','0','0','0','0','0','1','1','0','0','0','0','1','0','0','0','0','1','1','1','0','0','1','0','0','1','0','1',
'0','1','0','1','0','1','0','0','0'),('0','0','0','1','0','0','1','0','0','0','1','0','1','0','1','0','0','0','0','0','0','0','0','1','0','0','0','0','0','1','0','0','0','1','0','0','1','0','0',
'1','0','0','1','0','0','1','1','0'),('1','1','1','1','1','1','1','1','1','1','0','0','1','0','1','0','0','0','0','0','0','0','0','1','0','0','0','0','0','0','0','0','1','0','0','0','1','0','1',
'0','0','0','1','0','0','1','0','0'),('0','0','0','1','0','0','1','0','0','0','0','0','0','1','1','0','0','0','0','0','0','1','0','1','0','0','0','0','0','0','0','0','0','0','1','0','1','0','0',
'0','1','0','1','0','0','0','0','0'),('0','1','1','0','0','0','0','1','0','0','0','0','0','0','1','0','0','0','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','1','0','0','0',
'0','0','1','0','0','0','0','0','0')); variable Line:integer:=0;variable Pixel:integer:=0; begin --initial the screen if Clk25'event and Clk25 = '1' then if (Horizontal_Counter >= "0010010000" ) -- 144 why from 144? and (Horizontal_Counter < "1100010000" ) -- 784 640+100 and (Vertical_Counter >= "0000100111" ) -- 39 why from 39? and (Vertical_Counter < "1000000111" ) -- 519 480+39 then Red_out <= '0'; Green_out <= '0'; Blue_out <='0'; -----Line 1 if (Horizontal_Counter >= "0110111000" )--440 640/2-24+144 and (Horizontal_Counter <= "0111101000")-- 488 640/2+24+144 and (Vertical_Counter >= "0011101000") --232 240-8 and (Vertical_Counter <= "0011110111") then -- 247 240+8-1 if(Pixel <= 47) then --Line 1 Lets make our Text WHITE Red_out <= char_L1(Line, Pixel); Green_out <= char_L1(Line, Pixel); Blue_out <= char_L1(Line, Pixel); Pixel:= Pixel+1; elsif(Pixel >= 48) then -- All else BLACK Red_out <= '0'; Green_out <= '0'; Blue_out <= '0'; end if; end if; end if; if (Horizontal_Counter > "0000000000" ) and (Horizontal_Counter < "0001100001" ) -- 96+1 generate the hs_out and the vs_out then hs_out <= '0'; else hs_out <= '1'; end if; if (Vertical_Counter > "0000000000" ) and (Vertical_Counter < "0000000011" ) -- 2+1 then vs_out <= '0'; else vs_out <= '1'; end if; Horizontal_Counter <= Horizontal_Counter+"0000000001"; if (Horizontal_Counter="1100100000") then --800? decide the frequency of Hs 50000000/2/800 = 31.25K Hz Vertical_Counter <= Vertical_Counter+"0000000001"; Horizontal_Counter <= "0000000000"; Pixel:= 0; if (Vertical_Counter >= "0011101000") -- First Line 232 and (Vertical_Counter <= "0011110111") then --247 if (Line <= 15) then Line:= Line+1; elsif (Line >= 16) then Line:= 0; end if; end if; end if; if (Vertical_Counter="1000001001") then --521? decide the frequency of Hs 50000000/2/800/521 = 59.98 Hz Vertical_Counter <= "0000000000"; Line:= 0; end if; end if; end process; end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -