Rev 543 | 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 |
334 | lvd | 2 | // |
3 | // renders fetched video data to the pixels |
||
4 | |||
668 | lvd | 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 | `include "../include/tune.v" |
||
25 | |||
334 | lvd | 26 | module video_render( |
27 | |||
28 | input wire clk, // 28 MHz clock |
||
29 | |||
30 | |||
31 | input wire [63:0] pic_bits, // video data from fetcher |
||
32 | |||
336 | lvd | 33 | input wire fetch_sync, // synchronizes pixel rendering - |
34 | // coincides with cbeg!!! |
||
35 | |||
36 | input wire cbeg, |
||
334 | lvd | 37 | input wire post_cbeg, // pixel strobed and |
336 | lvd | 38 | input wire pre_cend, |
334 | lvd | 39 | input wire cend, // general sync |
336 | lvd | 40 | |
334 | lvd | 41 | input wire int_start, // for flash gen |
325 | lvd | 42 | |
336 | lvd | 43 | input wire [ 2:0] typos, // Y pos in text symbols |
325 | lvd | 44 | |
334 | lvd | 45 | output wire [ 3:0] pixels, // output pixels |
46 | |||
668 | lvd | 47 | // ulaplus related |
48 | output wire [ 1:0] up_palsel, |
||
49 | output wire [ 2:0] up_paper, |
||
50 | output wire [ 2:0] up_ink, |
||
51 | output wire up_pixel, |
||
334 | lvd | 52 | |
336 | lvd | 53 | |
395 | lvd | 54 | input wire [10:0] fnt_a, |
55 | input wire [ 7:0] fnt_d, |
||
56 | input wire fnt_wr, |
||
57 | |||
58 | |||
59 | |||
60 | |||
334 | lvd | 61 | input wire mode_atm_n_pent, // decoded modes |
336 | lvd | 62 | |
334 | lvd | 63 | input wire mode_zx, // |
64 | input wire mode_p_16c, // |
||
65 | input wire mode_p_hmclr, // |
||
66 | // |
||
67 | input wire mode_a_hmclr, // |
||
68 | input wire mode_a_16c, // |
||
69 | input wire mode_a_text, // |
||
336 | lvd | 70 | |
543 | lvd | 71 | input wire mode_pixf_14, // |
72 | |||
73 | |||
74 | output wire [ 7:0] fontrom_readback |
||
334 | lvd | 75 | ); |
76 | |||
77 | |||
325 | lvd | 78 | reg [4:0] flash_ctr; |
79 | wire flash; |
||
336 | lvd | 80 | |
325 | lvd | 81 | initial |
82 | begin |
||
83 | flash_ctr = 0; |
||
84 | end |
||
336 | lvd | 85 | |
325 | lvd | 86 | always @(posedge clk) if( int_start ) |
87 | begin |
||
88 | flash_ctr <= flash_ctr + 1; |
||
89 | end |
||
90 | assign flash = flash_ctr[4]; |
||
91 | |||
92 | |||
93 | |||
334 | lvd | 94 | |
336 | lvd | 95 | |
334 | lvd | 96 | // fetched data divided in bytes |
97 | wire [7:0] bits [0:7]; |
||
98 | |||
99 | assign bits[0] = pic_bits[ 7:0 ]; |
||
100 | assign bits[1] = pic_bits[15:8 ]; |
||
101 | assign bits[2] = pic_bits[23:16]; |
||
102 | assign bits[3] = pic_bits[31:24]; |
||
103 | assign bits[4] = pic_bits[39:32]; |
||
104 | assign bits[5] = pic_bits[47:40]; |
||
105 | assign bits[6] = pic_bits[55:48]; |
||
106 | assign bits[7] = pic_bits[63:56]; |
||
107 | |||
108 | |||
109 | |||
336 | lvd | 110 | reg [1:0] gnum; // pixel group number |
111 | reg [2:0] pnum; // pixel number |
||
112 | wire [1:0] gadd; |
||
113 | wire [2:0] padd; |
||
114 | wire ginc; |
||
334 | lvd | 115 | |
336 | lvd | 116 | wire modes_16c; |
334 | lvd | 117 | |
339 | lvd | 118 | wire modes_zxattr; |
338 | lvd | 119 | |
339 | lvd | 120 | |
334 | lvd | 121 | wire ena_pix; |
339 | lvd | 122 | assign ena_pix = cend | (mode_pixf_14 & post_cbeg); |
334 | lvd | 123 | |
336 | lvd | 124 | |
125 | assign modes_16c = mode_p_16c | mode_a_16c; |
||
126 | |||
339 | lvd | 127 | assign modes_zxattr = mode_zx | mode_p_hmclr; |
128 | |||
336 | lvd | 129 | assign {ginc, padd} = {1'b0, pnum} + {2'b00, modes_16c, ~modes_16c}; |
130 | |||
334 | lvd | 131 | always @(posedge clk) if( ena_pix ) |
336 | lvd | 132 | if( fetch_sync ) |
133 | pnum <= 3'b000; |
||
134 | else |
||
135 | pnum <= padd; |
||
334 | lvd | 136 | |
137 | |||
339 | lvd | 138 | assign gadd = gnum + ( {modes_zxattr,~modes_zxattr} & {2{ginc}} ); |
336 | lvd | 139 | |
140 | always @(posedge clk) if( ena_pix ) |
||
141 | if( fetch_sync ) |
||
142 | gnum <= 2'b00; |
||
143 | else |
||
144 | gnum <= gadd; |
||
145 | |||
146 | |||
147 | |||
148 | |||
149 | wire [15:0] pgroup; // pixel group |
||
395 | lvd | 150 | wire [7:0] pixbyte, symbyte, attrbyte; |
336 | lvd | 151 | wire [7:0] pix16_2 [0:1]; |
152 | wire [3:0] pix16 [0:3]; |
||
153 | |||
154 | wire pixbit; // pixel bit, for attr modes |
||
155 | wire [3:0] pix0, pix1; // colors for bit=0 and bit=1, for attr modes |
||
156 | |||
337 | lvd | 157 | wire [3:0] apix, c16pix; |
158 | |||
159 | |||
336 | lvd | 160 | assign pgroup = { bits[ {gnum[0], 1'b0, gnum[1]} ] , |
161 | bits[ {gnum[0], 1'b1, gnum[1]} ] }; |
||
162 | |||
163 | assign pixbyte = pgroup[15:8]; |
||
164 | assign attrbyte = pgroup[ 7:0]; |
||
165 | |||
166 | |||
167 | assign pix16_2[0] = pgroup[ 7:0]; |
||
168 | assign pix16_2[1] = pgroup[15:8]; |
||
169 | |||
170 | assign pix16[0] = { pix16_2[0][6], pix16_2[0][2:0] }; |
||
171 | assign pix16[1] = { pix16_2[0][7], pix16_2[0][5:3] }; |
||
172 | assign pix16[2] = { pix16_2[1][6], pix16_2[1][2:0] }; |
||
173 | assign pix16[3] = { pix16_2[1][7], pix16_2[1][5:3] }; |
||
174 | |||
175 | |||
338 | lvd | 176 | assign pixbit = mode_a_text ? symbyte[~pnum] : pixbyte[~pnum]; |
336 | lvd | 177 | |
339 | lvd | 178 | assign pix0 = { (modes_zxattr ? attrbyte[6] : attrbyte[7]), attrbyte[5:3] }; // paper |
337 | lvd | 179 | assign pix1 = { attrbyte[6], attrbyte[2:0] }; // ink |
336 | lvd | 180 | |
181 | |||
339 | lvd | 182 | assign apix = ( pixbit^(modes_zxattr & flash & attrbyte[7]) ) ? pix1 : pix0; |
338 | lvd | 183 | |
337 | lvd | 184 | assign c16pix = pix16[ pnum[2:1] ]; |
336 | lvd | 185 | |
186 | |||
187 | |||
337 | lvd | 188 | assign pixels = modes_16c ? c16pix : apix; |
189 | |||
190 | |||
395 | lvd | 191 | |
668 | lvd | 192 | // ulaplus signals |
193 | assign up_pixel = pixbit; |
||
194 | // |
||
195 | assign up_palsel = attrbyte[7:6]; |
||
196 | // |
||
197 | assign up_paper = attrbyte[5:3]; |
||
198 | assign up_ink = attrbyte[2:0]; |
||
395 | lvd | 199 | |
668 | lvd | 200 | |
201 | |||
202 | |||
395 | lvd | 203 | wire rom_ena; |
350 | lvd | 204 | assign rom_ena = ena_pix & ginc; |
349 | lvd | 205 | |
395 | lvd | 206 | video_fontrom video_fontrom( |
336 | lvd | 207 | |
395 | lvd | 208 | .clock (clk ), |
396 | lvd | 209 | /*.enable(1'b1),*/ |
395 | lvd | 210 | |
211 | .data (fnt_d ), |
||
212 | .wraddress(fnt_a ), |
||
213 | .wren (fnt_wr), |
||
214 | |||
215 | .rdaddress( {pixbyte, typos} ), |
||
216 | .rden ( rom_ena ), |
||
217 | .q ( symbyte ) |
||
218 | ); |
||
219 | |||
220 | |||
543 | lvd | 221 | assign fontrom_readback = symbyte; |
222 | |||
223 | |||
334 | lvd | 224 | endmodule |
225 |