2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
9 sys_clk : in std_logic;
10 sys_res_n : in std_logic;
12 new_data : in std_logic;
13 data : in std_logic_vector(7 downto 0);
16 s_take : out std_logic;
17 s_done : in std_logic;
18 s_backspace : out std_logic;
20 do_it : out std_logic;
21 finished : in std_logic
25 architecture beh of scanner is
26 type SCANNER_STATE is (SIDLE, SIGNORE_NEXT, SREAD_NEXT, STAKE, SDEL, SENTER);
27 signal state_int, state_next : SCANNER_STATE;
28 signal s_char_int, s_char_next : hbyte;
29 signal s_take_int, s_take_next : std_logic;
30 signal s_backspace_int, s_backspace_next : std_logic;
31 signal do_it_int, do_it_next : std_logic;
35 s_backspace <= s_backspace_int;
38 process(sys_clk, sys_res_n)
40 if sys_res_n = '0' then
44 s_char_int <= (others => '0');
46 s_backspace_int <= '0';
48 elsif rising_edge(sys_clk) then
50 state_int <= state_next;
52 s_char_int <= s_char_next;
53 s_take_int <= s_take_next;
54 s_backspace_int <= s_backspace_next;
55 do_it_int <= do_it_next;
60 process(state_int, new_data, data, finished, s_done)
62 state_next <= state_int;
66 if new_data = '1' then
69 state_next <= SIGNORE_NEXT;
71 state_next <= SREAD_NEXT;
76 when SC_KP_0 | SC_KP_1 | SC_KP_2 | SC_KP_3 |
77 SC_KP_4 | SC_KP_5 | SC_KP_6 | SC_KP_7 |
78 SC_KP_8 | SC_KP_9 | SC_KP_PLUS |
79 SC_KP_MINUS | SC_KP_MUL | SC_SPACE =>
81 when others => state_next <= SIDLE;
85 if new_data = '1' then
89 if new_data = '1' then
92 state_next <= SIGNORE_NEXT;
97 when others => state_next <= SIDLE;
105 if finished = '1' then
112 process(state_int, data, s_char_int, new_data)
113 function sc2ascii (x : hbyte) return hbyte is
117 when SC_KP_0 => y := x"30";
118 when SC_KP_1 => y := x"31";
119 when SC_KP_2 => y := x"32";
120 when SC_KP_3 => y := x"33";
121 when SC_KP_4 => y := x"34";
122 when SC_KP_5 => y := x"35";
123 when SC_KP_6 => y := x"36";
124 when SC_KP_7 => y := x"37";
125 when SC_KP_8 => y := x"38";
126 when SC_KP_9 => y := x"39";
127 when SC_KP_PLUS => y := x"2b";
128 when SC_KP_MINUS => y := x"2d";
129 when SC_KP_MUL => y := x"2a";
130 when SC_KP_DIV => y := x"2f";
131 when SC_SPACE => y := x"20";
132 when others => y := x"41";
137 s_char_next <= s_char_int;
139 s_backspace_next <= '0';
144 when SIGNORE_NEXT => null;
145 when SREAD_NEXT => null;
148 s_char_next <= sc2ascii(hbyte(data));
151 s_backspace_next <= '1';
156 end architecture beh;