state isР when lcd_clr => RS <= '0'; D <= "00000001"; NST <= lcd_g; RW <= '0';--清屏Р when lcd_g => RS <= '0'; D <= "00000110"; NST <= lcd_func; RW <= '0';--设置光标Р when lcd_func => RS <= '0'; D <= "00111100"; NST <= lcd_on; RW <= '0';--设置功能Р when lcd_on => RS <= '0'; D <= "00001100"; NST <= lcd_addr; RW <= '0';----设置显示Р when lcd_addr => RS <= '0'; NST <= lcd_wr; RW <= '0';--设置地址Р if n = 4 thenР D <= "10000000";Р elseР D <= "11000000";Р end if;Р when lcd_wr => RS <= '1'; -----数据写入Р if n = 19 thenР NST <= lcd_addr;RW <= '1';--设置第二列的地址Р elsif n< 19 then--显示第一排内容Р D <= data; NST <= lcd_wr;RW <= '0'; Р elsif n > 20 and n < 36 then--显示第二排的内容Р D <= data; NST <= lcd_wr;RW <= '0';Р else Р NST <= IDLE;--显示完就进入空闲状态Р end if;Р when others => RW <= '1';RS <= '0';--空闲状态则不进行任何操作Р end case;Р end process;Рend;