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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64/] [rtl/] [bench/] [soc/] [video/] [FT64_TextController.v] - Blame information for rev 46

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2006-2018  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
//      FT64_TextController.v
9
//              text controller
10
//
11
// This source file is free software: you can redistribute it and/or modify 
12
// it under the terms of the GNU Lesser General Public License as published 
13
// by the Free Software Foundation, either version 3 of the License, or     
14
// (at your option) any later version.                                      
15
//                                                                          
16
// This source file is distributed in the hope that it will be useful,      
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
19
// GNU General Public License for more details.                             
20
//                                                                          
21
// You should have received a copy of the GNU General Public License        
22
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
23
//                                                                          
24
//
25
//      Text Controller
26
//
27
//      FEATURES
28
//
29
//      This core requires an external timing generator to provide horizontal
30
//      and vertical sync signals, but otherwise can be used as a display
31
//  controller on it's own. However, this core may also be embedded within
32
//  another core such as a VGA controller.
33
//
34
//      Window positions are referenced to the rising edge of the vertical and
35
//      horizontal sync pulses.
36
//
37
//      The core includes an embedded dual port RAM to hold the screen
38
//      characters.
39
//
40
//
41
//--------------------------------------------------------------------
42
// Registers
43
//
44
//      00h -         nnnnnnnn  number of columns (horizontal displayed number of characters)
45
//      04h -         nnnnnnnn  number of rows    (vertical displayed number of characters)
46
//      08h -       n nnnnnnnn  window left       (horizontal sync position - reference for left edge of displayed)
47
//      0Ch -       n nnnnnnnn  window top        (vertical sync position - reference for the top edge of displayed)
48
//      10h -         ---nnnnn  maximum scan line (char ROM max value is 7)
49
//              14h -         hhhhwwww  pixel size, hhhh=height,wwww=width
50
//      18h -       - -------r  reset state bit
51
//      1Ch -       n nnnnnnnn  color code for transparent background
52
//      20h -         -BPnnnnn  cursor start / blink control
53
//                             BP: 00=no blink
54
//                             BP: 01=no display
55
//                             BP: 10=1/16 field rate blink
56
//                             BP: 11=1/32 field rate blink
57
//      24h -        ----nnnnn  cursor end
58
//      28h - aaaaaaaa aaaaaaaaa  start address (index into display memory)
59
//      2Ch - aaaaaaaa aaaaaaaaa  cursor position
60
//      30h - aaaaaaaa aaaaaaaaa  light pen position
61
//--------------------------------------------------------------------
62
//
63
// ============================================================================
64
 
65
module FT64_TextController(
66
        rst_i, clk_i, cs_i,
67
        cyc_i, stb_i, ack_o, wr_i, adr_i, dat_i, dat_o,
68
        lp, curpos,
69
        vclk, hsync, vsync, blank, border, rgbIn, rgbOut
70
);
71
parameter num = 4'd1;
72
parameter COLS = 12'd80;
73
parameter ROWS = 12'd31;
74
 
75
// Syscon
76
input  rst_i;                   // reset
77
input  clk_i;                   // clock
78
 
79
// Slave signals
80
input  cs_i;            // circuit select
81
input  cyc_i;                   // valid bus cycle
82
input  stb_i;           // data strobe
83
output ack_o;                   // data acknowledge
84
input  wr_i;                    // write
85
input  [15:0] adr_i;     // address
86
input  [31:0] dat_i;     // data input
87
output [31:0] dat_o;     // data output
88
reg    [31:0] dat_o;
89
 
90
//
91
input lp;                               // light pen
92
input [15:0] curpos;     // cursor position
93
 
94
// Video signals
95
input vclk;                             // video dot clock
96
input hsync;                    // end of scan line
97
input vsync;                    // end of frame
98
input blank;                    // blanking signal
99
input border;                   // border area
100
input [24:0] rgbIn;              // input pixel stream
101
output reg [24:0] rgbOut;        // output pixel stream
102
 
103
 
104
reg [23:0] bkColor24;    // background color
105
reg [23:0] fgColor24;    // foreground color
106
wire [23:0] tcColor24;   // transparent color
107
 
108
wire pix;                               // pixel value from character generator 1=on,0=off
109
 
110
reg por;
111
reg [15:0] rego;
112
reg [11:0] windowTop;
113
reg [11:0] windowLeft;
114
reg [11:0] numCols;
115
reg [11:0] numRows;
116
reg [11:0] charOutDelay;
117
reg [ 1:0] mode;
118
reg [ 4:0] maxScanline;
119
reg [ 4:0] maxScanpix;
120
reg [ 4:0] cursorStart, cursorEnd;
121
reg [15:0] cursorPos;
122
reg [1:0] cursorType;
123
reg [15:0] startAddress;
124
reg [ 2:0] rBlink;
125
reg [ 3:0] bdrColorReg;
126
reg [ 3:0] pixelWidth;   // horizontal pixel width in clock cycles
127
reg [ 3:0] pixelHeight;  // vertical pixel height in scan lines
128
 
129
wire [11:0] hctr;                // horizontal reference counter (counts clocks since hSync)
130
wire [11:0] scanline;    // scan line
131
wire [11:0] row;         // vertical reference counter (counts rows since vSync)
132
wire [11:0] col;         // horizontal column
133
reg  [ 4:0] rowscan;     // scan line within row
134
wire nxt_row;                   // when to increment the row counter
135
wire nxt_col;                   // when to increment the column counter
136
wire [ 5:0] bcnt;                // blink timing counter
137
wire blink;
138
reg  iblank;
139
 
140
wire nhp;                               // next horizontal pixel
141
wire ld_shft = nxt_col & nhp;
142
 
143
 
144
// display and timing signals
145
reg [15:0] txtAddr;              // index into memory
146
reg [15:0] penAddr;
147
wire [8:0] txtOut;               // character code
148
wire [8:0] charOut;              // character ROM output
149
wire [8:0] txtBkColor;   // background color code
150
wire [8:0] txtFgColor;   // foreground color code
151
reg  [8:0] txtTcCode;    // transparent color code
152
reg  bgt;
153
 
154
wire [27:0] tdat_o;
155
wire [8:0] chdat_o;
156
 
157
wire [2:0] scanindex = scanline[2:0];
158
 
159
//--------------------------------------------------------------------
160
// Address Decoding
161
// I/O range Dx
162
//--------------------------------------------------------------------
163
wire cs_rom  = cs_i && cyc_i && stb_i && (adr_i[15:13]==3'h7);
164
wire cs_reg  = cs_i && cyc_i && stb_i && (adr_i[15: 8]==8'hDF);
165
wire cs_text = cs_i && cyc_i && stb_i && !adr_i[15];
166
wire cs_any  = cs_i && cyc_i && stb_i;
167
 assign tdat_o[9] = 1'b0;
168
 
169
// Register outputs
170
always @(posedge clk_i)
171
        if (cs_text) dat_o <= {4'd0,tdat_o};
172
        else if (cs_rom) dat_o <= {23'd0,chdat_o};
173
        else if (cs_reg) dat_o <= {16'd0,rego};
174
        else dat_o <= 32'h0000;
175
 
176
//always @(posedge clk_i)
177
//      if (cs_text) begin
178
//              $display("TC WRite: %h %h", adr_i, dat_i);
179
//              $stop;
180
//      end
181
 
182
//--------------------------------------------------------------------
183
// Video Memory
184
//--------------------------------------------------------------------
185
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
186
// Address Calculation:
187
//  - Simple: the row times the number of  cols plus the col plus the
188
//    base screen address
189
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
190
 
191
wire [17:0] rowcol = row * numCols;
192
always @(posedge vclk)
193
        txtAddr <= startAddress + rowcol[15:0] + col;
194
 
195
// Register read-back memory
196
wire [3:0] rrm_adr = adr_i[5:2];
197
wire [15:0] rrm_o;
198
 
199
regReadbackMem #(.WID(16)) rrm1
200
(
201
    .wclk(clk_i),
202
    .adr(rrm_adr),
203
    .wce(cs_reg),
204
    .we(wr_i),
205
    .i(dat_i[15:0]),
206
    .o(rrm_o)
207
);
208
 
209
// text screen RAM
210
wire [11:0] bram_adr = adr_i[13:2];
211
syncRam4kx9_1rw1r textRam0
212
(
213
        .wclk(clk_i),
214
        .wadr(bram_adr),
215
        .i(dat_i[8:0]),
216
        .wo(tdat_o[8:0]),
217
        .wce(cs_text|por),
218
        .we(wr_i|por),
219
        .wrst(1'b0),
220
 
221
        .rclk(vclk),
222
        .radr(txtAddr[11:0]),
223
        .o(txtOut),
224
        .rce(ld_shft),
225
        .rrst(1'b0)
226
);
227
 
228
// screen attribute RAM
229
syncRam4kx9_1rw1r fgColorRam
230
(
231
        .wclk(clk_i),
232
        .wadr(bram_adr),
233
        .i(dat_i[18:10]),
234
        .wo(tdat_o[18:10]),
235
        .wce(cs_text|por),
236
        .we(wr_i|por),
237
        .wrst(1'b0),
238
 
239
        .rclk(vclk),
240
        .radr(txtAddr[11:0]),
241
        .o(txtFgColor),
242
        .rce(ld_shft),
243
        .rrst(1'b0)
244
);
245
 
246
// screen attribute RAM
247
syncRam4kx9_1rw1r bkColorRam
248
(
249
        .wclk(clk_i),
250
        .wadr(bram_adr),
251
        .i(dat_i[27:19]),
252
        .wo(tdat_o[27:19]),
253
        .wce(cs_text|por),
254
        .we(wr_i|por),
255
        .wrst(1'b0),
256
 
257
        .rclk(vclk),
258
        .radr(txtAddr[11:0]),
259
        .o(txtBkColor),
260
        .rce(ld_shft),
261
        .rrst(1'b0)
262
);
263
 
264
 
265
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
266
// Character bitmap ROM
267
// - room for 512 characters
268
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
269
syncRam4kx9_1rw1r charRam0
270
(
271
        .wclk(clk_i),
272
        .wadr(bram_adr),
273
        .i(dat_i[8:0]),
274
        .wo(chdat_o),
275
        .wce(cs_rom),
276
        .we(1'b0),//we_i),
277
        .wrst(1'b0),
278
 
279
        .rclk(vclk),
280
        .radr({txtOut,rowscan[2:0]}),
281
        .o(charOut),
282
        .rce(ld_shft),
283
        .rrst(1'b0)
284
);
285
 
286
 
287
// pipeline delay - sync color with character bitmap output
288
reg [8:0] txtBkCode1;
289
reg [8:0] txtFgCode1;
290
always @(posedge vclk)
291
        if (nhp & ld_shft) txtBkCode1 <= txtBkColor;
292
always @(posedge vclk)
293
        if (nhp & ld_shft) txtFgCode1 <= txtFgColor;
294
 
295
//--------------------------------------------------------------------
296
// bus interfacing
297
// - there is a two cycle latency for reads, an ack is generated
298
//   after the synchronous RAM read
299
// - writes can be acknowledged right away.
300
//--------------------------------------------------------------------
301
reg ramRdy,ramRdy1;
302
always @(posedge clk_i)
303
begin
304
        ramRdy1 <= cs_any;
305
        ramRdy <= ramRdy1 & cs_any;
306
end
307
 
308
assign ack_o = cs_any ? (wr_i ? 1'b1 : ramRdy) : 1'b0;
309
 
310
 
311
//--------------------------------------------------------------------
312
// Registers
313
//
314
// RW   00 -         nnnnnnnn  number of columns (horizontal displayed number of characters)
315
// RW   01 -         nnnnnnnn  number of rows    (vertical displayed number of characters)
316
//  W   02 -       n nnnnnnnn  window left       (horizontal sync position - reference for left edge of displayed)
317
//  W   03 -       n nnnnnnnn  window top        (vertical sync position - reference for the top edge of displayed)
318
//  W   04 -         ---nnnnn  maximum scan line (char ROM max value is 7)
319
//      W       05 -         hhhhwwww  pixel size, hhhh=height,wwww=width
320
//  W   07 -       n nnnnnnnn  transparent color
321
//  W   08 -         -BPnnnnn  cursor start / blink control
322
//                             BP: 00=no blink
323
//                             BP: 01=no display
324
//                             BP: 10=1/16 field rate blink
325
//                             BP: 11=1/32 field rate blink
326
//  W   09 -        ----nnnnn  cursor end
327
//  W   10 - aaaaaaaa aaaaaaaaa  start address (index into display memory)
328
//  W   11 - aaaaaaaa aaaaaaaaa  cursor position
329
//  R   12 - aaaaaaaa aaaaaaaaa  light pen position
330
//--------------------------------------------------------------------
331
 
332
//--------------------------------------------------------------------
333
// Light Pen
334
//--------------------------------------------------------------------
335
wire lpe;
336
edge_det u1 (.rst(rst_i), .clk(clk_i), .ce(1'b1), .i(lp), .pe(lpe), .ne(), .ee() );
337
 
338
always @(posedge clk_i)
339
        if (rst_i)
340
                penAddr <= 32'h0000_0000;
341
        else begin
342
                if (lpe)
343
                        penAddr <= txtAddr;
344
        end
345
 
346
 
347
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
348
// Register read port
349
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
350
always @(cs_reg or cursorPos or penAddr or adr_i or numCols or numRows or rrm_adr or rrm_o)
351
        if (cs_reg) begin
352
                case(rrm_adr)
353
                //4'd0:       rego <= numCols;
354
                //4'd1:       rego <= numRows;
355
                4'd12:          rego <= penAddr;
356
                default:        rego <= rrm_o;
357
                endcase
358
        end
359
        else
360
                rego <= 16'h0000;
361
 
362
 
363
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
364
// Register write port
365
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
366
 
367
reg interlace;
368
always @(posedge clk_i)
369
        if (rst_i) begin
370
           por <= 1'b1;
371
// 104x63
372
/*
373
                windowTop    <= 12'd26;
374
                windowLeft   <= 12'd260;
375
                pixelWidth   <= 4'd0;
376
                pixelHeight  <= 4'd1;           // 525 pixels (408 with border)
377
*/
378
// 52x31
379
/*
380
                // 84x47
381
                windowTop    <= 12'd16;
382
                windowLeft   <= 12'd90;
383
                pixelWidth   <= 4'd1;           // 681 pixels
384
                pixelHeight  <= 4'd1;           // 384 pixels
385
*/
386
                // 56x31
387
                if (num==4'd1) begin
388
            windowTop    <= 12'd16;//12'd16;
389
            windowLeft   <= 12'h64;//12'd86;
390
            pixelWidth   <= 4'd1;               // 640 pixels
391
            pixelHeight  <= 4'd2;               // 256 pixels
392
            numCols      <= COLS;
393
            numRows      <= ROWS;
394
            maxScanline  <= 5'd7;
395
            maxScanpix   <= 5'd7;
396
            rBlink       <= 3'b111;             // 01 = non display
397
            startAddress <= 16'h0000;
398
            cursorStart  <= 5'd00;
399
            cursorEnd    <= 5'd31;
400
            cursorPos    <= 16'h0003;
401
            cursorType   <= 2'b00;
402
            txtTcCode    <= 9'h1ff;
403
            charOutDelay <= 12'd3;
404
                end
405
                else if (num==4'd2) begin
406
            windowTop    <= 12'd64;//12'd16;
407
            windowLeft   <= 12'h376;//12'd86;
408
            pixelWidth   <= 4'd0;        // 680 pixels
409
            pixelHeight  <= 4'd1;        // 256 pixels
410
            numCols      <= 40;
411
            numRows      <= 25;
412
            maxScanline  <= 5'd7;
413
            maxScanpix   <= 5'd7;
414
            rBlink       <= 3'b111;        // 01 = non display
415
            startAddress <= 16'h0000;
416
            cursorStart  <= 5'd00;
417
            cursorEnd    <= 5'd31;
418
            cursorPos    <= 16'h0003;
419
            cursorType   <= 2'b00;
420
            txtTcCode    <= 9'h1ff;
421
            charOutDelay <= 12'd3;
422
                end
423
        end
424
        else begin
425
 
426
                if (cs_reg & wr_i) begin        // register write ?
427
                        $display("TC Write: r%d=%h", rrm_adr, dat_i);
428
                        case(rrm_adr)
429
                        4'd00:  begin
430
                                        numCols    <= dat_i[11:0];               // horizontal displayed
431
                                        charOutDelay <= dat_i[15:12];
432
                                        end
433
                        4'd01:  numRows    <= dat_i;
434
                        4'd02:  windowLeft <= dat_i[11:0];
435
                        4'd03:  windowTop  <= dat_i[11:0];               // vertical sync position
436
                        4'd04:  maxScanline <= dat_i[4:0];
437
                        4'd05:  begin
438
                                        pixelHeight <= dat_i[7:4];
439
                                        pixelWidth  <= dat_i[3:0];       // horizontal pixel width
440
                                        end
441
                    4'd06:  por <= dat_i[0];
442
                        4'd07:  txtTcCode   <= dat_i[8:0];
443
                        4'd08:  begin
444
                                        cursorStart <= dat_i[4:0];       // scan line sursor starts on
445
                                        rBlink      <= dat_i[7:5];
446
                                        cursorType  <= dat_i[9:8];
447
                                        end
448
                        4'd09:  cursorEnd   <= dat_i[4:0];       // scan line cursor ends on
449
                        4'd10:  startAddress <= dat_i;
450
                        4'd11:  cursorPos <= dat_i[15:0];
451
                        default: ;
452
                        endcase
453
                end
454
        end
455
 
456
 
457
//--------------------------------------------------------------------
458
//--------------------------------------------------------------------
459
 
460
// "Box" cursor bitmap
461
reg [7:0] curout;
462
always @(scanindex or cursorType)
463
        case({cursorType,scanindex})
464
        // Box cursor
465
        5'b00_000:      curout = 8'b11111111;
466
        5'b00_001:      curout = 8'b10000001;
467
        5'b00_010:      curout = 8'b10000001;
468
        5'b00_011:      curout = 8'b10000001;
469
        5'b00_100:      curout = 8'b10000001;
470
        5'b00_101:      curout = 8'b10000001;
471
        5'b00_110:      curout = 8'b10011001;
472
        5'b00_111:      curout = 8'b11111111;
473
        // vertical bar cursor
474
        5'b01_000:      curout = 8'b11000000;
475
        5'b01_001:      curout = 8'b10000000;
476
        5'b01_010:      curout = 8'b10000000;
477
        5'b01_011:      curout = 8'b10000000;
478
        5'b01_100:      curout = 8'b10000000;
479
        5'b01_101:      curout = 8'b10000000;
480
        5'b01_110:      curout = 8'b10000000;
481
        5'b01_111:      curout = 8'b11000000;
482
        // underline cursor
483
        5'b10_000:      curout = 8'b00000000;
484
        5'b10_001:      curout = 8'b00000000;
485
        5'b10_010:      curout = 8'b00000000;
486
        5'b10_011:      curout = 8'b00000000;
487
        5'b10_100:      curout = 8'b00000000;
488
        5'b10_101:      curout = 8'b00000000;
489
        5'b10_110:      curout = 8'b00000000;
490
        5'b10_111:      curout = 8'b11111111;
491
        // Asterisk
492
        5'b11_000:      curout = 8'b00000000;
493
        5'b11_001:      curout = 8'b00000000;
494
        5'b11_010:      curout = 8'b00100100;
495
        5'b11_011:      curout = 8'b00011000;
496
        5'b11_100:      curout = 8'b01111110;
497
        5'b11_101:      curout = 8'b00011000;
498
        5'b11_110:      curout = 8'b00100100;
499
        5'b11_111:      curout = 8'b00000000;
500
        endcase
501
 
502
 
503
//-------------------------------------------------------------
504
// Video Stuff
505
//-------------------------------------------------------------
506
 
507
wire pe_hsync;
508
wire pe_vsync;
509
edge_det edh1
510
(
511
        .rst(rst_i),
512
        .clk(vclk),
513
        .ce(1'b1),
514
        .i(hsync),
515
        .pe(pe_hsync),
516
        .ne(),
517
        .ee()
518
);
519
 
520
edge_det edv1
521
(
522
        .rst(rst_i),
523
        .clk(vclk),
524
        .ce(1'b1),
525
        .i(vsync),
526
        .pe(pe_vsync),
527
        .ne(),
528
        .ee()
529
);
530
 
531
// Horizontal counter:
532
//
533
HVCounter uhv1
534
(
535
        .rst(rst_i),
536
        .vclk(vclk),
537
        .pixcce(1'b1),
538
        .sync(hsync),
539
        .cnt_offs(windowLeft),
540
        .pixsz(pixelWidth),
541
        .maxpix(maxScanpix),
542
        .nxt_pix(nhp),
543
        .pos(col),
544
        .nxt_pos(nxt_col),
545
        .ctr(hctr)
546
);
547
 
548
 
549
// Vertical counter:
550
//
551
HVCounter uhv2
552
(
553
        .rst(rst_i),
554
        .vclk(vclk),
555
        .pixcce(pe_hsync),
556
        .sync(vsync),
557
        .cnt_offs(windowTop),
558
        .pixsz(pixelHeight),
559
        .maxpix(maxScanline),
560
        .nxt_pix(),
561
        .pos(row),
562
        .nxt_pos(nxt_row),
563
        .ctr(scanline)
564
);
565
 
566
always @(posedge vclk)
567
        rowscan <= scanline - row * (maxScanline+1);
568
 
569
 
570
// Blink counter
571
//
572
VT163 #(6) ub1
573
(
574
        .clk(vclk),
575
        .clr_n(!rst_i),
576
        .ent(pe_vsync),
577
        .enp(1'b1),
578
        .ld_n(1'b1),
579
        .d(6'd0),
580
        .q(bcnt),
581
        .rco()
582
);
583
 
584
wire blink_en = (cursorPos+2==txtAddr) && (scanline[4:0] >= cursorStart) && (scanline[4:0] <= cursorEnd);
585
 
586
VT151 ub2
587
(
588
        .e_n(!blink_en),
589
        .s(rBlink),
590
        .i0(1'b1), .i1(1'b0), .i2(bcnt[4]), .i3(bcnt[5]),
591
        .i4(1'b1), .i5(1'b0), .i6(bcnt[4]), .i7(bcnt[5]),
592
        .z(blink),
593
        .z_n()
594
);
595
 
596
always @(posedge vclk)
597
        if (nhp & ld_shft)
598
                bkColor24 <= {txtBkCode1[8:6],5'h10,txtBkCode1[5:3],5'h10,txtBkCode1[2:0],5'h10};
599
always @(posedge vclk)
600
        if (nhp & ld_shft)
601
                fgColor24 <= {txtFgCode1[8:6],5'h10,txtFgCode1[5:3],5'h10,txtFgCode1[2:0],5'h10};
602
 
603
always @(posedge vclk)
604
        if (nhp & ld_shft)
605
                bgt <= txtBkCode1==txtTcCode;
606
 
607
 
608
// Convert character bitmap to pixels
609
// For convenience, the character bitmap data in the ROM is in the
610
// opposite bit order to what's needed for the display. The following
611
// just alters the order without adding any hardware.
612
//
613
wire [7:0] charRev = {
614
        charOut[0],
615
        charOut[1],
616
        charOut[2],
617
        charOut[3],
618
        charOut[4],
619
        charOut[5],
620
        charOut[6],
621
        charOut[7]
622
};
623
 
624
wire [7:0] charout1 = blink ? (charRev ^ curout) : charRev;
625
 
626
// Convert parallel to serial
627
ParallelToSerial ups1
628
(
629
        .rst(rst_i),
630
        .clk(vclk),
631
        .ce(nhp),
632
        .ld(ld_shft),
633
        .qin(1'b0),
634
        .d(charout1),
635
        .qh(pix)
636
);
637
 
638
reg pix1;
639
always @(posedge vclk)
640
        if (nhp)
641
        pix1 <= pix;
642
 
643
// Pipelining Effect:
644
// - character output is delayed by 2 or 3 character times relative to the video counters
645
//   depending on the resolution selected
646
// - this means we must adapt the blanking signal by shifting the blanking window
647
//   two or three character times.
648
wire bpix = hctr[1] ^ scanline[4];// ^ blink;
649
always @(posedge vclk)
650
        if (nhp)
651
                iblank <= (row >= numRows) || (col >= numCols + charOutDelay) || (col < charOutDelay);
652
 
653
 
654
// Choose between input RGB and controller generated RGB
655
// Select between foreground and background colours.
656
always @(posedge vclk)
657
        if (nhp) begin
658
                casex({blank,iblank,border,bpix,pix1})
659
                5'b1xxxx:       rgbOut <= 25'h0000000;
660
                5'b01xxx:       rgbOut <= rgbIn;
661
                5'b0010x:       rgbOut <= 24'hBF2020;
662
                5'b0011x:       rgbOut <= 24'hDFDFDF;
663
                5'b000x0:       rgbOut <= bgt ? rgbIn : bkColor24;
664
                5'b000x1:       rgbOut <= fgColor24;
665
                endcase
666
        end
667
 
668
endmodule
669
 

powered by: WebSVN 2.1.0

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