📄 ps2_vga.v
字号:
////////////////////////////////////////////////////////////////////////////////// __ ___ _ ___ ____ //// \ \ / (_) |__ ___ ___|_ _/ ___| //// \ \ / /| | '_ \ / _ \/ __|| | | //// \ V / | | |_) | __/\__ \| | |___ //// \_/ |_|_.__/ \___||___/___\____| //// //////////////////////////////////////////////////////////////////////////////////// Copyright (C) 2003-2006 VibesIC, Inc. All rights reserved. ////----------------------------------------------------------------------------//// This source code is provided by VibesIC, and be verified on VibesIC FPGA //// development kit. The source code may be used and distributed without //// restriction provided that this copyright statement is not removed from the //// file and that any derivative work contains the original copyright notice //// and the associated disclaimer. ////----------------------------------------------------------------------------//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED //// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF //// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE//// AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, //// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,//// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,OR PROFITS; //// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, //// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR //// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF //// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ////----------------------------------------------------------------------------//// 本设计由威百仕( VibesIC )提供,并在其产品中验证通过,您可以在此基础上修改,//// 复制并分发,但请您保留版权声明部分。我们并不承诺本设计可以用做商业产品,同时//// 我们不保证设计的通用性。为了方便更新以及修改请保留设计的版本信息,并对自行 //// 修改部分添加足够的注释。对设计如有其他建议,请到网站进行讨论。 //// //////////////////////////////////////////////////////////////////////////////////// Company: www.richic.com //// Company bbs: www.edacn.net //// Engineer: mail007 (Gavin.xue) //// //// Target Device: XC3S400-PQ208 //// Tool versions: Simulation: ModelSim SE 6.2a //// Synthesis: XST(ise8.1...sp3) //// Place&Routing: ISE8.1...sp3 //// Others tools: UltraEdit-32 12.10a //// Create Date: 2005-9-6 10:59 //// Description: //// //// LOG: //// 1. Revision 1.0 (Initial version) 2005-9-6 10:59 mail007 //// //// 2. Revision 1.1 2006-12-27 17:12 alex_yang //// Updata ISE version from v6.3 to v8.1 //// Modify for VX-SP306 //////////////////////////////////////////////////////////////////////////////////module ps2_vga( clk, rst_n, ps2_ascii, ps2_data_ready, ps2_read, fg_color, bg_color, vga_hs, vga_vs, vga_r0, vga_g0, vga_b0 );input clk;input rst_n;input [7:0] ps2_ascii;input ps2_data_ready;output ps2_read;input [2:0] fg_color; //rrggbbinput [2:0] bg_color; //rrggbboutput vga_hs;output vga_vs; // sync signals for monitoroutput vga_r0, vga_g0, vga_b0;wire hsync;wire vsync;wire valid;wire [9:0] x_cnt;wire [9:0] y_cnt;wire [9:0] char_sel;wire [15:0] char;//设定屏幕分辨率:800x600 wire [9:0] xpos;//[0...799]wire [9:0] ypos;//[0...599]reg color;assign xpos = x_cnt - 10'd180; //确定X轴像素位置assign ypos = y_cnt - 10'd35; //确定Y轴像素位置 sync_gen_50m sync_gen_50m_int ( .clk ( clk ), .rst_n ( rst_n ), .hsync ( hsync ), .vsync ( vsync ), .valid ( valid ), .x_cnt ( x_cnt ), .y_cnt ( y_cnt ) ); wire table0 = (( ypos > 10'd136 && ypos < 10'd464 )&&( xpos > 10'd159 && xpos < 10'd674 )); wire line0 = (( ypos == 10'd136 || ypos == 10'd464 ) && ( xpos > 10'd159 && xpos < 10'd674 )|| ( xpos == 10'd159 || xpos == 10'd674 ) && ( ypos > 10'd136 && ypos < 10'd464 )); wire word0 = ((xpos > 10'd204) && (xpos < 10'd588) && (ypos > 10'd96) && (ypos < 10'd128)); wire word = word0 && color;wire pixel;assign vga_r0 = valid ? (word ? 1'b1 : (line0 ? 1'b0 : (table0? (pixel ? fg_color[2] : bg_color[2]) : 1'b0 ))) : 1'b0;assign vga_g0 = valid ? (word ? 1'b0 : (line0 ? 1'b1 : (table0? (pixel ? fg_color[1] : bg_color[1]) : 1'b0 ))) : 1'b0;assign vga_b0 = valid ? (word ? 1'b0 : (line0 ? 1'b0 : (table0? (pixel ? fg_color[0] : bg_color[0]) : 1'b1 ))) : 1'b0;assign vga_hs = hsync;assign vga_vs = vsync;wire [8:0] xpos_e = xpos - 10'd160;wire [8:0] ypos_e = ypos - 10'd140;//**********************************************************// 显示character //**********************************************************char_e_gen char_e_gen_inst( .clk ( clk ), .rst_n ( rst_n ), .rx_ascii ( ps2_ascii ), .rx_data_ready ( ps2_data_ready ), .rx_read ( ps2_read ), .xpos ( xpos_e ), .ypos ( ypos_e ), .pixel ( pixel ) );//**********************************************************// 显示标题 //**********************************************************assign char_sel = xpos -10'd204; char_rom_VibesIC char_rom_VibesIC_inst( .addr ({char_sel[9:5],ypos[4:1]}), //字符的Y轴由16 pixel变为32 pixel .data (char) ); always @(char_sel[4:1] or char) begin case (char_sel[4:1]) 4'h0 : color = char[15]; //将X轴对应点赋给color 4'h1 : color = char[14]; 4'h2 : color = char[13]; 4'h3 : color = char[12]; 4'h4 : color = char[11]; 4'h5 : color = char[10]; 4'h6 : color = char[9]; 4'h7 : color = char[8]; 4'h8 : color = char[7]; 4'h9 : color = char[6]; 4'hA : color = char[5]; 4'hB : color = char[4]; 4'hC : color = char[3]; 4'hD : color = char[2]; 4'hE : color = char[1]; 4'hF : color = char[0]; endcase end endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -