OpenCores
URL https://opencores.org/ocsvn/z80soc/z80soc/trunk

Subversion Repositories z80soc

[/] [z80soc/] [trunk/] [V0.7/] [DE1/] [vhdl/] [ps2bkd.vhd] - Blame information for rev 40

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 rrred
library IEEE;
2
use IEEE.std_logic_1164.all;
3
 
4
entity  ps2kbd is
5
        PORT (
6
                        keyboard_clk    : inout std_logic;
7
                        keyboard_data   : inout std_logic;
8
                        clock                   : in std_logic;
9
                        clkdelay                : in std_logic;
10
                        reset                   : in std_logic;
11
                        read                    : in std_logic;
12
                        scan_ready              : out std_logic;
13
                        ps2_ascii_code  : out std_logic_vector(7 downto 0));
14
end ps2kbd;
15
 
16
architecture rtl of ps2kbd is
17
 
18
--signal keyboard_clk           : std_logic;
19
--signal keyboard_data  : std_logic;
20
--signal clock                  : std_logic;
21
--signal reset                  : std_logic;
22
--signal read                           : std_logic;
23
--signal scan_ready             : std_logic;
24
--signal ps2_ascii_code : std_logic_vector(7 downto 0);
25
 
26
signal scan_code_sig    : std_logic_vector(7 downto 0);
27
signal scan_code                : std_logic_vector(11 downto 0);
28
signal shift                    : std_logic_vector(1 downto 0);
29
signal caps                             : std_logic_vector(1 downto 0);
30
signal ctrlkey                  : std_logic_vector(3 downto 0);
31
 
32
begin
33
process (clkdelay)
34
begin
35
        if clkdelay'event and clkdelay='1' then
36
                if scan_code_sig = x"58" then
37
                        if caps = "00" then
38
                                caps <= "01";
39
                        elsif caps = "01" then
40
                                caps <= "11";
41
                        elsif caps = "11" then
42
                                caps <= "10";
43
                        else
44
                                caps <= "00";
45
                        end if;
46
                end if;
47
        end if;
48
 
49
scan_code <= "000" & caps(0) & scan_code_sig;
50
 
51
end process;
52
 
53
ps2_ascii_decode : process(scan_code)
54
begin
55
  case scan_code is
56
    when x"066" => ps2_ascii_code <= x"08";  -- Backspace ("backspace" key)
57
    when x"00d" => ps2_ascii_code <= x"09";  -- Horizontal Tab
58
    when x"05a" => ps2_ascii_code <= x"0d";  -- Carriage return ("enter" key)
59
    when x"076" => ps2_ascii_code <= x"1b";  -- Escape ("esc" key)
60
    when x"029" => ps2_ascii_code <= x"20";  -- Space
61
    when x"116" => ps2_ascii_code <= x"21";  -- !
62
    when x"152" => ps2_ascii_code <= x"22";  -- "
63
    when x"126" => ps2_ascii_code <= x"23";  -- #
64
    when x"125" => ps2_ascii_code <= x"24";  -- $
65
    when x"12e" => ps2_ascii_code <= x"25";  --
66
    when x"13d" => ps2_ascii_code <= x"26";  --
67
    when x"052" => ps2_ascii_code <= x"27";  --
68
    when x"146" => ps2_ascii_code <= x"28";  --
69
    when x"145" => ps2_ascii_code <= x"29";  --
70
    when x"13e" => ps2_ascii_code <= x"2a";  -- *
71
    when x"155" => ps2_ascii_code <= x"2b";  -- +
72
    when x"041" => ps2_ascii_code <= x"2c";  -- ,
73
    when x"04e" => ps2_ascii_code <= x"2d";  -- -
74
    when x"049" => ps2_ascii_code <= x"2e";  -- .
75
    when x"04a" => ps2_ascii_code <= x"2f";  -- /
76
    when x"045" => ps2_ascii_code <= x"30";  -- 0
77
    when x"016" => ps2_ascii_code <= x"31";  -- 1
78
    when x"01e" => ps2_ascii_code <= x"32";  -- 2
79
    when x"026" => ps2_ascii_code <= x"33";  -- 3
80
    when x"025" => ps2_ascii_code <= x"34";  -- 4
81
    when x"02e" => ps2_ascii_code <= x"35";  -- 5
82
    when x"036" => ps2_ascii_code <= x"36";  -- 6
83
    when x"03d" => ps2_ascii_code <= x"37";  -- 7
84
    when x"03e" => ps2_ascii_code <= x"38";  -- 8
85
    when x"046" => ps2_ascii_code <= x"39";  -- 9
86
    when x"14c" => ps2_ascii_code <= x"3a";  -- :
87
    when x"04c" => ps2_ascii_code <= x"3b";  -- ;
88
    when x"141" => ps2_ascii_code <= x"3c";  -- <
89
    when x"055" => ps2_ascii_code <= x"3d";  -- =
90
    when x"149" => ps2_ascii_code <= x"3e";  -- >
91
    when x"14a" => ps2_ascii_code <= x"3f";  -- ?
92
    when x"11e" => ps2_ascii_code <= x"40";  -- @
93
    when x"11c" => ps2_ascii_code <= x"41";  -- A
94
    when x"132" => ps2_ascii_code <= x"42";  -- B
95
    when x"121" => ps2_ascii_code <= x"43";  -- C
96
    when x"123" => ps2_ascii_code <= x"44";  -- D
97
    when x"124" => ps2_ascii_code <= x"45";  -- E
98
    when x"12b" => ps2_ascii_code <= x"46";  -- F
99
    when x"134" => ps2_ascii_code <= x"47";  -- G
100
    when x"133" => ps2_ascii_code <= x"48";  -- H
101
    when x"143" => ps2_ascii_code <= x"49";  -- I
102
    when x"13b" => ps2_ascii_code <= x"4a";  -- J
103
    when x"142" => ps2_ascii_code <= x"4b";  -- K
104
    when x"14b" => ps2_ascii_code <= x"4c";  -- L
105
    when x"13a" => ps2_ascii_code <= x"4d";  -- M
106
    when x"131" => ps2_ascii_code <= x"4e";  -- N
107
    when x"144" => ps2_ascii_code <= x"4f";  -- O
108
    when x"14d" => ps2_ascii_code <= x"50";  -- P
109
    when x"115" => ps2_ascii_code <= x"51";  -- Q
110
    when x"12d" => ps2_ascii_code <= x"52";  -- R
111
    when x"11b" => ps2_ascii_code <= x"53";  -- S
112
    when x"12c" => ps2_ascii_code <= x"54";  -- T
113
    when x"13c" => ps2_ascii_code <= x"55";  -- U
114
    when x"12a" => ps2_ascii_code <= x"56";  -- V
115
    when x"11d" => ps2_ascii_code <= x"57";  -- W
116
    when x"122" => ps2_ascii_code <= x"58";  -- X
117
    when x"135" => ps2_ascii_code <= x"59";  -- Y
118
    when x"11a" => ps2_ascii_code <= x"5a";  -- Z
119
    when x"054" => ps2_ascii_code <= x"5b";  -- [
120
    when x"05d" => ps2_ascii_code <= x"5c";  -- \
121
    when x"05b" => ps2_ascii_code <= x"5d";  -- ]
122
    when x"136" => ps2_ascii_code <= x"5e";  -- ^
123
    when x"14e" => ps2_ascii_code <= x"5f";  -- _    
124
    when x"00e" => ps2_ascii_code <= x"60";  -- `
125
    when x"01c" => ps2_ascii_code <= x"61";  -- a
126
    when x"032" => ps2_ascii_code <= x"62";  -- b
127
    when x"021" => ps2_ascii_code <= x"63";  -- c
128
    when x"023" => ps2_ascii_code <= x"64";  -- d
129
    when x"024" => ps2_ascii_code <= x"65";  -- e
130
    when x"02b" => ps2_ascii_code <= x"66";  -- f
131
    when x"034" => ps2_ascii_code <= x"67";  -- g
132
    when x"033" => ps2_ascii_code <= x"68";  -- h
133
    when x"043" => ps2_ascii_code <= x"69";  -- i
134
    when x"03b" => ps2_ascii_code <= x"6a";  -- j
135
    when x"042" => ps2_ascii_code <= x"6b";  -- k
136
    when x"04b" => ps2_ascii_code <= x"6c";  -- l
137
    when x"03a" => ps2_ascii_code <= x"6d";  -- m
138
    when x"031" => ps2_ascii_code <= x"6e";  -- n
139
    when x"044" => ps2_ascii_code <= x"6f";  -- o
140
    when x"04d" => ps2_ascii_code <= x"70";  -- p
141
    when x"015" => ps2_ascii_code <= x"71";  -- q
142
    when x"02d" => ps2_ascii_code <= x"72";  -- r
143
    when x"01b" => ps2_ascii_code <= x"73";  -- s
144
    when x"02c" => ps2_ascii_code <= x"74";  -- t
145
    when x"03c" => ps2_ascii_code <= x"75";  -- u
146
    when x"02a" => ps2_ascii_code <= x"76";  -- v
147
    when x"01d" => ps2_ascii_code <= x"77";  -- w
148
    when x"022" => ps2_ascii_code <= x"78";  -- x
149
    when x"035" => ps2_ascii_code <= x"79";  -- y
150
    when x"01a" => ps2_ascii_code <= x"7a";  -- z
151
    when x"154" => ps2_ascii_code <= x"7b";  -- {
152
    when x"15d" => ps2_ascii_code <= x"7c";  -- |
153
    when x"15b" => ps2_ascii_code <= x"7d";  -- }
154
    when x"10e" => ps2_ascii_code <= x"7e";  -- ~
155
    when x"071" => ps2_ascii_code <= x"7f";  -- (Delete OR DEL on numeric keypad)
156
    when x"171" => ps2_ascii_code <= x"7f";  -- (Delete OR DEL on numeric keypad)        
157
    when others => ps2_ascii_code <= x"FF";  -- keys not mapped
158
  end case;
159
end process;
160
 
161
kbd_inst: work.keyboard port map (
162
        keyboard_clk    => keyboard_clk,
163
        keyboard_data   => keyboard_data,
164
        clock                   => clock,
165
        reset                   => reset,
166
        read                    => read,
167
        scan_ready              => scan_ready,
168
        scan_code               => scan_code_sig
169
);
170
 
171
end;
172
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.