OpenCores
URL https://opencores.org/ocsvn/vga_lcd/vga_lcd/trunk

Subversion Repositories vga_lcd

[/] [vga_lcd/] [trunk/] [rtl/] [verilog/] [vga_wb_master.v] - Blame information for rev 33

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 23 rherveille
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3 30 rherveille
////  WISHBONE rev.B2 compliant enhanced VGA/LCD Core            ////
4 23 rherveille
////  Wishbone master interface                                  ////
5
////                                                             ////
6
////  Author: Richard Herveille                                  ////
7
////          richard@asics.ws                                   ////
8
////          www.asics.ws                                       ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/projects/vga_lcd ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14 30 rherveille
//// Copyright (C) 2001, 2002 Richard Herveille                  ////
15
////                          richard@asics.ws                   ////
16 23 rherveille
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
//  CVS Log
39 17 rherveille
//
40 33 rherveille
//  $Id: vga_wb_master.v,v 1.8 2002-03-04 11:01:59 rherveille Exp $
41 17 rherveille
//
42 33 rherveille
//  $Date: 2002-03-04 11:01:59 $
43
//  $Revision: 1.8 $
44 23 rherveille
//  $Author: rherveille $
45
//  $Locker:  $
46
//  $State: Exp $
47
//
48
// Change History:
49
//               $Log: not supported by cvs2svn $
50 33 rherveille
//               Revision 1.7  2002/02/16 10:40:00  rherveille
51
//               Some minor bug-fixes.
52
//               Changed vga_ssel into vga_curproc (cursor processor).
53
//
54 31 rherveille
//               Revision 1.6  2002/02/07 05:42:10  rherveille
55
//               Fixed some bugs discovered by modified testbench
56
//               Removed / Changed some strange logic constructions
57
//               Started work on hardware cursor support (not finished yet)
58
//               Changed top-level name to vga_enh_top.v
59
//
60 17 rherveille
 
61
`include "timescale.v"
62 30 rherveille
`include "vga_defines.v"
63 17 rherveille
 
64 19 rherveille
module vga_wb_master (clk_i, rst_i, nrst_i, cyc_o, stb_o, cab_o, we_o, adr_o, sel_o, ack_i, err_i, dat_i, sint,
65 30 rherveille
        ctrl_ven, ctrl_cd, ctrl_pc, ctrl_vbl, ctrl_vbsw, ctrl_cbsw,
66 33 rherveille
        cursor0_en, cursor0_res, cursor0_xy, cursor0_ba, cursor0_ld, cc0_adr_o, cc0_dat_i,
67
        cursor1_en, cursor1_res, cursor1_xy, cursor1_ba, cursor1_ld, cc1_adr_o, cc1_dat_i,
68 30 rherveille
        VBAa, VBAb, Thgate, Tvgate,
69 19 rherveille
        stat_avmp, stat_acmp, vmem_switch, clut_switch, line_fifo_wreq, line_fifo_d, line_fifo_full,
70
        clut_req, clut_ack, clut_adr, clut_q);
71 17 rherveille
 
72
        // inputs & outputs
73
 
74
        // wishbone signals
75 19 rherveille
        input         clk_i;    // master clock input
76
        input         rst_i;    // synchronous active high reset
77
        input         nrst_i;   // asynchronous low reset
78
        output        cyc_o;    // cycle output
79
        reg cyc_o;
80
        output        stb_o;    // strobe ouput
81
        reg stb_o;
82
        output        cab_o;    // consecutive address burst output
83
        reg cab_o;
84
        output        we_o;     // write enable output
85
        reg we_o;
86
        output [31:0] adr_o;    // address output
87
        output [ 3:0] sel_o;    // byte select outputs (only 32bits accesses are supported)
88
        reg [3:0] sel_o;
89
        input         ack_i;    // wishbone cycle acknowledge 
90
        input         err_i;    // wishbone cycle error
91
        input [31:0]  dat_i;    // wishbone data in
92 17 rherveille
 
93 19 rherveille
        output        sint;     // non recoverable error, interrupt host
94 17 rherveille
 
95
        // control register settings
96
        input       ctrl_ven;   // video enable bit
97
        input [1:0] ctrl_cd;    // color depth
98
        input       ctrl_pc;    // 8bpp pseudo color/bw
99
        input [1:0] ctrl_vbl;   // burst length
100
        input       ctrl_vbsw;  // enable video bank switching
101
        input       ctrl_cbsw;  // enable clut bank switching
102
 
103 33 rherveille
        input          cursor0_en;  // enable hardware cursor0
104
        input          cursor0_res; // cursor0 resolution
105
        input  [31: 0] cursor0_xy;  // (x,y) address hardware cursor0
106
        input  [31:11] cursor0_ba;  // cursor0 video memory base address
107
        input          cursor0_ld;  // reload cursor0 from video memory
108
        output [ 3: 0] cc0_adr_o;   // cursor0 color registers address output
109
        input  [15: 0] cc0_dat_i;   // cursor0 color registers data input
110
        input          cursor1_en;  // enable hardware cursor1
111
        input          cursor1_res; // cursor1 resolution
112
        input  [31: 0] cursor1_xy;  // (x,y) address hardware cursor1
113
        input  [31:11] cursor1_ba;  // cursor1 video memory base address
114
        input          cursor1_ld;  // reload cursor1 from video memory
115
        output [ 3: 0] cc1_adr_o;   // cursor1 color registers address output
116
        input  [15: 0] cc1_dat_i;   // cursor1 color registers data input
117 30 rherveille
 
118 17 rherveille
        // video memory addresses
119
        input [31: 2] VBAa;     // video memory base address A
120
        input [31: 2] VBAb;     // video memory base address B
121
 
122
        input [15:0] Thgate;    // horizontal visible area (in pixels)
123
        input [15:0] Tvgate;    // vertical visible area (in horizontal lines)
124
 
125
        output stat_avmp;       // active video memory page
126
        output stat_acmp;       // active CLUT memory page
127 19 rherveille
        reg stat_acmp;
128
        output vmem_switch;     // video memory bank-switch request: memory page switched (when enabled)
129
        output clut_switch;     // clut memory bank-switch request: clut page switched (when enabled)
130 17 rherveille
 
131
        // to/from line-fifo
132
        output        line_fifo_wreq;
133
        output [23:0] line_fifo_d;
134
        input         line_fifo_full;
135
 
136 19 rherveille
        // to/from color lookup-table
137
        output        clut_req;  // clut access request
138
        input         clut_ack;  // clut access acknowledge
139
        output [ 8:0] clut_adr;  // clut access address
140
        input  [23:0] clut_q;    // clut access data in
141
 
142 17 rherveille
        //
143
        // variable declarations
144
        //
145 19 rherveille
 
146
        reg vmem_acc;                 // video memory access
147 17 rherveille
        wire nvmem_req, vmem_ack;     // NOT video memory access request // video memory access acknowledge
148
 
149 30 rherveille
        wire ImDone;                  // Done reading image from video mem 
150 19 rherveille
        reg  dImDone;                 // delayed ImDone
151
        wire  ImDoneStrb;             // image done (strobe signal)
152
        reg  dImDoneStrb;             // delayed ImDoneStrb
153
 
154
        wire data_fifo_rreq, data_fifo_empty, data_fifo_hfull;
155
        wire [31:0] data_fifo_q;
156 30 rherveille
        wire [23:0] color_proc_q, ssel1_q, rgb_fifo_d;
157
        wire        color_proc_wreq, ssel1_wreq, rgb_fifo_wreq;
158
        wire rgb_fifo_empty, rgb_fifo_full, rgb_fifo_rreq;
159 19 rherveille
        wire ImDoneFifoQ;
160 30 rherveille
        reg  dImDoneFifoQ, ddImDoneFifoQ;
161 19 rherveille
 
162
        reg sclr; // synchronous clear
163
 
164
        wire [7:0] clut_offs; // color lookup table offset
165
 
166 30 rherveille
        reg [8:0] cursor_adr;
167
        reg       cursor0_we, cursor1_we;
168
 
169 17 rherveille
        //
170
        // module body
171
        //
172
 
173 19 rherveille
        // generate synchronous clear
174
        always@(posedge clk_i)
175
                sclr <= #1 ~ctrl_ven;
176 17 rherveille
 
177
        //
178
        // WISHBONE block
179
        //
180
        reg  [ 2:0] burst_cnt;                       // video memory burst access counter
181
        wire        burst_done;                      // completed burst access to video mem
182 19 rherveille
        reg         sel_VBA;                         // select video memory base address
183 17 rherveille
        reg  [31:2] vmemA;                           // video memory address 
184
 
185
        // wishbone access controller, video memory access request has highest priority (try to keep fifo full)
186 19 rherveille
        always@(posedge clk_i)
187
                if (sclr)
188
                        vmem_acc <= #1 1'b0;
189 17 rherveille
                else
190 19 rherveille
                        vmem_acc <= #1 (!nvmem_req | (vmem_acc & !(burst_done & vmem_ack) ) ) & !ImDone;
191 17 rherveille
 
192 19 rherveille
        assign vmem_ack = ack_i;
193
        assign sint = err_i; // Non recoverable error, interrupt host system
194 17 rherveille
 
195 19 rherveille
        // select active memory page
196
        assign vmem_switch = ImDoneStrb;
197 17 rherveille
 
198 19 rherveille
        always@(posedge clk_i)
199
                if (sclr)
200 17 rherveille
                        sel_VBA <= #1 1'b0;
201
                else if (ctrl_vbsw)
202 19 rherveille
                        sel_VBA <= #1 sel_VBA ^ vmem_switch;  // select next video memory bank when finished reading current bank (and bank switch enabled)
203 17 rherveille
 
204
        assign stat_avmp = sel_VBA; // assign output
205
 
206 30 rherveille
        // selecting active clut page / cursor data
207
        // delay image done same amount as video-memory data
208 19 rherveille
        vga_fifo #(4, 1) clut_sw_fifo (
209
                .clk(clk_i),
210
                .aclr(1'b1),
211
                .sclr(sclr),
212
                .d(ImDone),
213 30 rherveille
                .wreq(vmem_ack),
214 19 rherveille
                .q(ImDoneFifoQ),
215
                .rreq(data_fifo_rreq),
216
                .empty(),
217
                .hfull(),
218
                .full()
219
        );
220
 
221 30 rherveille
        // clut bank switch / cursor data delay2: Account for ColorProcessor DataBuffer delay
222 19 rherveille
        always@(posedge clk_i)
223 30 rherveille
                if (sclr)
224
                        dImDoneFifoQ <= #1 1'b0;
225
                else    if (data_fifo_rreq)
226 19 rherveille
                        dImDoneFifoQ <= #1 ImDoneFifoQ;
227
 
228
        always@(posedge clk_i)
229
                if (sclr)
230 30 rherveille
                        ddImDoneFifoQ <= #1 1'b0;
231
                else
232
                        ddImDoneFifoQ <= #1 dImDoneFifoQ;
233 19 rherveille
 
234 30 rherveille
        assign clut_switch = ddImDoneFifoQ & !dImDoneFifoQ;
235 19 rherveille
 
236
        always@(posedge clk_i)
237
                if (sclr)
238
                        stat_acmp <= #1 1'b0;
239 17 rherveille
                else if (ctrl_cbsw)
240 19 rherveille
                        stat_acmp <= #1 stat_acmp ^ clut_switch;  // select next clut when finished reading clut for current video bank (and bank switch enabled)
241 17 rherveille
 
242 19 rherveille
        // generate clut-address
243
        assign clut_adr = {stat_acmp, clut_offs};
244 17 rherveille
 
245
        // generate burst counter
246
        wire [3:0] burst_cnt_val;
247
        assign burst_cnt_val = {1'b0, burst_cnt} -4'h1;
248
        assign burst_done = burst_cnt_val[3];
249
 
250 19 rherveille
        always@(posedge clk_i)
251 17 rherveille
                if ( (burst_done & vmem_ack) | !vmem_acc)
252
                        case (ctrl_vbl) // synopsis full_case parallel_case
253
                                2'b00: burst_cnt <= #1 3'b000; // burst length 1
254
                                2'b01: burst_cnt <= #1 3'b001; // burst length 2
255
                                2'b10: burst_cnt <= #1 3'b011; // burst length 4
256
                                2'b11: burst_cnt <= #1 3'b111; // burst length 8
257
                        endcase
258
                else if(vmem_ack)
259
                        burst_cnt <= #1 burst_cnt_val[2:0];
260
 
261
        //
262
        // generate image counters
263
        //
264
 
265
        // hgate counter
266 19 rherveille
        reg  [15:0] hgate_cnt;
267
        reg  [16:0] hgate_cnt_val;
268
        reg  [1:0]  hgate_div_cnt;
269
        reg  [2:0]  hgate_div_val;
270 17 rherveille
 
271 19 rherveille
        wire hdone = hgate_cnt_val[16] & vmem_ack; // ????
272
 
273
        always@(hgate_cnt or hgate_div_cnt or ctrl_cd)
274
                begin
275
                        hgate_div_val = {1'b0, hgate_div_cnt} - 3'h1;
276
 
277
                        if (ctrl_cd != 2'b10)
278
                                hgate_cnt_val = {1'b0, hgate_cnt} - 17'h1;
279
                        else if ( hgate_div_val[2] )
280
                                hgate_cnt_val = {1'b0, hgate_cnt} - 17'h1;
281 17 rherveille
                        else
282 19 rherveille
                                hgate_cnt_val = {1'b0, hgate_cnt};
283
                end
284 17 rherveille
 
285 19 rherveille
        always@(posedge clk_i)
286
                if (sclr)
287
                                begin
288
                                        case(ctrl_cd) // synopsys full_case parallel_case
289
                                                2'b00: // 8bpp
290
                                                        hgate_cnt <= #1 Thgate >> 2; // 4 pixels per cycle
291
                                                2'b01: //16bpp
292
                                                        hgate_cnt <= #1 Thgate >> 1; // 2 pixels per cycle
293
                                                2'b10: //24bpp
294
                                                        hgate_cnt <= #1 Thgate >> 2; // 4/3 pixels per cycle
295 28 rherveille
                                                2'b11: //32bpp
296
                                                        hgate_cnt <= #1 Thgate;      // 1 pixel per cycle
297 19 rherveille
                                        endcase
298
 
299
                                        hgate_div_cnt <= 2'b10;
300
                                end
301
                else if (vmem_ack)
302
                        if (hdone)
303
                                begin
304
                                        case(ctrl_cd) // synopsys full_case parallel_case
305
                                                2'b00: // 8bpp
306
                                                        hgate_cnt <= #1 Thgate >> 2; // 4 pixels per cycle
307
                                                2'b01: //16bpp
308
                                                        hgate_cnt <= #1 Thgate >> 1; // 2 pixels per cycle
309
                                                2'b10: //24bpp
310
                                                        hgate_cnt <= #1 Thgate >> 2; // 4/3 pixels per cycle
311 28 rherveille
                                                2'b11: //32bpp
312
                                                        hgate_cnt <= #1 Thgate;      // 1 pixel per cycle
313 19 rherveille
                                        endcase
314
                                        hgate_div_cnt <= #1 2'b10;
315
                                end
316
                        else //if (vmem_ack)
317
                                begin
318
                                        hgate_cnt <= #1 hgate_cnt_val[15:0];
319
 
320
                                        if ( hgate_div_val[2] )
321
                                                hgate_div_cnt <= #1 2'b10;
322
                                        else
323
                                                hgate_div_cnt <= #1 hgate_div_val[1:0];
324
                                end
325
 
326 17 rherveille
        // vgate counter
327 19 rherveille
        reg  [15:0] vgate_cnt;
328
        wire [16:0] vgate_cnt_val = {1'b0, vgate_cnt} -17'h1;
329
        wire vdone = vgate_cnt_val[16];
330 17 rherveille
 
331 19 rherveille
        always@(posedge clk_i)
332
                if (sclr)
333 17 rherveille
                        vgate_cnt <= #1 Tvgate;
334 19 rherveille
                else if (ImDoneStrb)
335
                        vgate_cnt <= #1 Tvgate;
336
                else if (hdone)
337
                        vgate_cnt <= #1 vgate_cnt_val[15:0];
338 17 rherveille
 
339 30 rherveille
        assign ImDone = hdone & vdone;
340 19 rherveille
 
341 17 rherveille
        assign ImDoneStrb = ImDone & !dImDone;
342
 
343 19 rherveille
        always@(posedge clk_i)
344
                begin
345 17 rherveille
                        dImDone <= #1 ImDone;
346 19 rherveille
                        dImDoneStrb <= #1 ImDoneStrb;
347
                end
348 17 rherveille
 
349
        //
350
        // generate addresses
351
        //
352
 
353
        // select video memory base address
354 19 rherveille
        always@(posedge clk_i)
355
                if (dImDoneStrb | sclr)
356 17 rherveille
                        if (!sel_VBA)
357
                                vmemA <= #1 VBAa;
358
                        else
359
                                vmemA <= #1 VBAb;
360
                else if (vmem_ack)
361
                        vmemA <= #1 vmemA +30'h1;
362
 
363
        // generate wishbone signals
364 19 rherveille
        assign adr_o = {vmemA, 2'b00};
365
        wire wb_cycle = vmem_acc & !(burst_done & vmem_ack & nvmem_req) & !ImDone;
366 17 rherveille
 
367 19 rherveille
        always@(posedge clk_i or negedge nrst_i)
368
                if (!nrst_i)
369 17 rherveille
                        begin
370 19 rherveille
                                cyc_o <= #1 1'b0;
371
                                stb_o <= #1 1'b0;
372
                                sel_o <= #1 4'b1111;
373
                                cab_o <= #1 1'b0;
374
                                we_o  <= #1 1'b0;
375 17 rherveille
                        end
376
                else
377 19 rherveille
                        if (rst_i)
378 17 rherveille
                                begin
379 19 rherveille
                                        cyc_o <= #1 1'b0;
380
                                        stb_o <= #1 1'b0;
381
                                        sel_o <= #1 4'b1111;
382
                                        cab_o <= #1 1'b0;
383
                                        we_o  <= #1 1'b0;
384 17 rherveille
                                end
385
                        else
386
                                begin
387 19 rherveille
                                        cyc_o <= #1 wb_cycle;
388
                                        stb_o <= #1 wb_cycle;
389
                                        sel_o <= #1 4'b1111;   // only 32bit accesses are supported
390
                                        cab_o <= #1 wb_cycle;
391
                                        we_o  <= #1 1'b0;      // read only
392 17 rherveille
                                end
393
 
394 30 rherveille
        // video-data buffer (temporary store data read from video memory)
395 19 rherveille
        vga_fifo #(4, 32) data_fifo (
396
                .clk(clk_i),
397 17 rherveille
                .aclr(1'b1),
398 19 rherveille
                .sclr(sclr),
399
                .d(dat_i),
400 17 rherveille
                .wreq(vmem_ack),
401 19 rherveille
                .q(data_fifo_q),
402
                .rreq(data_fifo_rreq),
403
                .empty(data_fifo_empty),
404
                .hfull(data_fifo_hfull),
405 17 rherveille
                .full()
406
        );
407
 
408 19 rherveille
        assign nvmem_req = data_fifo_hfull;
409 17 rherveille
 
410
 
411
        // hookup color processor
412
        vga_colproc color_proc (
413 19 rherveille
                .clk(clk_i),
414
                .srst(sclr),
415 30 rherveille
                .vdat_buffer_di(data_fifo_q),
416 17 rherveille
                .ColorDepth(ctrl_cd),
417
                .PseudoColor(ctrl_pc),
418 30 rherveille
                .vdat_buffer_empty(data_fifo_empty),
419
                .vdat_buffer_rreq(data_fifo_rreq),
420
                .rgb_fifo_full(rgb_fifo_full),
421
                .rgb_fifo_wreq(color_proc_wreq),
422
                .r(color_proc_q[23:16]),
423
                .g(color_proc_q[15:8]),
424
                .b(color_proc_q[7:0]),
425 17 rherveille
                .clut_req(clut_req),
426 19 rherveille
                .clut_ack(clut_ack),
427 17 rherveille
                .clut_offs(clut_offs),
428 19 rherveille
                .clut_q(clut_q)
429 17 rherveille
        );
430
 
431 30 rherveille
        // hookup data-source-selector && hardware cursor module
432 31 rherveille
`ifdef VGA_HWC1 // generate Hardware Cursor1 (if enabled)
433 30 rherveille
        reg scursor1_ld;
434
        reg scursor1_en;
435 33 rherveille
        reg scursor1_res;
436 30 rherveille
        reg [31:0] scursor1_xy;
437
 
438
        always@(posedge clk_i)
439
                if (sclr)
440
                        scursor1_ld <= #1 1'b0;
441
                else
442
                        scursor1_ld <= #1 cursor1_ld | (scursor1_ld & !(ddImDoneFifoQ & !dImDoneFifoQ));
443
 
444
        always@(posedge clk_i)
445
                if (sclr)
446
                        scursor1_en <= #1 1'b0;
447
                else if (scursor1_ld)
448
                        scursor1_en <= #1 cursor1_en;
449
 
450
        always@(posedge clk_i)
451
                if (scursor1_ld)
452
                        scursor1_xy <= #1 cursor1_xy;
453
 
454 33 rherveille
        always@(posedge clk_i)
455
                if (scursor1_ld)
456
                        scursor1_res <= #1 cursor1_res;
457
 
458 31 rherveille
        vga_curproc hw_cursor1 (
459 30 rherveille
                .clk(clk_i),
460
                .rst_i(sclr),
461
                .Thgate(Thgate),
462
                .Tvgate(Tvgate),
463
                .idat(color_proc_q),
464
                .idat_wreq(color_proc_wreq),
465
                .cursor_xy(scursor1_xy),
466 33 rherveille
                .cursor_res(scursor1_res),
467 30 rherveille
                .cursor_en(scursor1_en),
468 33 rherveille
                .cursor_wadr(cursor_adr),
469 30 rherveille
                .cursor_we(cursor1_we),
470 33 rherveille
                .cursor_wdat(dat_i),
471
                .cc_adr_o(cc1_adr_o),
472
                .cc_dat_i(cc1_dat_i),
473 30 rherveille
                .rgb_fifo_wreq(ssel1_wreq),
474
                .rgb(ssel1_q)
475
        );
476
 
477 31 rherveille
`ifdef VGA_HWC0 // generate additional signals for Hardware Cursor0 (if enabled)
478
        reg sddImDoneFifoQ, sdImDoneFifoQ;
479
 
480
        always@(posedge clk_i)
481
                if (ssel1_wreq)
482
                        begin
483
                                sdImDoneFifoQ  <= #1 dImDoneFifoQ;
484
                                sddImDoneFifoQ <= #1 sdImDoneFifoQ;
485
                        end
486
`endif
487
 
488
`else                   // Hardware Cursor1 disabled, generate pass-through signals
489
 
490 30 rherveille
        assign ssel1_wreq = color_proc_wreq;
491
        assign ssel1_q    = color_proc_q;
492
 
493 33 rherveille
        assign cc1_adr_0  = 4'h0;
494
 
495 31 rherveille
`ifdef VGA_HWC0 // generate additional signals for Hardware Cursor0 (if enabled)
496
        wire sddImDoneFifoQ, sdImDoneFifoQ;
497
 
498 30 rherveille
        assign sdImDoneFifoQ  = dImDoneFifoQ;
499
        assign sddImDoneFifoQ = ddImDoneFifoQ;
500
`endif
501
 
502 31 rherveille
`endif
503
 
504
 
505
`ifdef VGA_HWC0 // generate Hardware Cursor0 (if enabled)
506 30 rherveille
        reg scursor0_ld;
507
        reg scursor0_en;
508 33 rherveille
        reg scursor0_res;
509 30 rherveille
        reg [31:0] scursor0_xy;
510
 
511
        always@(posedge clk_i)
512
                if (sclr)
513
                        scursor0_ld <= #1 1'b0;
514
                else
515
                        scursor0_ld <= #1 cursor0_ld | (scursor0_ld & !(sddImDoneFifoQ & !sdImDoneFifoQ));
516
 
517
        always@(posedge clk_i)
518
                if (sclr)
519
                        scursor0_en <= #1 1'b0;
520
                else if (scursor0_ld)
521
                        scursor0_en <= #1 cursor0_en;
522
 
523
        always@(posedge clk_i)
524
                if (scursor0_ld)
525
                        scursor0_xy <= #1 cursor0_xy;
526
 
527 33 rherveille
        always@(posedge clk_i)
528
                if (scursor0_ld)
529
                        scursor0_res <= #1 cursor0_res;
530
 
531 31 rherveille
        vga_curproc hw_cursor0 (
532 30 rherveille
                .clk(clk_i),
533
                .rst_i(sclr),
534
                .Thgate(Thgate),
535
                .Tvgate(Tvgate),
536
                .idat(ssel1_q),
537
                .idat_wreq(ssel1_wreq),
538
                .cursor_xy(scursor0_xy),
539
                .cursor_en(scursor0_en),
540 33 rherveille
                .cursor_res(scursor0_res),
541
                .cursor_wadr(cursor_adr),
542 30 rherveille
                .cursor_we(cursor0_we),
543 33 rherveille
                .cursor_wdat(dat_i),
544
                .cc_adr_o(cc0_adr_o),
545
                .cc_dat_i(cc0_dat_i),
546 30 rherveille
                .rgb_fifo_wreq(rgb_fifo_wreq),
547
                .rgb(rgb_fifo_d)
548
        );
549 31 rherveille
`else   // Hardware Cursor0 disabled, generate pass-through signals
550 30 rherveille
        assign rgb_fifo_wreq = ssel1_wreq;
551
        assign rgb_fifo_d = ssel1_q;
552 33 rherveille
 
553
        assign cc0_adr_o  = 4'h0;
554 30 rherveille
`endif
555
 
556 33 rherveille
        // hookup RGB buffer (temporary station between WISHBONE-clock-domain 
557
        // and pixel-clock-domain)
558
        // The cursor_processor pipelines introduce a delay between the color
559
        // processor's rgb_fifo_wreq and the rgb_fifo_full signals. To compensate
560
        // for this we double the rgb_fifo.
561
        vga_fifo #(4, 24) rgb_fifo (
562 19 rherveille
                .clk(clk_i),
563 17 rherveille
                .aclr(1'b1),
564 19 rherveille
                .sclr(sclr),
565
                .d(rgb_fifo_d),
566
                .wreq(rgb_fifo_wreq),
567 17 rherveille
                .q(line_fifo_d),
568 19 rherveille
                .rreq(rgb_fifo_rreq),
569
                .empty(rgb_fifo_empty),
570
                .hfull(rgb_fifo_full),
571 17 rherveille
                .full()
572
        );
573
 
574 19 rherveille
        assign rgb_fifo_rreq = !line_fifo_full && !rgb_fifo_empty;
575
        assign line_fifo_wreq = rgb_fifo_rreq;
576 17 rherveille
 
577
endmodule
578
 
579
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.