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

Subversion Repositories z80soc

[/] [z80soc/] [trunk/] [V0.6/] [DE1/] [rtl/] [VHDL/] [PS2/] [KEYBOARD.VHD] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 40 rrred
LIBRARY IEEE;
2
USE  IEEE.STD_LOGIC_1164.all;
3
USE  IEEE.STD_LOGIC_ARITH.all;
4
USE  IEEE.STD_LOGIC_UNSIGNED.all;
5
 
6
ENTITY keyboard IS
7
        PORT(   keyboard_clk, keyboard_data, clock ,
8
                        reset, read             : IN    STD_LOGIC;
9
                        scan_code               : OUT   STD_LOGIC_VECTOR(7 DOWNTO 0);
10
                        scan_ready              : OUT   STD_LOGIC);
11
END keyboard;
12
 
13
ARCHITECTURE a OF keyboard IS
14
        SIGNAL INCNT                                    : std_logic_vector(3 downto 0);
15
        SIGNAL SHIFTIN                                  : std_logic_vector(8 downto 0);
16
        SIGNAL READ_CHAR, clock_enable  : std_logic;
17
        SIGNAL INFLAG, ready_set                : std_logic;
18
        SIGNAL keyboard_clk_filtered    : std_logic;
19
        SIGNAL filter                                   : std_logic_vector(7 downto 0);
20
BEGIN
21
 
22
PROCESS (read, ready_set)
23
BEGIN
24
  IF read = '1' THEN scan_ready <= '0';
25
  ELSIF ready_set'EVENT and ready_set = '1' THEN
26
                scan_ready <= '1';
27
  END IF;
28
END PROCESS;
29
 
30
 
31
--This process filters the raw clock signal coming from the keyboard using a shift register and two AND gates
32
Clock_filter: PROCESS
33
BEGIN
34
        WAIT UNTIL clock'EVENT AND clock= '1';
35
        clock_enable <= NOT clock_enable;
36
        IF clock_enable = '1' THEN
37
                filter (6 DOWNTO 0) <= filter(7 DOWNTO 1) ;
38
                filter(7) <= keyboard_clk;
39
                IF filter = "11111111" THEN keyboard_clk_filtered <= '1';
40
                ELSIF  filter= "00000000" THEN keyboard_clk_filtered <= '0';
41
                END IF;
42
        END IF;
43
END PROCESS Clock_filter;
44
 
45
 
46
--This process reads in serial data coming from the terminal
47
PROCESS
48
BEGIN
49
WAIT UNTIL (KEYBOARD_CLK_filtered'EVENT AND KEYBOARD_CLK_filtered='1');
50
IF RESET='0' THEN
51
        INCNT <= "0000";
52
        READ_CHAR <= '0';
53
        ready_set<= '0';
54
ELSE
55
  IF KEYBOARD_DATA='0' AND READ_CHAR='0' THEN
56
        READ_CHAR<= '1';
57
                ready_set<= '0';
58
  ELSE
59
                        -- Shift in next 8 data bits to assemble a scan code
60
    IF READ_CHAR = '1' THEN
61
        IF INCNT < "1001" THEN
62
                INCNT                           <= INCNT + 1;
63
                SHIFTIN(7 DOWNTO 0) <= SHIFTIN(8 DOWNTO 1);
64
                SHIFTIN(8)                      <= KEYBOARD_DATA;
65
                        -- End of scan code character, so set flags and exit loop
66
        ELSE
67
                        scan_code                       <= SHIFTIN(7 DOWNTO 0);
68
                        READ_CHAR                       <= '0';
69
                ready_set                       <= '1';
70
                INCNT                           <= "0000";
71
        END IF;
72
     END IF;
73
   END IF;
74
 END IF;
75
END PROCESS;
76
END a;
77
 
78
 

powered by: WebSVN 2.1.0

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