Line 1... |
Line 1... |
// ============================================================================
|
// ============================================================================
|
// (C) 2006-2011 Robert Finch
|
// (C) 2006-2012 Robert Finch
|
// robfinch@<remove>opencores.org
|
// robfinch@<remove>opencores.org
|
//
|
//
|
// rtfTextController.v
|
// rtfTextController.v
|
// text controller
|
// text controller
|
//
|
//
|
Line 62... |
Line 62... |
rst_i, clk_i,
|
rst_i, clk_i,
|
cyc_i, stb_i, ack_o, we_i, sel_i, adr_i, dat_i, dat_o,
|
cyc_i, stb_i, ack_o, we_i, sel_i, adr_i, dat_i, dat_o,
|
lp, curpos,
|
lp, curpos,
|
vclk, eol, eof, blank, border, rgbIn, rgbOut
|
vclk, eol, eof, blank, border, rgbIn, rgbOut
|
);
|
);
|
parameter COLS = 12'd52;
|
parameter COLS = 12'd56;
|
parameter ROWS = 12'd31;
|
parameter ROWS = 12'd31;
|
|
|
// Syscon
|
// Syscon
|
input rst_i; // reset
|
input rst_i; // reset
|
input clk_i; // clock
|
input clk_i; // clock
|
Line 75... |
Line 75... |
input cyc_i; // cycle valid
|
input cyc_i; // cycle valid
|
input stb_i; // data strobe
|
input stb_i; // data strobe
|
output ack_o; // transfer acknowledge
|
output ack_o; // transfer acknowledge
|
input we_i; // write
|
input we_i; // write
|
input [ 1:0] sel_i; // byte select
|
input [ 1:0] sel_i; // byte select
|
input [31:0] adr_i; // address
|
input [63:0] adr_i; // address
|
input [15:0] dat_i; // data input
|
input [15:0] dat_i; // data input
|
output [15:0] dat_o; // data output
|
output [15:0] dat_o; // data output
|
reg [15:0] dat_o;
|
reg [15:0] dat_o;
|
|
|
//
|
//
|
Line 135... |
Line 135... |
|
|
// display and timing signals
|
// display and timing signals
|
reg [15:0] txtAddr; // index into memory
|
reg [15:0] txtAddr; // index into memory
|
reg [15:0] penAddr;
|
reg [15:0] penAddr;
|
wire [8:0] txtOut; // character code
|
wire [8:0] txtOut; // character code
|
wire [7:0] charOut; // character ROM output
|
wire [8:0] charOut; // character ROM output
|
wire [3:0] txtBkCode; // background color code
|
wire [3:0] txtBkCode; // background color code
|
wire [4:0] txtFgCode; // foreground color code
|
wire [4:0] txtFgCode; // foreground color code
|
reg [4:0] txtTcCode; // transparent color code
|
reg [4:0] txtTcCode; // transparent color code
|
reg bgt;
|
reg bgt;
|
|
|
wire [8:0] tdat_o;
|
wire [8:0] tdat_o;
|
wire [8:0] cdat_o;
|
wire [8:0] cdat_o;
|
wire [7:0] chdat_o;
|
wire [8:0] chdat_o;
|
|
|
wire [2:0] scanindex = scanline[2:0];
|
wire [2:0] scanindex = scanline[2:0];
|
|
|
|
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
// Address Decoding
|
// Address Decoding
|
// I/O range FFDx
|
// I/O range FFDx
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
wire cs_text = cyc_i && stb_i && (adr_i[31:16]==16'hFFD0);
|
wire cs_text = cyc_i && stb_i && (adr_i[63:16]==48'hFFFF_FFFF_FFD0);
|
wire cs_color= cyc_i && stb_i && (adr_i[31:16]==16'hFFD1);
|
wire cs_color= cyc_i && stb_i && (adr_i[63:16]==48'hFFFF_FFFF_FFD1);
|
wire cs_rom = cyc_i && stb_i && (adr_i[31:16]==16'hFFD2);
|
wire cs_rom = cyc_i && stb_i && (adr_i[63:16]==48'hFFFF_FFFF_FFD2);
|
wire cs_reg = cyc_i && stb_i && (adr_i[31: 8]==24'hFFDA_00);
|
wire cs_reg = cyc_i && stb_i && (adr_i[63: 8]==56'hFFFF_FFFF_FFDA_00);
|
|
wire cs_any = cs_text|cs_color|cs_rom|cs_reg;
|
|
|
|
// Register outputs
|
always @(cs_text or cs_color or cs_rom or cs_reg or tdat_o or cdat_o or chdat_o or rego)
|
always @(posedge clk_i)
|
if (cs_text) dat_o <= tdat_o;
|
if (cs_text) dat_o <= tdat_o;
|
else if (cs_color) dat_o <= cdat_o;
|
else if (cs_color) dat_o <= cdat_o;
|
else if (cs_rom) dat_o <= chdat_o;
|
else if (cs_rom) dat_o <= chdat_o;
|
else if (cs_reg) dat_o <= rego;
|
else if (cs_reg) dat_o <= rego;
|
else dat_o <= 16'h0000;
|
else dat_o <= 16'h0000;
|
Line 227... |
Line 228... |
.wclk(clk_i),
|
.wclk(clk_i),
|
.wadr(adr_i[11:0]),
|
.wadr(adr_i[11:0]),
|
.i(dat_i),
|
.i(dat_i),
|
.wo(chdat_o),
|
.wo(chdat_o),
|
.wce(cs_rom),
|
.wce(cs_rom),
|
.we(we_i),
|
.we(1'b0),//we_i),
|
.wrst(1'b0),
|
.wrst(1'b0),
|
|
|
.rclk(vclk),
|
.rclk(vclk),
|
.radr({txtOut,rowscan[2:0]}),
|
.radr({txtOut,rowscan[2:0]}),
|
.o(charOut),
|
.o(charOut),
|
Line 248... |
Line 249... |
always @(posedge vclk)
|
always @(posedge vclk)
|
if (nhp & ld_shft) txtFgCode1 <= txtFgCode;
|
if (nhp & ld_shft) txtFgCode1 <= txtFgCode;
|
|
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
// bus interfacing
|
// bus interfacing
|
// - there is a one cycle latency for reads, an ack is generated
|
// - there is a two cycle latency for reads, an ack is generated
|
// after the synchronous RAM read
|
// after the synchronous RAM read
|
// - writes can be acknowledged right away.
|
// - writes can be acknowledged right away.
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
reg ramRdy;
|
reg ramRdy,ramRdy1;
|
always @(posedge clk_i)
|
always @(posedge clk_i)
|
ramRdy = cs_text|cs_rom|cs_color|cs_reg;
|
begin
|
|
ramRdy1 <= cs_any & !(ramRdy1|ramRdy);
|
|
ramRdy <= ramRdy1 & cs_any;
|
|
end
|
|
|
assign ack_o = (cyc_i & stb_i) ? (we_i ? (cs_text|cs_color|cs_rom|cs_reg) : ramRdy) : 1'b0;
|
assign ack_o = (cyc_i & stb_i) ? (we_i ? cs_any : ramRdy) : 1'b0;
|
|
|
|
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
// Registers
|
// Registers
|
//
|
//
|
Line 326... |
Line 330... |
windowLeft <= 12'd260;
|
windowLeft <= 12'd260;
|
pixelWidth <= 4'd0;
|
pixelWidth <= 4'd0;
|
pixelHeight <= 4'd1; // 525 pixels (408 with border)
|
pixelHeight <= 4'd1; // 525 pixels (408 with border)
|
*/
|
*/
|
// 52x31
|
// 52x31
|
windowTop <= 12'd14;
|
windowTop <= 12'd12;
|
windowLeft <= 12'd117;
|
windowLeft <= 12'd128;
|
pixelWidth <= 4'd1;
|
pixelWidth <= 4'd2;
|
pixelHeight <= 4'd3; // 262 pixels (248 with border)
|
pixelHeight <= 4'd2; // 262 pixels (248 with border)
|
|
|
numCols <= COLS;
|
numCols <= COLS;
|
numRows <= ROWS;
|
numRows <= ROWS;
|
maxScanline <= 5'd7;
|
maxScanline <= 5'd7;
|
maxScanpix <= 5'd7;
|
maxScanpix <= 5'd7;
|
Line 444... |
Line 448... |
.ld_n(1'b1),
|
.ld_n(1'b1),
|
.d(6'd0),
|
.d(6'd0),
|
.q(bcnt)
|
.q(bcnt)
|
);
|
);
|
|
|
wire blink_en = (cursorPos==txtAddr+2) && (scanline[4:0] >= cursorStart) && (scanline[4:0] <= cursorEnd);
|
wire blink_en = (cursorPos+2==txtAddr) && (scanline[4:0] >= cursorStart) && (scanline[4:0] <= cursorEnd);
|
|
|
VT151 ub2
|
VT151 ub2
|
(
|
(
|
.e_n(!blink_en),
|
.e_n(!blink_en),
|
.s(rBlink),
|
.s(rBlink),
|
Line 456... |
Line 460... |
.i4(1'b1), .i5(1'b0), .i6(bcnt[4]), .i7(bcnt[5]),
|
.i4(1'b1), .i5(1'b0), .i6(bcnt[4]), .i7(bcnt[5]),
|
.z(blink),
|
.z(blink),
|
.z_n()
|
.z_n()
|
);
|
);
|
|
|
// These tables map a five bit color code to an eight bit color value.
|
// These tables map a five bit color code to an 24 bit color value.
|
rtfColorROM ucm1 (.clk(vclk), .ce(nhp & ld_shft), .code(txtBkCode1), .color(bkColor24) );
|
rtfColorROM ucm1 (.clk(vclk), .ce(nhp & ld_shft), .code(txtBkCode1), .color(bkColor24) );
|
rtfColorROM ucm2 (.clk(vclk), .ce(nhp & ld_shft), .code(txtFgCode1), .color(fgColor24) );
|
rtfColorROM ucm2 (.clk(vclk), .ce(nhp & ld_shft), .code(txtFgCode1), .color(fgColor24) );
|
always @(posedge vclk)
|
always @(posedge vclk)
|
if (nhp & ld_shft)
|
if (nhp & ld_shft)
|
bgt <= {1'b0,txtBkCode1}==txtTcCode;
|
bgt <= {1'b0,txtBkCode1}==txtTcCode;
|
Line 502... |
Line 506... |
// - this means we must adapt the blanking signal by shifting the blanking window
|
// - this means we must adapt the blanking signal by shifting the blanking window
|
// three character times.
|
// three character times.
|
wire bpix = hctr[1] ^ scanline[4];// ^ blink;
|
wire bpix = hctr[1] ^ scanline[4];// ^ blink;
|
always @(posedge vclk)
|
always @(posedge vclk)
|
if (nhp)
|
if (nhp)
|
iblank <= (row >= numRows) || (col >= numCols + 3) || (col < 3);
|
iblank <= (row >= numRows) || (col >= numCols + 2) || (col < 2);
|
|
|
|
|
// Choose between input RGB and controller generated RGB
|
// Choose between input RGB and controller generated RGB
|
// Select between foreground and background colours.
|
// Select between foreground and background colours.
|
always @(posedge vclk)
|
always @(posedge vclk)
|