您的位置:首页 > 服装鞋帽 > 男装 > Xilinx Spartan 3E LCD显示屏驱动

Xilinx Spartan 3E LCD显示屏驱动

luyued 发布于 2011-03-10 03:02   浏览 N 次  
说白了就是一个计时系统 然后显示到屏幕上 很容易懂的

`timescale 1ns / 1ps//////////////////////////////////////////////////////////////////////////////////// Company: // Engineer: // // Create Date: 08:14:41 03/04/2011 // Design Name: // Module Name: LCD // Project Name: // Target Devices: // Tool versions: // Description: //// Dependencies: //// Revision: // Revision 0.01 - File Created// Additional Comments: ////////////////////////////////////////////////////////////////////////////////////
`timescale 1ns / 1ps//---------------------Spartan_3E-LCD-----------//
module LCD( clk_50MHZ, LCD_RS, LCD_DB, LCD_RW, LCD_E, rst,s call, Mode );input clk_50MHZ; input call;input rst;input Mode;output LCD_RS;output [3:0] LCD_DB;output LCD_RW;output LCD_E;
reg [15:0] cnt_clk = 16'hC350;wire clken_ms; // ms clock enable signwire [3:0] sec_H,sec_sec_LL ,min_H,min_L,hou_H,hou_L;wire [3:0] Y_H,Y_L,M; reg [7:0] cnt_cmd = 8'h00; reg rs = 1'b0;reg reset = 1'b0;reg [3:0] DB = 8'h00;// create 1ms clock enable sign (clken_ms)always @( posedge clk_50MHZ ) beginif( clken_ms == 1'b1 )cnt_clk <= 16'hC350;elsecnt_clk <= cnt_clk - 1;endassign clken_ms = ~(|cnt_clk);// FSMalways @( posedge clk_50MHZ ) beginif( cnt_cmd == 8'd168&&call==1)cnt_cmd <= 8'd64;else if( cnt_cmd == 8'd168&&call==0)cnt_cmd <= 8'd168;else if( clken_ms )begincnt_cmd <= cnt_cmd + 1;// rst=1'b1;end
endalways @(*) begincase( cnt_cmd )//--------------------------LCD init------------------------//8'd32:begin DB <= 4'h3; rs <= 1'b0; reset <= 1'b1; end 8'd38: // send "Function Set" begin DB <= 4'h3; rs <= 1'b0; reset <= 1'b1; end8'd40: // send "Function Set" begin DB <= 4'h3; rs <= 1'b0; reset <= 1'b1; end8'd42: // send "Function Set" begin DB <= 4'h2; rs <= 1'b0; reset <= 1'b1; end //set LCD function8'd44: // send function set begin DB <= 4'h2; rs <= 1'b0; reset <= 1'b1; end8'd46: begin DB <= 4'h8; rs <= 1'b0; reset <= 1'b1; end8'd48: // send "Display On/Off control" begin DB <= 4'h0; rs <= 1'b0; reset <= 1'b1; end8'd50: begin DB <= 4'hC; rs <= 1'b0; reset <= 1'b1; end
8'd52: // send "Display clear" begin DB <= 4'h0; rs <= 1'b0; reset <= 1'b1; end8'd54: begin DB <= 4'h1; rs <= 1'b0; reset <= 1'b1; end
8'd56: // send "Entry mode set" begin DB <= 4'h0; rs <= 1'b0; reset <= 1'b1; end8'd58: begin DB <= 4'h6; rs <= 1'b0; reset <= 1'b1; end 8'd60: // send "Set CGRAM address" begin DB <= 4'h5; rs <= 1'b0; reset <= 1'b1; end8'd62: begin DB <= 4'h0; rs <= 1'b0; reset <= 1'b1; end//Display First Line /////////////////////////////////////8'd64: // send "Set DDRAM address" ///begin DB <= 4'h8; rs <= 2'b00; reset <= 1'b1; end///8'd66: ///begin DB <= 4'h0; rs <= 2'b00; reset <= 1'b1; end/////////////////////////////////////////////////////////////8'd68: // T -H begin DB <= 4'h5; rs <= 1'b1; reset <= 1'b1; end8'd70: // T -L begin DB <= 4'h4; rs <= 1'b1; reset <= 1'b1; end8'd72: // i begin DB <= 4'h6; rs <= 1'b1; reset <= 1'b1; end 8'd74: begin DB <= 4'h9; rs <= 1'b1; reset <= 1'b1; end8'd76: // m begin DB <= 4'h6; rs <= 1'b1; reset <= 1'b1; end8'd78: begin DB <= 4'hd ; rs <= 1'b1; reset <= 1'b1; end8'd80: // e begin DB <= 4'h6; rs <= 1'b1; reset <= 1'b1; end8'd82: begin DB <= 4'h5; rs <= 1'b1; reset <= 1'b1; end8'd84: // : begin DB <= 4'h3; rs <= 1'b1; reset <= 1'b1; end8'd86: begin DB <= 4'ha; rs <= 1'b1; reset <= 1'b1; end/////--------------time_display---------------------------//8'd88: // send hour_H begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd90: begin DB <= hou_H[3:0]; rs <= 2'b01; reset <= 1'b1; end8'd92: // send hour_L begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd94: begin DB <= hou_L[3:0]; rs <= 2'b01; reset <= 1'b1; end8'd96: // send "/" begin DB <= 4'h2; rs <= 2'b01; reset <= 1'b1; end8'd98: begin DB <= 4'hf; rs <= 2'b01; reset <= 1'b1; end8'd100: // send min_H begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd102: begin DB <= min_H[3:0]; rs <= 2'b01; reset <= 1'b1; end8'd104: // send min_L begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd106: begin DB <= min_L[3:0]; rs <= 2'b01; reset <= 1'b1; end8'd108: // send "/" begin DB <= 4'h2; rs <= 2'b01; reset <= 1'b1; end8'd110: begin DB <= 4'hf; rs <= 2'b01; reset <= 1'b1; end/* 8'd112: // send sec_H begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd114: begin DB <= sec_H[3:0]; rs <= 2'b01; reset <= 1'b1; end8'd116: // send sec_L begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd118: begin DB <= sec_L[3:0]; rs <= 2'b01; reset <= 1'b1; end */// show bit on second line /////////////////////////////////8'd124: // send "Set DDRAM address" /////begin DB <= 4'hC; rs <= 2'b00; reset <= 1'b1; end/////8'd126: // send "Set DDRAM address" /////begin DB <= 4'h0; rs <= 2'b00; reset <= 1'b1; end///////////////////////////////////////////////////////////////// 8'd128: // send P begin DB <= 4'h5; rs <= 2'b01; reset <= 1'b1; end8'd130: begin DB <= 4'h0; rs <= 2'b01; reset <= 1'b1; end
8'd132: // send r begin DB <= 4'h7; rs <= 2'b01; reset <= 1'b1; end8'd134: begin DB <= 4'd2; rs <= 2'b01; reset <= 1'b1; end8'd136: // send i begin DB <= 4'h6; rs <= 2'b01; reset <= 1'b1; end 8'd138: begin DB <= 4'h9; rs <= 2'b01; reset <= 1'b1; end8'd140: // send c begin DB <= 4'h6; rs <= 2'b01; reset <= 1'b1; end8'd142: begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd144: // send e begin DB <= 4'h6; rs <= 2'b01; reset <= 1'b1; end8'd146: begin DB <= 4'h5; rs <= 2'b01; reset <= 1'b1; end 8'd148: // send : begin DB <= 4'h3; rs <= 2'b01; reset <= 1'b1; end8'd150: begin DB <= 4'ha; rs <= 2'b01; reset <= 1'b1; end//----------price display----------------------------------*/
上一篇:win7+ubuntu9.10双系统 下一篇:文件加密
广告赞助商