Rev 668 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
668 | lvd | 1 | // ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014 |
272 | lvd | 2 | // |
3 | // top module for video output. |
||
668 | lvd | 4 | |
5 | /* |
||
6 | This file is part of ZX-Evo Base Configuration firmware. |
||
7 | |||
8 | ZX-Evo Base Configuration firmware is free software: |
||
9 | you can redistribute it and/or modify it under the terms of |
||
10 | the GNU General Public License as published by |
||
11 | the Free Software Foundation, either version 3 of the License, or |
||
12 | (at your option) any later version. |
||
13 | |||
14 | ZX-Evo Base Configuration firmware is distributed in the hope that |
||
15 | it will be useful, but WITHOUT ANY WARRANTY; without even |
||
16 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
17 | See the GNU General Public License for more details. |
||
18 | |||
19 | You should have received a copy of the GNU General Public License |
||
20 | along with ZX-Evo Base Configuration firmware. |
||
21 | If not, see <http://www.gnu.org/licenses/>. |
||
22 | */ |
||
23 | |||
24 | |||
25 | |||
318 | lvd | 26 | // note: the only bandwidths currently in use are 1/8 and 1/4. |
272 | lvd | 27 | |
668 | lvd | 28 | `include "../include/tune.v" |
29 | |||
272 | lvd | 30 | module video_top( |
31 | |||
32 | input wire clk, // 28 MHz clock |
||
33 | |||
34 | |||
35 | // external video outputs |
||
36 | output wire [ 1:0] vred, |
||
37 | output wire [ 1:0] vgrn, |
||
38 | output wire [ 1:0] vblu, |
||
39 | output wire vhsync, |
||
40 | output wire vvsync, |
||
41 | output wire vcsync, |
||
42 | |||
43 | |||
44 | // aux video inputs |
||
322 | lvd | 45 | input wire [ 3:0] zxborder, // border zxcolor |
272 | lvd | 46 | |
47 | |||
48 | // config inputs |
||
49 | input wire [ 1:0] pent_vmode, // 2'b00 - standard ZX |
||
50 | // 2'b01 - hardware multicolor |
||
51 | // 2'b10 - pentagon 16 colors |
||
52 | // 2'b11 - not defined yet |
||
53 | |||
54 | input wire [ 2:0] atm_vmode, // 3'b011 - zx modes (pent_vmode is active) |
||
55 | // 3'b010 - 640x200 hardware multicolor |
||
56 | // 3'b000 - 320x200 16 colors |
||
57 | // 3'b110 - 80x25 text mode |
||
58 | // 3'b??? (others) - not defined yet |
||
668 | lvd | 59 | |
272 | lvd | 60 | |
61 | input wire scr_page, // screen page (bit 3 of 7FFD) |
||
62 | |||
63 | input wire vga_on, // vga mode ON - scandoubler activated |
||
64 | |||
684 | lvd | 65 | input wire [ 1:0] modes_raster, // 2'b00 - pentagon raster (71680 clocks) |
66 | // 2'b01 - 60Hz raster |
||
67 | // 2'b10 - 48k raster (69888 clocks) |
||
68 | // 2'b11 - 128k raster (70908 clocks) |
||
69 | |||
70 | input wire mode_contend_type, // 2'b0 - 48k/128k/+2 contend type (6 5 4 3 2 1 0 0) |
||
71 | // 2'b1 - +2a/+3 contend type (1 0 7 6 5 4 3 2) |
||
272 | lvd | 72 | |
73 | // memory synchronization inputs |
||
334 | lvd | 74 | input wire cbeg, |
75 | input wire post_cbeg, |
||
76 | input wire pre_cend, |
||
272 | lvd | 77 | input wire cend, |
78 | |||
79 | |||
80 | // memory arbiter video port connection |
||
319 | lvd | 81 | input wire video_strobe, |
82 | input wire video_next, |
||
83 | output wire [20:0] video_addr, |
||
84 | input wire [15:0] video_data, |
||
85 | output wire [ 1:0] video_bw, |
||
322 | lvd | 86 | output wire video_go, |
87 | |||
88 | |||
89 | // atm palette write strobe adn data |
||
90 | input wire atm_palwr, |
||
328 | lvd | 91 | input wire [ 5:0] atm_paldata, |
92 | |||
395 | lvd | 93 | |
668 | lvd | 94 | input wire up_ena, |
95 | input wire up_palwr, |
||
96 | input wire [ 5:0] up_paladdr, |
||
97 | input wire [ 7:0] up_paldata, |
||
98 | |||
99 | |||
100 | |||
543 | lvd | 101 | output wire int_start, |
102 | |||
103 | |||
104 | |||
105 | input wire [10:0] fnt_a, |
||
106 | input wire [ 7:0] fnt_d, |
||
107 | input wire fnt_wr, |
||
108 | |||
109 | output wire [ 5:0] palcolor, // for palette readback |
||
110 | |||
684 | lvd | 111 | output wire [ 7:0] fontrom_readback, |
112 | |||
113 | output wire contend // for 48k/128k contended memory emulation |
||
272 | lvd | 114 | ); |
115 | |||
275 | lvd | 116 | // these decoded in video_modedecode.v |
117 | wire mode_atm_n_pent; |
||
118 | wire mode_zx; |
||
119 | wire mode_p_16c; |
||
120 | wire mode_p_hmclr; |
||
121 | wire mode_a_hmclr; |
||
322 | lvd | 122 | wire mode_a_16c; |
123 | wire mode_a_text; |
||
528 | lvd | 124 | wire mode_a_txt_1page; |
275 | lvd | 125 | wire mode_pixf_14; |
272 | lvd | 126 | |
127 | |||
275 | lvd | 128 | |
317 | lvd | 129 | // synchronization |
130 | wire hsync_start; |
||
131 | wire line_start; |
||
132 | wire hint_start; |
||
275 | lvd | 133 | |
323 | lvd | 134 | |
317 | lvd | 135 | wire vblank; |
136 | wire hblank; |
||
328 | lvd | 137 | |
323 | lvd | 138 | wire vpix; |
139 | wire hpix; |
||
328 | lvd | 140 | |
317 | lvd | 141 | wire vsync; |
142 | wire hsync; |
||
328 | lvd | 143 | |
323 | lvd | 144 | wire vga_hsync; |
145 | |||
317 | lvd | 146 | wire scanin_start; |
323 | lvd | 147 | wire scanout_start; |
275 | lvd | 148 | |
323 | lvd | 149 | |
150 | |||
318 | lvd | 151 | wire fetch_start; |
152 | wire fetch_end; |
||
322 | lvd | 153 | wire fetch_sync; |
275 | lvd | 154 | |
155 | |||
322 | lvd | 156 | wire [63:0] pic_bits; |
317 | lvd | 157 | |
158 | |||
323 | lvd | 159 | wire [3:0] pixels; |
317 | lvd | 160 | |
161 | |||
323 | lvd | 162 | wire [5:0] color; |
163 | wire [5:0] vga_color; |
||
317 | lvd | 164 | |
165 | |||
395 | lvd | 166 | wire [2:0] typos; |
317 | lvd | 167 | |
668 | lvd | 168 | |
169 | // ulaplus related |
||
170 | wire [ 1:0] up_palsel; |
||
171 | wire [ 2:0] up_paper; |
||
172 | wire [ 2:0] up_ink; |
||
173 | wire up_pixel; |
||
395 | lvd | 174 | |
175 | |||
684 | lvd | 176 | // border sync for 48k/128k emulation |
177 | wire border_sync; |
||
178 | |||
179 | |||
180 | |||
275 | lvd | 181 | // decode video modes |
182 | video_modedecode video_modedecode( |
||
183 | |||
184 | .clk(clk), |
||
185 | |||
186 | .pent_vmode(pent_vmode), |
||
187 | .atm_vmode (atm_vmode), |
||
188 | |||
528 | lvd | 189 | .mode_atm_n_pent (mode_atm_n_pent ), |
190 | .mode_zx (mode_zx ), |
||
191 | .mode_p_16c (mode_p_16c ), |
||
192 | .mode_p_hmclr (mode_p_hmclr ), |
||
193 | .mode_a_hmclr (mode_a_hmclr ), |
||
194 | .mode_a_16c (mode_a_16c ), |
||
195 | .mode_a_text (mode_a_text ), |
||
196 | .mode_a_txt_1page(mode_a_txt_1page), |
||
275 | lvd | 197 | |
319 | lvd | 198 | .mode_pixf_14(mode_pixf_14), |
199 | |||
200 | .mode_bw(video_bw) |
||
275 | lvd | 201 | ); |
202 | |||
203 | |||
204 | |||
205 | |||
206 | |||
207 | |||
317 | lvd | 208 | // vertical sync generator |
209 | video_sync_v video_sync_v( |
||
275 | lvd | 210 | |
317 | lvd | 211 | .clk(clk), |
275 | lvd | 212 | |
317 | lvd | 213 | .mode_atm_n_pent(mode_atm_n_pent), |
684 | lvd | 214 | .modes_raster(modes_raster), |
275 | lvd | 215 | |
317 | lvd | 216 | .hsync_start(hsync_start), |
217 | .line_start(line_start), |
||
218 | .hint_start(hint_start), |
||
275 | lvd | 219 | |
317 | lvd | 220 | .vblank(vblank), |
221 | .vsync(vsync), |
||
222 | .vpix(vpix), |
||
275 | lvd | 223 | |
317 | lvd | 224 | .int_start(int_start) |
225 | ); |
||
226 | |||
227 | |||
228 | // horizontal sync generator |
||
229 | video_sync_h video_sync_h( |
||
230 | |||
231 | .clk(clk), |
||
232 | |||
233 | .mode_atm_n_pent(mode_atm_n_pent), |
||
528 | lvd | 234 | .mode_a_text (mode_a_text), |
317 | lvd | 235 | |
684 | lvd | 236 | .modes_raster (modes_raster ), |
237 | .mode_contend_type(mode_contend_type), |
||
317 | lvd | 238 | |
239 | .init(1'b0), |
||
240 | |||
241 | .pre_cend(pre_cend), |
||
334 | lvd | 242 | .cend (cend ), |
317 | lvd | 243 | |
244 | |||
245 | .hblank(hblank), |
||
246 | .hsync(hsync), |
||
684 | lvd | 247 | .vpix(vpix), |
317 | lvd | 248 | .hpix(hpix), |
249 | |||
250 | .line_start(line_start), |
||
251 | .hsync_start(hsync_start), |
||
252 | |||
253 | .hint_start(hint_start), |
||
254 | |||
318 | lvd | 255 | .scanin_start(scanin_start), |
256 | |||
257 | .fetch_start(fetch_start), |
||
684 | lvd | 258 | .fetch_end (fetch_end ), |
322 | lvd | 259 | |
684 | lvd | 260 | .contend(contend), |
261 | |||
262 | .border_sync(border_sync) |
||
317 | lvd | 263 | ); |
264 | |||
265 | |||
319 | lvd | 266 | // address generation |
267 | video_addrgen video_addrgen( |
||
317 | lvd | 268 | |
319 | lvd | 269 | .clk(clk), |
317 | lvd | 270 | |
319 | lvd | 271 | .video_addr(video_addr), |
272 | .video_next(video_next), |
||
273 | |||
355 | lvd | 274 | .line_start(hsync_start), |
334 | lvd | 275 | .int_start (int_start ), |
276 | .vpix (vpix ), |
||
319 | lvd | 277 | |
278 | .scr_page(scr_page), |
||
279 | |||
335 | lvd | 280 | .typos(typos), |
319 | lvd | 281 | |
528 | lvd | 282 | .mode_atm_n_pent (mode_atm_n_pent ), |
283 | .mode_zx (mode_zx ), |
||
284 | .mode_p_16c (mode_p_16c ), |
||
285 | .mode_p_hmclr (mode_p_hmclr ), |
||
286 | .mode_a_hmclr (mode_a_hmclr ), |
||
287 | .mode_a_16c (mode_a_16c ), |
||
288 | .mode_a_text (mode_a_text ), |
||
289 | .mode_a_txt_1page(mode_a_txt_1page) |
||
319 | lvd | 290 | ); |
291 | |||
292 | |||
322 | lvd | 293 | // data fetch |
294 | video_fetch video_fetch( |
||
319 | lvd | 295 | |
322 | lvd | 296 | .clk(clk), |
297 | |||
334 | lvd | 298 | .pre_cend (pre_cend), |
299 | .cend (cend ), |
||
322 | lvd | 300 | |
333 | lvd | 301 | .vpix(vpix), |
302 | |||
322 | lvd | 303 | .fetch_start(fetch_start), |
304 | .fetch_end (fetch_end ), |
||
305 | |||
306 | .fetch_sync (fetch_sync ), |
||
307 | |||
308 | .video_data (video_data ), |
||
309 | .video_strobe(video_strobe), |
||
310 | .video_go (video_go ), |
||
311 | |||
312 | .pic_bits(pic_bits) |
||
313 | ); |
||
314 | |||
315 | |||
316 | // render fetched data to pixels |
||
317 | video_render video_render( |
||
318 | |||
319 | .clk(clk), |
||
320 | |||
321 | .pic_bits(pic_bits), |
||
322 | |||
330 | lvd | 323 | .fetch_sync(fetch_sync), |
328 | lvd | 324 | |
336 | lvd | 325 | .cbeg (cbeg ), |
334 | lvd | 326 | .post_cbeg(post_cbeg), |
336 | lvd | 327 | .pre_cend (pre_cend ), |
334 | lvd | 328 | .cend (cend ), |
330 | lvd | 329 | |
325 | lvd | 330 | .int_start(int_start), |
322 | lvd | 331 | |
332 | .mode_atm_n_pent(mode_atm_n_pent), |
||
333 | .mode_zx (mode_zx ), |
||
334 | .mode_p_16c (mode_p_16c ), |
||
335 | .mode_p_hmclr (mode_p_hmclr ), |
||
336 | .mode_a_hmclr (mode_a_hmclr ), |
||
337 | .mode_a_16c (mode_a_16c ), |
||
338 | .mode_a_text (mode_a_text ), |
||
334 | lvd | 339 | .mode_pixf_14 (mode_pixf_14 ), |
322 | lvd | 340 | |
336 | lvd | 341 | .typos(typos), |
395 | lvd | 342 | |
394 | tsl | 343 | .pixels(pixels), |
322 | lvd | 344 | |
668 | lvd | 345 | .up_palsel(up_palsel), |
346 | .up_paper (up_paper ), |
||
347 | .up_ink (up_ink ), |
||
348 | .up_pixel (up_pixel ), |
||
322 | lvd | 349 | |
668 | lvd | 350 | |
528 | lvd | 351 | .fnt_a (fnt_a ), |
352 | .fnt_d (fnt_d ), |
||
543 | lvd | 353 | .fnt_wr(fnt_wr), |
354 | |||
355 | .fontrom_readback(fontrom_readback) |
||
528 | lvd | 356 | ); |
357 | |||
358 | |||
323 | lvd | 359 | // combine border and pixels, apply palette |
360 | video_palframe video_palframe( |
||
322 | lvd | 361 | |
323 | lvd | 362 | .clk(clk), |
322 | lvd | 363 | |
323 | lvd | 364 | .hblank(hblank), |
365 | .vblank(vblank), |
||
366 | |||
668 | lvd | 367 | .hsync_start(hsync_start), |
368 | .vsync (vsync ), |
||
369 | |||
323 | lvd | 370 | .hpix(hpix), |
371 | .vpix(vpix), |
||
372 | |||
373 | .pixels(pixels), |
||
329 | lvd | 374 | .border(zxborder), |
323 | lvd | 375 | |
684 | lvd | 376 | .border_sync (border_sync ), |
377 | .border_sync_ena(modes_raster[1]), |
||
378 | |||
323 | lvd | 379 | .atm_palwr (atm_palwr ), |
380 | .atm_paldata(atm_paldata), |
||
668 | lvd | 381 | |
382 | .up_palsel(up_palsel), |
||
383 | .up_paper (up_paper ), |
||
384 | .up_ink (up_ink ), |
||
385 | .up_pixel (up_pixel ), |
||
386 | |||
387 | .up_ena (up_ena ), |
||
388 | .up_paladdr(up_paladdr), |
||
389 | .up_paldata(up_paldata), |
||
390 | .up_palwr (up_palwr ), |
||
323 | lvd | 391 | |
528 | lvd | 392 | .color(color), |
393 | |||
394 | .palcolor(palcolor) // palette readback |
||
323 | lvd | 395 | ); |
396 | |||
397 | |||
398 | // VGA hsync doubling |
||
399 | video_vga_sync_h video_vga_sync_h( |
||
328 | lvd | 400 | |
323 | lvd | 401 | .clk(clk), |
402 | |||
403 | .hsync_start(hsync_start), |
||
684 | lvd | 404 | |
405 | .modes_raster(modes_raster), |
||
323 | lvd | 406 | |
407 | .scanout_start(scanout_start), |
||
408 | |||
409 | .vga_hsync(vga_hsync) |
||
410 | ); |
||
411 | |||
412 | |||
413 | // VGA scandoubling |
||
325 | lvd | 414 | video_vga_double video_vga_double( |
323 | lvd | 415 | |
416 | .clk(clk), |
||
417 | |||
418 | .hsync_start (hsync_start ), |
||
419 | .scanout_start(scanout_start), |
||
420 | .scanin_start (scanin_start ), |
||
421 | |||
422 | .pix_in(color), |
||
423 | |||
329 | lvd | 424 | .pix_out(vga_color) |
323 | lvd | 425 | ); |
426 | |||
427 | |||
428 | // final MUXing of VGA and TV signals |
||
429 | video_outmux video_outmux( |
||
430 | |||
431 | .clk(clk), |
||
432 | |||
331 | lvd | 433 | .vga_on(vga_on), |
328 | lvd | 434 | |
331 | lvd | 435 | |
323 | lvd | 436 | .tvcolor(color), |
329 | lvd | 437 | .vgacolor(vga_color), |
323 | lvd | 438 | |
439 | .vga_hsync(vga_hsync), |
||
440 | .hsync (hsync ), |
||
441 | .vsync (vsync ), |
||
442 | |||
443 | .vred(vred), |
||
444 | .vgrn(vgrn), |
||
445 | .vblu(vblu), |
||
446 | |||
447 | .vhsync(vhsync), |
||
448 | .vvsync(vvsync), |
||
449 | .vcsync(vcsync) |
||
450 | ); |
||
451 | |||
452 | |||
453 | |||
454 | |||
455 | |||
395 | lvd | 456 | |
272 | lvd | 457 | endmodule |
458 |