Free VHDL library

  • Main Page
  • Related Pages
  • Design Unit List
  • Files
  • File List

amba_lcd_16x2_ctrlr/LCD_16x2_DRVR.vhd

Go to the documentation of this file.
00001 ------------------------------------------------------------------------------
00002 --  This file is a part of the LPP VHDL IP LIBRARY
00003 --  Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
00004 --
00005 --  This program is free software; you can redistribute it and/or modify
00006 --  it under the terms of the GNU General Public License as published by
00007 --  the Free Software Foundation; either version 3 of the License, or
00008 --  (at your option) any later version.
00009 --
00010 --  This program is distributed in the hope that it will be useful,
00011 --  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 --  GNU General Public License for more details.
00014 --
00015 --  You should have received a copy of the GNU General Public License
00016 --  along with this program; if not, write to the Free Software
00017 --  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00018 -------------------------------------------------------------------------------
00019 --                    Author : Alexis Jeandet
00020 --                     Mail : alexis.jeandet@lpp.polytechnique.fr
00021 -------------------------------------------------------------------------------
00022 
00023 ---TDODO => Clean Enable pulse FSM
00024 library IEEE;
00025 use IEEE.STD_LOGIC_1164.ALL;
00026 use IEEE.NUMERIC_STD.all;
00027 library lpp;
00028 use lpp.amba_lcd_16x2_ctrlr.all;
00029 use lpp.lcd_16x2_cfg.all;
00030 
00031 entity LCD_16x2_DRIVER is
00032         generic(
00033                 OSC_Freq_KHz     :      integer:=50000
00034         );
00035     Port( 
00036            reset      : in  STD_LOGIC;
00037            clk        : in  STD_LOGIC;
00038       LCD_CTRL    : out LCD_DRVR_CTRL_BUSS;
00039            SYNCH             : out LCD_DRVR_SYNCH_BUSS;
00040            DRIVER_CMD : in  LCD_DRVR_CMD_BUSS
00041                           );
00042 end LCD_16x2_DRIVER;
00043 
00044 architecture Behavioral of LCD_16x2_DRIVER is
00045 
00046 type stateT is (idle,Enable0,Enable1,Enable2,tempo);
00047 signal  state   :       stateT;
00048 
00049 
00050 constant        trigger_4us             :       integer := 5;
00051 constant        trigger_100us   :       integer := 100;
00052 constant        trigger_4ms             :       integer := 4200;
00053 constant        trigger_20ms    :       integer := 20000;
00054 
00055 
00056 signal  i                               :       integer :=0;
00057 signal  reset_i         :       std_logic := '0';
00058 signal  tempoTRIG       :       integer :=0;
00059 
00060 signal  clk_1us         :       std_logic;
00061 signal  clk_1us_reg     :       std_logic;
00062 
00063 begin
00064 
00065 
00066 CLK0: LCD_CLK_GENERATOR
00067          generic map(OSC_Freq_KHz)
00068     Port map( clk,reset,clk_1us);
00069 
00070 
00071 
00072 process(clk_1us,reset_i)
00073 begin
00074         if reset_i = '0' then
00075                 i       <=      0;
00076         elsif clk_1us'event and clk_1us ='1' then
00077                         i       <=      i+1;
00078         end if;
00079 end process;
00080 
00081 LCD_CTRL.LCD_RW <=      '0';
00082 
00083 process(clk,reset)
00084 begin
00085         if reset = '0' then
00086                 state   <=      idle;
00087                 LCD_CTRL.LCD_E                          <=      '0';
00088                 SYNCH.DRVR_READY                        <=      '0';
00089                 SYNCH.LCD_INITIALISED   <=      '0';
00090                 reset_i                                         <=      '0';
00091         elsif clk'event and clk = '1' then
00092                 case state is
00093                         when idle =>
00094                                 SYNCH.LCD_INITIALISED   <=      '1';
00095                                 LCD_CTRL.LCD_E                          <=      '0';
00096                                 if DRIVER_CMD.Exec = '1' then
00097                                         state   <=      Enable0;
00098                                         reset_i <=      '1';
00099                                         SYNCH.DRVR_READY                        <=      '0';
00100                                         LCD_CTRL.LCD_DATA       <=      DRIVER_CMD.Word;
00101                                         LCD_CTRL.LCD_RS <=      DRIVER_CMD.CMD_Data;
00102                                         case DRIVER_CMD.Duration is
00103                                                 when Duration_4us =>
00104                                                         tempoTRIG       <=      trigger_4us;
00105                                                 when Duration_100us =>
00106                                                         tempoTRIG       <=      trigger_100us;
00107                                                 when Duration_4ms =>
00108                                                         tempoTRIG       <=      trigger_4ms;
00109                                                 when Duration_20ms =>
00110                                                         tempoTRIG       <=      trigger_20ms;
00111                                                 when others =>
00112                                                         tempoTRIG       <=      trigger_20ms;
00113                                         end case;
00114                                 else
00115                                         SYNCH.DRVR_READY                        <=      '1';
00116                                         reset_i                                         <=      '0';
00117                                 end if;
00118                         when Enable0 =>
00119                                 if i = 1 then
00120                                         reset_i <=      '0';
00121                                         LCD_CTRL.LCD_E                          <=      '1';
00122                                         state   <=      Enable1;
00123                                 else
00124                                         reset_i <=      '1';
00125                                         LCD_CTRL.LCD_E                          <=      '0';
00126                                 end if;
00127                         when Enable1 =>
00128                                 if i = 2 then
00129                                         reset_i <=      '0';
00130                                         LCD_CTRL.LCD_E                          <=      '0';
00131                                         state   <=      Enable2;
00132                                 else
00133                                         reset_i <=      '1';
00134                                         LCD_CTRL.LCD_E                          <=      '1';
00135                                 end if;
00136                         when Enable2 =>
00137                                 if i = 1 then
00138                                         reset_i <=      '0';
00139                                         LCD_CTRL.LCD_E                          <=      '0';
00140                                         state   <=      tempo;
00141                                 else
00142                                         reset_i <=      '1';
00143                                         LCD_CTRL.LCD_E                          <=      '0';
00144                                 end if;
00145                         when tempo =>
00146                                 if i = tempoTRIG then
00147                                         reset_i <=      '0';
00148                                         state   <=      idle;
00149                                 else
00150                                         reset_i <=      '1';
00151                                 end if;
00152                 end case;
00153         end if;
00154 end process;
00155 
00156 end Behavioral;
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 

© Copyright 2011 LPP-CNRS | Design by Alexis Jeandet