-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeytr.v
83 lines (70 loc) · 2.27 KB
/
keytr.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// ============================================================================
// Copyright (c) 2012 by Terasic Technologies Inc.
// ============================================================================
//
// Permission:
//
// Terasic grants permission to use and modify this code for use
// in synthesis for all Terasic Development Boards and Altrea Development
// Kits made by Terasic. Other use of this code, including the selling
// ,duplication, or modification of any portion is strictly prohibited.
//
// Disclaimer:
//
// This VHDL or Verilog source code is intended as a design reference
// which illustrates how these types of functions can be implemented.
// It is the user's responsibility to verify their design for
// consistency and functionality through the use of formal
// verification methods. Terasic provides no warranty regarding the use
// or functionality of this code.
//
// ============================================================================
//
// Terasic Technologies Inc
// 9F., No.176, Sec.2, Gongdao 5th Rd, East Dist, Hsinchu City, 30070. Taiwan
//
//
//
// web: http://www.terasic.com/
// email: support@terasic.com
//
// ============================================================================
//
// Major Functions:KEY triggle
//
// ============================================================================
//
// Revision History :
// ============================================================================
// Ver :| Author :| Mod. Date :| Changes Made:
// V1.0 :| Joe Yang :| 05/07/10 :| Initial Revision
// ============================================================================
`define OUT_BIT 9
module keytr (
key,
ON,
clock,
KEYON,
counter
);
input key;
output ON;
output KEYON;
input clock;
output [9:0]counter;
reg [9:0]counter;
reg KEYON;
wire ON=((counter[`OUT_BIT]==1) && (key==0))?0:1;
always @(negedge ON or posedge clock) begin
if (!ON)
counter=0;
else if (counter[`OUT_BIT]==0)
counter=counter+1;
end
always @(posedge clock) begin
if ((counter>=1) && (counter <5))
KEYON=0;
else
KEYON=1;
end
endmodule