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

Subversion Repositories rtftextcontroller

[/] [rtftextcontroller/] [trunk/] [rtl/] [verilog/] [rtfTextController3.v] - Blame information for rev 27

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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