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

📄 color.vhd

📁 几个VHDL实现的源程序及其代码
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity color is
port(
     clk : in std_logic;
     md  : in std_logic;
     hs,vs,r,g,b : out std_logic);
end color;

architecture behav of color is
signal hs1,vs1,fclk,cclk : std_logic;
signal mmd : 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 grbx : std_logic_vector(3 downto 1);   --X横彩条
signal grby : std_logic_vector(3 downto 1);   --Y竖彩条
signal grbp : std_logic_vector(3 downto 1);
signal grb  : std_logic_vector(3 downto 1);

begin
grb(1)<=(grbp(1) xor md) and hs1 and vs1;   --BLUE;
grb(2)<=(grbp(2) xor md) and hs1 and vs1;   --RED;
grb(3)<=(grbp(3) xor md) and hs1 and vs1;   --GREEN;

process(md)
begin
if (md'event and md='1') then
if(mmd="10") then
mmd<="00";
else mmd<=mmd+1;    --三种模式
end if;
END IF;
end process;

process(mmd)
begin
if(mmd="00") then
grbp<=grbx;         --选择横彩条
elsif(mmd="01") then
grbp<=grby;         --选择竖彩条
elsif(mmd="10") then
grbp<=grbx xor grby;--产生棋盘格
else
grbp<="000";
end if;
end process;

process(clk)
begin
if(clk'event and clk='1') then    --12MHZ 13分频
if (fs=12) then
fs<="0000";
else
fs<=fs+1;
end if;
end if;
end process;
FCLK<=FS(2);   --FCLK=1.5MHZ

process(fclk)
begin
if(fclk'event and fclk='1') then
if(cc=29) then
cc<="00000";
else
cc<=cc+1;
end if;
end if;
end process;
CCLK<=CC(4);     --CCLK=46.875KHZ

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

process(cc,ll)
begin
if(cc>23) then    -->62.5K
hs1<='0';
else
hs1<='1';
end if;
if(ll>479) then   -->97.65625HZ
vs1<='0';
else
vs1<='1';
end if;
end process;

process(cc,ll)
begin
if(cc<3) then        
grbx<="111";      --横彩条
elsif cc<6  then grbx<="110";
elsif cc<9  then grbx<="101";
elsif cc<12 then grbx<="100";
elsif cc<15 then grbx<="011";
elsif cc<18 then grbx<="010";
elsif cc<21 then grbx<="001";
else  grbx<="000";
end if;
If(ll<60) then             
Grby<="111";      --竖彩条
elsif ll<120 then grby<="110";
elsif ll<180 then grby<="101";
elsif ll<240 then grby<="100";
elsif ll<300 then grby<="011";
elsif ll<360 then grby<="010";
elsif ll<420 then grby<="001";
else  grby<="000";
end if;
end process;
hs<=hs1;
vs<=vs1;
B<=GRB(1);
r<=GRB(2);
G<=GRB(3);
END BEHAV;



⌨️ 快捷键说明

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