VGA显示实验代码

简介: VGA显示实验代码

这次的实验现象如下:微信图片_20221013083732.png需要自己做一个VGA控制信号模块,并且显示在电脑屏幕上面,有问题的可以私聊,我们这个实验还没有做完,后续会继续更新,不希望有些人直接把代码拷走,还是要自己动脑子想想,25MHZ信号是通过直接设置锁相环生成的,我没有写具体的方法,你们的书上应该也有,拜拜吃饭去了!

例化语句的顶层代码
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY VGA_GAME IS
PORT(  
CLK20MHZ: IN STD_LOGIC;
Hs,Vs,r,g,b:OUT STD_LOGIC
);
END VGA_GAME;
ARCHITECTURE modelstru OF VGA_GAME IS
COMPONENT SPORTS
  PORT(
Q:IN STD_LOGIC;
HS,VS,R,G,B:OUT STD_LOGIC
);
END COMPONENT;
COMPONENT PLL
  PORT
  (
    inclk0    : IN STD_LOGIC  := '0';
    c0    : OUT STD_LOGIC 
  );
END COMPONENT;
SIGNAL NET1:STD_LOGIC;
BEGIN
U1:PLL PORT MAP(inclk0=>CLK20MHZ,c0 =>NET1);
U2:SPORTS PORT MAP(Q=>NET1,HS=>Hs,VS=>Vs,R=>r,G=>g,B=>b);                                  
END modelstru;
VGA控制模块代码
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY SPORTS IS 
PORT(
Q:IN STD_LOGIC;
HS,VS,R,G,B:OUT STD_LOGIC
);
END SPORTS;
ARCHITECTURE ONE OF SPORTS IS
SIGNAL HCNT:STD_LOGIC_VECTOR(0 to 9);
SIGNAL VCNT:STD_LOGIC_VECTOR(0 to 9);
BEGIN
场频的产生
PROCESS(Q)BEGIN
 IF(rising_edge(Q)) then
   IF(HCNT<800) THEN
     HCNT<=HCNT+1;
    ELSE
     HCNT<=(OTHERS=>'0');
   END IF;
 END IF;
END PROCESS;
行频的产生
PROCESS(Q) BEGIN
 IF(rising_edge(Q)) then
   IF(HCNT=640+8) THEN
     IF(VCNT<525)THEN
     VCNT<=VCNT+1;
    ELSE
     VCNT<=(OTHERS=>'0');
   END IF;
 END IF;
 END IF;
END PROCESS;
PROCESS(Q)BEGIN
 IF(rising_edge(Q)) then
  IF((HCNT>=640+8+8)AND (HCNT<(640+8+8+96)))THEN
   HS<='0';
  ELSE
   HS<='1';
  END IF;
  END IF;
 END  PROCESS;
PROCESS(VCNT)BEGIN
  IF((VCNT>=480+8+2)AND (VCNT<(480+8+2+2)))THEN
   VS<='0';
  ELSE
   VS<='1';
  END IF;
 END  PROCESS;
PROCESS(Q) BEGIN
 IF(rising_edge(Q)) THEN
  IF(HCNT<640 and VCNT<60) THEN
    R <= '0';          
    G <= '0';
    B <= '0';
   ELSIF (HCNT<=62 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1';
   ELSIF (64<HCNT AND HCNT<126 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1';
   ELSIF (128<HCNT AND HCNT<190 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1';
    ELSIF (192<HCNT AND HCNT<254 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1'; 
    ELSIF (256<HCNT AND HCNT<318 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1'; 
    ELSIF (320<HCNT AND HCNT< 382 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1'; 
    ELSIF (384<HCNT AND HCNT< 446 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1'; 
   ELSIF (448<HCNT AND HCNT< 510 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1';  
    ELSIF (512<HCNT AND HCNT< 574 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1'; 
    ELSIF (576<HCNT AND HCNT< 638 and 60<VCNT AND VCNT<80)THEN 
    R <= '0';          
    G <= '1';
    B <= '1'; 
    ELSIF (HCNT<=62 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1';
    ELSIF (64<HCNT AND HCNT< 126 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (128<HCNT AND HCNT< 190 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (192<HCNT AND HCNT< 254 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (256<HCNT AND HCNT< 318 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (320<HCNT AND HCNT< 382 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (384<HCNT AND HCNT< 446 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (448<HCNT AND HCNT< 510 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (512<HCNT AND HCNT< 574 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1';
    ELSIF (576<HCNT AND HCNT< 638 and 82<VCNT AND VCNT<102)THEN 
    R <= '1';          
    G <= '0';
    B <= '1'; 
    ELSIF (HCNT<=62 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0';
    ELSIF (64<HCNT AND HCNT< 126 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
    ELSIF (128<HCNT AND HCNT< 190 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
    ELSIF (192<HCNT AND HCNT< 254 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
    ELSIF (256<HCNT AND HCNT< 318 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
    ELSIF (320<HCNT AND HCNT< 382 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
    ELSIF (384<HCNT AND HCNT< 446 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
    ELSIF (448<HCNT AND HCNT< 510 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
    ELSIF (512<HCNT AND HCNT< 574 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0';
    ELSIF (576<HCNT AND HCNT< 638 and 104<VCNT AND VCNT<124)THEN 
    R <= '1';          
    G <= '0';
    B <= '0'; 
   ELSIF (HCNT<=62 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (64<HCNT AND HCNT< 126 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (128<HCNT AND HCNT< 190 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (192<HCNT AND HCNT< 254 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (256<HCNT AND HCNT< 318 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (320<HCNT AND HCNT< 382 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (384<HCNT AND HCNT< 446 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (448<HCNT AND HCNT< 510 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
    ELSIF (512<HCNT AND HCNT< 574 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0';
    ELSIF (576<HCNT AND HCNT< 638 and 126<VCNT AND VCNT<146)THEN 
    R <= '0';          
    G <= '1';
    B <= '0'; 
  ELSE
    R <='0';
    G <='0';
    B <='0';
  END IF;
 END IF;
END PROCESS;
END ONE;
目录
打赏
0
0
0
0
1
分享
相关文章
Linux MIPI DSI驱动调试笔记-设备树DCS格式序列之配置LCD初始化代码(二)
Linux MIPI DSI驱动调试笔记-设备树DCS格式序列之配置LCD初始化代码(二)
1693 0
使用LabVIEW和示波器测试IGBT参数
使用LabVIEW和示波器测试IGBT参数
95 0
LabVIEW 打开NI范例查找器时报错
LabVIEW 打开NI范例查找器时报错
350 0
|
11月前
【坑爹升级】更新NVIDIA GeForce GTX Ti最新驱动,突然屏幕亮瞎我24K钛合金双眼。导致Fn+F2/F3、win+x无法控制笔记本电脑显示器亮度调整, 电源选项屏幕亮度也不见了!
【坑爹升级】更新NVIDIA GeForce GTX Ti最新驱动,突然屏幕亮瞎我24K钛合金双眼。导致Fn+F2/F3、win+x无法控制笔记本电脑显示器亮度调整, 电源选项屏幕亮度也不见了!
xilinx小实验——vivado纯逻辑编程第一个demo
xilinx小实验——vivado纯逻辑编程第一个demo
433 0
xilinx小实验——vivado纯逻辑编程第一个demo
ZYNQ-使用HDMI显示器进行VDMA彩条显示测试
ZYNQ-使用HDMI显示器进行VDMA彩条显示测试
388 0
ZYNQ-使用HDMI显示器进行VDMA彩条显示测试
单片机开发之LCD1602显示实验
本文主要介绍了单片机开发之LCD1602显示的过程
548 0
单片机开发之LCD1602显示实验

热门文章

最新文章