⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcddisplay.vhd

📁 Xilinx sparten3E Lcd显示程序
💻 VHD
字号:
------------------------------------------------------------------------------------ Company: -- Engineer: -- -- Create Date:    18:30:12 11/26/2007 -- Design Name: -- Module Name:    Lcddisplay - Behavioral -- Project Name: -- Target Devices: -- Tool versions: -- Description: ---- Dependencies: ---- Revision: -- Revision 0.01 - File Created-- Additional Comments: ------------------------------------------------------------------------------------library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;---- Uncomment the following library declaration if instantiating---- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;entity Lcddisplay is    Port ( lcd_e : inout  STD_LOGIC;           lcd_rw : inout  STD_LOGIC;           lcd_rs : inout  STD_LOGIC;           sf_d : inout  STD_LOGIC_VECTOR (3 downto 0);			  clk : in STD_LOGIC);end Lcddisplay;architecture Behavioral of Lcddisplay issignal state : std_logic_vector(1 downto 0) := "00";Type data is array (0 to 7, 0 to 1) of std_logic_vector(3 downto 0);constant words : data := (("0010","1000"),--Function set								  ("0000","0110"),--Entry mode set								  ("0000","1100"),--Display on/off								  ("1000","0000"),--Set DDram address								  ("0100","0110"),--F								  ("0101","0000"),--P								  ("0100","0111"),--G								  ("0100","0001") --A								  );signal index : integer range 0 to 8 :=0;signal count0 : integer range 0 to 750000 := 0;signal sflag : std_logic := '0';signal flag : integer range 0 to 15 := 0;beginprocess(clk)beginif rising_edge(clk) then	if(state = "00") then --初始化 		if(flag = 0) then			if count0 = 750000 then				flag <= 1;				sf_d <= "0011";				lcd_e <= '1';				count0 <= 0;			else				count0 <= count0+1;			end if;		elsif flag = 1 then			if count0 = 12 then				flag <= 2;				lcd_e <= '0';				count0 <= 0;			else				count0 <= count0+1;			end if;		elsif flag = 2 then			if count0 = 205000 then				flag <= 3;				sf_d <= "0011";				lcd_e <= '1';				count0 <= 0;			else				count0 <= count0+1;			end if;		elsif flag = 3 then			if count0 = 12 then				flag <= 4;				lcd_e <= '0';				count0 <= 0;			else				count0 <= count0+1;			end if;		elsif flag = 4 then			if count0 = 5000 then				flag <= 5;				sf_d <= "0011";				lcd_e <= '1';				count0 <= 0;			else				count0 <= count0+1;			end if;			elsif flag = 5 then			if count0 = 12 then				flag <= 6;				lcd_e <= '0';				count0 <= 0;			else				count0 <= count0+1;			end if;			elsif flag = 6 then			if count0 = 2000 then				flag <= 7;				sf_d <= "0010";				lcd_e <= '1';				count0 <= 0;			else				count0 <= count0+1;			end if;			elsif flag = 7 then			if count0 = 12 then				flag <= 8;				lcd_e <= '0';				count0 <= 0;			else				count0 <= count0+1;			end if;			else			if count0 = 2000 then				flag <= 0;				count0 <= 0;				state <= "01";				lcd_rs <= '0';				lcd_rw <= '0';				sf_d <= words(index,0);			else				count0 <= count0+1;			end if;						end if;			elsif state = "01" then	--配置显示		if flag = 0 then	   --延时40ns			if count0 = 2 then				flag <= 1;				count0 <= 0;				lcd_e <= '1';			else				count0 <= count0+1;			end if;		elsif flag = 1 then  --延时230ns			if count0 = 12 then				flag <= 2;				lcd_e <= '0';				count0 <= 0;			else				count0 <= count0+1;				end if;		elsif flag = 2 then --延时20ns			if count0 = 1 then				if sflag = '0' then --一个字节未完										flag <= 3;				else					flag <= 4; --next 4bits			
				end if;				lcd_rw <= '1';				count0 <= 0;			else				count0 <= count0+1;			end if;		elsif flag = 3 then --延时1us			if count0 = 50 then				sflag <= '1';				flag <= 0;				lcd_rw <= '0';				count0 <= 0;				sf_d <= words(index,1);				index <= index+1;			else				count0 <= count0+1;			end if;		elsif flag = 4 then --延时40us			if count0 = 2000 then				sflag <= '0';				flag <= 0;				lcd_rw <= '0';				count0 <= 0;				sf_d <= words(index,0);				if index = 4 then					lcd_rs <= '1';				end if;				if index = 8 then					state <= "10";				end if;			else				count0 <= count0+1;			end if;		end if;	else	end if;		end if;--clkend process;end Behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -