library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.all;
USE IEEE.STD_LOGIC_UNSIGNED.all;
entity oled_module_controllerv1 is
Port ( clk : in STD_LOGIC;
rst : in STD_LOGIC;
preset : in std_logic ;
key_in: in std_logic_vector (0 to 15) ;
adt_sec10 : in std_logic_vector(3 downto 0) ;
status_reg : in std_logic_vector( 1 downto 0) ;
led : out std_logic_vector(1 downto 0) ;
cdt_hour10 , cdt_hour1, cdt_min10 ,cdt_min1, cdt_sec10 ,cdt_sec1 : in std_logic_vector (3 downto 0) ;
adt_day100,adt_day10 ,adt_day1 : in std_logic_Vector ( 3 downto 0) ;
adt_sec1 : in std_logic_vector( 3 downto 0) ;
adt_min10, adt_min1 : in std_logic_vector( 3 downto 0) ;
adt_hour10,adt_hour1:in std_logic_vector( 3 downto 0) ;
data_out : inout STD_LOGIC_vector( 7 downto 0) ;
rs : out STD_LOGIC;
rw : out STD_LOGIC;
e : out STD_LOGIC;
dac_a0 , dac_scl, dac_sda : out std_logic );
end oled_module_controllerv1;
architecture Behavioral of oled_module_controllerv1 is
signal clock_count : unsigned ( 23 downto 0) :=(others=>'0') ;
signal clk_enable400 : std_logic :='0' ;
type state_type is (power_up,reset1, reset2,
reset3, func_set, display_on, mode_set,
line2, return_home, drop_lcd_e, display_off, display_clear ,line2_data,char_mode, cursor_shift,
line3,line3_data,line4,line4_data,adt_state,sec10,sec1 ,min10,min1,coln1,coln2, hour10 , hour1,day100,day10 ,day1 ,dcoln,
cdth10 ,cdth1, cdtm10,cdtm1 ,cdts10,cdts1, status ,coln3,coln4,coln5,coln6,coln7 ,cdt_ih10,cdt_ih1, cdt_im10,cdt_im1,cdt_is10,cdt_is1,
adt_space1,adt_space2 , st1,st2,st3,st4,st5,cdt_space2,read_addr,
cdt_c,cdt_d,cdt_t ,cdt_coln, cdt_space1, dram_address,rst1,rst2,rst3,rst4,disp_off, func, clear_screen ,disp_on, MODE ,ADDR, message_enter ,
second_line,CURSOR_ON,second_linedata, input_data , delay_state,time_save,CURSOR_LEFT,CURSOR_RIGHT,OVERIDE_C);
----------st1,st2,st3,st4,st5,cdt_space2,read_addr
signal state, next_command : state_type;
signal data_bus : std_logic_vector ( 7 downto 0) ;
signal lcd_e, lcd_rs, lcd_rw_int : std_Logic ;
type character_string is array ( 0 to 15 ) of STD_LOGIC_VECTOR( 7 downto 0 );
signal lcd_display_string : character_string;
signal lcd_display_string_01 : character_string;
signal lcd_display_string_02 : character_string;
signal lcd_display_string_03 : character_string;
signal next_char : STD_LOGIC_VECTOR(7 downto 0);
signal char_count : STD_LOGIC_VECTOR(4 downto 0);
signal counter : unsigned ( 26 downto 0) :=( others=>'0') ;
signal sec_bcd: unsigned( 3 downto 0) :=( others=>'0') ;
signal sec_en: std_logic ;
signal sec_out : std_logic_vector( 7 downto 0) ;
------------------adt ------------
type str1 is array ( 0 to 5) of std_logic_Vector ( 7 downto 0) ;
signal adt_string,cdt_string : str1;
signal adt :std_logic_vector ( 7 downto 0) ;
signal cdt: std_logic_vector( 7 downto 0) ;
signal str_count : std_logic_vector( 3 downto 0) :="0000" ;
signal message_count : std_Logic_vector( 3 downto 0) ;
signal wait_count : std_logic_vector( 19 downto 0) := (others=>'0') ;
signal adt_d1s: std_logic_vector ( 7 downto 0) ;
signal adt_d10s : std_logic_vector ( 7 downto 0) ;
signal adt_d100s: std_logic_vector ( 7 downto 0) ;
signal adt_sec1s: std_logic_vector ( 7 downto 0) ;
signal adt_sec10s : std_logic_vector ( 7 downto 0) ;
signal adt_min1s: std_logic_vector ( 7 downto 0) ;
signal adt_min10s : std_logic_vector ( 7 downto 0) ;
signal adt_hour1s: std_logic_vector ( 7 downto 0) ;
signal adt_hour10s : std_logic_vector ( 7 downto 0) ;
--------------------------cdt--------------------------------
signal cdt_sec1s: std_logic_vector ( 7 downto 0) ;
signal cdt_sec10s : std_logic_vector ( 7 downto 0) ;
signal cdt_min1s: std_logic_vector ( 7 downto 0) ;
signal cdt_min10s : std_logic_vector ( 7 downto 0) ;
signal cdt_hour1s: std_logic_vector ( 7 downto 0) ;
signal cdt_hour10s : std_logic_vector ( 7 downto 0) ;
---------------------xxxxxxxxxxxxxxxx----------
signal key_stored, fkey_stored: std_logic_vector( 7 downto 0) ;
signal key_q : std_logic_vector( 0 to 15 ) ;
-------status -register ---------
signal sts_reg : std_logic_vector ( 1 downto 0) ;
signal wait_1sec : integer range 0 to 239999 := 0 ;
signal space_count : integer range 0 to 19 := 0 ;
signal one_mscounter : natural range 0 to 835 :=0 ; -------counter for 10 mhz clock enable for 10 mhz checking
signal f1khz : std_logic ;
attribute mark_debug : string ;
attribute mark_debug of key_q : signal is "true" ;
attribute mark_debug of lcd_e : signal is "true" ;
attribute mark_debug of lcd_rs : signal is "true" ;
attribute mark_debug of lcd_rw_int : signal is "true" ;
attribute mark_debug of data_bus : signal is "true" ;
attribute mark_debug of preset : signal is "true" ;
begin
dac_a0<=lcd_rs ;
dac_scl<= lcd_rw_int;
dac_sda<=lcd_e ;
---------------=============================
lcd_display_string <=( X"45" , X"6E" , X"74" ,X"65" , X"72" , X"20" ,X"63" , X"64" , X"74" , X"20" , X"54" , X"69" , X"6D" , X"65" , X"20", X"20") ;
next_char<= lcd_display_string( conv_integer( message_count)) ;
---------===============================
process(clk )
begin
if rising_edge ( clk ) then
if (clk_enable400='1') then
key_q <= key_in ;
end if ;
end if ;
end process ;
--process( key_in)
-- begin
-- case key_in is
-- when x"4000" =>
-- key_stored<=x"30" ;
-- when x"2000"=>
-- key_stored<=x"31" ;
-- when x"1000"=>
-- key_stored <=x"32" ;
-- when x"0020"=>
-- key_stored<=x"33" ;
-- when x"0800"=>
-- key_stored <=x"34" ;
-- when x"0400"=>
-- key_stored <=x"35" ;
-- when x"0200"=>
-- key_stored<=x"36" ;
-- when x"0010"=>
-- key_stored <=x"37" ;
-- when x"0100"=>
-- key_stored <=x"38" ;
-- when x"0080"=>
-- key_stored <=x"39" ;
-- when x"0040"=>
-- key_stored <=x"40" ;
-- when x"0008"=>
-- key_stored <=x"41" ;
-- when x"8000"=>
-- key_stored <=x"42" ;
-- when x"0001"=>
-- key_stored <=x"43" ;
-- when x"0002"=>
-- key_stored <=x"44" ;
-- when x"0004"=>
-- key_stored <=x"45" ;
-- when others =>
-- key_stored <= x"20" ;
-- end case ;
-- end process ;
-----------------xxxxxxxxx----------------------------
-----------adt day---------------------------------
--------------------------------------------
process ( adt_day1) begin
case adt_day1 is
when "0000" =>
adt_d1s<=x"30" ;
when "0001"=>
adt_d1s<=x"31" ;
when "0010"=>
adt_d1s <=x"32" ;
when "0011"=>
adt_d1s<=x"33" ;
when "0100"=>
adt_d1s <=x"34" ;
when "0101"=>
adt_d1s <=x"35" ;
when others=>
adt_d1s <=x"30" ;
end case ;
end process ;
process ( adt_day10) begin
case adt_day10 is
when "0000" =>
adt_d10s<=x"30" ;
when "0001"=>
adt_d10s<=x"31" ;
when "0010"=>
adt_d10s <=x"32" ;
when "0011"=>
adt_d10s<=x"33" ;
when "0100"=>
adt_d10s <=x"34" ;
when "0101"=>
adt_d10s <=x"35" ;
when "0110"=>
adt_d10s<=x"36" ;
when others=>
adt_d10s <=x"30" ;
end case ;
end process ;
process ( adt_day100) begin
case adt_day100 is
when "0000" =>
adt_d100s<=x"30" ;
when "0001"=>
adt_d100s<=x"31" ;
when "0010"=>
adt_d100s <=x"32" ;
when "0011"=>
adt_d100s<=x"33" ;
when others=>
adt_d100s <=x"30" ;
end case ;
end process ;
----------------------------XXXXXXXXXXXXXXXXXX---------------------------------
------------------ADT HOUR ---------------------------------------------------
----------=============================================
process ( adt_hour10)
begin
case adt_hour10 is
when "0000" =>
adt_hour10s<=x"30" ;
when "0001"=>
adt_hour10s<=x"31" ;
when "0010"=>
adt_hour10s <=x"32" ;
when "0011"=>
adt_hour10s<=x"33" ;
when "0100"=>
adt_hour10s <=x"34" ;
when "0101"=>
adt_hour10s <=x"35" ;
when "0110"=>
adt_hour10s<=x"36" ;
when "0111"=>
adt_hour10s <=x"37" ;
when "1000"=>
adt_hour10s <=x"38" ;
when "1001"=>
adt_hour10s <=x"39" ;
when others =>
adt_hour10s <= x"30" ;
end case ;
end process ;
process ( adt_hour1)
begin
case adt_hour1 is
when "0000" =>
adt_hour1s<=x"30" ;
when "0001"=>
adt_hour1s <=x"31" ;
when "0010"=>
adt_hour1s<=x"32" ;
when "0011"=>
adt_hour1s <=x"33" ;
when "0100"=>
adt_hour1s <=x"34" ;
when "0101"=>
adt_hour1s <=x"35" ;
when "0110"=>
adt_hour1s <=x"36" ;
when "0111"=>
adt_hour1s <=x"37" ;
when "1000"=>
adt_hour1s <=x"38" ;
when "1001"=>
adt_hour1s <=x"39" ;
when others =>
adt_hour1s <= x"30" ;
end case ;
end process ;
----------------------XXXXXXXXXXXXXXXXX-------------------------------
--------------------ADT MIN-------------------------------------------------
------------------======================================
process ( adt_min10)
begin
case adt_min10 is
when "0000" =>
adt_min10s<=x"30" ;
when "0001"=>
adt_min10s <=x"31" ;
when "0010"=>
adt_min10s <=x"32" ;
when "0011"=>
adt_min10s <=x"33" ;
when "0100"=>
adt_min10s <=x"34" ;
when "0101"=>
adt_min10s <=x"35" ;
when "0110"=>
adt_min10s <=x"36" ;
when "0111"=>
adt_min10s <=x"37" ;
when "1000"=>
adt_min10s <=x"38" ;
when "1001"=>
adt_min10s <=x"39" ;
when others =>
adt_min10s <= x"30" ;
end case ;
end process ;
process ( adt_min1)
begin
case adt_min1 is
when "0000" =>
adt_min1s<=x"30" ;
when "0001"=>
adt_min1s <=x"31" ;
when "0010"=>
adt_min1s <=x"32" ;
when "0011"=>
adt_min1s <=x"33" ;
when "0100"=>
adt_min1s <=x"34" ;
when "0101"=>
adt_min1s <=x"35" ;
when "0110"=>
adt_min1s <=x"36" ;
when "0111"=>
adt_min1s <=x"37" ;
when "1000"=>
adt_min1s <=x"38" ;
when "1001"=>
adt_min1s <=x"39" ;
when others =>
adt_min1s <= x"30" ;
end case ;
end process ;
----------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------------
---------------ADT SEC-------------------------------------------------
-------===============================================
process ( adt_sec1)
begin
case (adt_sec1 ) is
when "0000" =>
adt_sec1s <=x"30" ;
when "0001"=>
adt_sec1s <=x"31" ;
when "0010"=>
adt_sec1s <=x"32" ;
when "0011"=>
adt_sec1s <=x"33" ;
when "0100"=>
adt_sec1s <=x"34" ;
when "0101"=>
adt_sec1s <=x"35" ;
when "0110"=>
adt_sec1s <=x"36" ;
when "0111"=>
adt_sec1s <=x"37" ;
when "1000"=>
adt_sec1s <=x"38" ;
when "1001"=>
adt_sec1s <=x"39" ;
when others =>
adt_sec1s <= x"30" ;
end case ;
end process ;
process ( adt_sec10)
begin
case adt_sec10 is
when "0000" =>
adt_sec10s <=x"30" ;
when "0001"=>
adt_sec10s <=x"31" ;
when "0010"=>
adt_sec10s <=x"32" ;
when "0011"=>
adt_sec10s <=x"33" ;
when "0100"=>
adt_sec10s <=x"34" ;
when "0101"=>
adt_sec10s <=x"35" ;
when "0110"=>
adt_sec10s <=x"36" ;
when "0111"=>
adt_sec10s <=x"37" ;
when "1000"=>
adt_sec10s <=x"38" ;
when "1001"=>
adt_sec10s <=x"39" ;
when others =>
adt_sec10s <= x"30" ;
end case ;
end process ;
--------------=============================cdt=======================
----============================================================
----------------------------XXXXXXXXXXXXXXXXXX---------------------------------
------------------CDT HOUR ---------------------------------------------------
----------=============================================
process ( cdt_hour10)
begin
case cdt_hour10 is
when "0000" =>
cdt_hour10s<=x"30" ;
when "0001"=>
cdt_hour10s<=x"31" ;
when "0010"=>
cdt_hour10s <=x"32" ;
when "0011"=>
cdt_hour10s<=x"33" ;
when "0100"=>
cdt_hour10s <=x"34" ;
when "0101"=>
cdt_hour10s <=x"35" ;
when "0110"=>
cdt_hour10s<=x"36" ;
when "0111"=>
cdt_hour10s <=x"37" ;
when "1000"=>
cdt_hour10s <=x"38" ;
when "1001"=>
cdt_hour10s <=x"39" ;
when others =>
cdt_hour10s <= x"30" ;
end case ;
end process ;
process ( cdt_hour1)
begin
case cdt_hour1 is
when "0000" =>
cdt_hour1s<=x"30" ;
when "0001"=>
cdt_hour1s <=x"31" ;
when "0010"=>
cdt_hour1s<=x"32" ;
when "0011"=>
cdt_hour1s <=x"33" ;
when "0100"=>
cdt_hour1s <=x"34" ;
when "0101"=>
cdt_hour1s <=x"35" ;
when "0110"=>
cdt_hour1s <=x"36" ;
when "0111"=>
cdt_hour1s <=x"37" ;
when "1000"=>
cdt_hour1s <=x"38" ;
when "1001"=>
cdt_hour1s <=x"39" ;
when others =>
cdt_hour1s <= x"30" ;
end case ;
end process ;
----------------------XXXXXXXXXXXXXXXXX-------------------------------
--------------------ADT MIN-------------------------------------------------
------------------======================================
process ( cdt_min10)
begin
case cdt_min10 is
when "0000" =>
cdt_min10s<=x"30" ;
when "0001"=>
cdt_min10s <=x"31" ;
when "0010"=>
cdt_min10s <=x"32" ;
when "0011"=>
cdt_min10s <=x"33" ;
when "0100"=>
cdt_min10s <=x"34" ;
when "0101"=>
cdt_min10s <=x"35" ;
when "0110"=>
cdt_min10s <=x"36" ;
when "0111"=>
cdt_min10s <=x"37" ;
when "1000"=>
cdt_min10s <=x"38" ;
when "1001"=>
cdt_min10s <=x"39" ;
when others =>
cdt_min10s <= x"30" ;
end case ;
end process ;
process ( cdt_min1)
begin
case cdt_min1 is
when "0000" =>
cdt_min1s<=x"30" ;
when "0001"=>
cdt_min1s <=x"31" ;
when "0010"=>
cdt_min1s <=x"32" ;
when "0011"=>
cdt_min1s <=x"33" ;
when "0100"=>
cdt_min1s <=x"34" ;
when "0101"=>
cdt_min1s <=x"35" ;
when "0110"=>
cdt_min1s <=x"36" ;
when "0111"=>
cdt_min1s <=x"37" ;
when "1000"=>
cdt_min1s <=x"38" ;
when "1001"=>
cdt_min1s <=x"39" ;
when others =>
cdt_min1s <= x"30" ;
end case ;
end process ;
----------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------------
---------------ADT SEC-------------------------------------------------
-------===============================================
process ( cdt_sec1)
begin
case (cdt_sec1 ) is
when "0000" =>
cdt_sec1s <=x"30" ;
when "0001"=>
cdt_sec1s <=x"31" ;
when "0010"=>
cdt_sec1s <=x"32" ;
when "0011"=>
cdt_sec1s <=x"33" ;
when "0100"=>
cdt_sec1s <=x"34" ;
when "0101"=>
cdt_sec1s <=x"35" ;
when "0110"=>
cdt_sec1s <=x"36" ;
when "0111"=>
cdt_sec1s <=x"37" ;
when "1000"=>
cdt_sec1s <=x"38" ;
when "1001"=>
cdt_sec1s <=x"39" ;
when others =>
cdt_sec1s <= x"30" ;
end case ;
end process ;
process ( cdt_sec10)
begin
case cdt_sec10 is
when "0000" =>
cdt_sec10s <=x"30" ;
when "0001"=>
cdt_sec10s <=x"31" ;
when "0010"=>
cdt_sec10s <=x"32" ;
when "0011"=>
cdt_sec10s <=x"33" ;
when "0100"=>
cdt_sec10s <=x"34" ;
when "0101"=>
cdt_sec10s <=x"35" ;
when "0110"=>
cdt_sec10s <=x"36" ;
when "0111"=>
cdt_sec10s <=x"37" ;
when "1000"=>
cdt_sec10s <=x"38" ;
when "1001"=>
cdt_sec10s <=x"39" ;
when others =>
cdt_sec10s <= x"30" ;
end case ;
end process ;
------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------
adt_string <=( x"41" ,x"44" ,x"54" , x"3a",x"20" ,x"20" ) ;
adt <= adt_string (conv_integer ( str_count ) ) ;
cdt_string <=(x"43" , x"44" , x"54" ,x"3a",x"20" ,x"20" );
cdt <= cdt_string ( conv_integer ( str_count)) ;
-- BIDIRECTIONAL TRI STATE LCD DATA BUS
data_out <= data_bus when lcd_rw_int = '0' else "ZZZZZZZZ";
-- LCD_RW PORT is assigned to it matching SIGNAL
rw <= lcd_rw_int;
e<=lcd_e ;
rs <=lcd_rs ;
process ( clk )
begin
if rising_edge ( clk) then
if ( rst='1') then
clock_count <=(others=>'0') ;
clk_enable400<='0' ;
else
if ( clock_count <= 416) then -----------240 khz enable signal for zedboard working 100 mhz
-- if ( clock_count <= 99999) then -----------240 khz enable signal for zedboard working 100 mhz
-- if ( clock_count <= 99999) then -----------240 khz enable signal for zedboard working 100 mhz
-- if ( clock_count <= 24999) then ----------- working 4khz final
clock_count <= clock_count +1 ;
clk_enable400 <='0' ;
else
clock_count<=(others=>'0') ;
clk_enable400 <='1';
end if ;
end if ;
end if ;
end process ;
------------xx-------------------------
process ( clk, rst )
begin
if (rst='1') then
one_mscounter <=0;
f1khz <='0';
elsif rising_edge( clk) then
-- if ( one_mscounter =835) then ---- for zedboard default 120 khz
if ( one_mscounter =417) then ---- for zedboard default 120 khz
-- if ( one_mscounter =4999) then -------for 10 mhz clock
-- if ( one_mscounter =62499) then -------for 1khz clock for zybo ----working
one_mscounter <=0;
f1khz <= not (f1khz) ;
else
one_mscounter <= one_mscounter +1 ;
end if ;
end if ;
end process;
------------------------------------------------------------------
---------------statemachine cotnrol-----------------------------
--------------------------------------------------------------------
process ( f1khz,rst)
begin
if (rst='1') then
state <= power_up;
data_bus <= x"38"; -- RESET ---default
-- data_bus <= x"01"; -- --- x"01"; -- clearing the display
-- next_command <= reset2;
next_command <= reset1;
lcd_e <= '1'; ------------enableing data in 120 khz half of the clk_enable
lcd_rs <= '0';
lcd_rw_int <= '0';
str_count <= "0000" ;
wait_count <=(others=>'0') ;
space_count <=0;
message_count<=(others=>'0') ;
elsif rising_edge(f1khz) then
-- if clk_enable400 = '1' then
case (state ) is
when power_up =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
if ( wait_count =512) then ------ testing
wait_count <=(others=>'0') ;
next_command <= reset1; ----500 ms reached
else
wait_count <= wait_count +1 ;
end if ;
char_count <= "00000";
if ( preset='1') then
next_command <= rst1 ;
end if ;
--======================= INITIALIZATION START ============================--
when reset1 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
-- next_command <= reset2;
-- if ( wait_count =250) then ------ working
if ( wait_count =512) then ------ testing
wait_count <=(others=>'0') ;
next_command <= reset2; ----500 ms reached
else
wait_count <= wait_count +1 ;
end if ;
char_count <= "00000";
if ( preset='1') then
next_command <= rst1 ;
end if ;
when reset2 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
next_command <= reset3;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when reset3 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- EXTERNAL RESET
state <= drop_lcd_e;
next_command <= func_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-- Function Set
--==============--
when func_set =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; -- Set Function to 8-bit transfer, 2 line display and a 5x8 Font size
state <= drop_lcd_e;
next_command <= display_off; ---default working
-- next_command <= display_clear;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-- Turn off Display
--==============--
when display_off =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"08"; -- Turns OFF the Display, Cursor OFF and Blinking Cursor Position OFF.......
-- data_bus <= x"0D"; -- (0F = Display ON and Cursor ON, Blinking cursor position ON)
state <= drop_lcd_e;
next_command <= display_clear;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-- Clear Display
--==============--
when display_clear =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"01"; -- Clears the Display
state <= drop_lcd_e;
next_command <= display_on;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-- Turn on Display and Turn off cursor
--===================================--
when display_on =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"0C"; -- Turns on the Display (0E = Display ON, Cursor ON and Blinking cursor OFF)
-- data_bus <= x"0D";
state <= drop_lcd_e;
-- next_command <= mode_set;
-- next_command <= char_mode;
next_command <= dram_address;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-----------------enable while inputing from keypad
when cursor_shift =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"14";
state <= drop_lcd_e;
next_command <= mode_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when char_mode =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"17";
state <= drop_lcd_e;
next_command <= mode_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when dram_address =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= "10000001";
state <= drop_lcd_e;
next_command <= mode_set;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-- Set write mode to auto increment address and move cursor to the right
--====================================================================--
when mode_set =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"06"; -- Auto increment address and move cursor to the right
-- data_bus <= x"07";
state <= drop_lcd_e;
-- next_command <=st1 ;
-- next_command <=adt_a ;
next_command <=adt_state ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when adt_state =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt ;
next_command <=adt_state; ----added
if ( str_count ="0101") then
str_count <="0000" ;
next_command<=day100;
else
str_count <= str_count +1 ;
end if ;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
------------------------added code ------------------
when day100=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_d100s;
next_command<=day10;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when day10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_d10s;
next_command<=day1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when day1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_d1s;
next_command<=dcoln;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when dcoln=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=hour10;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when hour10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_hour10s;
next_command<=hour1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when hour1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_hour1s;
next_command<=coln2;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when coln2=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=min10;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when min10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_min10s;
next_command<=min1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when min1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_min1s;
next_command<=coln1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-----------------------------------------------------
when coln1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=sec10;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when sec10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_sec10s;
next_command<=sec1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when sec1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=adt_sec1s;
next_command<=line2;
-- next_command<=adt_space1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when adt_space1 =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"20" ;
if ( space_count=5) then
-- next_command<=adt_space2;
next_command<=line2;
else
space_count <= space_count +1 ;
end if ;
when adt_space2 =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"20" ;
next_command<=line2;
when line2 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"c0"; ---c0 default ---working
-- data_bus <= x"40";
state <= drop_lcd_e;
-- next_command<=cdt_c;
next_command<=line2_data;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdt_c =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"43" ;
next_command<=cdt_d;
when cdt_d =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"44" ;
next_command<=cdt_t;
when cdt_t =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"54" ;
next_command<=cdt_coln;
when cdt_coln =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"3a" ;
next_command<=cdt_space1;
when line2_data=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= cdt ;
next_command <=line2_data; ----added
if ( str_count ="0101") then
str_count <="0000" ;
next_command<=cdth10;
-- next_command<=line3;
else
str_count <= str_count +1 ;
end if ;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
----------------==========================cdt -timing
when cdth10=>
----------------------------
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=cdt_hour10s;
next_command<=cdth1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
--------------------------------
when cdth1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=cdt_hour1s;
next_command<=coln3;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when coln3=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"3a";
next_command<=cdtm10;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdtm10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_min10s;
next_command<=cdtm1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdtm1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_min1s;
next_command<=coln4;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
-----------------------------------------------------
when coln4=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=cdts10;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdts10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_sec10s;
next_command<=cdts1;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdts1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_sec1s;
next_command<=coln5 ;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when coln5=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=status;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when status =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
if ( status_reg ="00" ) then
data_bus <=x"30";
elsif ( status_reg="10" ) then
data_bus<=x"55" ;
elsif (status_reg="01" ) then
data_bus <=x"44" ;
elsif (status_reg="11" ) then
data_bus <=x"48" ;
else
data_bus <=x"55" ;
end if ;
next_command<=return_home;
if ( key_in=x"0004") then
next_command<=power_up;
end if ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when cdt_space1 =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"20" ;
if ( space_count=7) then
next_command<=line3;
else
space_count <= space_count +1 ;
end if ;
next_command<=cdt_space2;
when cdt_space2 =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"20" ;
next_command<=RETURN_HOME;
---------------added for keypad input ------------------
when st1=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"20";
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ; ---c0 default ---working
state <= drop_lcd_e;
next_command<=st2;
end if ;
if ( key_q =x"0008") then ----- 2
lcd_e <= '1';
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0002" ) then -------4
data_bus <= x"34" ;
state <= drop_lcd_e;
next_command<=st2;
end if;
if (key_q=x"0040" ) then ------5
data_bus <= x"35" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0200" ) then --------------6
data_bus <= x"36" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0001" ) then ------ 7
data_bus <= x"37" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0080" ) then ----- 8
data_bus <= x"38" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0400" ) then ------ 9
data_bus <= x"39" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=st2;
end if ;
if (key_q=x"0020" ) then -----cursor left a
-- data_bus <= x"10" ;
state <= drop_lcd_e;
next_command<=read_addr;
-- next_command<=st3;
end if ;
if (key_q=x"1000" ) then ------cursor right b
data_bus <= x"1C" ;
state <= drop_lcd_e;
next_command<=st4;
end if ;
if (key_q=x"2000" ) then ---------clear all c
data_bus <= x"01" ;
state <= drop_lcd_e;
next_command<=display_clear;
end if ;
if (key_q=x"4000" ) then -------return home d
data_bus <= x"02" ;
state <= drop_lcd_e;
next_command<=RETURN_HOME;
end if ;
if (key_q=x"0800" ) then -------enter time #
data_bus <= x"01" ;
state <= drop_lcd_e;
next_command<=ST5;
end if ;
if (key_q=x"8000" ) then -------save and exit *
data_bus <= x"02" ;
state <= drop_lcd_e;
next_command<=RETURN_HOME;
end if ;
when st2=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
wait_1sec <= wait_1sec+1 ;
data_bus <=x"20";
if ( wait_1sec=119617) then ---- .5 sec wait
-- if ( wait_1sec=169617) then ---- .5 sec wait
-- if ( wait_1sec=11000) then ---- .5 sec wait
wait_1sec <=0 ;
state<=st1 ;
-- state <= line4_data ;
end if ;
when st3=> ----CURSOR LEFT
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"10" ;
state <= drop_lcd_e;
next_command<=ST1;
when st4=> ---CURSOR RIGHT
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"1C" ;
state <= drop_lcd_e;
next_command<=st1;
when st5 =>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"41" ;
state <= drop_lcd_e;
next_command<=return_home;
when read_addr=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '1';
state <= drop_lcd_e;
next_command<=read_addr;
if (key_q=x"1000" ) then ------ when pressed b go to the state st1
next_command<=st1;
end if ;
if ( preset='1') then
next_command <= clear_screen ;
end if ;
-------------------xxxxxxxxx---------------------------------
when return_home =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"02"; ----just now commented
state <= drop_lcd_e;
next_command <=adt_state ;
if ( preset='1') then
next_command <= rst1 ;
end if ;
when drop_lcd_e =>
state <= next_command;
lcd_e <= '0';
when rst1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"01" ; ---- defualt working x"38";
next_command <= rst2;
when rst2=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38"; ---38 working defualt
if ( wait_count =512) then ------ testing
wait_count <=(others=>'0') ;
next_command <= func; ----500 ms reached
else
wait_count <= wait_count +1 ;
end if ;
when rst3=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38";
next_command <= rst4; ----500 ms reached
when rst4=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38";
next_command <= func; ----500 ms reached
when func=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"38";
-- next_command <= disp_off; ----500 ms reached WORKING
next_command <= disp_on; ----500 ms reached
when disp_off =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"08";
next_command <=clear_screen ; ----500 ms reached
when clear_screen=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"01";
next_command <= disp_on; ----500 ms reached
when disp_on =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"0C"; -- Turns on the Display (0E = Display ON, Cursor ON and Blinking cursor OFF)
-- data_bus <= "00001110"; ----display on , cursor on , blink off
next_command <= ADDR; ---- working default
-- next_command <= MODE;
when ADDR =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
-- data_bus <= "10000001"; ---dram selection
data_bus <= "01000000";------ cgram
next_command <= MODE;
when MODE =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"06";
next_command <= message_enter;
when message_enter=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= next_char;
next_command <=message_enter;
if ( message_count ="1111") then
message_count <="0000" ;
IF ( PRESET='1') THEN
next_command<=time_save;
else
next_command<=second_line;
-- next_command<=CURSOR_ON;
END IF ;
else
message_count <= message_count +1 ;
end if ;
when second_line=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"c0";
-- next_command<=second_linedata;
-- next_command<=input_data; ------ input numbe in the second line when the preset button is make zero working
next_command<=cdt_ih10;
when CURSOR_ON=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= "00010000";
state <= drop_lcd_e;
next_command<=time_save;
-- next_command<=cdt_ih10;
---------start added ------------------
when cdt_ih10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=cdt_hour10s;
next_command<=cdt_ih1;
-- if ( key_q =x"0004" ) then ------1
-- data_bus <= x"31" ;
-- state <= drop_lcd_e;
-- next_command<=delay_state;
-- elsif ( key_q =x"0008") then ----- 2
-- data_bus <=x"32" ;
-- state <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
when cdt_ih1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=cdt_hour1s;
next_command<=coln6;
-- if ( key_q =x"0008") then ----- 2
-- data_bus <=x"32" ;
-- state <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
when coln6=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"3a";
next_command<=cdt_im10;
when cdt_im10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_min10s;
next_command<=cdt_im1;
when cdt_im1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_min1s;
next_command<=coln7;
when coln7=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=x"3a";
next_command<=cdt_is10;
when cdt_is10=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_sec10s;
next_command<=cdt_is1;
when cdt_is1=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
----------------------------added
data_bus <=cdt_sec1s;
next_command<=line3 ;
if (key_q=x"8000" ) then -------save and exit *
state <= drop_lcd_e;
next_command<=power_up;
end if ;
if (key_q=x"0800" ) then ----# go to rst1 state
state <= drop_lcd_e;
next_command<=rst1;
end if ;
when line3 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"94"; ---c0 default ---working
state <= drop_lcd_e;
next_command<=line3_data;
when line3_data =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"41" ;
next_command<=line4;
when line4 =>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"d4"; ---c0 default ---working
state <= drop_lcd_e;
next_command<=line4_data;
when line4_data =>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"44";
-- next_command<=time_save;
next_command<=input_data ;
------------end --------------------------------------
when second_linedata=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"41";
next_command<=time_save;
when input_data=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
-- data_bus <=x"20";
next_command<=time_save;
if ( key_q =x"0004" ) then ------1
data_bus <= x"31" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if ( key_q =x"0008") then ----- 2
data_bus <=x"32" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"0010" ) then -------3
data_bus <= x"33" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"0002" ) then -------4
data_bus <= x"34" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if;
if (key_q=x"0040" ) then ------5
data_bus <= x"35" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"0200" ) then --------------6
data_bus <= x"36" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"0001" ) then ------ 7
data_bus <= x"37" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"0080" ) then ----- 8
data_bus <= x"38" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"0400" ) then ------ 9
data_bus <= x"39" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"0100" ) then ------ 0
data_bus <= x"30" ;
state <= drop_lcd_e;
next_command<=delay_state;
end if ;
if (key_q=x"8000" ) then -------save and exit *
data_bus <= x"02" ;
state <= drop_lcd_e;
next_command<=power_up;
end if ;
if (key_q=x"0800" ) then ----# go to rst1 state
data_bus <= x"02" ;
state <= drop_lcd_e;
next_command<=rst1;
end if ;
if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
data_bus <= x"10" ;
state <= drop_lcd_e;
next_command<=CURSOR_LEFT;
end if ;
if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
data_bus <= x"1C" ;
state <= drop_lcd_e;
next_command<=CURSOR_RIGHT;
end if ;
if (key_q=x"2000" ) then ----C WORTE WJATEVER PRESENT AT LAST IN PLAE OF C
data_bus <= x"43" ;
state <= drop_lcd_e;
next_command<=OVERIDE_C;
end if ;
if (key_q=x"4000" ) then ---D
data_bus <= x"02" ;
state <= drop_lcd_e;
next_command<=power_up ;
end if ;
when OVERIDE_C=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <= x"43" ;
-- state <= drop_lcd_e;
next_command<=input_data;
when CURSOR_LEFT=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"10" ;
-- state <= drop_lcd_e;
next_command<=input_data;
when CURSOR_RIGHT=>
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"1C" ;
-- state <= drop_lcd_e;
next_command<=input_data;
when delay_state=>
lcd_e <= '1';
lcd_rs <= '1';
lcd_rw_int <= '0';
data_bus <=x"20";
wait_1sec <= wait_1sec+1 ;
-- -- if ( wait_1sec=119617) then ---- .5 sec wait
-- if ( wait_1sec=110000) then ---- .5 sec wait
if ( wait_1sec=60000) then ---- .5 sec wait
-- if ( wait_1sec=6000) then ---- .5 sec wait
wait_1sec <=0 ;
-- state<=second_linedata ;
state<= input_data ; ----defualt working
-- state <=next_command;
end if ;
when time_save=>
state <= drop_lcd_e;
lcd_e <= '1';
lcd_rs <= '0';
lcd_rw_int <= '0';
data_bus <= x"02"; ----just now commented
next_command<=message_enter;
-- next_command<=input_data;
end case ;
end if ;
-- end if ;
end process ;
end Behavioral;-- Company:
--------------------------xxxx-------------------------------new -----------------------------------------updated---------------
------ Company: aujus technology pvt.ltd
------ Engineer: arun chaudhary
------
------ Create Date: 31.08.2020 13:24:34
------ Design Name: raystar oled cotrol -- timming dissimination
------ Module Name: oled_module_controllerv1 - Behavioral
------ Project Name: timming dissimination
------ Target Devices: zynq ,zedboard
------ Tool Versions: vivado 2018.3
------ Description:
------
------ Dependencies:
------
------ Revision:
------ Revision 0.01 - File Created
------ Additional Comments:
------
------------------------------------------------------------------------------------
------------------starting code -----------------
--library IEEE;
--use IEEE.STD_LOGIC_1164.ALL;
--USE IEEE.STD_LOGIC_ARITH.all;
--USE IEEE.STD_LOGIC_UNSIGNED.all;
--entity oled_module_controllerv1 is
-- Port ( clk : in STD_LOGIC;
-- rst : in STD_LOGIC;
-- preset : in std_logic ;
-- key_in: in std_logic_vector (0 to 15) ;
-- adt_sec10 : in std_logic_vector(3 downto 0) ;
-- status_reg : in std_logic_vector( 1 downto 0) ;
-- led : out std_logic_vector(1 downto 0) ;
-- cdt_hour10 , cdt_hour1, cdt_min10 ,cdt_min1, cdt_sec10 ,cdt_sec1 : in std_logic_vector (3 downto 0) ;
-- adt_day100,adt_day10 ,adt_day1 : in std_logic_Vector ( 3 downto 0) ;
-- adt_sec1 : in std_logic_vector( 3 downto 0) ;
-- adt_min10, adt_min1 : in std_logic_vector( 3 downto 0) ;
-- adt_hour10,adt_hour1:in std_logic_vector( 3 downto 0) ;
-- data_out : inout STD_LOGIC_vector( 7 downto 0) ;
-- rs : out STD_LOGIC;
-- rw : out STD_LOGIC;
-- e : out STD_LOGIC;
-- dac_a0 , dac_scl, dac_sda : out std_logic );
--end oled_module_controllerv1;
--architecture Behavioral of oled_module_controllerv1 is
--type state_type is ( power_up,reset1, func_set,display_clear, display_on, dram_address,mode_set, adt_state,day100,day10 ,day1,dcoln,hour10 , hour1,coln2,min10,min1 ,
-- coln1, sec10,sec1 ,
-- line2, line2_data, cdth10 ,cdth1, coln3,cdtm10,cdtm1, coln4,cdts10,cdts1, coln5,status , rst1,func, clear_screen ,disp_on, MODE ,ADDR, message_enter ,
-- second_line,second_linedata, input_data , delay_state,time_save,return_home, drop_lcd_e );
-- signal state_reg, state_next ,next_command : state_type;
--signal data_bus : std_logic_vector ( 7 downto 0) ;
--signal lcd_e, lcd_rs, lcd_rw_int : std_Logic ;
--signal lcd_e_reg , lcd_e_next , lcd_rs_reg , lcd_rs_next , lcd_rw_int_reg , lcd_rw_int_next : std_logic ;
--signal clk_enable400 : std_logic :='0' ;
--type character_string is array ( 0 to 13 ) of STD_LOGIC_VECTOR( 7 downto 0 );
-- signal lcd_display_string : character_string;
-- signal next_char : STD_LOGIC_VECTOR(7 downto 0);
--------------------adt ------------
--type str1 is array ( 0 to 5) of std_logic_Vector ( 7 downto 0) ;
--signal adt_string,cdt_string : str1;
--signal adt :std_logic_vector ( 7 downto 0) ;
--signal cdt: std_logic_vector( 7 downto 0) ;
--signal str_count_reg , str_count_next : std_logic_vector( 3 downto 0) :="0000" ;
--signal wait_count_reg , wait_count_next : std_logic_vector( 19 downto 0) := (others=>'0') ;
--signal adt_d1s: std_logic_vector ( 7 downto 0) ;
--signal adt_d10s : std_logic_vector ( 7 downto 0) ;
--signal adt_d100s: std_logic_vector ( 7 downto 0) ;
--signal adt_sec1s: std_logic_vector ( 7 downto 0) ;
--signal adt_sec10s : std_logic_vector ( 7 downto 0) ;
--signal adt_min1s: std_logic_vector ( 7 downto 0) ;
--signal adt_min10s : std_logic_vector ( 7 downto 0) ;
--signal adt_hour1s: std_logic_vector ( 7 downto 0) ;
--signal adt_hour10s : std_logic_vector ( 7 downto 0) ;
----------------------------cdt--------------------------------
--signal cdt_sec1s: std_logic_vector ( 7 downto 0) ;
--signal cdt_sec10s : std_logic_vector ( 7 downto 0) ;
--signal cdt_min1s: std_logic_vector ( 7 downto 0) ;
--signal cdt_min10s : std_logic_vector ( 7 downto 0) ;
--signal cdt_hour1s: std_logic_vector ( 7 downto 0) ;
--signal cdt_hour10s : std_logic_vector ( 7 downto 0) ;
-----------------------xxxxxxxxxxxxxxxx----------
--signal key_stored, fkey_stored: std_logic_vector( 7 downto 0) ;
--signal key_q : std_logic_vector( 0 to 15 ) ;
---------status -register ---------
-- signal wait_1sec_reg, wait_1sec_next :std_logic_vector (14 downto 0 ) :=(others=>'0') ; ----- integer range 0 to 239999 := 0 ;
--signal one_mscounter : natural range 0 to 49999 :=0 ; -------counter for 10 mhz clock enable for 10 mhz checking
--signal f1khz : std_logic ;
--signal message_count_reg , message_count_next : std_logic_Vector ( 3 downto 0) :=(others=>'0') ;
--signal data_bus_reg , data_bus_next : std_logic_vector ( 7 downto 0) ;
--attribute mark_debug : string ;
--attribute mark_debug of key_q : signal is "true" ;
----attribute mark_debug of lcd_e : signal is "true" ;
----attribute mark_debug of lcd_rs : signal is "true" ;
----attribute mark_debug of lcd_rw_int : signal is "true" ;
----attribute mark_debug of data_bus : signal is "true" ;
--attribute mark_debug of preset : signal is "true" ;
--begin
---- dac_a0<=lcd_rs ;
---- dac_scl<= lcd_rw_int;
---- dac_sda<=lcd_e ;
-----------------=============================
--lcd_display_string <=( X"45" , X"6E" , X"74" ,X"65" , X"72" , X"20" ,X"63" , X"64" , X"74" , X"20" , X"54" , X"69" , X"6D" , X"65" ) ;
--next_char <= lcd_display_string( conv_integer( message_count_reg)) ;
-----------===============================
--process(clk )
-- begin
-- if rising_edge ( clk ) then
-- if (clk_enable400='1') then
-- key_q <= key_in ;
-- end if ;
-- end if ;
--end process ;
----process( key_in)
---- begin
---- case key_in is
---- when x"4000" =>
---- key_stored<=x"30" ;
---- when x"2000"=>
---- key_stored<=x"31" ;
---- when x"1000"=>
---- key_stored <=x"32" ;
---- when x"0020"=>
---- key_stored<=x"33" ;
---- when x"0800"=>
---- key_stored <=x"34" ;
---- when x"0400"=>
---- key_stored <=x"35" ;
---- when x"0200"=>
---- key_stored<=x"36" ;
---- when x"0010"=>
---- key_stored <=x"37" ;
---- when x"0100"=>
---- key_stored <=x"38" ;
---- when x"0080"=>
---- key_stored <=x"39" ;
---- when x"0040"=>
---- key_stored <=x"40" ;
---- when x"0008"=>
---- key_stored <=x"41" ;
---- when x"8000"=>
---- key_stored <=x"42" ;
---- when x"0001"=>
---- key_stored <=x"43" ;
---- when x"0002"=>
---- key_stored <=x"44" ;
---- when x"0004"=>
---- key_stored <=x"45" ;
---- when others =>
---- key_stored <= x"20" ;
---- end case ;
---- end process ;
-------------------xxxxxxxxx----------------------------
-------------adt day---------------------------------
----------------------------------------------
--process ( adt_day1) begin
-- case adt_day1 is
-- when "0000" =>
-- adt_d1s<=x"30" ;
-- when "0001"=>
-- adt_d1s<=x"31" ;
-- when "0010"=>
-- adt_d1s <=x"32" ;
--when "0011"=>
-- adt_d1s<=x"33" ;
-- when "0100"=>
-- adt_d1s <=x"34" ;
--when "0101"=>
-- adt_d1s <=x"35" ;
-- when others=>
-- adt_d1s <=x"30" ;
-- end case ;
--end process ;
--process ( adt_day10) begin
-- case adt_day10 is
-- when "0000" =>
-- adt_d10s<=x"30" ;
-- when "0001"=>
-- adt_d10s<=x"31" ;
-- when "0010"=>
-- adt_d10s <=x"32" ;
--when "0011"=>
-- adt_d10s<=x"33" ;
-- when "0100"=>
-- adt_d10s <=x"34" ;
--when "0101"=>
-- adt_d10s <=x"35" ;
--when "0110"=>
-- adt_d10s<=x"36" ;
-- when others=>
-- adt_d10s <=x"30" ;
-- end case ;
--end process ;
--process ( adt_day100) begin
-- case adt_day100 is
-- when "0000" =>
-- adt_d100s<=x"30" ;
-- when "0001"=>
-- adt_d100s<=x"31" ;
-- when "0010"=>
-- adt_d100s <=x"32" ;
--when "0011"=>
-- adt_d100s<=x"33" ;
-- when others=>
-- adt_d100s <=x"30" ;
-- end case ;
--end process ;
------------------------------XXXXXXXXXXXXXXXXXX---------------------------------
--------------------ADT HOUR ---------------------------------------------------
------------=============================================
--process ( adt_hour10)
--begin
-- case adt_hour10 is
-- when "0000" =>
-- adt_hour10s<=x"30" ;
-- when "0001"=>
-- adt_hour10s<=x"31" ;
-- when "0010"=>
-- adt_hour10s <=x"32" ;
--when "0011"=>
-- adt_hour10s<=x"33" ;
--when "0100"=>
-- adt_hour10s <=x"34" ;
--when "0101"=>
-- adt_hour10s <=x"35" ;
--when "0110"=>
-- adt_hour10s<=x"36" ;
--when "0111"=>
-- adt_hour10s <=x"37" ;
--when "1000"=>
-- adt_hour10s <=x"38" ;
--when "1001"=>
-- adt_hour10s <=x"39" ;
-- when others =>
-- adt_hour10s <= x"30" ;
--end case ;
--end process ;
--process ( adt_hour1)
--begin
-- case adt_hour1 is
-- when "0000" =>
-- adt_hour1s<=x"30" ;
-- when "0001"=>
-- adt_hour1s <=x"31" ;
-- when "0010"=>
-- adt_hour1s<=x"32" ;
--when "0011"=>
-- adt_hour1s <=x"33" ;
--when "0100"=>
-- adt_hour1s <=x"34" ;
--when "0101"=>
-- adt_hour1s <=x"35" ;
--when "0110"=>
-- adt_hour1s <=x"36" ;
--when "0111"=>
-- adt_hour1s <=x"37" ;
--when "1000"=>
-- adt_hour1s <=x"38" ;
--when "1001"=>
-- adt_hour1s <=x"39" ;
-- when others =>
-- adt_hour1s <= x"30" ;
--end case ;
--end process ;
------------------------XXXXXXXXXXXXXXXXX-------------------------------
----------------------ADT MIN-------------------------------------------------
--------------------======================================
--process ( adt_min10)
--begin
-- case adt_min10 is
-- when "0000" =>
-- adt_min10s<=x"30" ;
-- when "0001"=>
-- adt_min10s <=x"31" ;
-- when "0010"=>
-- adt_min10s <=x"32" ;
--when "0011"=>
-- adt_min10s <=x"33" ;
--when "0100"=>
-- adt_min10s <=x"34" ;
--when "0101"=>
-- adt_min10s <=x"35" ;
--when "0110"=>
-- adt_min10s <=x"36" ;
--when "0111"=>
-- adt_min10s <=x"37" ;
--when "1000"=>
-- adt_min10s <=x"38" ;
--when "1001"=>
-- adt_min10s <=x"39" ;
-- when others =>
-- adt_min10s <= x"30" ;
--end case ;
--end process ;
--process ( adt_min1)
--begin
-- case adt_min1 is
-- when "0000" =>
-- adt_min1s<=x"30" ;
-- when "0001"=>
-- adt_min1s <=x"31" ;
-- when "0010"=>
-- adt_min1s <=x"32" ;
--when "0011"=>
-- adt_min1s <=x"33" ;
--when "0100"=>
-- adt_min1s <=x"34" ;
--when "0101"=>
-- adt_min1s <=x"35" ;
--when "0110"=>
-- adt_min1s <=x"36" ;
--when "0111"=>
-- adt_min1s <=x"37" ;
--when "1000"=>
-- adt_min1s <=x"38" ;
--when "1001"=>
-- adt_min1s <=x"39" ;
-- when others =>
-- adt_min1s <= x"30" ;
--end case ;
--end process ;
------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------------
-----------------ADT SEC-------------------------------------------------
---------===============================================
-- process ( adt_sec1)
-- begin
-- case (adt_sec1 ) is
-- when "0000" =>
-- adt_sec1s <=x"30" ;
-- when "0001"=>
-- adt_sec1s <=x"31" ;
-- when "0010"=>
-- adt_sec1s <=x"32" ;
-- when "0011"=>
-- adt_sec1s <=x"33" ;
-- when "0100"=>
-- adt_sec1s <=x"34" ;
-- when "0101"=>
-- adt_sec1s <=x"35" ;
-- when "0110"=>
-- adt_sec1s <=x"36" ;
-- when "0111"=>
-- adt_sec1s <=x"37" ;
-- when "1000"=>
-- adt_sec1s <=x"38" ;
-- when "1001"=>
-- adt_sec1s <=x"39" ;
-- when others =>
-- adt_sec1s <= x"30" ;
-- end case ;
-- end process ;
-- process ( adt_sec10)
-- begin
-- case adt_sec10 is
-- when "0000" =>
-- adt_sec10s <=x"30" ;
-- when "0001"=>
-- adt_sec10s <=x"31" ;
-- when "0010"=>
-- adt_sec10s <=x"32" ;
--when "0011"=>
-- adt_sec10s <=x"33" ;
--when "0100"=>
-- adt_sec10s <=x"34" ;
--when "0101"=>
-- adt_sec10s <=x"35" ;
--when "0110"=>
-- adt_sec10s <=x"36" ;
--when "0111"=>
-- adt_sec10s <=x"37" ;
--when "1000"=>
-- adt_sec10s <=x"38" ;
--when "1001"=>
-- adt_sec10s <=x"39" ;
-- when others =>
-- adt_sec10s <= x"30" ;
--end case ;
--end process ;
----------------=============================cdt=======================
------============================================================
------------------------------XXXXXXXXXXXXXXXXXX---------------------------------
--------------------CDT HOUR ---------------------------------------------------
------------=============================================
--process ( cdt_hour10)
--begin
-- case cdt_hour10 is
-- when "0000" =>
-- cdt_hour10s<=x"30" ;
-- when "0001"=>
-- cdt_hour10s<=x"31" ;
-- when "0010"=>
-- cdt_hour10s <=x"32" ;
--when "0011"=>
-- cdt_hour10s<=x"33" ;
--when "0100"=>
-- cdt_hour10s <=x"34" ;
--when "0101"=>
-- cdt_hour10s <=x"35" ;
--when "0110"=>
-- cdt_hour10s<=x"36" ;
--when "0111"=>
-- cdt_hour10s <=x"37" ;
--when "1000"=>
-- cdt_hour10s <=x"38" ;
--when "1001"=>
-- cdt_hour10s <=x"39" ;
-- when others =>
-- cdt_hour10s <= x"30" ;
--end case ;
--end process ;
--process ( cdt_hour1)
--begin
-- case cdt_hour1 is
-- when "0000" =>
-- cdt_hour1s<=x"30" ;
-- when "0001"=>
-- cdt_hour1s <=x"31" ;
-- when "0010"=>
-- cdt_hour1s<=x"32" ;
--when "0011"=>
-- cdt_hour1s <=x"33" ;
--when "0100"=>
-- cdt_hour1s <=x"34" ;
--when "0101"=>
-- cdt_hour1s <=x"35" ;
--when "0110"=>
-- cdt_hour1s <=x"36" ;
--when "0111"=>
-- cdt_hour1s <=x"37" ;
--when "1000"=>
-- cdt_hour1s <=x"38" ;
--when "1001"=>
-- cdt_hour1s <=x"39" ;
-- when others =>
-- cdt_hour1s <= x"30" ;
--end case ;
--end process ;
------------------------XXXXXXXXXXXXXXXXX-------------------------------
----------------------ADT MIN-------------------------------------------------
--------------------======================================
--process ( cdt_min10)
--begin
-- case cdt_min10 is
-- when "0000" =>
-- cdt_min10s<=x"30" ;
-- when "0001"=>
-- cdt_min10s <=x"31" ;
-- when "0010"=>
-- cdt_min10s <=x"32" ;
--when "0011"=>
-- cdt_min10s <=x"33" ;
--when "0100"=>
-- cdt_min10s <=x"34" ;
--when "0101"=>
-- cdt_min10s <=x"35" ;
--when "0110"=>
-- cdt_min10s <=x"36" ;
--when "0111"=>
-- cdt_min10s <=x"37" ;
--when "1000"=>
-- cdt_min10s <=x"38" ;
--when "1001"=>
-- cdt_min10s <=x"39" ;
-- when others =>
-- cdt_min10s <= x"30" ;
--end case ;
--end process ;
--process ( cdt_min1)
--begin
-- case cdt_min1 is
-- when "0000" =>
-- cdt_min1s<=x"30" ;
-- when "0001"=>
-- cdt_min1s <=x"31" ;
-- when "0010"=>
-- cdt_min1s <=x"32" ;
--when "0011"=>
-- cdt_min1s <=x"33" ;
--when "0100"=>
-- cdt_min1s <=x"34" ;
--when "0101"=>
-- cdt_min1s <=x"35" ;
--when "0110"=>
-- cdt_min1s <=x"36" ;
--when "0111"=>
-- cdt_min1s <=x"37" ;
--when "1000"=>
-- cdt_min1s <=x"38" ;
--when "1001"=>
-- cdt_min1s <=x"39" ;
-- when others =>
-- cdt_min1s <= x"30" ;
--end case ;
--end process ;
------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------------
-----------------ADT SEC-------------------------------------------------
---------===============================================
-- process ( cdt_sec1)
-- begin
-- case (cdt_sec1 ) is
-- when "0000" =>
-- cdt_sec1s <=x"30" ;
-- when "0001"=>
-- cdt_sec1s <=x"31" ;
-- when "0010"=>
-- cdt_sec1s <=x"32" ;
-- when "0011"=>
-- cdt_sec1s <=x"33" ;
-- when "0100"=>
-- cdt_sec1s <=x"34" ;
-- when "0101"=>
-- cdt_sec1s <=x"35" ;
-- when "0110"=>
-- cdt_sec1s <=x"36" ;
-- when "0111"=>
-- cdt_sec1s <=x"37" ;
-- when "1000"=>
-- cdt_sec1s <=x"38" ;
-- when "1001"=>
-- cdt_sec1s <=x"39" ;
-- when others =>
-- cdt_sec1s <= x"30" ;
-- end case ;
-- end process ;
-- process ( cdt_sec10)
-- begin
-- case cdt_sec10 is
-- when "0000" =>
-- cdt_sec10s <=x"30" ;
-- when "0001"=>
-- cdt_sec10s <=x"31" ;
-- when "0010"=>
-- cdt_sec10s <=x"32" ;
--when "0011"=>
-- cdt_sec10s <=x"33" ;
--when "0100"=>
-- cdt_sec10s <=x"34" ;
--when "0101"=>
-- cdt_sec10s <=x"35" ;
--when "0110"=>
-- cdt_sec10s <=x"36" ;
--when "0111"=>
-- cdt_sec10s <=x"37" ;
--when "1000"=>
-- cdt_sec10s <=x"38" ;
--when "1001"=>
-- cdt_sec10s <=x"39" ;
-- when others =>
-- cdt_sec10s <= x"30" ;
--end case ;
--end process ;
--------------------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-----------------------
--adt_string <=( x"41" ,x"44" ,x"54" , x"3a",x"20" ,x"20" ) ;
--adt <= adt_string (conv_integer ( str_count_reg ) ) ;
--cdt_string <=(x"43" , x"44" , x"54" ,x"3a",x"20" ,x"20" );
--cdt <= cdt_string ( conv_integer ( str_count_reg)) ;
---- BIDIRECTIONAL TRI STATE LCD DATA BUS
---- data_out <= data_bus when lcd_rw_int = '0' else "ZZZZZZZZ";
-- data_out <= data_bus_next when lcd_rw_int_next = '0' else "ZZZZZZZZ";
-- rw <= lcd_rw_int_next;
-- e<=lcd_e_next ;
-- rs <=lcd_rs_next ;
-------- LCD_RW PORT is assigned to it matching SIGNAL
---- rw <= lcd_rw_int;
---- e<=lcd_e ;
---- rs <=lcd_rs ;
--------------xx-------------------------
--process ( clk, rst )
-- begin
-- if (rst='1') then
-- one_mscounter <=0;
-- f1khz <='0';
-- elsif rising_edge( clk) then
-- if ( one_mscounter =4999) then ---- for zedboard default
---- if ( one_mscounter =4999) then -------for 10 mhz clock
-- one_mscounter <=0;
-- f1khz <= not (f1khz) ;
-- else
-- one_mscounter <= one_mscounter +1 ;
-- end if ;
-- end if ;
-- end process;
-- process (f1khz,rst)
-- begin
-- if ( rst='1') then
-- state_reg <=power_up ;
-- str_count_reg <=(others=>'0') ;
-- wait_count_reg <=(others=>'0') ;
-- message_count_reg<=(others=>'0') ;
-- data_bus_reg<=x"38";
-- lcd_rs_reg <='0';
-- lcd_e_reg <='1' ;
-- lcd_rw_int_reg <='0' ;
-- elsif rising_edge (f1khz) then
-- state_reg <= state_next;
-- str_count_reg <=str_count_next;
-- wait_count_reg <=wait_count_next;
-- message_count_reg<=message_count_next ;
-- data_bus_reg<=data_bus_next ;
-- lcd_rs_reg <= lcd_rs_next ;
-- lcd_e_reg <=lcd_e_next ;
-- lcd_rw_int_reg <=lcd_rw_int_next ;
-- end if ;
-- end process ;
-- process( state_reg, str_count_reg,wait_count_reg,next_command,key_q,status_reg,preset,message_count_reg,data_bus_reg,lcd_rs_reg,lcd_e_reg ,lcd_rw_int_reg )
-- begin
-- state_next <= state_reg ;
-- str_count_next <= str_count_reg ;
-- wait_count_next<=wait_count_reg ;
-- message_count_next <= message_count_reg;
-- data_bus_next <= data_bus_reg;
-- lcd_rs_next <= lcd_rs_reg ;
-- lcd_e_next <= lcd_e_reg ;
-- lcd_rw_int_next <= lcd_rw_int_reg ;
-- case state_reg is
-- when power_up =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= x"38"; -- EXTERNAL RESET
-- data_bus_next <= x"38";
-- state_next<= drop_lcd_e;
-- if ( wait_count_reg =512) then ------ testing
-- wait_count_next <=(others=>'0') ;
-- next_command <= reset1; ----500 ms reached
-- else
-- wait_count_next <= wait_count_reg +1 ;
-- end if ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when reset1 =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= x"38"; -- EXTERNAL RESET
-- data_bus_next <= x"38";
-- state_next <= drop_lcd_e;
-- if ( wait_count_reg =312) then ------ testing
-- wait_count_next <=(others=>'0') ;
-- next_command <= func_set; ----500 ms reached
-- else
-- wait_count_next <= wait_count_reg +1 ;
-- end if ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when func_set =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= x"38"; -- Set Function to 8-bit transfer, 2 line display and a 5x8 Font size
-- data_bus_next <= x"38";
-- state_next <= drop_lcd_e;
-- next_command <= display_clear;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when display_clear =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= x"01"; -- Clears the Display
-- data_bus_next <= x"01";
-- state_next <= drop_lcd_e;
-- next_command <= display_on;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when display_on =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= x"0C"; -- Turns on the Display (0E = Display ON, Cursor ON and Blinking cursor OFF)
-- data_bus_next <= x"0C";
-- state_next <= drop_lcd_e;
---- next_command <= dram_address;
-- next_command <= mode_set;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when dram_address =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= "10000001";
-- data_bus_next <= x"81";
-- state_next <= drop_lcd_e;
-- next_command <= mode_set;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when mode_set =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= x"06"; -- Auto increment address and move cursor to the right
-- data_bus_next <= x"06";
-- state_next <= drop_lcd_e;
-- next_command <=adt_state ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when adt_state =>
-- state_next<= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt ;
-- data_bus_next <= adt;
-- if ( str_count_reg ="0101") then
-- str_count_next <="0000" ;
-- next_command<=day100;
---- next_command<=return_home;
-- else
-- str_count_next <= str_count_reg +1 ;
-- end if ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when day100=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_d100s;
-- data_bus_next <= adt_d100s;
-- next_command<=day10;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when day10=>
-- state_next<= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_d10s;
-- data_bus_next <= adt_d10s;
-- next_command<=day1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when day1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_d1s;
-- data_bus_next <= adt_d1s;
-- next_command<=dcoln;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when dcoln=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=x"3a";
-- data_bus_next <=x"3a";
-- next_command<=hour10;
-- if ( key_in=x"0004") then
-- next_command<=power_up;
-- end if ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when hour10=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_hour10s;
-- data_bus_next <=adt_hour10s;
-- next_command<=hour1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when hour1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_hour1s;
-- data_bus_next <=adt_hour1s;
-- next_command<=coln2;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when coln2=>
-- state_next<= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=x"3a";
-- data_bus_next <=x"3a";
-- next_command<=min10;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when min10=>
-- state_next<= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_min10s;
-- data_bus_next <=adt_min10s;
-- next_command<=min1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when min1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_min1s;
-- data_bus_next <=adt_min1s;
-- next_command<=coln1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- -----------------------------------------------------
-- when coln1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=x"3a";
-- data_bus_next <=x"3a";
-- next_command<=sec10;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when sec10=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_sec10s;
-- data_bus_next <=adt_sec10s;
-- next_command<=sec1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when sec1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=adt_sec1s;
-- data_bus_next <=adt_sec1s;
-- next_command<=line2;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when line2 =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
---- data_bus <= x"c0"; ---c0 default ---working
-- data_bus_next <=x"C0";
-- state_next <= drop_lcd_e;
-- next_command<=line2_data;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when line2_data=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <= cdt ;
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=cdt;
-- if ( str_count_reg ="0101") then
-- str_count_next <="0000" ;
-- next_command<=cdth10;
-- else
-- str_count_next <= str_count_reg +1 ;
-- end if ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when cdth10=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <=cdt_hour10s;
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=cdt_hour10s;
-- next_command<=cdth1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- --------------------------------
-- when cdth1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <=cdt_hour1s;
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=cdt_hour1s;
-- next_command<=coln3;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when coln3=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <=x"3a";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"3a";
-- next_command<=cdtm10;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when cdtm10=>
-- state_next<= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- ----------------------------added
---- data_bus <=cdt_min10s;
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=cdt_min10s;
-- next_command<=cdtm1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when cdtm1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- ----------------------------added
---- data_bus <=cdt_min1s;
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=cdt_min1s;
-- next_command<=coln4;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- -----------------------------------------------------
-- when coln4=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- ----------------------------added
---- data_bus <=x"3a";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"3a";
-- next_command<=cdts10;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when cdts10=>
-- state_next<= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
---- data_bus <=cdt_sec10s;
-- data_bus_next <=cdt_sec10s ;
-- next_command<=cdts1;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when cdts1=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- ----------------------------added
---- data_bus <=cdt_sec1s;
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=cdt_sec1s ;
-- next_command<=coln5 ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when coln5=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- ----------------------------added
---- data_bus <=x"3a";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"3a";
-- next_command<=status;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when status =>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- ----------------------------added
-- if ( status_reg ="00" ) then
---- data_bus <=x"30";
-- data_bus_next <=x"30";
-- elsif ( status_reg="10" ) then
---- data_bus<=x"55" ;
-- data_bus_next <=x"55";
-- elsif (status_reg="01" ) then
---- data_bus <=x"44" ;
-- data_bus_next <=x"44";
-- elsif (status_reg="11" ) then
---- data_bus <=x"48" ;
-- data_bus_next <=x"48";
-- else
---- data_bus <=x"55" ;
-- data_bus_next <=x"55";
-- end if ;
-- next_command<=return_home;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when return_home =>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"02"; ----just now commented
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <= x"80";
-- state_next <= drop_lcd_e;
-- next_command <=adt_state ;
---- next_command <=st1 ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when drop_lcd_e =>
-- state_next <= next_command;
-- lcd_e_next <= '0' ;
-- if ( preset='1') then
-- next_command <= rst1 ;
-- end if ;
-- when rst1=>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"38";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"01";
-- state_next <= drop_lcd_e;
-- if ( wait_count_reg =312) then ------ testing
-- wait_count_next <=(others=>'0') ;
-- next_command <= func; ----500 ms reached
-- else
-- wait_count_next <= wait_count_reg +1 ;
-- end if ;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when func=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"38";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"38";
-- if ( wait_count_reg =512) then ------ testing
-- wait_count_next <=(others=>'0') ;
-- next_command <= clear_screen; ----500 ms reached
-- else
-- wait_count_next <= wait_count_reg +1 ;
-- end if ;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when clear_screen=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"01";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"01";
---- if ( wait_count_reg =) then ------ testing
---- wait_count_next <=(others=>'0') ;
-- next_command <= disp_on; ----500 ms reached
---- else
---- wait_count_next <= wait_count_reg +1 ;
---- end if ;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when disp_on =>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"0C"; -- Turns on the Display (0E = Display ON, Cursor ON and Blinking cursor OFF)
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"0C";
-- next_command <= MODE;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when MODE =>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"06";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=x"06";
-- next_command <= ADDR;
---- next_command <= message_enter;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when ADDR =>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= "10000001";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <="10000001";
-- next_command <= input_data;
-- str_count_next <=(others=>'0') ;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when message_enter=>
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <= NEXT_CHAR ;
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <=next_char;
-- state_next <= drop_lcd_e;
-- if ( message_count_reg =13 ) then
-- message_count_next <=(others=>'0') ;
---- next_command<=time_save;
-- next_command<=second_line;
-- else
-- message_count_next <= message_count_reg +1 ;
-- end if ;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when second_line=>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"c0"; ---c0 default ---working
---- data_bus <= x"C4";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <= x"c0";
-- state_next <= drop_lcd_e;
-- next_command<=second_linedata;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when second_linedata=>
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <=x"43";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <= x"43";
-- state_next <= drop_lcd_e;
-- next_command<=time_save;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when input_data=>
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <=x"20";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <= x"20";
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- if ( key_q =x"0004" ) then ------1
---- data_bus <= x"31" ;
-- data_bus_next <= x"31";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if ( key_q =x"0008") then ----- 2
---- data_bus <=x"32" ;
-- data_bus_next <= x"32";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"0010" ) then -------3
---- data_bus <= x"33" ;
-- data_bus_next <= x"33";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"0002" ) then -------4
---- data_bus <= x"34" ;
-- data_bus_next <= x"34";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if;
-- if (key_q=x"0040" ) then ------5
---- data_bus <= x"35" ;
-- data_bus_next <= x"35";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"0200" ) then --------------6
---- data_bus <= x"36" ;
-- data_bus_next <= x"36";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"0001" ) then ------ 7
---- data_bus <= x"37" ;
-- data_bus_next <= x"37";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"0080" ) then ----- 8
---- data_bus <= x"38" ;
-- data_bus_next <= x"38";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"0400" ) then ------ 9
---- data_bus <= x"39" ;
-- data_bus_next <= x"39";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"0100" ) then ------ 0
---- data_bus <= x"30" ;
-- data_bus_next <= x"30";
-- state_next <= drop_lcd_e;
-- next_command<=delay_state;
-- end if ;
-- if (key_q=x"8000" ) then -------save and exit *
---- data_bus <= x"02" ;
-- data_bus_next <= x"02";
-- state_next <= drop_lcd_e;
-- next_command<=rst1;
-- end if ;
---- if (key_q=x"0020" ) then ----A SHIFT THE CURSOR TO THE LIFT
---- data_bus <= x"10" ;
---- state <= drop_lcd_e;
---- next_command<=CURSOR_LEFT;
---- end if ;
---- if (key_q=x"1000" ) then ---B SHIFT THE DISPLAY AND CURSOR POSITION TO RIGHT
---- data_bus <= x"1C" ;
---- state <= drop_lcd_e;
---- next_command<=CURSOR_RIGHT;
---- end if ;
---- if (key_q=x"2000" ) then ----C WORTE WJATEVER PRESENT AT LAST IN PLAE OF C
---- data_bus <= x"43" ;
---- state <= drop_lcd_e;
---- next_command<=OVERIDE_C;
---- end if ;
---- if (key_q=x"0800" ) then ----# SAVE AND EXIT
---- data_bus <= x"02" ;
---- next_command<=time_save;
---- end if ;
---- if (key_q=x"8000" ) then ---* CLEAR A DISPLAY
---- data_bus <= x"01" ;
---- state <= drop_lcd_e;
---- next_command<=clear_screen;
---- end if ;
---- if (key_q=x"4000" ) then ---D
---- data_bus <= x"38" ;
---- state <= drop_lcd_e;
---- next_command<=reset2;
---- end if ;
---- when OVERIDE_C=>
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <= x"43" ;
---- state <= drop_lcd_e;
---- next_command<=second_linedata;
---- when CURSOR_LEFT=>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"10" ;
---- state <= drop_lcd_e;
---- next_command<=second_linedata;
---- when CURSOR_RIGHT=>
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"1C" ;
---- state <= drop_lcd_e;
---- next_command<=second_linedata;
-- when delay_state=>
---- lcd_e <= '1';
---- lcd_rs <= '1';
---- lcd_rw_int <= '0';
---- data_bus <=x"20";
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '1' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <= x"20";
-- wait_1sec_next <= wait_1sec_reg+1 ;
-- if ( wait_1sec_reg=110000) then ---- .5 sec wait
-- wait_1sec_next <=(others=>'0');
-- state_next<=second_linedata ;
-- end if ;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- when time_save=>
-- state_next <= drop_lcd_e;
---- lcd_e <= '1';
---- lcd_rs <= '0';
---- lcd_rw_int <= '0';
---- data_bus <= x"02"; ----just now commented
-- lcd_e_next <= '1' ;
-- lcd_rs_next <= '0' ;
-- lcd_rw_int_next <= '0' ;
-- data_bus_next <= x"02";
-- next_command<=message_enter;
-- if ( preset='0') then
-- next_command <= power_up ;
-- end if ;
-- end case ;
-- end process ;
--end Behavioral;-- Company:
---------end----updated------------------------------------------------------------------------------------------------------
No comments:
Post a Comment