📄 vgainterface.vhd
字号:
--------------------------------------------------------------------------------------------------------------------
--实验题号 : Ex5-1
--项目名称 : VGA接口
--文件名 : vgainterface.vhd
--作者 : 田甲
--班号. : 计45
--创建日期 : 2006-05-25
--目标芯片 : EP1C6Q240C8
--电路模式 : 模式5
--功能描述 : 本文件给出了VGA接口的结构描述
--------------------------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
--use IEEE.std_logic_arith.all;
entity VgaInterface is
port(
reset : in STD_LOGIC;
clk_0 : in STD_LOGIC;
---- These are the Signals connect with CalControl
pid_vga_data : in STD_LOGIC_VECTOR(23 downto 0);
---- These are the VGA Control Signal
pod_vga_r : out STD_LOGIC;
pod_vga_g : out STD_LOGIC;
pod_vga_b : out STD_LOGIC;
poc_vga_hs : out STD_LOGIC;
poc_vga_vs : out STD_LOGIC
);
end VgaInterface;
architecture behavior of VgaInterface is
signal vga_data : std_logic_vector(23 downto 0);
signal clk : std_logic:='0';
signal vga_r : std_logic;
signal vga_g : std_logic;
signal vga_b : std_logic;
signal vga_hs : std_logic;
signal vga_vs : std_logic;
signal hs_p : std_logic;
signal vs_p : std_logic;
signal enable, en : std_logic;
signal vector_x : std_logic_vector(9 downto 0);
signal vector_y : std_logic_vector(8 downto 0);
signal char_data : std_logic_vector(0 downto 0);
signal char_address : std_logic_vector(15 downto 0);
component rom1
PORT
(
address : IN STD_LOGIC_VECTOR (15 DOWNTO 0);
clock : IN STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (0 DOWNTO 0)
);
end component;
begin
u1:rom1 port map
(address => char_address, clock => clk, q => char_data);
process(clk_0)
begin
if(clk_0'event and clk_0='1') then
clk <= not clk;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
vga_data <= (others=>'0');
elsif clk'event and clk='1' then
vga_data <= pid_vga_data;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
vector_x <= (others=>'0');
elsif clk'event and clk='1' then
if vector_x=799 then
vector_x <= (others=>'0');
else
vector_x <= vector_x + 1;
end if;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
vector_y <= (others=>'0');
elsif clk'event and clk='1' then
if vector_x=799 then
if vector_y=524 then
vector_y <= (others=>'0');
else
vector_y <= vector_y + 1;
end if;
end if;
end if;
end process;
--begin
process(clk,reset)
begin
if clk'event and clk='1' then
char_address <= (others => '0');
char_address(4 downto 0) <= vector_x(4 downto 0);
char_address(9 downto 5) <= vector_y(4 downto 0);
if vector_x <= 63 and vector_x >=32 and vector_y <= 63 and vector_y >= 32 then
char_address(13 downto 10) <= vga_data(23 downto 20);
elsif vector_x <= 95 and vector_x >=64 and vector_y <= 63 and vector_y >= 32 then
char_address(13 downto 10) <= vga_data(19 downto 16);
elsif vector_x <= 127 and vector_x >=96 and vector_y <= 63 and vector_y >= 32 then
char_address(13 downto 10) <= vga_data(15 downto 12);
elsif vector_x <= 159 and vector_x >=128 and vector_y <= 63 and vector_y >= 32 then
char_address(13 downto 10) <= vga_data(11 downto 8);
elsif vector_x <= 191 and vector_x >=160 and vector_y <= 63 and vector_y >= 32 then
char_address(13 downto 10) <= vga_data(7 downto 4);
elsif vector_x <= 223 and vector_x >=192 and vector_y <= 63 and vector_y >= 32 then
char_address(13 downto 10) <= vga_data(3 downto 0);
else
char_address <= (others => '0');
end if;
if char_address(13 downto 10) = "1111" then
en <= '1';
else
en <= '0';
end if;
end if;
end process;
process(clk,reset)
begin
if clk'event and clk='1' then
if en = '0' then
vga_r <= char_data(0);
vga_g <= char_data(0);
vga_b <= char_data(0);
else
vga_r <= '0';
vga_g <= '0';
vga_b <= '0';
end if;
end if;
end process;
--end
process(clk,reset)
begin
if reset='1' then
hs_p <= '1';
elsif clk'event and clk='1' then
if vector_x>=656 and vector_x<752 then
hs_p <= '0';
else
hs_p <= '1';
end if;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
vs_p <= '1';
elsif clk'event and clk='1' then
if vector_y>=490 and vector_y<492 then
vs_p <= '0';
else
vs_p <= '1';
end if;
end if;
end process;
process(clk)
begin
if(clk'event and clk='1')then
if (vector_x>=640 or vector_y>=480)then
enable <= '0';
else
enable <= '1';
end if;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
pod_vga_r <= '0';
elsif clk'event and clk='1' then
pod_vga_r <= vga_r and enable;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
pod_vga_g <= '0';
elsif clk'event and clk='1' then
pod_vga_g <= vga_g and enable;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
pod_vga_b <= '0';
elsif clk'event and clk='1' then
pod_vga_b <= vga_b and enable;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
poc_vga_hs <= '0';
elsif clk'event and clk='1' then
poc_vga_hs <= hs_p;
end if;
end process;
process(clk,reset)
begin
if reset='1' then
poc_vga_vs <= '0';
elsif clk'event and clk='1' then
poc_vga_vs <= vs_p;
end if;
end process;
end behavior;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -