⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vgacolor.vhd

📁 彩条信号发生器使用说明 使用模块有:VGA接口、脉冲沿模块、时钟源模块。 使用步骤: 1. 打开电源+5V 2. 信号连接
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity vgacolor is
  port(clk1,ms1  : in std_logic;--扫描时钟/显示模式选择时间
      hs,vs,r,g,b : out std_logic);--行场同步/红、绿、蓝
end vgacolor;

architecture hav of vgacolor is
  signal hs1,vs1,fclk,cclk : std_logic;
  signal mode: std_logic_vector(1 downto 0);--方式选择
  signal fs: std_logic_vector(3 downto 0);
  signal cc: std_logic_vector(4 downto 0);--行同步/横彩条生成
  signal ll: std_logic_vector(8 downto 0);--场同步/竖彩条生成
  signal graphx: std_logic_vector(3 downto 1);--X横彩条
  signal graphy: std_logic_vector(3 downto 1);--Y竖彩条
  signal graphp: std_logic_vector(3 downto 1);
  signal graph: std_logic_vector(3 downto 1);
 begin
  graph(2)<=(graphp(2) xor ms1) and hs1 and vs1;
  graph(3)<=(graphp(3) xor ms1) and hs1 and vs1;
  graph(1)<=(graphp(1) xor ms1) and hs1 and vs1;
process(ms1)
 begin
  if ms1'event and ms1='1' then
    if mode="10" then mode<="00";
    else mode<=mode+1;           --三种模式
    end if;
  end if;
end process;

process(mode)
 begin
 if mode="00" then graphp<=graphx;         --选择横彩条
 elsif mode="01" then graphp<=graphy;      --选择竖彩条
 elsif mode="10" then graphp<=graphx xor graphy;--产生棋盘格
 else graphp<="000";
 end if;
end process;

process(clk1)
 begin
 if clk1'event and clk1='1' then--12MHz 12分频
  if fs=11 then fs<="0000";
  else fs<=fs+1;
  end if;
 end if;
end process;

process(fclk)
 begin
if fclk'event and fclk='1' then
 if cc=31 then cc<="00000";
   else cc<=cc+1;
 end if;
end if;
end process;

process(cclk)
 begin
if cclk'event and cclk='1' then
 if ll=481 then ll<="000000000";
   else ll<=ll+1;
 end if;
end if;
end process;

process(cc,ll)
begin
 if cc>25 then hs1<='0';         --行同步
 else hs1<='1';
 end if;
 if ll>479 then vs1<='0';        --场同步
 else vs1<='1';
 end if;
end process;

process(cc,ll)--横彩条
 begin
 if cc<4 then graphx<="010";--red
 elsif cc<7 then graphx<="000";--black
 elsif cc<10 then graphx<="111";--white
 elsif cc<13 then graphx<="011";--pin
 elsif cc<16 then graphx<="101";--qin
 elsif cc<20 then graphx<="110";--yellow
 elsif cc<23 then graphx<="001";--blue
 else graphx<="100";--green
 end if;
if ll<60 then graphy<="010";    --竖彩条
  elsif ll<120 then graphy<="000";
  elsif ll<180 then graphy<="111";
  elsif ll<240 then graphy<="011";
  elsif ll<300 then graphy<="101";
  elsif ll<360 then graphy<="110";
  elsif ll<420 then graphy<="001";
  else graphy<="100";
 end if;
end process;
fclk<=fs(2);
cclk<=cc(4);
hs<=hs1;
vs<=vs1;
r<=graph(2);
g<=graph(3);
b<=graph(1);
end hav;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -