display: vorbereitungen fuer eine art $PS1 :p
authorBernhard Urban <lewurm@gmail.com>
Fri, 21 May 2010 05:54:35 +0000 (07:54 +0200)
committerBernhard Urban <lewurm@gmail.com>
Fri, 21 May 2010 05:54:35 +0000 (07:54 +0200)
src/beh_display_tb.vhd
src/display.vhd

index 6b0b19b762e273a991ed33afb4b6c0255d0bcb7c..059d598de47e4055524e2eaaf44deb7ae60ae15e 100644 (file)
@@ -59,6 +59,17 @@ begin
                end if;
        end process;
 
+       process
+       begin
+               free <= '0';
+               wait for 15 ns;
+               free <= '1';
+               wait for 30 ns;
+               if stop = true then
+                       wait;
+               end if;
+       end process;
+
        process
                variable input : hstring := "123513                                                                  ";
                variable ctmp : character;
@@ -73,7 +84,6 @@ begin
                d_new_bs <= '0';
                d_done <= '0';
                d_char <= x"00";
-               free <= '1';
 
                icwait(sys_clk, 5);
                sys_res_n <= '1';
@@ -93,17 +103,6 @@ begin
                        icwait(sys_clk, 1);
                        d_done <= '0';
 
-                       free <= '0';
-                       icwait(sys_clk, 1);
-                       free <= '1';
-                       icwait(sys_clk, 1);
-
-                       -- fuer NOP
-                       free <= '0';
-                       icwait(sys_clk, 1);
-                       free <= '1';
-                       icwait(sys_clk, 1);
-
                        i := i + 1;
                end loop;
 
@@ -112,21 +111,6 @@ begin
                icwait(sys_clk, 2);
                d_new_result <= '0';
 
-               -- fuer NOP
-               free <= '0';
-               icwait(sys_clk, 1);
-               free <= '1';
-               icwait(sys_clk, 2);
-
-               -- fuer NOP
-               free <= '0';
-               icwait(sys_clk, 1);
-               free <= '1';
-               icwait(sys_clk, 1);
-               icwait(sys_clk, 1);
-
-
-
                if checkall then
                        report "alle testfaelle des Displays waren erfolgreich!";
                else
index 19c9d24caf789571c2836279793b0eaca0ab061b..d632596c06d21a2222ecca9a8ab8319c08b9466d 100644 (file)
@@ -29,14 +29,15 @@ 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_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);
        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(2 downto 0);
+       signal istate_next, istate_int : signed(3 downto 0);
 begin
        d_zeile <= d_zeile_int;
        d_spalte <= d_spalte_int;
@@ -48,7 +49,7 @@ begin
        begin
                if sys_res_n = '0' then
                        -- internal
-                       state_int <= SIDLE;
+                       state_int <= S_INIT;
                        istate_int <= (others => '0');
                        -- out
                        d_zeile_int <= (others => '0');
@@ -77,8 +78,30 @@ begin
                istate_next <= istate_int;
 
                case state_int is
+                       when S_INIT =>
+                               state_next <= S_PS1_0;
+
+                       when S_PS1_0 =>
+                               istate_next <= b"1001";
+                               state_next <= S_WAIT;
+                       when S_PS1_1 =>
+                               istate_next <= b"1010";
+                               state_next <= S_WAIT;
+                       when S_PS1_2 =>
+                               istate_next <= b"1011";
+                               state_next <= S_WAIT;
+                       when S_PS1_3 =>
+                               istate_next <= b"1100";
+                               state_next <= S_WAIT;
+                       when S_PS1_4 =>
+                               istate_next <= b"1101";
+                               state_next <= S_WAIT;
+                       when S_PS1_5 =>
+                               istate_next <= b"0111";
+                               state_next <= S_WAIT;
+
                        when SIDLE =>
-                               istate_next <= b"111"; -- default: immer wieder ins SIDLE;
+                               istate_next <= b"0111"; -- default: immer wieder ins SIDLE;
                                if d_new_bs = '1' then
                                        state_next <= S_NEW_BS;
                                elsif d_new_eingabe = '1' then
@@ -99,21 +122,21 @@ begin
                                if free = '0' then
                                        state_next <= S_WAIT;
                                        case istate_int is
-                                               when b"111" => istate_next <= b"001"; -- => danach S_BLANK und wieder hierher
-                                               when others => istate_next <= b"111"; -- => danach SIDLE
+                                               when b"0111" => istate_next <= b"0001"; -- => danach S_BLANK und wieder hierher
+                                               when others => istate_next <= b"0111"; -- => danach SIDLE
                                        end case;
                                end if;
                        when S_BLANK =>
                                if free = '0' then
                                        state_next <= S_WAIT;
-                                       istate_next <= b"010"; -- => danach S_BACK
+                                       istate_next <= b"0010"; -- => danach S_BACK
                                end if;
 
                        when S_ZEILEUP =>
                                case istate_int is
-                                       when b"011" =>
+                                       when b"0011" =>
                                                state_next <= S_WAIT;
-                                               istate_next <= b"111";
+                                               istate_next <= b"1000"; -- => danach S_PS1
                                        when others => state_next <= S_CR1;
                                end case;
 
@@ -121,25 +144,25 @@ begin
                                if free = '0' then
                                        state_next <= S_WAIT;
                                        case istate_int is
-                                               when b"110" => istate_next <= b"101"; -- => danach S_NL1 und SIDLe
-                                               when others => istate_next <= b"000"; -- => danach S_NL1 und S_COUNTUP
+                                               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
                                        end case;
                                end if;
                        when S_NL1 =>
                                if free = '0' then
                                        state_next <= S_WAIT;
                                        case istate_int is
-                                               when b"101" => istate_next <= b"011"; -- => danach S_ZEILEUP
-                                               when others => istate_next <= b"100"; -- => danach S_READ_RESULT
+                                               when b"0101" => istate_next <= b"0011"; -- => danach S_ZEILEUP, PS1
+                                               when others => istate_next <= b"0100"; -- => danach S_READ_RESULT
                                        end case;
                                end if;
                        when S_READ_RESULT =>
                                if unsigned(d_spalte_int) /= 70 then
                                        state_next <= S_COUNTUP;
-                                       istate_next <= b"100"; -- => wieder nach S_READ_RESULT
+                                       istate_next <= b"0100"; -- => wieder nach S_READ_RESULT
                                else
                                        state_next <= S_WAIT;
-                                       istate_next <= b"110"; -- => danach S_CR1 und d_spalte_next clearen und d_zeile_next inkrementieren
+                                       istate_next <= b"0110"; -- => danach S_CR1 und d_spalte_next clearen und d_zeile_next inkrementieren
                                end if;
 
                        when S_COUNTUP =>
@@ -161,13 +184,20 @@ begin
                        when S_NOP1 =>
                                if free = '1' then
                                        case istate_int is
-                                               when b"000" => state_next <= S_NL1;
-                                               when b"001" => state_next <= S_BLANK;
-                                               when b"010" => state_next <= S_BACK;
-                                               when b"011" => state_next <= S_ZEILEUP;
-                                               when b"100" => state_next <= S_READ_RESULT;
-                                               when b"110" => state_next <= S_CR1;
-                                               when b"101" => state_next <= S_NL1;
+                                               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"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 others => state_next <= SIDLE;
                                        end case;
                                end if;
@@ -176,7 +206,7 @@ begin
 
        -- out
        process(state_int, d_zeile_int, d_spalte_int, d_get_int, command_int,
-               command_data_int, d_char, istate_int)
+               command_data_int, d_char)
        begin
                d_zeile_next <= d_zeile_int;
                d_spalte_next <= d_spalte_int;
@@ -185,19 +215,41 @@ begin
                command_data_next <= command_data_int;
 
                case state_int is
-                       when SIDLE =>
-                               null;
-                       when S_NEW_RESULT =>
-                       when S_NEW_INPUT =>
-                               null;
+                       when S_INIT => null;
+
+                       -- TODO: coole farben
+                       when S_PS1_0 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               command_data_next <= x"ffffff" & x"28"; -- '('
+                       when S_PS1_1 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               -- d_zeile/2, zehnerstelle
+                               command_data_next <= x"ffffff" & x"78"; -- 'x'
+                       when S_PS1_2 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               -- d_zeile/2, einerstelle
+                               command_data_next <= x"ffffff" & x"79"; -- 'y'
+                       when S_PS1_3 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               command_data_next <= x"ffffff" & x"29"; -- ')'
+                       when S_PS1_4 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               command_data_next <= x"ffffff" & x"24"; -- '$'
+                       when S_PS1_5 =>
+                               command_next <= COMMAND_SET_CHAR;
+                               command_data_next <= x"ffffff" & x"20"; -- ' '
+
+                       when SIDLE => null;
+                       when S_NEW_RESULT => null;
+                       when S_NEW_INPUT => null;
 
                        when S_NEW_BS =>
                                -- underflow check schon im history modul
                                d_spalte_next <= std_logic_vector(unsigned(d_spalte_int) - 1);
                        when S_BACK =>
-                               -- einen schritt zurueck
+                               -- einen schritt zurueck, +6 wegen $PS1
                                command_next <= COMMAND_SET_CURSOR_COLUMN;
-                               command_data_next <= x"ffffff" & '0' & std_logic_vector(unsigned(d_spalte_int));
+                               command_data_next <= x"ffffff" & '0' & std_logic_vector(unsigned(d_spalte_int) + 6);
                        when S_BLANK =>
                                command_next <= COMMAND_SET_CHAR;
                                command_data_next <= x"ffffff" & x"20"; -- white space
@@ -205,7 +257,8 @@ begin
                        when S_ZEILEUP =>
                                d_spalte_next <= (others => '0');
                                case d_zeile_int is
-                                       when "1111111" => d_zeile_next <= (others => '0');
+                                       -- 49 * 2 + 1
+                                       when "1100010" => d_zeile_next <= (others => '0');
                                        when others => d_zeile_next <= std_logic_vector(unsigned(d_zeile_int) + 1);
                                end case;