Page 206 - MDP2020-2
P. 206
| 인천전자마이스터고등학교 ·············································································································
200
end
end
endmodule
//keypad
// key_col[3] Output PIN_106
// key_col[2] Output PIN_105
// key_col[1] Output PIN_104
// key_col[0] Output PIN_100
// key_row[3] Input PIN_121
// key_row[2] Input PIN_125
// key_row[1] Input PIN_126
// key_row[0] Input PIN_127
module keypad(clk, rst, key_col, key_row, key_data);
input clk, rst;
input [3:0] key_row;
output [3:0] key_col;
output reg [3:0] key_data;
reg [31:0] clk_cnt;
reg [5:0] state;
reg [1:0] i;
parameter column1 = 4'b0001;
parameter column2 = 4'b0010;
parameter column3 = 4'b0100;
parameter column4 = 4'b1000;
//parameter scan_delay = 250;
parameter scan_delay = 1000000;
//assign key_stop = key_row[0] | key_row[1] | key_row[2] | key_row[3];
assign key_col = state;
always @(posedge clk, negedge rst)
begin
if(!rst)
begin
clk_cnt <= 0;
end
else
begin
if(clk_cnt >= scan_delay - 1)
begin