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

Subversion Repositories z80soc

[/] [z80soc/] [trunk/] [V0.7.3/] [DE2115/] [vhdl/] [ps2bkd.vhd] - Blame information for rev 46

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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