From c4927d1e3e275d42596f7f3647abd0314e75125a Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Fri, 21 May 2010 08:19:25 +0200 Subject: [PATCH] display: ergebnis mit '> ' prefix --- src/display.vhd | 91 ++++++++++++++++++++++++++++++------------------- src/parser.test | 24 ++++++------- src/parser.vhd | 6 ++-- 3 files changed, 70 insertions(+), 51 deletions(-) diff --git a/src/display.vhd b/src/display.vhd index d632596..d28e158 100644 --- a/src/display.vhd +++ b/src/display.vhd @@ -29,15 +29,16 @@ end entity display; architecture beh of display is type DISPLAY_STATE is (SIDLE, S_NEW_BS, S_BACK, S_BLANK, S_NEW_RESULT, S_ZEILEUP, S_NEW_INPUT, S_COUNTUP, S_GETCH, S_CR1, S_NL1, S_PUTCH1, - S_PUTCH2, S_WAIT, S_NOP1, S_READ_RESULT, S_INIT, S_PS1_0, - S_PS1_1, S_PS1_2, S_PS1_3, S_PS1_4, S_PS1_5); + S_PUTCH2, S_WAIT, S_NOP1, S_READ_RESULT_0, S_READ_RESULT_1, + S_READ_RESULT_2, S_INIT, S_PS1_0, S_PS1_1, S_PS1_2, S_PS1_3, S_PS1_4, + S_PS1_5); signal state_int, state_next : DISPLAY_STATE; signal d_zeile_int, d_zeile_next : hzeile; signal d_spalte_int, d_spalte_next : hspalte; signal d_get_int, d_get_next : std_logic; signal command_int, command_next : std_logic_vector(7 downto 0); signal command_data_int, command_data_next : std_logic_vector(31 downto 0); - signal istate_next, istate_int : signed(3 downto 0); + signal istate_next, istate_int : signed(4 downto 0); begin d_zeile <= d_zeile_int; d_spalte <= d_spalte_int; @@ -82,26 +83,26 @@ begin state_next <= S_PS1_0; when S_PS1_0 => - istate_next <= b"1001"; + istate_next <= b"01001"; state_next <= S_WAIT; when S_PS1_1 => - istate_next <= b"1010"; + istate_next <= b"01010"; state_next <= S_WAIT; when S_PS1_2 => - istate_next <= b"1011"; + istate_next <= b"01011"; state_next <= S_WAIT; when S_PS1_3 => - istate_next <= b"1100"; + istate_next <= b"01100"; state_next <= S_WAIT; when S_PS1_4 => - istate_next <= b"1101"; + istate_next <= b"01101"; state_next <= S_WAIT; when S_PS1_5 => - istate_next <= b"0111"; + istate_next <= b"00111"; state_next <= S_WAIT; when SIDLE => - istate_next <= b"0111"; -- default: immer wieder ins SIDLE; + istate_next <= b"00111"; -- default: immer wieder ins SIDLE; if d_new_bs = '1' then state_next <= S_NEW_BS; elsif d_new_eingabe = '1' then @@ -122,21 +123,21 @@ begin if free = '0' then state_next <= S_WAIT; case istate_int is - when b"0111" => istate_next <= b"0001"; -- => danach S_BLANK und wieder hierher - when others => istate_next <= b"0111"; -- => danach SIDLE + when b"00111" => istate_next <= b"00001"; -- => danach S_BLANK und wieder hierher + when others => istate_next <= b"00111"; -- => danach SIDLE end case; end if; when S_BLANK => if free = '0' then state_next <= S_WAIT; - istate_next <= b"0010"; -- => danach S_BACK + istate_next <= b"00010"; -- => danach S_BACK end if; when S_ZEILEUP => case istate_int is - when b"0011" => + when b"00011" => state_next <= S_WAIT; - istate_next <= b"1000"; -- => danach S_PS1 + istate_next <= b"01000"; -- => danach S_PS1 when others => state_next <= S_CR1; end case; @@ -144,25 +145,32 @@ begin if free = '0' then state_next <= S_WAIT; case istate_int is - when b"0110" => istate_next <= b"0101"; -- => danach S_NL1, S_ZEILEUP, S_PS1, SIDLE - when others => istate_next <= b"0000"; -- => danach S_NL1 und S_COUNTUP + when b"00110" => istate_next <= b"00101"; -- => danach S_NL1, S_ZEILEUP, S_PS1, SIDLE + when others => istate_next <= b"00000"; -- => danach S_NL1 und S_COUNTUP end case; end if; when S_NL1 => if free = '0' then state_next <= S_WAIT; case istate_int is - when b"0101" => istate_next <= b"0011"; -- => danach S_ZEILEUP, PS1 - when others => istate_next <= b"0100"; -- => danach S_READ_RESULT + when b"00101" => istate_next <= b"00011"; -- => danach S_ZEILEUP, PS1 + when others => istate_next <= b"10000"; -- => danach S_READ_RESULT_0 end case; end if; - when S_READ_RESULT => + + when S_READ_RESULT_0 => + istate_next <= b"10001"; + state_next <= S_WAIT; + when S_READ_RESULT_1 => + istate_next <= b"10010"; + state_next <= S_WAIT; + when S_READ_RESULT_2 => if unsigned(d_spalte_int) /= 70 then state_next <= S_COUNTUP; - istate_next <= b"0100"; -- => wieder nach S_READ_RESULT + istate_next <= b"10010"; -- => wieder nach S_READ_RESULT_2 else state_next <= S_WAIT; - istate_next <= b"0110"; -- => danach S_CR1 und d_spalte_next clearen und d_zeile_next inkrementieren + istate_next <= b"00110"; -- => danach S_CR1 und d_spalte_next clearen und d_zeile_next inkrementieren end if; when S_COUNTUP => @@ -184,20 +192,23 @@ begin when S_NOP1 => if free = '1' then case istate_int is - when b"0000" => state_next <= S_NL1; - when b"0001" => state_next <= S_BLANK; - when b"0010" => state_next <= S_BACK; - when b"0011" => state_next <= S_ZEILEUP; - when b"0100" => state_next <= S_READ_RESULT; - when b"0110" => state_next <= S_CR1; - when b"0101" => state_next <= S_NL1; + when b"00000" => state_next <= S_NL1; + when b"00001" => state_next <= S_BLANK; + when b"00010" => state_next <= S_BACK; + when b"00011" => state_next <= S_ZEILEUP; + when b"00110" => state_next <= S_CR1; + when b"00101" => state_next <= S_NL1; - when b"1000" => state_next <= S_PS1_0; - when b"1001" => state_next <= S_PS1_1; - when b"1010" => state_next <= S_PS1_2; - when b"1011" => state_next <= S_PS1_3; - when b"1100" => state_next <= S_PS1_4; - when b"1101" => state_next <= S_PS1_5; + when b"10000" => state_next <= S_READ_RESULT_0; + when b"10001" => state_next <= S_READ_RESULT_1; + when b"10010" => state_next <= S_READ_RESULT_2; + + when b"01000" => state_next <= S_PS1_0; + when b"01001" => state_next <= S_PS1_1; + when b"01010" => state_next <= S_PS1_2; + when b"01011" => state_next <= S_PS1_3; + when b"01100" => state_next <= S_PS1_4; + when b"01101" => state_next <= S_PS1_5; when others => state_next <= SIDLE; end case; end if; @@ -268,7 +279,15 @@ begin when S_NL1 => command_next <= COMMAND_SET_CHAR; command_data_next <= x"ffffff" & x"0a"; -- newline - when S_READ_RESULT => null; + + -- TODO: coole farben + when S_READ_RESULT_0 => + command_next <= COMMAND_SET_CHAR; + command_data_next <= x"ffffff" & x"3e"; -- '>' + when S_READ_RESULT_1 => + command_next <= COMMAND_SET_CHAR; + command_data_next <= x"ffffff" & x"20"; -- ' ' + when S_READ_RESULT_2 => null; when S_COUNTUP => d_get_next <= '1'; diff --git a/src/parser.test b/src/parser.test index a507576..3d7c62f 100644 --- a/src/parser.test +++ b/src/parser.test @@ -77,43 +77,43 @@ 2 # t26 3 3 - > Fehler: Syntax + Fehler: Syntax # t27 ++ - > Fehler: Syntax + Fehler: Syntax # t28 ** - > Fehler: Syntax + Fehler: Syntax # t29 *+/- - > Fehler: Syntax + Fehler: Syntax # t30 * / - > Fehler: Syntax + Fehler: Syntax # t31 2 + ---- - > Fehler: Syntax + Fehler: Syntax # t32 2 --1 3 # t33 21448368 * 123141 - > Fehler: Over- bzw. Underflow + Fehler: Over- bzw. Underflow # t34 21448368 * -123141 - > Fehler: Over- bzw. Underflow + Fehler: Over- bzw. Underflow # t35 341212 / 0 - > Fehler: Division durch Null + Fehler: Division durch Null # t36 341212 / -0*2 - > Fehler: Division durch Null + Fehler: Division durch Null # t37 0--2147483648 - > Fehler: Over- bzw. Underflow + Fehler: Over- bzw. Underflow # t38 5--2147483648 - > Fehler: Over- bzw. Underflow + Fehler: Over- bzw. Underflow # t39 -2147483647-1 -2147483648 diff --git a/src/parser.vhd b/src/parser.vhd index 8fa3a2b..b4b9593 100644 --- a/src/parser.vhd +++ b/src/parser.vhd @@ -350,9 +350,9 @@ begin type errstrings is array (natural range 1 to 3) of hstring; constant error_str : errstrings := ( - 1 => " > Fehler: Division durch Null " & nul, - 2 => " > Fehler: Syntax " & nul, - 3 => " > Fehler: Over- bzw. Underflow " & nul + 1 => " Fehler: Division durch Null " & nul, + 2 => " Fehler: Syntax " & nul, + 3 => " Fehler: Over- bzw. Underflow " & nul ); begin -- internal -- 2.25.1