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

Subversion Repositories ps2_keyboard_interface

[/] [ps2_keyboard_interface/] [Keyboard_Controller.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 OmarMokhta
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.numeric_std.all;
4
use IEEE.std_logic_unsigned.all;
5
entity Keyboard_Controller is
6
    Port ( Clk : in  STD_LOGIC;
7
                          Clk2 : in  STD_LOGIC;
8
           DataIn : in  STD_LOGIC;
9
                          Enables : out  STD_LOGIC_VECTOR (3 downto 0);
10
                          pressed : out  STD_LOGIC_VECTOR (7 downto 0);
11
                          Segments : out  STD_LOGIC_VECTOR (7 downto 0));
12
end Keyboard_Controller;
13
architecture Behavioral of Keyboard_Controller is
14
signal data : STD_LOGIC_VECTOR (21 downto 0) := "1111111111111111111111";
15
signal OutByte1,OutByte2 : STD_LOGIC_VECTOR (7 downto 0);
16
signal presses,npresses : STD_LOGIC_VECTOR (7 downto 0) := x"00";
17
signal Counter,nCounter : STD_LOGIC_VECTOR (4 downto 0) := "00000";
18
COMPONENT SevenSegment
19
PORT(
20
        Clk : IN std_logic;
21
        dataIn : IN std_logic_vector(15 downto 0);
22
        Enables : OUT std_logic_vector(3 downto 0);
23
        Segments : OUT std_logic_vector(7 downto 0));
24
END COMPONENT;
25
begin
26
pressed <= presses;
27
npresses <= presses + 1;
28
nCounter <= Counter + 1;
29
Inst_SevenSegment: SevenSegment PORT MAP(
30
        Clk => Clk2,
31
        Enables => Enables,
32
        Segments => Segments,
33
        dataIn(15 downto 8) => OutByte1,
34
        dataIn(7 downto 0) => OutByte2);
35
process (Clk) begin
36
        if (falling_edge(Clk)) then
37
                data(21 downto 1) <= data(20 downto 0);
38
                data(0) <= DataIn;
39
                if (Counter = "10101") then
40
                        --if (data(9 downto 2) <= x"0F") then
41
                                OutByte1 <= data(9 downto 2);
42
                                OutByte2 <= data(20 downto 13);
43
                                presses <= npresses;
44
                        --end if;
45
                end if;
46
                if (Counter = "10101") then
47
                        Counter <= "00000";
48
                else
49
                        Counter <= nCounter;
50
                end if;
51
        end if;
52
end process;
53
end Behavioral;

powered by: WebSVN 2.1.0

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