8.3LCD控制VHDL程序与仿真1.FPGA驱动LCD显示中文字符“年”程序--文件名:lcd_driver.vhd。--功能:FGAD驱动LCD显示中文字符“年”。--最后修改日期:2004.3.24。libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;entitylcd_driverisPort(clk:instd_logic;--状态机时钟信号,同时也是液晶时钟信号,其周期应该满足液晶数据的建立时间reset:instd_logic;lcdda:outstd_logic;--寄存器选择信号lcdrw:outstd_logic;--液晶读写信号lcden:outstd_logic;--液晶时钟信号data:outstd_logic_vector(7downto0));--液晶数据信号endlcd_driver;architectureBehavioraloflcd_driveristypestateis(set_dlnf,set_cursor,set_dcb,set_cgram,write_cgram,set_ddram,write_data);signalcurrent_state:state;typeram2isarray(0to7)ofstd_logic_vector(7downto0);constantcgram:ram2:=(("00001000"),("00001111"),("00010010"),("00001111"),("00001010"),("00011111"),("00000010"),("00000010"));--年字符数据存储器signalclkk:std_logic;beginlcden<=clk;--液晶时钟信号lcdrw<='0';--写数据control:process(clk,reset,current_state)--液晶驱动控制器variablecnt1:std_logic_vector(2downto0);beginifreset='0'thencurrent_state<=set_dlnf;cnt1:=(others=>'1');lcdda<='0';elsifrising_edge(clk)thencurrent_state<=current_state;lcdda<='0';casecurrent_stateiswhenset_dlnf=>data<="00111100";--3cHcurrent_state<=set_cursor;whenset_cursor=>data<="00000110";--06Hcurrent_state<=set_dcb;whenset_dcb=>data<="00001111";--0fHcurrent_state<=set_cgram;whenset_cgram=>data<="01000000";--40Hcurrent_state<=write_cgram;whenwrite_cgram=>--向CGRAM中写入“年”lcdda<='1';cnt1:=cnt1+1;data<=cgram(conv_integer(cnt1));ifcnt1="111"thencurrent_state<=set_ddram;endif;whenset_ddram=>--从第一行的起始地址开始显示data<="10000000";--80Hcurrent_state<=write_data;whenwrite_data=>lcdda<='1';data<="00000000";--写入字符“年”whenothers=>null;endcase;endif;endprocess;endBehavioral;