📄 keypad.vhd
字号:
-----------------------------------------------------------------------
--
-- Original Code Copyright (c) 1999 by Esperan. All rights reserved.
-- www.esperan.com
--
-- This source file may be used and distributed without restriction
-- provided that this copyright statement is not removed from the file
-- and that any derivative work contains this copyright notice.
--
-- Esperan VHDL Alarm Clock Lab Exercise Design V5.0
--
-- Keypad.vhd
-- Matrix keypad "Bus functional interface" model to interface between
-- the testbench and the keypad scanner. The model converts the testbench
-- key press instruction (T_KEYPAD) to the equivalent 4 bit std_logic_vector
-- required by the key pad scanner
--
-- The keypad is organised as follows
--
-- COLUMN 2 1 0
--
-- | | |
-- 1--------2--------3-- ROW 3
-- | | |
-- 4--------5--------6-- ROW 2
-- | | |
-- 7--------8--------9-- ROW 1
-- | | |
-- *--------0--------#-- ROW 0
-- | | |
--
-- The columns are "scanned" with a "walking 0"
-- pattern - if a '0' appears on a row line it
-- indicates that a key has been pressed
--
----------------------------------------------------
Library IEEE;
use IEEE.Std_Logic_1164.all;
use work.P_alarm_test.all;
entity KEYPAD is
port (KEY: in T_KEYPAD;
COLUMNS : in std_logic_vector(2 downto 0);
ROWS: out std_logic_vector(3 downto 0));
end KEYPAD;
architecture BEHAVE of KEYPAD is
begin
SWITCH_MATRIX: process (KEY, COLUMNS)
begin
ROWS <= "1111";
case KEY is
when '0' => ROWS(0) <= COLUMNS(1);
when '1' => ROWS(3) <= COLUMNS(2);
when '2' => ROWS(3) <= COLUMNS(1);
when '3' => ROWS(3) <= COLUMNS(0);
when '4' => ROWS(2) <= COLUMNS(2);
when '5' => ROWS(2) <= COLUMNS(1);
when '6' => ROWS(2) <= COLUMNS(0);
when '7' => ROWS(1) <= COLUMNS(2);
when '8' => ROWS(1) <= COLUMNS(1);
when '9' => ROWS(1) <= COLUMNS(0);
when '*' => ROWS(0) <= COLUMNS(2);
when '#' => ROWS(0) <= COLUMNS(0);
-- for "no key pressed", use the default ROWS assignment
when '-' => NULL;
end case;
end process;
end BEHAVE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -