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 library IEEE; 00023 use IEEE.STD_LOGIC_1164.ALL; 00024 use ieee.numeric_std.all; 00025 library grlib; 00026 use grlib.amba.all; 00027 use grlib.stdlib.all; 00028 use grlib.devices.all; 00029 library lpp; 00030 use lpp.amba_lcd_16x2_ctrlr.all; 00031 use lpp.LCD_16x2_CFG.all; 00032 use lpp.lpp_amba.all; 00033 use lpp.apb_devices_list.all; 00034 00035 entity apb_lcd_ctrlr is 00036 generic ( 00037 pindex : integer := 0; 00038 paddr : integer := 0; 00039 pmask : integer := 16#fff#; 00040 pirq : integer := 0; 00041 abits : integer := 8); 00042 port ( 00043 rst : in std_ulogic; 00044 clk : in std_ulogic; 00045 apbi : in apb_slv_in_type; 00046 apbo : out apb_slv_out_type; 00047 LCD_data : out STD_LOGIC_VECTOR (7 downto 0); 00048 LCD_RS : out STD_LOGIC; 00049 LCD_RW : out STD_LOGIC; 00050 LCD_E : out STD_LOGIC; 00051 LCD_RET : out STD_LOGIC; 00052 LCD_CS1 : out STD_LOGIC; 00053 LCD_CS2 : out STD_LOGIC; 00054 SF_CE0 : out std_logic 00055 ); 00056 end apb_lcd_ctrlr; 00057 00058 architecture Behavioral of apb_lcd_ctrlr is 00059 00060 signal FramBUFF : FRM_Buff_Space; 00061 signal CMD : std_logic_vector(10 downto 0); 00062 signal Exec : std_logic; 00063 signal Ready : std_logic; 00064 signal LCD_CTRL : LCD_DRVR_CTRL_BUSS; 00065 00066 00067 00068 constant REVISION : integer := 1; 00069 00070 constant pconfig : apb_config_type := ( 00071 0 => ahb_device_reg (VENDOR_LPP, LPP_LCD_CTRLR, 0, REVISION, 0), 00072 1 => apb_iobar(paddr, pmask)); 00073 00074 00075 --type FRM_Buff_El is std_logic_vector(31 downto 0); 00076 type FRM_Buff_Reg is array(lcd_space_size-1 downto 0) of std_logic_vector(31 downto 0); 00077 00078 00079 type LCD_ctrlr_Reg is record 00080 CTRL_Reg : std_logic_vector(31 downto 0); 00081 FRAME_BUFF : FRM_Buff_Reg; 00082 end record; 00083 00084 signal r : LCD_ctrlr_Reg; 00085 00086 signal Rdata : std_logic_vector(31 downto 0); 00087 00088 begin 00089 00090 LCD_data <= LCD_CTRL.LCD_DATA; 00091 LCD_RS <= LCD_CTRL.LCD_RS; 00092 LCD_RW <= LCD_CTRL.LCD_RW; 00093 LCD_E <= LCD_CTRL.LCD_E; 00094 00095 00096 LCD_RET <= '0'; 00097 LCD_CS1 <= '0'; 00098 LCD_CS2 <= '0'; 00099 00100 SF_CE0 <= '1'; 00101 00102 CMD(7 downto 0) <= r.CTRL_Reg(7 downto 0); --CMD value 00103 CMD(9 downto 8) <= r.CTRL_Reg(9 downto 8); --CMD tempo value 00104 00105 r.CTRL_Reg(10) <= Ready; 00106 00107 Driver0 : LCD_16x2_ENGINE 00108 generic map(50000) 00109 Port map(clk,rst,FramBUFF,CMD,Exec,Ready,LCD_CTRL); 00110 00111 FRM_BF : for i in 0 to lcd_space_size-1 generate 00112 FramBUFF(i) <= r.FRAME_BUFF(i)(7 downto 0); 00113 end generate; 00114 00115 00116 process(rst,clk) 00117 begin 00118 if rst = '0' then 00119 r.CTRL_Reg(9 downto 0) <= (others => '0'); 00120 Exec <= '0'; 00121 elsif clk'event and clk = '1' then 00122 00123 --APB Write OP 00124 if (apbi.psel(pindex) and apbi.penable and apbi.pwrite) = '1' then 00125 case apbi.paddr(7 downto 2) is 00126 when "000000" => 00127 r.CTRL_Reg(9 downto 0) <= apbi.pwdata(9 downto 0); 00128 Exec <= '1'; 00129 when others => 00130 writeC: for i in 1 to lcd_space_size loop 00131 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then 00132 r.FRAME_BUFF(i-1) <= apbi.pwdata; 00133 end if; 00134 Exec <= '0'; 00135 end loop; 00136 end case; 00137 else 00138 Exec <= '0'; 00139 end if; 00140 00141 --APB READ OP 00142 if (apbi.psel(pindex) and (not apbi.pwrite)) = '1' then 00143 case apbi.paddr(7 downto 2) is 00144 when "000000" => 00145 Rdata <= r.CTRL_Reg; 00146 when others => 00147 readC: for i in 1 to lcd_space_size loop 00148 if TO_INTEGER(unsigned(apbi.paddr(abits-1 downto 2))) =i then 00149 Rdata(7 downto 0) <= r.FRAME_BUFF(i-1)(7 downto 0); 00150 end if; 00151 end loop; 00152 end case; 00153 end if; 00154 00155 end if; 00156 apbo.pconfig <= pconfig; 00157 end process; 00158 00159 apbo.prdata <= Rdata when apbi.penable = '1' ; 00160 00161 end Behavioral; 00162 00163 00164 00165 00166 00167
© Copyright 2011 LPP-CNRS | Design by Alexis Jeandet