-
Notifications
You must be signed in to change notification settings - Fork 4
/
f18a_core.vhd
586 lines (522 loc) · 22.8 KB
/
f18a_core.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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
--
-- F18A
-- A pin-compatible enhanced replacement for the TMS9918A VDP family.
-- https://dnotq.io
--
-- Released under the 3-Clause BSD License:
--
-- Copyright 2011-2018 Matthew Hagerty (matthew <at> dnotq <dot> io)
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- 3. Neither the name of the copyright holder nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-- Version history. See README.md for details.
--
-- V1.9 Dec 31, 2018
-- V1.8 Aug 24, 2016
-- V1.7 Jan 1, 2016
-- V1.6 May 3, 2014 .. Apr 26, 2015
-- V1.5 Jul 23, 2013
-- V1.4 Mar 20, 2013 .. Apr 26, 2013
-- V1.3 Jul 26, 2012, Release firmware
-- Main F18A core.
-- TODO:
--
-- Register mode_i and cd_i in the host-interface (CPU) module.
--
-- The host interface module needs to renamed and split up, it is too big.
--
-- Rewrite sprite layer and remove sprite linking.
--
-- Rewrite GPU module and fix memory interface to not block.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity f18a_core is
port (
clk_100m0_i : in std_logic;
clk_25m0_i : in std_logic;
-- 9918A to Host System Interface
reset_n_i : in std_logic; -- Must be active for at least one 25MHz clock cycle
mode_i : in std_logic;
csw_n_i : in std_logic;
csr_n_i : in std_logic;
int_n_o : out std_logic;
cd_i : in std_logic_vector(0 to 7);
cd_o : out std_logic_vector(0 to 7);
-- Video Output
blank_o : out std_logic;
hsync_o : out std_logic;
vsync_o : out std_logic;
red_o : out std_logic_vector(0 to 3);
grn_o : out std_logic_vector(0 to 3);
blu_o : out std_logic_vector(0 to 3);
-- Feature Selection
sprite_max_i : in std_logic; -- Default sprite max, '0' = 32, '1' = 4
scanlines_i : in std_logic; -- Simulated scan lines, '0' = no, '1' = yes
-- SPI to GPU
spi_clk_o : out std_logic;
spi_cs_o : out std_logic;
spi_mosi_o : out std_logic;
spi_miso_i : in std_logic
);
end f18a_core;
architecture rtl of f18a_core is
-- Output video registers.
signal blank_r : std_logic := '0';
signal hsync_r : std_logic := '0';
signal vsync_r : std_logic := '0';
signal red_r, red_s : std_logic_vector(0 to 3) := "0000";
signal grn_r, grn_s : std_logic_vector(0 to 3) := "0000";
signal blu_r, blu_s : std_logic_vector(0 to 3) := "0000";
-- Video signals
-- blank here is NOT the same as the soft_blank signal from the CPU I/O
signal blank_s : std_logic; -- VGA blanking
signal sl_blank_s : std_logic; -- scan line blanking for GPU
signal vsync_s : std_logic;
signal hsync_s : std_logic;
signal raster_x_s : unsigned(0 to 9);
signal raster_y_s : unsigned(0 to 9);
signal y_tick_s : std_logic;
signal y_max_s : std_logic;
-- Counter signals
signal in_margin_s : std_logic;
signal y_margin_n_s : std_logic;
signal x_pixel_max_s : unsigned(0 to 8);
signal x_pixel_pos_s : unsigned(0 to 8);
signal x_sprt_pos_s : unsigned(0 to 7);
signal y_next_s : unsigned(0 to 8);
signal y_sprt_pos_s : unsigned(0 to 7);
signal prescan_start_s : std_logic;
signal sprite_start_s : std_logic;
-- Scroll support
signal t1ntba_s : std_logic_vector(0 to 3); -- tile1 name table base address
signal t1ctba_s : std_logic_vector(0 to 7); -- tile1 color table base address
signal t1hsize_s : std_logic; -- tile1 horz page size (1 page or 2 pages)
signal t1vsize_s : std_logic; -- tile1 vert page size (1 page or 2 pages)
signal t1horz_s : std_logic_vector(0 to 7); -- tile1 horz scroll
signal t1vert_s : std_logic_vector(0 to 7); -- tile1 vert scroll
signal t2_en_s : std_logic; -- tile2 enable
signal t2_pri_en_s : std_logic; -- tile2 priority enable (0 = TL2 always on top)
signal t2ntba_s : std_logic_vector(0 to 3); -- tile2 name table base address
signal t2ctba_s : std_logic_vector(0 to 7); -- tile2 color table base address
signal t2hsize_s : std_logic; -- tile2 horz page size (1 page or 2 pages)
signal t2vsize_s : std_logic; -- tile2 vert page size (1 page or 2 pages)
signal t2horz_s : std_logic_vector(0 to 7); -- tile2 horz scroll
signal t2vert_s : std_logic_vector(0 to 7); -- tile2 vert scroll
-- Bitmap layer
signal bmlba_s : std_logic_vector(0 to 7); -- bitmap layer base address
signal bml_x_s : std_logic_vector(0 to 7);
signal bml_y_s : std_logic_vector(0 to 7);
signal bml_w_s : std_logic_vector(0 to 7);
signal bml_h_s : std_logic_vector(0 to 7);
signal bml_ps_s : std_logic_vector(0 to 3); -- bitmap layer palette select
signal bml_en_s : std_logic; -- '1' to enable the bitmap layer
signal bml_pri_s : std_logic; -- '1' when bitmap has priority over tiles
signal bml_trans_s : std_logic; -- '1' to set "00" pixels transparent
signal bml_fat_s : std_logic;
-- Tile and sprite output
signal tile_color_s : std_logic_vector(0 to 7);
signal sprt_color_s : std_logic_vector(0 to 7);
signal bg_color_s : std_logic_vector(0 to 5);
-- Color palette access
signal col_we_s : std_logic;
signal col_addr_cpu_s : std_logic_vector(0 to 5);
signal col_din_s : std_logic_vector(0 to 11);
signal col_dout_s : std_logic_vector(0 to 11);
-- Color output
signal tile_r_s : std_logic_vector(0 to 3);
signal tile_g_s : std_logic_vector(0 to 3);
signal tile_b_s : std_logic_vector(0 to 3);
signal show_bg : std_logic;
-- CPU outputs
signal pgba_s : std_logic_vector(0 to 2);
signal gmode_s : unsigned(0 to 3);
signal textfg_s : std_logic_vector(0 to 3);
signal textbg_s : std_logic_vector(0 to 3);
signal unlocked_s : std_logic;
signal row30_s : std_logic;
signal tile_ecm_s : unsigned(0 to 1);
signal sprt_ecm_s : unsigned(0 to 1);
signal tl1_off_s : std_logic;
signal pos_attr_s : std_logic;
signal tpgsize_s : std_logic_vector(0 to 1);
signal spgsize_s : std_logic_vector(0 to 1);
signal tile_ps_s : std_logic_vector(0 to 3);
signal sprt_ps_s : std_logic_vector(0 to 1);
signal sprt_yreal_s : std_logic;
signal reportmax_s : std_logic;
signal soft_blank_s : std_logic;
signal size_bit_s : std_logic;
signal mag_bit_s : std_logic;
signal satba_s : std_logic_vector(0 to 6);
signal spgba_s : std_logic_vector(0 to 2);
signal sp_cf_s : std_logic;
signal sp_5s_s : std_logic;
signal sp_5th_s : std_logic_vector(0 to 4);
signal intr_en_s : std_logic;
signal sp_cf_en_s : std_logic;
signal scanline_s : unsigned(0 to 7);
signal vscanln_en_s : std_logic; -- Virtual scan line enable
-- CPU to VRAM
signal cpu_din_s : std_logic_vector(0 to 7);
signal cpu_we_s : std_logic;
signal cpu_addr_s : std_logic_vector(0 to 13);
signal cpu_dout_s : std_logic_vector(0 to 7);
-- Tile to VRAM
signal tile_active_s : std_logic;
signal tile_addr_s : std_logic_vector(0 to 13);
signal tile_dout_s : std_logic_vector(0 to 7);
signal override_s : std_logic;
signal override_r_s : std_logic_vector(0 to 3);
signal override_g_s : std_logic_vector(0 to 3);
signal override_b_s : std_logic_vector(0 to 3);
-- Sprite to VRAM
signal sprt_addr_s : std_logic_vector(0 to 13);
-- Internal options
signal stop_sprt_s : unsigned(0 to 5);
signal sprite_max_s : unsigned(0 to 4); -- From VDP register, do not confuse with sprite_max_r
-- Register external inputs.
signal reset_n_r : std_logic := '1';
signal scanlines_r : std_logic := '0';
signal sprite_max_r : std_logic_vector(0 to 4) := "11111";
begin
-- Register external inputs other than those associated with data (which
-- are registered in the host interface).
process (clk_100m0_i) begin
if rising_edge(clk_100m0_i) then
reset_n_r <= reset_n_i;
scanlines_r <= scanlines_i;
-- Select the power-on / reset default maximum number of sprites per line.
-- The max sprites can also be changed after power-on via a VDP register.
if sprite_max_i = '0' then
sprite_max_r <= "11111";
else
sprite_max_r <= "00100";
end if;
end if; end process;
-- Dual-port 16K VRAM
inst_vram : entity work.f18a_vram
port map (
clk => clk_100m0_i,
-- CPU Interface
cpu_din => cpu_din_s,
cpu_we => cpu_we_s,
cpu_addr => cpu_addr_s,
cpu_dout => cpu_dout_s,
-- Tile Interface
tile_active => tile_active_s,
tile_addr => tile_addr_s,
tile_dout => tile_dout_s,
-- Sprite Interface
sprt_addr => sprt_addr_s
);
-- Host CPU interface
inst_cpu : entity work.f18a_cpu
port map (
clk => clk_100m0_i,
rst_n => reset_n_r,
mode => mode_i,
csw_n => csw_n_i,
csr_n => csr_n_i,
cd_i => cd_i,
cd_o => cd_o,
sp_cf => sp_cf_s,
sp_5s => sp_5s_s,
sp_5th => sp_5th_s,
intr_en => intr_en_s,
sp_cf_en => sp_cf_en_s,
scanline => scanline_s,
vscanln_en => vscanln_en_s, -- Virtual scan line enable
blank => sl_blank_s,
-- VRAM Interface
vdin => cpu_dout_s, -- In to CPU from *out* of VRAM
vwe => cpu_we_s,
vaddr => cpu_addr_s,
vdout => cpu_din_s, -- Out from CPU goes *in* to VRAM
-- PRAM Interface
pwe => col_we_s,
paddr => col_addr_cpu_s,
pdout => col_din_s, -- Out from CPU goes *in* to PRAM
pdin => col_dout_s, -- in to the GPU
-- Outputs
intr_n => int_n_o,
gmode => gmode_s,
soft_blank => soft_blank_s,
size_bit => size_bit_s,
mag_bit => mag_bit_s,
pgba => pgba_s,
satba => satba_s,
spgba => spgba_s,
textfg => textfg_s,
textbg => textbg_s,
-- F18A specific
unlocked => unlocked_s,
row30 => row30_s,
tl1_off_o => tl1_off_s, -- '1' to disable tile layer 1
pos_attr_o => pos_attr_s, -- '1' to use position-based tile attributes
tpgsize_o => tpgsize_s, -- tile pattern table offset size
spgsize_o => spgsize_s, -- sprite pattern table offset size
tile_ecm => tile_ecm_s,
sprt_ecm => sprt_ecm_s,
tile_ps => tile_ps_s,
sprt_ps => sprt_ps_s,
sprt_yreal => sprt_yreal_s,
-- Sprite max
usr_sprite_max => sprite_max_r, -- Jumper setting, used at reset
sprite_max => sprite_max_s, -- Register setting overrides jumper
stop_sprt => stop_sprt_s, -- Stop Sprite to limit sprite processing
reportmax_o => reportmax_s, -- Report max sprite ('1') or 5th sprite ('0')
-- Scroll support
t1ntba => t1ntba_s, -- tile1 name table base address
t1ctba => t1ctba_s, -- tile1 color table base address
t1hsize => t1hsize_s, -- tile1 horz page size (1 page or 2 pages)
t1vsize => t1vsize_s, -- tile1 vert page size (1 page or 2 pages)
t1horz => t1horz_s, -- tile1 horz scroll
t1vert => t1vert_s, -- tile1 vert scroll
t2_en => t2_en_s, -- tile2 enable
t2_pri_en => t2_pri_en_s, -- tile2 priority enable (0 = TL2 always on top)
t2ntba => t2ntba_s, -- tile2 name table base address
t2ctba => t2ctba_s, -- tile2 color table base address
t2hsize => t2hsize_s, -- tile2 horz page size (1 page or 2 pages)
t2vsize => t2vsize_s, -- tile2 vert page size (1 page or 2 pages)
t2horz => t2horz_s, -- tile2 horz scroll
t2vert => t2vert_s, -- tile2 vert scroll
-- Bitmap layer
bmlba => bmlba_s,
bml_x => bml_x_s,
bml_y => bml_y_s,
bml_w => bml_w_s,
bml_h => bml_h_s,
bml_ps => bml_ps_s,
bml_en => bml_en_s,
bml_pri => bml_pri_s,
bml_trans => bml_trans_s,
bml_fat_o => bml_fat_s,
-- SPI Interface
spi_clk => spi_clk_o,
spi_cs => spi_cs_o,
spi_mosi => spi_mosi_o,
spi_miso => spi_miso_i
);
-- Video controller
inst_vga_cont : entity work.f18a_vga_cont_640_60
port map (
vga_clk => clk_25m0_i,
rst_n => reset_n_r,
hsync => hsync_s,
vsync => vsync_s,
raster_x => raster_x_s,
raster_y => raster_y_s,
y_tick => y_tick_s,
y_max => y_max_s,
blank => blank_s
);
-- Video counters
inst_counters : entity work.f18a_counters
port map (
clk => clk_100m0_i,
vga_clk => clk_25m0_i,
rst_n => reset_n_r,
raster_x => raster_x_s,
raster_y => raster_y_s,
y_tick => y_tick_s,
y_max => y_max_s,
sprt_yreal => sprt_yreal_s,
gmode => gmode_s,
row30 => row30_s,
blank_in => blank_s, -- VGA blank input
sl_blank => sl_blank_s, -- Scan line blank output
intr_en => intr_en_s,
sp_cf_en => sp_cf_en_s,
scanline => scanline_s,
-- Sprite and pixel counters
in_margin => in_margin_s,
y_margin_n => y_margin_n_s,
x_pixel_max => x_pixel_max_s,
x_pixel_pos => x_pixel_pos_s,
x_sprt_pos => x_sprt_pos_s,
y_next => y_next_s,
y_sprt_pos => y_sprt_pos_s,
prescan_start => prescan_start_s
);
-- Tile layer
inst_tiles : entity work.f18a_tiles
port map (
clk => clk_100m0_i,
rst_n => reset_n_r,
x_pixel_max => x_pixel_max_s,
x_pixel_pos => x_pixel_pos_s,
y_next_in => y_next_s,
prescan_start => prescan_start_s,
-- Table base addresses
pgba => pgba_s,
gmode => gmode_s,
row30 => row30_s,
textfg => textfg_s,
textbg => textbg_s,
-- F18A specific
unlocked => unlocked_s,
ecm => tile_ecm_s,
tl1_off_i => tl1_off_s, -- '1' to disable tile layer 1
pos_attr_i => pos_attr_s,
tpgsize_i => tpgsize_s, -- tile pattern table offset size
tile_ps => tile_ps_s,
-- Scroll support
t1ntba => t1ntba_s, -- tile1 name table base address
t1ctba => t1ctba_s, -- tile1 color table base address
t1hsize => t1hsize_s, -- tile1 horz page size (1 page or 2 pages)
t1vsize => t1vsize_s, -- tile1 vert page size (1 page or 2 pages)
t1horz => t1horz_s, -- tile1 horz scroll
t1vert => t1vert_s, -- tile1 vert scroll
t2_en => t2_en_s, -- tile2 enable
t2_pri_en => t2_pri_en_s, -- tile2 priority enable (0 = TL2 always on top)
t2ntba => t2ntba_s, -- tile2 name table base address
t2ctba => t2ctba_s, -- tile2 color table base address
t2hsize => t2hsize_s, -- tile2 horz page size (1 page or 2 pages)
t2vsize => t2vsize_s, -- tile2 vert page size (1 page or 2 pages)
t2horz => t2horz_s, -- tile2 horz scroll
t2vert => t2vert_s, -- tile2 vert scroll
-- Bitmap layer
bmlba => bmlba_s,
bml_x => bml_x_s,
bml_y => bml_y_s,
bml_w => bml_w_s,
bml_h => bml_h_s,
bml_ps => bml_ps_s,
bml_en => bml_en_s,
bml_pri => bml_pri_s,
bml_trans => bml_trans_s,
bml_fat_i => bml_fat_s,
-- VRAM Interface
tile_active => tile_active_s, -- 1 when tiles are active, otherwise 0
vdin => tile_dout_s, -- In to Tile from *out* of VRAM
vaddr => tile_addr_s,
-- Outputs
sprite_start => sprite_start_s,
tile_color => tile_color_s
);
-- Sprite layer
inst_sprites : entity work.f18a_sprites
port map (
clk => clk_100m0_i,
rst_n => reset_n_r,
x_sprt_pos => x_sprt_pos_s,
y_sprt_pos => y_sprt_pos_s,
y_next_in => y_next_s,
y_margin_n => y_margin_n_s,
prescan_start => prescan_start_s,
sprite_start => sprite_start_s,
sprite_max => sprite_max_s,
stop_sprt => stop_sprt_s,
-- Table base addresses
size_bit => size_bit_s,
mag_bit => mag_bit_s,
satba => satba_s,
spgba => spgba_s,
gmode => gmode_s,
-- F18A specific
unlocked => unlocked_s,
row30 => row30_s,
spgsize_i => spgsize_s, -- sprite pattern table offset size
sprt_ps => sprt_ps_s,
ecm => sprt_ecm_s,
-- VRAM Interface
vdin => tile_dout_s, -- In to Sprite from *out* of VRAM
vaddr => sprt_addr_s,
-- Outputs
sprt_color => sprt_color_s,
sprt_cf => sp_cf_s,
sprt_5s => sp_5s_s,
sprt_5th => sp_5th_s,
reportmax_i => reportmax_s
);
-- Color RAM and output pixel selection
inst_color : entity work.f18a_color
port map (
clk => clk_100m0_i,
vga_clk => clk_25m0_i,
we1 => col_we_s,
addr1 => col_addr_cpu_s,
din => col_din_s,
dout1 => col_dout_s, -- to the GPU! :-)
tile_color => tile_color_s,
sprt_color => sprt_color_s,
bg_color => bg_color_s,
show_bg => show_bg,
tile_r => tile_r_s,
tile_g => tile_g_s,
tile_b => tile_b_s
);
-- Version ROM and banner generation
inst_version : entity work.f18a_version
port map (
clk => clk_100m0_i,
rst_n_i => reset_n_r,
vga_clk => clk_25m0_i,
intr_en_i => intr_en_s,
raster_x => raster_x_s,
raster_y => raster_y_s,
blank_i => blank_s,
-- outputs
override_o => override_s,
red_o => override_r_s,
grn_o => override_g_s,
blu_o => override_b_s
);
-- Use TL1 as the background color palette selector.
bg_color_s <= (tile_ps_s(2 to 3) & textbg_s);
-- soft_blank_s == VR1 blank bit and '0' means blank to background color
show_bg <= in_margin_s or (not soft_blank_s);
-- Simulated scan lines every other VGA line when scanlines_i = '1'.
-- The odd scan lines have their color value reduced by 50%.
red_s <=
override_r_s when override_s = '1' else
"0" & tile_r_s(0 to 2) when ((scanlines_r = '1' or vscanln_en_s = '1') and raster_y_s(9) = '1') else
tile_r_s;
grn_s <=
override_g_s when override_s = '1' else
"0" & tile_g_s(0 to 2) when ((scanlines_r = '1' or vscanln_en_s = '1') and raster_y_s(9) = '1') else
tile_g_s;
blu_s <=
override_b_s when override_s = '1' else
"0" & tile_b_s(0 to 2) when ((scanlines_r = '1' or vscanln_en_s = '1') and raster_y_s(9) = '1') else
tile_b_s;
-- Register the VGA outputs.
process (clk_25m0_i) begin if rising_edge(clk_25m0_i) then
blank_r <= blank_s;
hsync_r <= hsync_s;
vsync_r <= vsync_s;
red_r <= red_s;
grn_r <= grn_s;
blu_r <= blu_s;
end if; end process;
blank_o <= blank_r;
hsync_o <= hsync_r;
vsync_o <= vsync_r;
red_o <= red_r;
grn_o <= grn_r;
blu_o <= blu_r;
end rtl;