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

Subversion Repositories rtfbitmapcontroller

[/] [rtfbitmapcontroller/] [trunk/] [rtl/] [verilog/] [rtfBitmapController.v] - Diff between revs 9 and 12

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 9 Rev 12
Line 29... Line 29...
//              $4100000 - the second 4MiB of RAM
//              $4100000 - the second 4MiB of RAM
//
//
//
//
//      Verilog 1995
//      Verilog 1995
//
//
 
// ref: XC6SLX45-3
 
// 600 LUTs / 2 BRAMs / 410 FF's
 
// 150 MHz
// ============================================================================
// ============================================================================
 
 
module rtfBitmapController(
module rtfBitmapController(
        rst_i, s_clk_i, s_cyc_i, s_stb_i, s_ack_o, s_we_i, s_adr_i, s_dat_i, s_dat_o, irq_o,
        rst_i, s_clk_i, s_cyc_i, s_stb_i, s_ack_o, s_we_i, s_adr_i, s_dat_i, s_dat_o, irq_o,
        clk_i, bte_o, cti_o, bl_o, cyc_o, stb_o, ack_i, we_o, sel_o, adr_o, dat_i, dat_o,
        clk_i, bte_o, cti_o, bl_o, cyc_o, stb_o, ack_i, we_o, sel_o, adr_o, dat_i, dat_o,
Line 119... Line 122...
reg [11:0] hDisplayed,vDisplayed;
reg [11:0] hDisplayed,vDisplayed;
reg [33:0] bm_base_addr1,bm_base_addr2;
reg [33:0] bm_base_addr1,bm_base_addr2;
reg [1:0] color_depth;
reg [1:0] color_depth;
wire [8:0] fifo_cnt;
wire [8:0] fifo_cnt;
reg onoff;
reg onoff;
reg [5:0] Bpp;                   // bits per pixel, 8,16, or 32
reg [1:0] vbl;                   // video burst length
reg [1:0] hres,vres;
reg [1:0] hres,vres;
 
reg greyscale;
reg page;
reg page;
 
reg pals;                               // palette select
reg [11:0] hrefdelay;
reg [11:0] hrefdelay;
reg [11:0] vrefdelay;
reg [11:0] vrefdelay;
reg [11:0] hctr;         // horizontal reference counter
reg [11:0] hctr;         // horizontal reference counter
wire [11:0] hctr1 = hctr - hrefdelay;
wire [11:0] hctr1 = hctr - hrefdelay;
reg [11:0] vctr;         // vertical reference counter
reg [11:0] vctr;         // vertical reference counter
Line 138... Line 143...
wire [31:0] pal_o;
wire [31:0] pal_o;
 
 
always @(page or bm_base_addr1 or bm_base_addr2)
always @(page or bm_base_addr1 or bm_base_addr2)
        baseAddr = page ? bm_base_addr2 : bm_base_addr1;
        baseAddr = page ? bm_base_addr2 : bm_base_addr1;
 
 
 
// Color palette RAM for 8bpp modes
syncRam512x32_1rw1r upal1
syncRam512x32_1rw1r upal1
(
(
        .wrst(1'b0),
        .wrst(1'b0),
        .wclk(s_clk_i),
        .wclk(s_clk_i),
        .wce(cs & s_adr_i[13]),
        .wce(cs & s_adr_i[13]),
Line 150... Line 156...
        .i(s_dat_i),
        .i(s_dat_i),
        .wo(pal_wo),
        .wo(pal_wo),
        .rrst(1'b0),
        .rrst(1'b0),
        .rclk(vclk),
        .rclk(vclk),
        .rce(1'b1),
        .rce(1'b1),
        .radr({1'b0,rgbo4[7:0]}),
        .radr({pals,rgbo4[7:0]}),
        .o(pal_o)
        .o(pal_o)
);
);
 
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
always @(posedge s_clk_i)
always @(posedge s_clk_i)
if (rst_i) begin
if (rst_i) begin
        page <= 1'b0;
        page <= 1'b0;
        hres <= 2'b11;
        pals <= 1'b0;
        vres <= 2'b11;
        hres <= 2'b01;
        hDisplayed <= 12'd340;
        vres <= 2'b01;
        vDisplayed <= 12'd192;
        hDisplayed <= 12'd680;
 
        vDisplayed <= 12'd384;
        onoff <= 1'b1;
        onoff <= 1'b1;
 
        vbl <= 2'b11;
        color_depth <= 2'b00;
        color_depth <= 2'b00;
 
        greyscale <= 1'b0;
        bm_base_addr1 <= {BM_BASE_ADDR1,2'b00};
        bm_base_addr1 <= {BM_BASE_ADDR1,2'b00};
        bm_base_addr2 <= {BM_BASE_ADDR2,2'b00};
        bm_base_addr2 <= {BM_BASE_ADDR2,2'b00};
        hrefdelay <= 12'd218;
        hrefdelay <= 12'd218;
        vrefdelay <= 12'd27;
        vrefdelay <= 12'd27;
end
end
Line 177... Line 186...
                if (s_we_i) begin
                if (s_we_i) begin
                        casex(s_adr_i[13:2])
                        casex(s_adr_i[13:2])
                        REG_CTRL:
                        REG_CTRL:
                                begin
                                begin
                                        onoff <= s_dat_i[0];
                                        onoff <= s_dat_i[0];
 
                                        vbl <= s_dat_i[8:7];
                                        color_depth <= s_dat_i[10:9];
                                        color_depth <= s_dat_i[10:9];
 
                                        greyscale <= s_dat_i[11];
                                        hres <= s_dat_i[17:16];
                                        hres <= s_dat_i[17:16];
                                        vres <= s_dat_i[19:18];
                                        vres <= s_dat_i[19:18];
                                end
                                end
                        REG_CTRL2:
                        REG_CTRL2:
                                begin
                                begin
                                        page <= s_dat_i[16];
                                        page <= s_dat_i[16];
 
                                        pals <= s_dat_i[17];
                                end
                                end
                        REG_HDISPLAYED: hDisplayed <= s_dat_i[11:0];
                        REG_HDISPLAYED: hDisplayed <= s_dat_i[11:0];
                        REG_VDISPLAYED: vDisplayed <= s_dat_i[11:0];
                        REG_VDISPLAYED: vDisplayed <= s_dat_i[11:0];
                        REG_PAGE1ADDR:  bm_base_addr1 <= {s_dat_i,2'b00};
                        REG_PAGE1ADDR:  bm_base_addr1 <= {s_dat_i,2'b00};
                        REG_PAGE2ADDR:  bm_base_addr2 <= {s_dat_i,2'b00};
                        REG_PAGE2ADDR:  bm_base_addr2 <= {s_dat_i,2'b00};
Line 200... Line 212...
                end
                end
                casex(s_adr_i[13:2])
                casex(s_adr_i[13:2])
                REG_CTRL:
                REG_CTRL:
                        begin
                        begin
                                s_dat_o[0] <= onoff;
                                s_dat_o[0] <= onoff;
 
                                s_dat_o[8:7] <= vbl;
                                s_dat_o[10:9] <= color_depth;
                                s_dat_o[10:9] <= color_depth;
 
                                s_dat_o[11] <= greyscale;
                                s_dat_o[17:16] <= hres;
                                s_dat_o[17:16] <= hres;
                                s_dat_o[19:18] <= vres;
                                s_dat_o[19:18] <= vres;
                        end
                        end
                REG_CTRL2:
                REG_CTRL2:
                        begin
                        begin
                                s_dat_o[16] <= page;
                                s_dat_o[16] <= page;
 
                                s_dat_o[17] <= pals;
                        end
                        end
                REG_HDISPLAYED: s_dat_o <= hDisplayed;
                REG_HDISPLAYED: s_dat_o <= hDisplayed;
                REG_VDISPLAYED: s_dat_o <= vDisplayed;
                REG_VDISPLAYED: s_dat_o <= vDisplayed;
                REG_PAGE1ADDR:  s_dat_o <= bm_base_addr1;
                REG_PAGE1ADDR:  s_dat_o <= bm_base_addr1;
                REG_PAGE2ADDR:  s_dat_o <= bm_base_addr2;
                REG_PAGE2ADDR:  s_dat_o <= bm_base_addr2;
Line 243... Line 258...
else if (hSyncEdge) vctr <= vctr + 1;
else if (hSyncEdge) vctr <= vctr + 1;
 
 
 
 
// Pixel row and column are derived from the horizontal and vertical counts.
// Pixel row and column are derived from the horizontal and vertical counts.
 
 
always @(vctr1)
always @(posedge vclk)
        case(vres)
        case(vres)
        2'b00:          pixelRow <= vctr1[11:0];
        2'b00:          pixelRow <= vctr1[11:0];
        2'b01:          pixelRow <= vctr1[11:1];
        2'b01:          pixelRow <= vctr1[11:1];
        2'b10:          pixelRow <= vctr1[11:2];
        2'b10:          pixelRow <= vctr1[11:2];
        default:        pixelRow <= vctr1[11:2];
        default:        pixelRow <= vctr1[11:2];
Line 258... Line 273...
        2'b01:          pixelCol = hctr1[11:1];
        2'b01:          pixelCol = hctr1[11:1];
        2'b10:          pixelCol = hctr1[11:2];
        2'b10:          pixelCol = hctr1[11:2];
        default:        pixelCol = hctr1[11:2];
        default:        pixelCol = hctr1[11:2];
        endcase
        endcase
 
 
wire vFetch = vctr1 < vDisplayed;
wire vFetch = pixelRow < vDisplayed;
wire fifo_rst = hctr[11:4]==8'h00;
wire fifo_rst = hctr[11:4]==8'h00;
 
 
wire[23:0] rowOffset = pixelRow * hDisplayed;
wire[23:0] rowOffset = pixelRow * hDisplayed;
reg [11:0] fetchCol;
reg [11:0] fetchCol;
 
 
 
// The following bypasses loading the fifo when all the pixels from a scanline
 
// are buffered in the fifo and the pixel row doesn't change. Since the fifo
 
// pointers are reset at the beginning of a scanline, the fifo can be used like
 
// a cache.
 
wire blankEdge;
 
edge_det ed2(.rst(rst_i), .clk(clk_i), .ce(1'b1), .i(blank), .pe(blankEdge), .ne(), .ee() );
 
reg do_loads;
 
reg [11:0] opixelRow;
 
reg load_fifo;
 
always @(posedge clk_i)
 
        load_fifo <= fifo_cnt < 9'd500 && vFetch && onoff && xonoff && fetchCol < hDisplayed && !cyc_o && do_loads;
 
always @(posedge clk_i)
 
        if (!(hDisplayed < (12'd2048 >> color_depth)))
 
                do_loads <= 1'b1;
 
        else if (pixelRow != opixelRow)
 
                do_loads <= 1'b1;
 
        else if (blankEdge)
 
                do_loads <= 1'b0;
 
 
// - read from assigned video memory address, using burst mode reads
// - read from assigned video memory address, using burst mode reads
// - 64 pixels at a time are read
// - 32 bytes (8 words) at a time are read
// - video data is fetched one pixel row in advance
 
//
//
reg [5:0] bcnt;
reg [5:0] bcnt;
wire [5:0] bcnt_inc = bcnt + 6'd1;
wire [5:0] bcnt_inc = bcnt + 6'd1;
reg [33:0] adr;
reg [33:0] adr;
always @(posedge clk_i)
always @(posedge clk_i)
if (rst_i) begin
if (rst_i) begin
        wb_nack();
        wb_nack();
        fetchCol <= 12'd0;
        fetchCol <= 12'd0;
        bcnt <= 6'd0;
        bcnt <= 6'd0;
 
        opixelRow <= 12'hFFF;
end
end
else begin
else begin
        if (fifo_rst) begin
        if (fifo_rst) begin
                fetchCol <= 12'd0;
                fetchCol <= 12'd0;
                adr <= baseAddr + rowOffset;
                adr <= baseAddr + rowOffset;
 
                opixelRow <= pixelRow;
        end
        end
        else if (fifo_cnt < 9'd500 && vFetch && onoff && xonoff && fetchCol < hDisplayed && !cyc_o) begin
        else if (load_fifo) begin
                cti_o <= 3'b001;        // constant address burst
                cti_o <= vbl==2'b00 ? 3'b000 : 3'b001;  // constant address burst
                cyc_o <= 1'b1;
                cyc_o <= 1'b1;
                stb_o <= 1'b1;
                stb_o <= 1'b1;
                sel_o <= 4'b1111;
                sel_o <= 4'b1111;
                bcnt <= 6'd0;
                bcnt <= 6'd0;
                bl_o <= 6'd7;
                case(vbl)
 
                2'b00:  bl_o <= 6'd0;
 
                2'b01:  bl_o <= 6'd1;
 
                2'b10:  bl_o <= 6'd3;
 
                2'b11:  bl_o <= 6'd7;
 
                endcase
                adr_o <= adr;
                adr_o <= adr;
        end
        end
        if (cyc_o & ack_i) begin
        if (cyc_o & ack_i) begin
                case(color_depth)
                case(color_depth)
                2'b00:  fetchCol <= fetchCol + 12'd4;
                2'b00:  fetchCol <= fetchCol + 12'd4;
Line 326... Line 366...
 
 
reg [11:0] pixelColD1;
reg [11:0] pixelColD1;
reg [31:0] rgbo2,rgbo3,rgbo4;
reg [31:0] rgbo2,rgbo3,rgbo4;
always @(posedge vclk)
always @(posedge vclk)
        if (color_depth==2'b00)
        if (color_depth==2'b00)
                rgbo4 <= rgbo2;
                rgbo4 <= greyscale ? {3{rgbo2[7:0]}} : rgbo2;
        else if (color_depth==2'b01)
        else if (color_depth==2'b01)
                rgbo4 <= {rgbo3[14:10],3'b0,rgbo3[9:5],3'b0,rgbo3[4:0],3'b0};
                rgbo4 <= {rgbo3[14:10],3'b0,rgbo3[9:5],3'b0,rgbo3[4:0],3'b0};
        else
        else
                rgbo4 <= rgbo1;
                rgbo4 <= rgbo1;
 
 
Line 341... Line 381...
        if (rd_fifo1)
        if (rd_fifo1)
                de <= ~blank;
                de <= ~blank;
 
 
always @(posedge vclk)
always @(posedge vclk)
        if (onoff & xonoff & de) begin
        if (onoff & xonoff & de) begin
                if (color_depth==2'b00)
                if (color_depth==2'b00 && !greyscale)
                        rgbo <= pal_o;
                        rgbo <= pal_o;
                else
                else
                        rgbo <= rgbo4;
                        rgbo <= rgbo4;
        end
        end
        else
        else

powered by: WebSVN 2.1.0

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