display/history: robuster, trotzdem funktioniert es noch nicht so wie ich moechte
[hwmod.git] / src / display.vhd
index f540dd2bffff777be23696abea9721c21e1dbbce..8fca39cc8e8372b726ad4800811dfe7ff94be4b6 100644 (file)
@@ -27,7 +27,7 @@ end entity display;
 
 architecture beh of display is
        type DISPLAY_STATE is (SIDLE, S_NEW_RESULT, S_NEW_INPUT, S_COUNTUP, S_GETCH,
-       S_PUTCH, S_WAIT, S_NOP1, S_NOP2);
+       S_CR1, S_NL1, S_PUTCH1, S_PUTCH2, S_WAIT, S_NOP1);
        signal state_int, state_next : DISPLAY_STATE;
        signal d_zeile_int, d_zeile_next : hzeile;
        signal d_spalte_int, d_spalte_next : hspalte;
@@ -65,7 +65,8 @@ begin
        end process;
 
        -- next state
-       process(state_int, d_new_result, d_new_eingabe, d_done, free)
+       process(state_int, d_new_result, d_new_eingabe, d_done, free, d_spalte_int,
+               d_char)
        begin
                state_next <= state_int;
 
@@ -77,16 +78,28 @@ begin
                                if d_new_result = '1' then
                                        state_next <= S_NEW_RESULT;
                                end if;
-                       when S_NEW_RESULT | S_NEW_INPUT =>
+                       when S_NEW_RESULT =>
+                               state_next <= S_CR1;
+                       when S_NEW_INPUT =>
                                state_next <= S_COUNTUP;
+                       when S_CR1 =>
+                               if free = '0' then
+                                       state_next <= S_NL1;
+                               end if;
+                       when S_NL1 =>
+                               if free = '0' then
+                                       state_next <= S_COUNTUP;
+                               end if;
                        when S_COUNTUP =>
                                state_next <= S_GETCH;
                        when S_GETCH =>
-                               if free = '1' and d_done = '1' then
-                                       state_next <= S_PUTCH;
+                               if free = '1' and d_done = '1' and d_new_result = '0' and d_new_eingabe = '0' then
+                                       state_next <= S_PUTCH1;
                                end if;
-                       when S_PUTCH =>
-                               if free = '0' then
+                       when S_PUTCH1 =>
+                               state_next <= S_PUTCH2;
+                       when S_PUTCH2 =>
+                               if free = '0' or (free = '1' and d_char = x"00") then
                                        state_next <= S_WAIT;
                                end if;
                        when S_WAIT =>
@@ -94,23 +107,20 @@ begin
                                        state_next <= S_NOP1;
                                end if;
                        when S_NOP1 =>
-                               if free = '0' then
-                                       state_next <= S_NOP2;
-                               end if;
-                       when S_NOP2 =>
                                if free = '1' then
-                                       if unsigned(d_spalte_int) = 71 then
-                                               state_next <= SIDLE;
-                                       else
-                                               state_next <= S_COUNTUP;
-                                       end if;
+                                       state_next <= SIDLE;
+                                       --if unsigned(d_spalte_int) = 71 then
+                                       --      state_next <= SIDLE;
+                                       --else
+                                       --      state_next <= S_COUNTUP;
+                                       --end if;
                                end if;
                end case;
        end process;
 
        -- out
        process(state_int, d_zeile_int, d_spalte_int, d_get_int, command_int,
-               command_data_int)
+               command_data_int, d_char)
        begin
                d_zeile_next <= d_zeile_int;
                d_spalte_next <= d_spalte_int;
@@ -122,24 +132,31 @@ begin
                        when SIDLE =>
                                null;
                        when S_NEW_INPUT =>
-                               d_spalte_next <= (others => '0');
+                               null;
                        when S_NEW_RESULT =>
                                d_spalte_next <= (others => '0');
                                case d_zeile_int is
                                        when "11111" => d_zeile_next <= "00000";
                                        when others => d_zeile_next <= std_logic_vector(unsigned(d_zeile_int) + 1);
                                end case;
+                       when S_CR1 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               command_data_next <= x"ffffff" & x"0d"; -- carrige return
+                       when S_NL1 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               command_data_next <= x"ffffff" & x"0a"; -- newline
                        when S_COUNTUP =>
                                d_get_next <= '1';
                                d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) + 1);
                        when S_GETCH =>
                                d_get_next <= '1';
-                       when S_PUTCH =>
-                               command_next <= COMMAND_SET_CHAR;
-                               command_data_next <= x"000000" & std_logic_vector(d_char);
-                       when S_WAIT | S_NOP2 =>
-                               null;
-                       when S_NOP1 =>
+                       when S_PUTCH1 =>
+                               if d_char /= x"00" then
+                                       command_next <= COMMAND_SET_CHAR;
+                                       command_data_next <= x"ffffff" & std_logic_vector(d_char);
+                               end if;
+                       when S_PUTCH2 => null;
+                       when S_WAIT | S_NOP1 =>
                                command_next <= COMMAND_NOP;
                                command_data_next <= x"00000000";
                end case;