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

Subversion Repositories z80soc

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

powered by: WebSVN 2.1.0

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