library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity lcd is port ( clk_in : in std_logic; lcd_on : out std_logic; e : out std_logic; -- LCD Enable Bit -- rs : out std_logic; -- Control Bit -- rw : out std_logic; -- Control Bit -- data : out std_logic_vector(7 downto 0)); -- LCD Data -- end lcd; architecture ldg of lcd is constant addr_line : std_logic_vector(7 downto 0):= "10000000"; -- Start Display Location : 80H -- constant function_set : std_logic_vector(7 downto 0):= "00111100"; -- LCD Initialization : DL=1 8bit,N =1 2 lines,F=0 5*8 dot font -- constant clear_display : std_logic_vector(7 downto 0):= "00000001"; -- Clear LCD Screen -- constant entry_mode_set : std_logic_vector(7 downto 0):= "00000110"; -- Mode Setting , I/D=1 increment, S =0 cursor shift on data entry-- constant display_on_off : std_logic_vector(7 downto 0):= "00001110"; -- Display ON/Off , D =1 display on, C =1 cursor on, B=0 blink no-- signal clk : std_logic; begin process(clk_in) variable count2 : integer range 0 to 60000 := 0; begin if(clk_in='1' and clk_in'event) then count2 := count2 + 1; if (count2 = 60000) then clk <= not clk; count2 := 0; end if; end if; end process; process(clk) variable count : std_logic_vector(4 downto 0) := "00000"; begin if(clk' event and clk = '1') then case count is when "00000" => rs <= '0'; rw <= '0'; data <= function_set; --LCD Initialization count := count + 1; when "00001" => rs <= '0'; rw <= '0'; data <= clear_display; -- Clear LCD Screen count := count + 1; when "00010" => rs <= '0'; rw <= '0'; data <= entry_mode_set; -- Mode Setting count := count + 1; when "00011" => rs <= '0'; rw <= '0'; data <= display_on_off; -- display on/off count := count + 1; when "00100" => rs <= '0'; rw <= '0'; data <= addr_line; -- Start Display Location : 80H count := count + 1; when "00101" => rs <= '1'; rw <= '0'; data <= "01001101"; --M count := count + 1; when "00110" => rs <= '1'; rw <= '0'; data <= "01010010"; --R count := count + 1; when "00111" => rs <= '1'; rw <= '0'; data <= "00100000"; --" " count := count + 1; when "01000" => rs <= '1'; rw <= '0'; data <= "01001101"; --M count := count + 1; when "01001" => rs <= '1'; rw <= '0'; data <= "01001111"; --O count := count + 1; when "01010" => rs <= '1'; rw <= '0'; data <= "01001110"; --N count := count + 1; when "01011" => rs <= '1'; rw <= '0'; data <= "01001011"; --K count := count + 1; when "01100" => rs <= '1'; rw <= '0'; data <= "01000101"; --E count := count + 1; when "01101" => rs <= '1'; rw <= '0'; data <= "01011001"; --Y count := count + 1; when others => rs <= '0'; rw <= '0'; end case; end if; end process; e <= clk; lcd_on <= '1'; end ldg;