|
MAXII CPLD 实验板
VGA信号发生器程序
|
注: |
本实验是针对 MC570/MC240 实验板 设计的,如选用其它开发板实现,部分内容需做调整。 |
|
实现一个VGA信号发生器,在VGA显示器上以640x480分辨率显示一个彩色棋盘格图像。 |
1. |
点击 这里 下载示例工程。*.qar 是 QuartusII 的压缩文档,用 QuartusII6.0 打开。 |
|
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
ENTITY maxii_vga IS
PORT(
clk : IN STD_LOGIC;
R : OUT STD_LOGIC;
G : OUT STD_LOGIC;
B : OUT STD_LOGIC;
HS : OUT STD_LOGIC;
VS : OUT STD_LOGIC
);
END maxii_vga;
ARCHITECTURE maxii_vga OF maxii_vga IS
SIGNAL hcnt : INTEGER RANGE 0 TO 1588 :=0;
SIGNAL vcnt : INTEGER RANGE 0 TO 481 :=0;
SIGNAL row : INTEGER RANGE 0 TO 7;
SIGNAL col : INTEGER RANGE 0 TO 7;
SIGNAL rgb : STD_LOGIC_VECTOR(2 DOWNTO 0);
BEGIN
PROCESS(clk)
BEGIN
IF clk'EVENT AND clk='1' THEN
IF hcnt=1588 THEN
hcnt <= 0;
ELSE
hcnt <= hcnt+1;
END IF;
END IF;
END PROCESS;
PROCESS(clk)
BEGIN
IF clk'EVENT AND clk='1' THEN
IF hcnt=1471 THEN
HS <= '0';
ELSIF hcnt=1588 THEN
HS <= '1';
END IF;
END IF;
END PROCESS;
PROCESS(clk)
BEGIN
IF clk'EVENT AND clk='1' THEN
IF hcnt=1588 THEN
IF vcnt=481 THEN
vcnt <= 0;
ELSE
vcnt <= vcnt+1;
END IF;
END IF;
END IF;
END PROCESS;
PROCESS(clk)
BEGIN
IF clk'EVENT AND clk='1' THEN
IF hcnt=1588 THEN
IF vcnt=479 THEN
VS <= '0';
ELSIF vcnt=481 THEN
VS <= '1';
END IF;
END IF;
END IF;
END PROCESS;
PROCESS(clk)
BEGIN
IF clk'EVENT AND clk='1' THEN
CASE hcnt IS
WHEN 183 => col <= 1;
WHEN 367 => col <= 2;
WHEN 551 => col <= 3;
WHEN 735 => col <= 4;
WHEN 919 => col <= 5;
WHEN 1103 => col <= 6;
WHEN 1287 => col <= 7;
WHEN 1471 => col <= 0;
WHEN OTHERS => NULL;
END CASE;
END IF;
END PROCESS;
PROCESS(clk)
BEGIN
IF clk'EVENT AND clk='1' THEN
IF hcnt=1588 THEN
CASE vcnt IS
WHEN 59 => row <= 1;
WHEN 119 => row <= 2;
WHEN 179 => row <= 3;
WHEN 239 => row <= 4;
WHEN 299 => row <= 5;
WHEN 359 => row <= 6;
WHEN 419 => row <= 7;
WHEN 479 => row <= 0;
WHEN OTHERS => NULL;
END CASE;
END IF;
END IF;
END PROCESS;
rgb <= CONV_STD_LOGIC_VECTOR(row+col, 3);
R <= rgb(0);
G <= rgb(1);
B <= rgb(2);
END maxii_vga;
|
|
|
|