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

Subversion Repositories vga_lcd

[/] [vga_lcd/] [trunk/] [rtl/] [verilog/] [vga_wb_master.v] - Diff between revs 33 and 34

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

Rev 33 Rev 34
Line 35... Line 35...
////                                                             ////
////                                                             ////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
 
 
//  CVS Log
//  CVS Log
//
//
//  $Id: vga_wb_master.v,v 1.8 2002-03-04 11:01:59 rherveille Exp $
//  $Id: vga_wb_master.v,v 1.9 2002-03-04 16:05:52 rherveille Exp $
//
//
//  $Date: 2002-03-04 11:01:59 $
//  $Date: 2002-03-04 16:05:52 $
//  $Revision: 1.8 $
//  $Revision: 1.9 $
//  $Author: rherveille $
//  $Author: rherveille $
//  $Locker:  $
//  $Locker:  $
//  $State: Exp $
//  $State: Exp $
//
//
// Change History:
// Change History:
//               $Log: not supported by cvs2svn $
//               $Log: not supported by cvs2svn $
 
//               Revision 1.8  2002/03/04 11:01:59  rherveille
 
//               Added 64x64pixels 4bpp hardware cursor support.
 
//
//               Revision 1.7  2002/02/16 10:40:00  rherveille
//               Revision 1.7  2002/02/16 10:40:00  rherveille
//               Some minor bug-fixes.
//               Some minor bug-fixes.
//               Changed vga_ssel into vga_curproc (cursor processor).
//               Changed vga_ssel into vga_curproc (cursor processor).
//
//
//               Revision 1.6  2002/02/07 05:42:10  rherveille
//               Revision 1.6  2002/02/07 05:42:10  rherveille
Line 161... Line 164...
 
 
        reg sclr; // synchronous clear
        reg sclr; // synchronous clear
 
 
        wire [7:0] clut_offs; // color lookup table offset
        wire [7:0] clut_offs; // color lookup table offset
 
 
        reg [8:0] cursor_adr;
        //
        reg       cursor0_we, cursor1_we;
        // hardware cursors
 
        reg [31:11] cursor_ba;              // cursor pattern base address
 
        reg [ 8: 0] cursor_adr;             // cursor pattern offset
 
        wire        cursor0_we, cursor1_we; // cursor buffers write_request
 
        reg         ld_cursor0, ld_cursor1; // reload cursor0, cursor1
 
        reg         cur_acc;                // cursor processors request memory access
 
        reg         cur_acc_sel;            // which cursor to reload
 
        wire        cur_ack;                // cursor processor memory access acknowledge
 
        wire        cur_done;               // done reading cursor pattern
 
 
 
 
        //
        //
        // module body
        // module body
        //
        //
 
 
Line 183... Line 195...
        reg  [31:2] vmemA;                           // video memory address 
        reg  [31:2] vmemA;                           // video memory address 
 
 
        // wishbone access controller, video memory access request has highest priority (try to keep fifo full)
        // wishbone access controller, video memory access request has highest priority (try to keep fifo full)
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (sclr)
                if (sclr)
                        vmem_acc <= #1 1'b0;
                        vmem_acc <= #1 1'b0; // video memory access request
 
                else
 
                        vmem_acc <= #1 (!nvmem_req | (vmem_acc & !(burst_done & vmem_ack) ) ) & !ImDone & !cur_acc;
 
 
 
        always@(posedge clk_i)
 
                if (sclr)
 
                        cur_acc <= #1 1'b0; // cursor processor memory access request
                else
                else
                        vmem_acc <= #1 (!nvmem_req | (vmem_acc & !(burst_done & vmem_ack) ) ) & !ImDone;
                        cur_acc <= #1 (cur_acc | ImDone & (ld_cursor0 | ld_cursor1)) & !cur_done;
 
 
 
 
        assign vmem_ack = ack_i;
        assign vmem_ack = ack_i & vmem_acc;
 
        assign cur_ack  = ack_i & cur_acc;
        assign sint = err_i; // Non recoverable error, interrupt host system
        assign sint = err_i; // Non recoverable error, interrupt host system
 
 
 
 
        // select active memory page
        // select active memory page
        assign vmem_switch = ImDoneStrb;
        assign vmem_switch = ImDoneStrb;
 
 
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (sclr)
                if (sclr)
Line 216... Line 237...
                .empty(),
                .empty(),
                .hfull(),
                .hfull(),
                .full()
                .full()
        );
        );
 
 
 
        //
        // clut bank switch / cursor data delay2: Account for ColorProcessor DataBuffer delay
        // clut bank switch / cursor data delay2: Account for ColorProcessor DataBuffer delay
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (sclr)
                if (sclr)
                        dImDoneFifoQ <= #1 1'b0;
                        dImDoneFifoQ <= #1 1'b0;
                else    if (data_fifo_rreq)
                else    if (data_fifo_rreq)
Line 237... Line 259...
                if (sclr)
                if (sclr)
                        stat_acmp <= #1 1'b0;
                        stat_acmp <= #1 1'b0;
                else if (ctrl_cbsw)
                else if (ctrl_cbsw)
                        stat_acmp <= #1 stat_acmp ^ clut_switch;  // select next clut when finished reading clut for current video bank (and bank switch enabled)
                        stat_acmp <= #1 stat_acmp ^ clut_switch;  // select next clut when finished reading clut for current video bank (and bank switch enabled)
 
 
 
        //
        // generate clut-address
        // generate clut-address
        assign clut_adr = {stat_acmp, clut_offs};
        assign clut_adr = {stat_acmp, clut_offs};
 
 
 
        //
        // generate burst counter
        // generate burst counter
        wire [3:0] burst_cnt_val;
        wire [3:0] burst_cnt_val;
        assign burst_cnt_val = {1'b0, burst_cnt} -4'h1;
        assign burst_cnt_val = {1'b0, burst_cnt} -4'h1;
        assign burst_done = burst_cnt_val[3];
        assign burst_done = burst_cnt_val[3];
 
 
Line 358... Line 382...
                        else
                        else
                                vmemA <= #1 VBAb;
                                vmemA <= #1 VBAb;
                else if (vmem_ack)
                else if (vmem_ack)
                        vmemA <= #1 vmemA +30'h1;
                        vmemA <= #1 vmemA +30'h1;
 
 
 
 
 
        ////////////////////////////////////
 
        // hardware cursor signals section
 
        //
 
        always@(posedge clk_i)
 
                if (ImDone)
 
                        cur_acc_sel <= #1 ld_cursor0; // cursor0 has highest priority
 
 
 
        always@(posedge clk_i)
 
        if (sclr)
 
                begin
 
                        ld_cursor0 <= #1 1'b0;
 
                        ld_cursor1 <= #1 1'b0;
 
                end
 
        else
 
                begin
 
                        ld_cursor0 <= #1 cursor0_ld | (ld_cursor0 & !(cur_done &  cur_acc_sel));
 
                        ld_cursor1 <= #1 cursor1_ld | (ld_cursor1 & !(cur_done & !cur_acc_sel));
 
                end
 
 
 
        // select cursor base address
 
        always@(posedge clk_i)
 
                if (!cur_acc)
 
                        cursor_ba <= #1 ld_cursor0 ? cursor0_ba : cursor1_ba;
 
 
 
        // generate pattern offset
 
        wire [9:0] next_cursor_adr = {1'b0, cursor_adr} + 10'h1;
 
        assign     cur_done = next_cursor_adr[9];
 
 
 
        always@(posedge clk_i)
 
                if (!cur_acc)
 
                        cursor_adr <= #1 9'h0;
 
                else if (cur_ack)
 
                        cursor_adr <= #1 next_cursor_adr;
 
 
 
        // generate cursor buffers write enable signals
 
        assign cursor1_we = cur_ack & !cur_acc_sel;
 
        assign cursor0_we = cur_ack &  cur_acc_sel;
 
 
 
 
 
        //////////////////////////////
        // generate wishbone signals
        // generate wishbone signals
        assign adr_o = {vmemA, 2'b00};
        //
        wire wb_cycle = vmem_acc & !(burst_done & vmem_ack & nvmem_req) & !ImDone;
        assign adr_o = cur_acc ? {cursor_ba, cursor_adr, 2'b00} : {vmemA, 2'b00};
 
        wire wb_cycle = vmem_acc & !(burst_done & vmem_ack & nvmem_req) & !ImDone ||
 
                        cur_acc & !cur_done;
 
 
        always@(posedge clk_i or negedge nrst_i)
        always@(posedge clk_i or negedge nrst_i)
                if (!nrst_i)
                if (!nrst_i)
                        begin
                        begin
                                cyc_o <= #1 1'b0;
                                cyc_o <= #1 1'b0;
Line 389... Line 456...
                                        sel_o <= #1 4'b1111;   // only 32bit accesses are supported
                                        sel_o <= #1 4'b1111;   // only 32bit accesses are supported
                                        cab_o <= #1 wb_cycle;
                                        cab_o <= #1 wb_cycle;
                                        we_o  <= #1 1'b0;      // read only
                                        we_o  <= #1 1'b0;      // read only
                                end
                                end
 
 
 
        //
        // video-data buffer (temporary store data read from video memory)
        // video-data buffer (temporary store data read from video memory)
        vga_fifo #(4, 32) data_fifo (
        vga_fifo #(4, 32) data_fifo (
                .clk(clk_i),
                .clk(clk_i),
                .aclr(1'b1),
                .aclr(1'b1),
                .sclr(sclr),
                .sclr(sclr),
Line 405... Line 473...
                .full()
                .full()
        );
        );
 
 
        assign nvmem_req = data_fifo_hfull;
        assign nvmem_req = data_fifo_hfull;
 
 
 
        //
        // hookup color processor
        // hookup color processor
        vga_colproc color_proc (
        vga_colproc color_proc (
                .clk(clk_i),
                .clk(clk_i),
                .srst(sclr),
                .srst(sclr),
                .vdat_buffer_di(data_fifo_q),
                .vdat_buffer_di(data_fifo_q),
Line 426... Line 494...
                .clut_ack(clut_ack),
                .clut_ack(clut_ack),
                .clut_offs(clut_offs),
                .clut_offs(clut_offs),
                .clut_q(clut_q)
                .clut_q(clut_q)
        );
        );
 
 
 
        //
        // hookup data-source-selector && hardware cursor module
        // hookup data-source-selector && hardware cursor module
`ifdef VGA_HWC1 // generate Hardware Cursor1 (if enabled)
`ifdef VGA_HWC1 // generate Hardware Cursor1 (if enabled)
        reg scursor1_ld;
        wire cursor1_ld_strb;
        reg scursor1_en;
        reg scursor1_en;
        reg scursor1_res;
        reg scursor1_res;
        reg [31:0] scursor1_xy;
        reg [31:0] scursor1_xy;
 
 
        always@(posedge clk_i)
        assign cursor1_ld_strb = ddImDoneFifoQ & !dImDoneFifoQ;
                if (sclr)
 
                        scursor1_ld <= #1 1'b0;
 
                else
 
                        scursor1_ld <= #1 cursor1_ld | (scursor1_ld & !(ddImDoneFifoQ & !dImDoneFifoQ));
 
 
 
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (sclr)
                if (sclr)
                        scursor1_en <= #1 1'b0;
                        scursor1_en <= #1 1'b0;
                else if (scursor1_ld)
                else if (cursor1_ld_strb)
                        scursor1_en <= #1 cursor1_en;
                        scursor1_en <= #1 cursor1_en;
 
 
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (scursor1_ld)
                if (cursor1_ld_strb)
                        scursor1_xy <= #1 cursor1_xy;
                        scursor1_xy <= #1 cursor1_xy;
 
 
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (scursor1_ld)
                if (cursor1_ld_strb)
                        scursor1_res <= #1 cursor1_res;
                        scursor1_res <= #1 cursor1_res;
 
 
        vga_curproc hw_cursor1 (
        vga_curproc hw_cursor1 (
                .clk(clk_i),
                .clk(clk_i),
                .rst_i(sclr),
                .rst_i(sclr),
Line 484... Line 549...
                                sddImDoneFifoQ <= #1 sdImDoneFifoQ;
                                sddImDoneFifoQ <= #1 sdImDoneFifoQ;
                        end
                        end
`endif
`endif
 
 
`else                   // Hardware Cursor1 disabled, generate pass-through signals
`else                   // Hardware Cursor1 disabled, generate pass-through signals
 
 
        assign ssel1_wreq = color_proc_wreq;
        assign ssel1_wreq = color_proc_wreq;
        assign ssel1_q    = color_proc_q;
        assign ssel1_q    = color_proc_q;
 
 
        assign cc1_adr_0  = 4'h0;
        assign cc1_adr_0  = 4'h0;
 
 
Line 501... Line 565...
 
 
`endif
`endif
 
 
 
 
`ifdef VGA_HWC0 // generate Hardware Cursor0 (if enabled)
`ifdef VGA_HWC0 // generate Hardware Cursor0 (if enabled)
        reg scursor0_ld;
        wire cursor0_ld_strb;
        reg scursor0_en;
        reg scursor0_en;
        reg scursor0_res;
        reg scursor0_res;
        reg [31:0] scursor0_xy;
        reg [31:0] scursor0_xy;
 
 
        always@(posedge clk_i)
        assign cursor0_ld_strb = sddImDoneFifoQ & !sdImDoneFifoQ;
                if (sclr)
 
                        scursor0_ld <= #1 1'b0;
 
                else
 
                        scursor0_ld <= #1 cursor0_ld | (scursor0_ld & !(sddImDoneFifoQ & !sdImDoneFifoQ));
 
 
 
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (sclr)
                if (sclr)
                        scursor0_en <= #1 1'b0;
                        scursor0_en <= #1 1'b0;
                else if (scursor0_ld)
                else if (cursor0_ld_strb)
                        scursor0_en <= #1 cursor0_en;
                        scursor0_en <= #1 cursor0_en;
 
 
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (scursor0_ld)
                if (cursor0_ld_strb)
                        scursor0_xy <= #1 cursor0_xy;
                        scursor0_xy <= #1 cursor0_xy;
 
 
        always@(posedge clk_i)
        always@(posedge clk_i)
                if (scursor0_ld)
                if (cursor0_ld_strb)
                        scursor0_res <= #1 cursor0_res;
                        scursor0_res <= #1 cursor0_res;
 
 
        vga_curproc hw_cursor0 (
        vga_curproc hw_cursor0 (
                .clk(clk_i),
                .clk(clk_i),
                .rst_i(sclr),
                .rst_i(sclr),
Line 551... Line 611...
        assign rgb_fifo_d = ssel1_q;
        assign rgb_fifo_d = ssel1_q;
 
 
        assign cc0_adr_o  = 4'h0;
        assign cc0_adr_o  = 4'h0;
`endif
`endif
 
 
 
        //
        // hookup RGB buffer (temporary station between WISHBONE-clock-domain 
        // hookup RGB buffer (temporary station between WISHBONE-clock-domain 
        // and pixel-clock-domain)
        // and pixel-clock-domain)
        // The cursor_processor pipelines introduce a delay between the color
        // The cursor_processor pipelines introduce a delay between the color
        // processor's rgb_fifo_wreq and the rgb_fifo_full signals. To compensate
        // processor's rgb_fifo_wreq and the rgb_fifo_full signals. To compensate
        // for this we double the rgb_fifo.
        // for this we double the rgb_fifo.
Line 575... Line 636...
        assign line_fifo_wreq = rgb_fifo_rreq;
        assign line_fifo_wreq = rgb_fifo_rreq;
 
 
endmodule
endmodule
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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