ENTITY KEYBOARD IS
PORT(CLK_1K:IN STD_LOGIC;
KEY_IN:IN STD_LOGIC_VECTOR(2 DOWNTO 0);
CLK_SACN:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
DATA_N:OUT STD_LOGIC_VECTOR(3 DOWNTO );
DATA_F:OUT STD_LOGIC_VECTOR(3 DOWNTO );
FLAG_N:OUT STD_LOGIC;
FLAG_F:OUT STD_LOGIC;
CLK_CTR:OUT STD_LOGIC;
CLK_DEBOUNCE:OUT STD_LOGIC);
END ENTITY KEYBOATD;
ARCHITECTURE ART OF KEYBOARD IS
COMPONENT DEBOUNGING IS
PORT(D_IN:IN STD_LOGIC;
CLK: IN STD_LOGIC;
D_OUT:OUT STD_LOGIC);
END COMPONENT DEBOUNGING;
SIGNAL CLK:STD_LOGIC;
SIGNAL C_KEYBOARD:STD_LOGIC_VECTOR(1 DOWNTO 0);
SIGNAL C_DEBOUNCE:STD_LOGIC;
SIGNAL C:STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL N,F:STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL FN,FF:STD_LOGIC;
SIGNAL SEL:STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
内部连接
DATA_N<=N;
DATA_F<=F;
FLAN_N<=FN;
FLAN_F<=FF;
CLK_CLR<=CLK;
――扫描信号发生器
COUNTER:BLOCK IS
SIGNAL Q:STD_LOGIC_VECTOR(5 DOWNTO 0);
SIGNAL SEL: STD_LOGIC_ VECTOR(3 DOWNTO 0);
BEGIN
PROCESS(CLK_1K) IS
BEGIN
IF CLK_1K’EVENT AND CLK_1K=’1’THEN
Q<=Q+1;
ENDIF;
C_DEBOUNCE<=Q(2);
C_KEYBOARD<=Q(6 DOWNTO 5);
――产生键扫描信号
--C_DEBOUNCE<=Q(1);
--C_KEYBOARD<=Q(5 DOWNTO 4);
CLK<=Q(0);
END PROCESS;
CLK_DEBOUNG<=C_DEBOUNCE;
SEL<=“1110”WHEN C_KEYBOARD=0 ELSE
1101”WHEN C_KEYBOARD=1 ELSE
“1011”WHEN C_KEYBOARD=2 ELSE
“0111”WHEN C_KEYBOARD=3 ELSE
“1111”
CLK_SCAN<=SEL;
END BLOCK COUNTER;
--键盘去抖
DEBOUNUING :BLOCK IS
BEGIN
U1: DEBOUNCING PORT MAP (D_IN=>KEY_IN(0),D_OUT=>C(0),
CLK=>C_DEBOUNCE);
U2: DEBOUNCING PORT MAP (D_IN=>KEY_IN(1),D_OUT=>C(1),
CLK=>C_DEBOUNCE);
U3: DEBOUNCING PORT MAP (D_IN=>KEY_IN(2),D_OUT=>C(2),
CLK=>C_DEBOUNCE);
END BLOCK DEBOUNUING;
――键盘译码
KEY_DECODER:BLOCK
SIGNAL Z:STD_LOGIC_VECTOR(4 DOWNTO 0);
BEGIN
Z<=C_KEYBOARD&C
IF CLK’EVENT AND CLK=’1’ THEN
CASE Z IS
WHEN“11101”=>N<=“0000”;0
WHEN“00011”=>N<=“0001”;1
WHEN“00101”=>N<=“0010”;2
WHEN“11101”=>N<=“0000”;3
WHEN“01011”=>N<=“0100”;4
WHEN“01101”=>N<=“0101”;5
WHEN“01110”=>N<=“0110”;6
WHEN“10101”=>N<=“0111”;7
WHEN“10110”=>N<=“1000”;8
WHEN“10110”=>N<=“1001”;9
WHEN OTHERS =>N<=“1111”;
END CASE;
END IF;
IF CLK’EVENT AND CLK=’1’ THEN
CASE Z IS
WHEN“11011”=>F<=“0100”;
需要完整内容的请联系QQ752018766,本文免费,转发请注明源于www.youerw.com
END ARCHITECTURE ART;
――密码控制电路的VHDL源程序
--CTRL.VHD
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] ... 下一页 >>