00001 --**************************************************************
00002 --* *
00003 --* The source code for the ATLAS BCM "AAA" FPGA is made *
00004 --* available via the GNU General Public License (GPL) *
00005 --* unless otherwise stated below. *
00006 --* *
00007 --* In case of problems/questions/bug reports etc. please *
00008 --* contact michael.niegl@cern.ch *
00009 --* *
00010 --**************************************************************
00011
00012 --**************************************************************
00013 --* *
00014 --* $Source: /local/reps/bcmfpga/bcm_aaa/bcm_aaa/lcd/lcd_controller.vhd,v $ *
00015 --* $Revision: 1.9.2.3 $ *
00016 --* $Name: dev $ *
00017 --* $Author: mniegl $ *
00018 --* $Date: 2008/11/03 17:57:46 $ *
00019
00020
00021 --* *
00022 --**************************************************************
00023
00024
00025 library ieee;
00026
00027 use ieee.std_logic_1164.all;
00028
00029 use ieee.std_logic_arith.all;
00030
00031 use ieee.std_logic_unsigned.all;
00032
00033 library work;
00034 use work.lcd_characters.all;
00035 use work.main_components.all;
00036
00037
00038
00039 entity lcd_controller is
00040 port (
00041 CLOCK_LCD : in ;
00042 CLOCK_ANI_I : in ;
00043 CLOCK_ANI_II : in ;
00044 LINE_I : in lcd_line;
00045 LINE_II : in lcd_line;
00046 LINE_I_PAINT : in ;
00047 LINE_II_PAINT : in ;
00048 LINE_I_MODE : in (1 downto 0);
00049 LINE_II_MODE : in (1 downto 0);
00050 AUTO_REFRESH_I : in ;
00051 AUTO_REFRESH_II : in ;
00052 BUSY : out ;
00053 DIRECTION : out ;
00054 RS : out ;
00055 RW : out ;
00056 DB : inout (7 downto 0);
00057 E : out );
00058 end lcd_controller;
00059
00060 architecture lcd_controller_arc of lcd_controller is
00061
00062
00063 component lcd_commander is
00064 port (CLOCK : in ;
00065 IN_RS : in ;
00066 IN_DB : in (7 downto 0);
00067 STROBE : in ;
00068 BUSY : out := '1';
00069 RS : out ;
00070 RW : out ;
00071 DB : inout (7 downto 0);
00072 DIRECTION : out ;
00073 E : out );
00074 end component;
00075
00076 signal int_rs : := '0';
00077 signal int_strobe : := '0';
00078 signal int_busy : := '0';
00079 signal int_db : (7 downto 0) := "00000000";
00080 signal int_busy_commander : := '0';
00081
00082 signal int_sample_paint_I : := '0';
00083 signal int_sample_paint_II : := '0';
00084 signal int_line_I : lcd_line := (ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space);
00085 signal int_line_II : lcd_line := (ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space);
00086 signal int_text : lcd_line := (ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space);
00087
00088
00089 signal int_initialized : := '0';
00090 signal int_init_count : (3 downto 0) := "0000";
00091
00092
00093 signal int_state : (3 downto 0) := "0000";
00094 signal int_panint_state : (3 downto 0) := "0000";
00095 signal int_cycle : (1 downto 0) := "00";
00096
00097
00098 signal int_sample_clock_I : := '0';
00099 signal int_sample_clock_II : := '0';
00100 signal int_waiting_I : := '0';
00101 signal int_waiting_II : := '0';
00102 signal int_priority : := '0';
00103
00104
00105 signal int_line : (1 downto 0) := "00";
00106
00107
00108 signal int_counter_I : (4 downto 0) := "00000";
00109 signal int_counter_II : (4 downto 0) := "00000";
00110 signal int_move_I : := '1';
00111 signal int_move_II : := '1';
00112
00113
00114 signal int_character : range 0 to 16 := 0;
00115
00116 --signal int_orders : array (0 to 2) of std_logic_vector(2 downto 0);
00117 begin
00118
00119
00120 commander : lcd_commander port map (
00121 CLOCK => CLOCK_LCD ,
00122 IN_RS => int_rs,
00123 IN_DB => int_db,
00124 STROBE => int_strobe ,
00125 BUSY => int_busy_commander,
00126 RS => RS,
00127 RW => RW,
00128 DB => DB,
00129 DIRECTION => DIRECTION,
00130 E => E );
00131
00132
00133 lcd_clock : process (CLOCK_LCD) is --positive edges
00134 variable var_mode : (1 downto 0) := "00";
00135 variable move : range 0 to 31 := 0;
00136 begin
00137 if (CLOCK_LCD'event and CLOCK_LCD = '1') then
00138 if int_initialized = '0' then
00139 if int_init_count = "1000" then
00140 if int_state = "0000"then
00141
00142 int_state <= "0001";
00143 int_rs <= '0';
00144 int_db <= "00000001";
00145 elsif int_state = "0001" then
00146 int_state <= "0010";
00147 int_strobe <= '1';
00148 elsif int_state = "0010" then
00149 int_state <= "0011";
00150 int_strobe <= '0';
00151 elsif int_state = "0011" then
00152
00153 if int_busy_commander = '0' then
00154 int_state <= "0100";
00155
00156 int_rs <= '0';
00157 int_db <= "00111011";
00158 end if;
00159 elsif int_state = "0100" then
00160 int_state <= "0101";
00161 int_strobe <= '1';
00162 elsif int_state = "0101" then
00163 int_state <= "0110";
00164 int_strobe <= '0';
00165 elsif int_state = "0110" then
00166
00167 if int_busy_commander = '0' then
00168 int_state <= "0111";
00169
00170 int_rs <= '0';
00171 int_db <= "00001100";
00172 end if;
00173 elsif int_state = "0111" then
00174 int_state <= "1000";
00175 int_strobe <= '1';
00176 elsif int_state = "1000" then
00177 int_state <= "1001";
00178 int_strobe <= '0';
00179 elsif int_state = "1001" then
00180
00181 if int_busy_commander = '0' then
00182 int_state <= "1010";
00183
00184 int_rs <= '0';
00185 int_db <= "00000110";
00186 end if;
00187 elsif int_state = "1010" then
00188 int_state <= "1011";
00189 int_strobe <= '1';
00190 elsif int_state = "1011" then
00191 int_state <= "1100";
00192 int_strobe <= '0';
00193 elsif int_state = "1100" then
00194
00195 if int_busy_commander = '0' then
00196 int_state <= "0000";
00197 int_initialized <= '1';
00198 BUSY <= '0';
00199
00200 end if;
00201 end if;
00202 else
00203 int_init_count <= int_init_count + 1;
00204 end if;
00205 else
00206
00207 if int_line = "00" then
00208 if int_priority = '0' then
00209 if int_waiting_I = '1' then
00210 int_line <= "01";
00211 else
00212 int_priority <= not int_priority;
00213 end if;
00214 else
00215 if int_waiting_II = '1' then --the second line needs to be displayed
00216 int_line <= "10";
00217 else
00218 int_priority <= not int_priority;
00219 end if;
00220 end if;
00221 else
00222 if int_panint_state = "0000" then
00223 if int_line = "01" then
00224 var_mode := LINE_I_MODE;
00225 else
00226 var_mode := LINE_II_MODE;
00227 end if;
00228 if var_mode = "00" then
00229 if int_line = "01" then
00230 int_text <= int_line_I;
00231 else
00232 int_text <= int_line_II;
00233 end if;
00234 elsif var_mode = "01" then
00235
00236 if int_line = "01" then
00237 if int_move_I = '1' then
00238 int_counter_I <= int_counter_I + 1;
00239 end if;
00240 move := conv_integer(int_counter_I);
00241 else
00242 if int_move_II = '1' then
00243 int_counter_II <= int_counter_II + 1;
00244 end if;
00245 move := conv_integer(int_counter_II);
00246 end if;
00247
00248 for i in 0 to 15 loop
00249 if move <= 16 then
00250 if i < move then
00251 if int_line = "01" then
00252 int_text(i) <= int_line_I(i+16-move);
00253 else
00254 int_text(i) <= int_line_II(i+16-move);
00255 end if;
00256 else
00257 int_text(i) <= ch_space;
00258 end if;
00259 else
00260 if i < move-16 then
00261 int_text(i) <= ch_space;
00262 else
00263 if int_line = "01" then
00264 int_text(i) <= int_line_I(i+16-move);
00265 else
00266 int_text(i) <= int_line_II(i+16-move);
00267 end if;
00268 end if;
00269 end if;
00270 end loop;
00271
00272 elsif var_mode = "10" then
00273 if int_line = "01" then
00274 int_text <= int_line_I;
00275 else
00276 int_text <= int_line_II;
00277 end if;
00278
00279 if int_line = "01" then
00280 if int_move_I = '1' then
00281 int_counter_I <= int_counter_I + 1;
00282 end if;
00283 move := conv_integer(int_counter_I);
00284 else
00285 if int_move_II = '1' then
00286 int_counter_II <= int_counter_II + 1;
00287 end if;
00288 move := conv_integer(int_counter_II);
00289 end if;
00290
00291 for i in 0 to 15 loop
00292 if move <= 16 then
00293 if i < move then
00294 if int_line = "01" then
00295 int_text(i+16-move) <= int_line_I(i);
00296 else
00297 int_text(i+16-move) <= int_line_II(i);
00298 end if;
00299 else
00300 int_text(15-i) <= ch_space;
00301 end if;
00302 else
00303 if i < 32-move then
00304 if int_line = "01" then
00305 int_text(i) <= int_line_I(move-16+i);
00306 else
00307 int_text(i) <= int_line_II(move-16+i);
00308 end if;
00309 else
00310 int_text(i) <= ch_space;
00311 end if;
00312 end if;
00313 end loop;
00314 elsif var_mode = "11" then
00315
00316 if int_line = "01" then
00317 if int_move_I = '1' then
00318 int_counter_I <= int_counter_I + 1;
00319 end if;
00320 move := conv_integer(int_counter_I(0));
00321 else
00322 if int_move_II = '1' then
00323 int_counter_II <= int_counter_II + 1;
00324 end if;
00325 move := conv_integer(int_counter_II(0));
00326 end if;
00327 if move = 0 then
00328 if int_line = "01" then
00329 int_text <= int_line_I;
00330 else
00331 int_text <= int_line_II;
00332 end if;
00333 else
00334 int_text <= (ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space, ch_space);
00335 end if;
00336 end if;
00337 int_panint_state <= "0001";
00338 elsif int_panint_state = "0001" then
00339
00340 int_panint_state <= "0010";
00341 int_rs <= '0';
00342 if int_line = "01" then
00343 int_db <= "10000000";
00344 else
00345 int_db <= "11000000";
00346 end if;
00347 int_character <= 0;
00348 int_cycle <= "00";
00349 elsif int_panint_state = "0010" and int_cycle = "00" then
00350 int_strobe <= '1';
00351 int_cycle <= "01";
00352 elsif int_panint_state = "0010" and int_cycle = "01" then
00353 int_panint_state <= "0011";
00354 int_cycle <= "00";
00355 elsif int_panint_state = "0011" then
00356 int_panint_state <= "0100";
00357 int_strobe <= '0';
00358 int_rs <= '1';
00359 elsif int_panint_state = "0100" and int_cycle = "00" then
00360
00361 if int_busy_commander = '0' then
00362 if int_character = 16 then
00363 int_cycle <= "00";
00364 int_character <= 0;
00365 int_panint_state <= "0000";
00366
00367 int_priority <= not int_priority;
00368 int_line <= "00";
00369 if int_line = "01" then
00370 int_waiting_I <= '0';
00371 int_move_I <= '1';
00372 else
00373 int_waiting_II <= '0';
00374 int_move_II <= '1';
00375 end if;
00376 else
00377
00378 int_rs <= '1';
00379 int_db <= int_text(int_character);
00380 int_character <= int_character + 1;
00381 int_cycle <= "01";
00382 end if;
00383 end if;
00384 elsif int_panint_state = "0100" and int_cycle = "01" then
00385 int_cycle <= "10";
00386 int_strobe <= '1';
00387 elsif int_panint_state = "0100" and int_cycle = "10" then
00388 int_cycle <= "11";
00389 elsif int_panint_state = "0100" and int_cycle = "11" then
00390 int_cycle <= "00";
00391 int_strobe <= '0';
00392 end if;
00393 end if;
00394
00395
00396 if int_sample_paint_I = '0' and LINE_I_PAINT = '1' then
00397 int_line_I <= LINE_I;
00398 if AUTO_REFRESH_I = '1' and int_waiting_I = '0' then
00399 int_move_I <= '0';
00400 int_waiting_I <= '1';
00401 end if;
00402 end if;
00403 if int_sample_paint_II = '0' and LINE_II_PAINT = '1' then
00404 int_line_II <= LINE_II;
00405 if AUTO_REFRESH_II = '1' and int_waiting_II = '0' then
00406 int_move_II <= '0';
00407 int_waiting_II <= '1';
00408 end if;
00409 end if;
00410 int_sample_paint_I <= LINE_I_PAINT;
00411 int_sample_paint_II <= LINE_II_PAINT;
00412
00413
00414 if int_sample_clock_I = '0' and CLOCK_ANI_I = '1' then
00415 int_waiting_I <= '1';
00416 int_move_I <= '1';
00417 end if;
00418 if int_sample_clock_II = '0' and CLOCK_ANI_II = '1' then
00419 int_waiting_II <= '1';
00420 int_move_II <= '1';
00421 end if;
00422 int_sample_clock_I <= CLOCK_ANI_I;
00423 int_sample_clock_II <= CLOCK_ANI_II;
00424
00425 end if;
00426 end if;
00427 end process;
00428
00429 end lcd_controller_arc;
00430