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

Subversion Repositories signed_unsigned_multiplier_and_divider

[/] [signed_unsigned_multiplier_and_divider/] [trunk/] [PmodKYPD.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zpekic
----------------------------------------------------------------------------------
2
-- Company: @Home
3
-- Engineer: Zoltan Pekic (zpekic@hotmail.com)
4
-- 
5
-- Create Date:    23:44:29 03/08/2016 
6
-- Design Name: 
7
-- Module Name:    PmodKYPD - Behavioral (http://store.digilentinc.com/pmodkypd-16-button-keypad/)
8
-- Project Name:   Alarm Clock
9
-- Target Devices: Mercury FPGA + Baseboard (http://www.micro-nova.com/mercury/)
10
-- Tool versions:  Xilinx ISE 14.7 (nt64)
11
-- Description:    Hex keyboard driver
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
 
23
-- Uncomment the following library declaration if using
24
-- arithmetic functions with Signed or Unsigned values
25
use IEEE.NUMERIC_STD.ALL;
26
 
27
-- Uncomment the following library declaration if instantiating
28
-- any Xilinx primitives in this code.
29
--library UNISIM;
30
--use UNISIM.VComponents.all;
31
 
32
entity PmodKYPD is
33
    Port (
34
           clk : in  STD_LOGIC;
35
                          reset: in STD_LOGIC;
36
                          bcdmode: in STD_LOGIC;
37
           Col : out  STD_LOGIC_VECTOR (3 downto 0);
38
                          Row : in  STD_LOGIC_VECTOR (3 downto 0);
39
                          key_code: out  STD_LOGIC_VECTOR (3 downto 0);
40
                          key_down: out STD_LOGIC
41
         );
42
end PmodKYPD;
43
 
44
use work.debouncer;
45
 
46
architecture Behavioral of PmodKYPD is
47
 
48
component debouncer is
49
    Port ( clock : in  STD_LOGIC;
50
           reset : in  STD_LOGIC;
51
           signal_in : in  STD_LOGIC;
52
           signal_out : out  STD_LOGIC);
53
end component;
54
 
55
signal counter: unsigned(5 downto 0);
56
signal key_pressed: std_logic;
57
 
58
begin
59
 
60
scan_key: process(reset, bcdmode, clk, key_pressed)
61
begin
62
   if (reset = '1') then
63
                counter <= "000000";
64
        else
65
                if (rising_edge(clk)) then
66
                        if (bcdmode = '1' and counter = "100111") then
67
                                counter <= "000000";
68
                        else
69
                                counter <= counter + 1;
70
                        end if;
71
                        if (key_pressed = '0') then
72
                                key_code <= std_logic_vector(counter(5 downto 2));
73
                                key_down <= '1';
74
                        else
75
                                key_down <= '0';
76
                        end if;
77
                end if;
78
        end if;
79
end process;
80
 
81
-- scanning rows and cols
82
drive_kbd: process(counter)
83
begin
84
        case counter(5 downto 2) is
85
                when X"0" =>
86
                        col <= "1110";
87
                        key_pressed <= row(3);
88
                when X"1" =>
89
                        col <= "1110";
90
                        key_pressed <= row(0);
91
                when X"2" =>
92
                        col <= "1101";
93
                        key_pressed <= row(0);
94
                when X"3" =>
95
                        col <= "1011";
96
                        key_pressed <= row(0);
97
                when X"4" =>
98
                        col <= "1110";
99
                        key_pressed <= row(1);
100
                when X"5" =>
101
                        col <= "1101";
102
                        key_pressed <= row(1);
103
                when X"6" =>
104
                        col <= "1011";
105
                        key_pressed <= row(1);
106
                when X"7" =>
107
                        col <= "1110";
108
                        key_pressed <= row(2);
109
                when X"8" =>
110
                        col <= "1101";
111
                        key_pressed <= row(2);
112
                when X"9" =>
113
                        col <= "1011";
114
                        key_pressed <= row(2);
115
                when X"A" =>
116
                        col <= "0111";
117
                        key_pressed <= row(0);
118
                when X"B" =>
119
                        col <= "0111";
120
                        key_pressed <= row(1);
121
                when X"C" =>
122
                        col <= "0111";
123
                        key_pressed <= row(2);
124
                when X"D" =>
125
                        col <= "0111";
126
                        key_pressed <= row(3);
127
                when X"E" =>
128
                        col <= "1011";
129
                        key_pressed <= row(3);
130
                when X"F" =>
131
                        col <= "1101";
132
                        key_pressed <= row(3);
133
                when others =>
134
                        key_pressed <= '1';
135
        end case;
136
end process;
137
 
138
end Behavioral;
139
 

powered by: WebSVN 2.1.0

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