/
vgaTest.vhd
107 lines (91 loc) · 2.73 KB
/
vgaTest.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 08:49:22 10/30/2008
-- Design Name:
-- Module Name: vgaTest - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity vgaTest is
port(clock : in std_logic;
R, G : out std_logic_vector(2 downto 0);
B : out std_logic_vector(1 downto 0);
H, V : out std_logic;
LD0 : out std_logic);
end vgaTest;
architecture Behavioral of vgaTest is
component vgadrive is
port( clock : in std_logic; -- 25.175 Mhz clock
red, green, blue : in std_logic; -- input values for RGB signals
row, column : out std_logic_vector(9 downto 0); -- for current pixel
Rout, Gout : out std_logic_vector(2 downto 0);
Bout : out std_logic_vector(1 downto 0);
H, V : out std_logic); -- VGA drive signals
end component;
signal row, column : std_logic_vector(9 downto 0);
signal red, green, blue : std_logic;
signal clk2 : std_logic;
signal tmp_clkf : std_logic := '0';
begin
my_div_fast: process (clock,tmp_clkf)
variable div_cnt : integer := 0;
begin
if (rising_edge(clock)) then
if (div_cnt = 0) then
tmp_clkf <= not tmp_clkf;
div_cnt := 0;
else
div_cnt := div_cnt + 1;
end if;
end if;
clk2 <= tmp_clkf;
end process my_div_fast;
LD0 <= clk2;
-- for debugging: to view the bit order
VGA : component vgadrive
port map ( clock => clk2,
red => red, green => green, blue => blue, -- inputs
row => row, column => column, -- input coordinates
Rout => R, Gout => G, Bout => B, H => H, V => V -- outputs
);
-- red square from 0,0 to 360, 350
-- green square from 0,250 to 360, 640
-- blue square from 120,150 to 480,500
RGB : process(row, column)
begin
if row < 360 and column < 350 then
red <= '1';
else
red <= '0';
end if;
if row < 360 and column > 250 and column < 640 then
green <= '1';
else
green <= '0';
end if;
if row > 120 and row < 480 and column > 150 and column < 500 then
blue <= '1';
else
blue <= '0';
end if;
end process;
end Behavioral;