-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchecker.vhd
141 lines (124 loc) · 3.41 KB
/
checker.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use WORK.uas.ALL;
entity draw_checkers is
Generic (
red_width : positive := 3;
green_width : positive := 3;
blue_width : positive := 2
);
Port (
clk : in STD_LOGIC;
rst : in STD_LOGIC;
hs : out STD_LOGIC;
vs : out STD_LOGIC;
red : out STD_LOGIC_VECTOR (red_width-1 downto 0);
green : out STD_LOGIC_VECTOR (green_width-1 downto 0);
blue : out STD_LOGIC_VECTOR (blue_width-1 downto 0)
);
end draw_checkers;
architecture Behavioral of draw_checkers is
COMPONENT vga_configurable
Generic (
config : vga_timing;
red_width : positive;
green_width : positive;
blue_width : positive
);
PORT(
clk : IN std_logic;
rst : IN std_logic;
blue_in : IN std_logic_vector;
red_in : IN std_logic_vector;
green_in : IN std_logic_vector;
hs : OUT std_logic;
vs : OUT std_logic;
green : OUT std_logic_vector;
red : OUT std_logic_vector;
blue : OUT std_logic_vector;
x_pos : OUT integer range -1 to config.horizontal_video - 1;
y_pos : OUT integer range -1 to config.vertical_video - 1
);
END COMPONENT;
-- Nexys3
COMPONENT nexys3_clock
PORT(
CLK_IN1 : in std_logic;
CLK_OUT1 : out std_logic
);
END COMPONENT;
-- Mojo
COMPONENT mojo_clock
PORT(
CLK_IN1 : in std_logic;
CLK_OUT1 : out std_logic
);
END COMPONENT;
-- Basys2
-- COMPONENT clock
-- PORT(
-- CLKIN_IN : IN std_logic;
-- CLKFX_OUT : OUT std_logic;
-- CLKIN_IBUFG_OUT : OUT std_logic;
-- CLK0_OUT : OUT std_logic
-- );
-- END COMPONENT;
constant vga_config : vga_timing := vga_25mhz_640x480;
signal vga_clk : std_logic;
signal red_buf : std_logic_vector(red_width - 1 downto 0) := (others => '1');
signal green_buf : std_logic_vector(green_width - 1 downto 0) := (others => '0');
signal blue_buf : std_logic_vector(blue_width - 1 downto 0) := (others => '0');
signal x_pos : integer range -1 to vga_config.horizontal_video - 1;
signal y_pos : integer range -1 to vga_config.vertical_video - 1;
begin
process(vga_clk)
begin
if(rising_edge(vga_clk)) then
if(x_pos > 0 and y_pos > 0) then
if((x_pos mod 128 < 64 and y_pos mod 128 < 64) or (y_pos mod 128 > 64 and x_pos mod 128 > 64)) then
red_buf <= (others => '1');
else
red_buf <= (others => '0');
end if;
end if;
end if;
end process;
-- Nexys3
Inst_clock : nexys3_clock PORT MAP(
CLK_IN1 => clk,
CLK_OUT1 => vga_clk
);
-- Mojo
-- Inst_clock : mojo_clock PORT MAP(
-- CLK_IN1 => clk,
-- CLK_OUT1 => vga_clk
-- );
-- Basys2
-- Inst_clock: clock PORT MAP(
-- CLKIN_IN => clk,
-- CLKFX_OUT => vga_clk,
-- CLKIN_IBUFG_OUT => open,
-- CLK0_OUT => open
-- );
Inst_vga_configurable: vga_configurable
GENERIC MAP(
config => vga_25mhz_640x480,
red_width => red_width,
green_width => green_width,
blue_width => blue_width
)
PORT MAP(
clk => vga_clk,
rst => rst,
hs => hs,
vs => vs,
green => green,
red => red,
blue => blue,
x_pos => x_pos,
y_pos => y_pos,
blue_in => blue_buf,
red_in => red_buf,
green_in => green_buf
);
end Behavioral;