PoC.io.KeyPadScanner

This module drives a one-hot encoded column vector to read back a rows vector. By scanning column-by-column it’s possible to extract the current button state of the whole keypad. The scanner uses high-active logic. The keypad size and scan frequency can be configured. The outputed signal matrix is not debounced.

Entity Declaration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
entity io_KeyPadScanner is
  generic (
    CLOCK_FREQ              : FREQ        := 100 MHz;
    SCAN_FREQ               : FREQ        := 1 kHz;
    ROWS                    : positive    := 4;
    COLUMNS                 : positive    := 4;
    ADD_INPUT_SYNCHRONIZERS : boolean     := TRUE
  );
  port (
    Clock         : in  std_logic;
    Reset         : in  std_logic;
    -- Matrix interface
    KeyPadMatrix  : out T_SLM(COLUMNS - 1 downto 0, ROWS - 1 downto 0);
    -- KeyPad interface
    ColumnVector  : out std_logic_vector(COLUMNS - 1 downto 0);
    RowVector     : in  std_logic_vector(ROWS - 1 downto 0)
  );
end entity;