-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtop_level.vhd
248 lines (215 loc) · 5.96 KB
/
top_level.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
----------------------------------------------------------------------------------
-- Engineer: Mike Field <[email protected]>
--
-- Module Name: top_level - Behavioral
-- Description: Top level module of the Zedboard OV7670 design
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity top_level is
Port ( clk100 : in STD_LOGIC;
btnl : in STD_LOGIC;
btnc : in STD_LOGIC;
btnr : in STD_LOGIC;
config_finished : out STD_LOGIC;
vga_hsync : out STD_LOGIC;
vga_vsync : out STD_LOGIC;
vga_r : out STD_LOGIC_vector(3 downto 0);
vga_g : out STD_LOGIC_vector(3 downto 0);
vga_b : out STD_LOGIC_vector(3 downto 0);
ov7670_pclk : in STD_LOGIC;
ov7670_xclk : out STD_LOGIC;
ov7670_vsync : in STD_LOGIC;
ov7670_href : in STD_LOGIC;
ov7670_data : in STD_LOGIC_vector(7 downto 0);
ov7670_sioc : out STD_LOGIC;
ov7670_siod : inout STD_LOGIC;
ov7670_pwdn : out STD_LOGIC;
ov7670_reset : out STD_LOGIC
);
end top_level;
architecture Behavioral of top_level is
COMPONENT VGA
PORT(
CLK25 : IN std_logic;
rez_160x120 : IN std_logic;
rez_320x240 : IN std_logic;
Hsync : OUT std_logic;
Vsync : OUT std_logic;
Nblank : OUT std_logic;
clkout : OUT std_logic;
activeArea : OUT std_logic;
Nsync : OUT std_logic
);
END COMPONENT;
COMPONENT ov7670_controller
PORT(
clk : IN std_logic;
resend : IN std_logic;
siod : INOUT std_logic;
config_finished : OUT std_logic;
sioc : OUT std_logic;
reset : OUT std_logic;
pwdn : OUT std_logic;
xclk : OUT std_logic
);
END COMPONENT;
COMPONENT debounce
PORT(
clk : IN std_logic;
i : IN std_logic;
o : OUT std_logic
);
END COMPONENT;
COMPONENT frame_buffer
PORT(
data : IN std_logic_vector(11 downto 0);
rdaddress : IN std_logic_vector(18 downto 0);
rdclock : IN std_logic;
wraddress : IN std_logic_vector(18 downto 0);
wrclock : IN std_logic;
wren : IN std_logic;
q : OUT std_logic_vector(11 downto 0)
);
END COMPONENT;
COMPONENT ov7670_capture
PORT(
rez_160x120 : IN std_logic;
rez_320x240 : IN std_logic;
pclk : IN std_logic;
vsync : IN std_logic;
href : IN std_logic;
d : IN std_logic_vector(7 downto 0);
addr : OUT std_logic_vector(18 downto 0);
dout : OUT std_logic_vector(11 downto 0);
we : OUT std_logic
);
END COMPONENT;
COMPONENT RGB
PORT(
Din : IN std_logic_vector(11 downto 0);
Nblank : IN std_logic;
R : OUT std_logic_vector(7 downto 0);
G : OUT std_logic_vector(7 downto 0);
B : OUT std_logic_vector(7 downto 0)
);
END COMPONENT;
component vga_pll_zedboard
port (
CLK100 : in std_logic;
CLK50_camera : out std_logic;
CLK25_vga : out std_logic);
end component;
COMPONENT vga_pll
PORT(
inclk0 : IN std_logic;
c0 : OUT std_logic;
c1 : OUT std_logic
);
END COMPONENT;
COMPONENT Address_Generator
PORT(
CLK25 : IN std_logic;
rez_160x120 : IN std_logic;
rez_320x240 : IN std_logic;
enable : IN std_logic;
vsync : in STD_LOGIC;
address : OUT std_logic_vector(18 downto 0)
);
END COMPONENT;
signal clk_camera : std_logic;
signal clk_vga : std_logic;
signal wren : std_logic;
signal resend : std_logic;
signal nBlank : std_logic;
signal vSync : std_logic;
signal nSync : std_logic;
signal wraddress : std_logic_vector(18 downto 0);
signal wrdata : std_logic_vector(11 downto 0);
signal rdaddress : std_logic_vector(18 downto 0);
signal rddata : std_logic_vector(11 downto 0);
signal red,green,blue : std_logic_vector(7 downto 0);
signal activeArea : std_logic;
signal rez_160x120 : std_logic;
signal rez_320x240 : std_logic;
begin
vga_r <= red(7 downto 4);
vga_g <= green(7 downto 4);
vga_b <= blue(7 downto 4);
rez_160x120 <= btnl;
rez_320x240 <= btnr;
-- For the Nexys2
-- Inst_vga_pll: vga_pll PORT MAP(
-- inclk0 => clk50,
-- c0 => clk_camera,
-- c1 => clk_vga
-- );
inst_vga_pll : vga_pll_zedboard
port map
( CLK100 => CLK100,
CLK50_camera => CLK_camera,
CLK25_vga => CLK_vga);
vga_vsync <= vsync;
Inst_VGA: VGA PORT MAP(
CLK25 => clk_vga,
rez_160x120 => rez_160x120,
rez_320x240 => rez_320x240,
clkout => open,
Hsync => vga_hsync,
Vsync => vsync,
Nblank => nBlank,
Nsync => nsync,
activeArea => activeArea
);
Inst_debounce: debounce PORT MAP(
clk => clk_vga,
i => btnc,
o => resend
);
Inst_ov7670_controller: ov7670_controller PORT MAP(
clk => clk_camera,
resend => resend,
config_finished => config_finished,
sioc => ov7670_sioc,
siod => ov7670_siod,
reset => ov7670_reset,
pwdn => ov7670_pwdn,
xclk => ov7670_xclk
);
Inst_frame_buffer: frame_buffer PORT MAP(
rdaddress => rdaddress,
rdclock => clk_vga,
q => rddata,
wrclock => ov7670_pclk,
wraddress => wraddress(18 downto 0),
data => wrdata,
wren => wren
);
Inst_ov7670_capture: ov7670_capture PORT MAP(
pclk => ov7670_pclk,
rez_160x120 => rez_160x120,
rez_320x240 => rez_320x240,
vsync => ov7670_vsync,
href => ov7670_href,
d => ov7670_data,
addr => wraddress,
dout => wrdata,
we => wren
);
Inst_RGB: RGB PORT MAP(
Din => rddata,
Nblank => activeArea,
R => red,
G => green,
B => blue
);
Inst_Address_Generator: Address_Generator PORT MAP(
CLK25 => clk_vga,
rez_160x120 => rez_160x120,
rez_320x240 => rez_320x240,
enable => activeArea,
vsync => vsync,
address => rdaddress
);
end Behavioral;