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;
相关文章
|
7月前
|
算法 异构计算
m基于FPGA的电子钟verilog实现,可设置闹钟,包含testbench测试文件
该文介绍了基于FPGA的电子钟设计,利用Vivado2019.2平台进行开发并展示测试结果。电子钟设计采用Verilog硬件描述语言,核心包括振荡器、分频器和计数器。时间显示为2个十进制格式,闹钟功能通过存储器和比较器实现,当当前时间等于设定时间时触发。文中给出了Verilog核心程序示例,展示了时钟信号、设置信号及输出的交互。
245 2
|
5月前
stm32f407探索者开发板(八)——按键输入实验--GPIO做输入
stm32f407探索者开发板(八)——按键输入实验--GPIO做输入
|
5月前
|
数据采集 存储 测试技术
使用LabVIEW和示波器测试IGBT参数
使用LabVIEW和示波器测试IGBT参数
50 0
|
7月前
|
流计算
LabVIEW开发LED滚动显示程序
LabVIEW开发LED滚动显示程序
49 2
|
7月前
|
安全 网络协议 网络安全
LabVIEW 打开NI范例查找器时报错
LabVIEW 打开NI范例查找器时报错
299 0
|
芯片
具体单板的按键驱动程序(查询方式)-以IMX6ull单板为例子
具体单板的按键驱动程序(查询方式)-以IMX6ull单板为例子
100 0
STM32:输入捕获模式测频率和占空比(内置1.实物图+2.代码部分/注释)
STM32:输入捕获模式测频率和占空比(内置1.实物图+2.代码部分/注释)
505 0
STM32:输入捕获模式测频率和占空比(内置1.实物图+2.代码部分/注释)
STM32:TIM输入捕获模式测频率并在OLED上显示频率(内含:1.接线图/实物图+2.代码部分+3.输入捕获模式使用到的STM32库函数)
STM32:TIM输入捕获模式测频率并在OLED上显示频率(内含:1.接线图/实物图+2.代码部分+3.输入捕获模式使用到的STM32库函数)
462 0
STM32:TIM输入捕获模式测频率并在OLED上显示频率(内含:1.接线图/实物图+2.代码部分+3.输入捕获模式使用到的STM32库函数)
STM32:PWM驱动直流电机(内含:1.实验现象+2.代码部分/详细注释)
STM32:PWM驱动直流电机(内含:1.实验现象+2.代码部分/详细注释)
387 0
STM32:PWM驱动直流电机(内含:1.实验现象+2.代码部分/详细注释)