scanner: es gibt key_pressed und key_released -- bei beiden wird das zeichen gesendet
authorBernhard Urban <lewurm@gmail.com>
Wed, 19 May 2010 15:42:15 +0000 (17:42 +0200)
committerBernhard Urban <lewurm@gmail.com>
Wed, 19 May 2010 15:42:15 +0000 (17:42 +0200)
... das erklaert warum die zeichen doppelt angezeigt wurden :) nun wird es nur
noch nach key-released akzeptiert, das macht die ganze logik sogar noch etwas
einfacher

src/beh_scanner_tb.vhd
src/gen_pkg.vhd
src/scanner.test
src/scanner.vhd

index f0704d5fe64b7544e5ec818f4286d96a2026867c..379d26b546c837a8fbfbf15cb095f1c3da609191 100644 (file)
@@ -80,14 +80,11 @@ begin
                                variable y : boolean;
                begin
                        case x is
-                               -- nur gueltig wenn davor ein numpad-mod byte gekommen ist
-                               when SC_KP_DIV => y := last = x"e0";
-
-                               -- immer gueltig
                                when SC_KP_0 | SC_KP_1 | SC_KP_2 | SC_KP_3 |
                                        SC_KP_4 | SC_KP_5 | SC_KP_6 | SC_KP_7 |
                                        SC_KP_8 | SC_KP_9 | SC_KP_PLUS |
-                                       SC_KP_MINUS | SC_KP_MUL | SC_SPACE |
+                                       SC_KP_MINUS | SC_KP_MUL |
+                                       SC_KP_DIV | SC_SPACE |
                                        SC_BKSP | SC_ENTER =>
                                                y := true;
                                when others => y := false;
@@ -178,11 +175,17 @@ begin
                                        next mainl;
                                end if;
 
+                               -- jedes mal release
+                               new_data <= '1';
+                               data <= x"f0";
+                               icwait(sys_clk, 1);
+                               new_data <= '0';
+                               icwait(sys_clk, 1);
                                new_data <= '1';
+
                                case input(j) is
                                        when nul => data <= ascii2sc(x"1c"); -- $ (enter)
                                        when '!' => data <= ascii2sc(x"0e"); -- ! (backspace)
-                                       when '.' => data <= x"e0"; -- . (modifier fuer Numpad)
                                        when others => data <= ascii2sc(std_logic_vector(to_unsigned(character'pos(input(j)),8)));
                                end case;
                                icwait(sys_clk, 1);
index 3b7f87e67f2c7d4cbfa2b95605804f70cc299047..cf80155fce127c384d1bd0d6c4ce2fcfc0832796 100644 (file)
@@ -50,7 +50,6 @@ package gen_pkg is
        constant SC_KP_DIV : std_logic_vector(7 downto 0) := x"4a"; -- inkl. 0xe0!
 
        constant SC_ENTER : std_logic_vector(7 downto 0) := x"5a";
-       constant SC_KP_ENTER : std_logic_vector(7 downto 0) := x"5a"; -- inkl. 0xe0!
        constant SC_BKSP : std_logic_vector(7 downto 0) := x"66";
        constant SC_SPACE : std_logic_vector(7 downto 0) := x"29";
 end package gen_pkg;
index 10433283783c83c9341dc6ffa7714a7ce550753d..71b6af5d2caa7a02961a93c953c8b1ceb53939e5 100644 (file)
@@ -1,6 +1,5 @@
 # readme: folgende spezialzeichen werden zum testen verwendet
 # ! ... Backspace
-# . ... 0xe0 (modifier fuer Numpad)
 #
 # testfall 1:
 asdf213
@@ -12,17 +11,17 @@ asdf213
 2 * 2456
 2 * 2456
 # t4:
-2 ./         24+         
+2 /         24+         
 2 /         24+         
 # t5:
 2345 !!1
 2341
 # t6:
-+-*./
++-*/
 +-*/
 # t7:
 234!!
 2
 # t8:
-2+-*./!! !! !!!!!1
+2+-*/!! !! !!!!!1
 1
index 9e1f0bde5b9e8e28fc8e657d587980fa3d0dd2a9..875cddda4a88fa9979823c6bba6e46ceb2ae9f73 100644 (file)
@@ -23,12 +23,13 @@ entity scanner is
 end entity scanner;
 
 architecture beh of scanner is
-       type SCANNER_STATE is (SIDLE, SREAD, SMOD, STAKE, SDEL, SENTER);
+       type SCANNER_STATE is (SINIT, SIDLE, SREAD, STAKE, SDEL, SENTER);
        signal state_int, state_next : SCANNER_STATE;
        signal s_char_int, s_char_next : hbyte;
        signal s_take_int, s_take_next : std_logic;
        signal s_backspace_int, s_backspace_next : std_logic;
        signal do_it_int, do_it_next : std_logic;
+       signal was_f0_int, was_f0_next : std_logic;
 begin
        s_char <= s_char_int;
        s_take <= s_take_int;
@@ -39,7 +40,8 @@ begin
        begin
                if sys_res_n = '0' then
                        -- internal
-                       state_int <= SIDLE;
+                       state_int <= SINIT;
+                       was_f0_int <= '0';
                        -- out
                        s_char_int <= (others => '0');
                        s_take_int <= '0';
@@ -48,6 +50,7 @@ begin
                elsif rising_edge(sys_clk) then
                        -- internal
                        state_int <= state_next;
+                       was_f0_int <= was_f0_next;
                        -- out
                        s_char_int <= s_char_next;
                        s_take_int <= s_take_next;
@@ -57,37 +60,28 @@ begin
        end process;
 
        -- next state
-       process(state_int, new_data, data, finished, s_done)
+       process(state_int, new_data, data, finished, s_done, was_f0_int)
        begin
                state_next <= state_int;
 
                case state_int is
+                       when SINIT =>
+                               state_next <= SIDLE;
                        when SIDLE =>
-                               if new_data = '1' and finished = '0' and s_done = '0' then
+                               if new_data = '1' and was_f0_int = '1' then
                                        state_next <= SREAD;
                                end if;
                        when SREAD =>
                                case data is
-                                       when x"e0" => state_next <= SMOD;
                                        when SC_BKSP => state_next <= SDEL;
                                        when SC_ENTER => state_next <= SENTER;
                                        when SC_KP_0 | SC_KP_1 | SC_KP_2 | SC_KP_3 |
                                                SC_KP_4 | SC_KP_5 | SC_KP_6 | SC_KP_7 |
                                                SC_KP_8 | SC_KP_9 | SC_KP_PLUS |
-                                               SC_KP_MINUS | SC_KP_MUL | SC_SPACE =>
-                                                       state_next <= STAKE;
+                                               SC_KP_MINUS | SC_KP_MUL | SC_SPACE |
+                                               SC_KP_DIV => state_next <= STAKE;
                                        when others => state_next <= SIDLE;
                                end case;
-                       when SMOD =>
-                               if new_data = '1' then
-                                       if data = SC_KP_ENTER then
-                                               state_next <= SENTER;
-                                       elsif data = SC_KP_DIV then
-                                               state_next <= STAKE;
-                                       else
-                                               state_next <= SIDLE;
-                                       end if;
-                               end if;
                        when STAKE | SDEL=>
                                if s_done = '1' then
                                        state_next <= SIDLE;
@@ -100,7 +94,7 @@ begin
        end process;
 
        -- out
-       process(state_int, data)
+       process(state_int, data, s_char_int, new_data, was_f0_int)
                function sc2ascii (x : hbyte) return hbyte is
                        variable y : hbyte;
                begin
@@ -125,18 +119,21 @@ begin
                        return y;
                end function;
        begin
-               s_char_next <= (others => '0');
+               s_char_next <= s_char_int;
                s_take_next <= '0';
                s_backspace_next <= '0';
                do_it_next <= '0';
+               was_f0_next <= was_f0_int;
 
                case state_int is
+                       when SINIT =>
+                               was_f0_next <= '0';
                        when SIDLE =>
-                               null;
+                               if new_data = '1' and data = x"f0" then
+                                       was_f0_next <= '1';
+                               end if;
                        when SREAD =>
-                               null;
-                       when SMOD =>
-                               null;
+                               was_f0_next <= '0';
                        when STAKE =>
                                s_take_next <= '1';
                                s_char_next <= sc2ascii(hbyte(data));