1 |
11 |
smpickett |
//==================================================================//
|
2 |
|
|
// File: d_MouseInput.v //
|
3 |
|
|
// Version: 0.0.0.2 //
|
4 |
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
|
5 |
|
|
// Copyright (C) Stephen Pickett //
|
6 |
|
|
// Jun 08, 2005 //
|
7 |
|
|
// //
|
8 |
|
|
// This program is free software; you can redistribute it and/or //
|
9 |
|
|
// modify it under the terms of the GNU General Public License //
|
10 |
|
|
// as published by the Free Software Foundation; either version 2 //
|
11 |
|
|
// of the License, or (at your option) any later version. //
|
12 |
|
|
// //
|
13 |
|
|
// This program is distributed in the hope that it will be useful, //
|
14 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
15 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
16 |
|
|
// GNU General Public License for more details. //
|
17 |
|
|
// //
|
18 |
|
|
// If you have not received a copy of the GNU General Public License//
|
19 |
|
|
// along with this program; write to: //
|
20 |
|
|
// Free Software Foundation, Inc., //
|
21 |
|
|
// 51 Franklin Street, Fifth Floor, //
|
22 |
|
|
// Boston, MA 02110-1301, USA. //
|
23 |
|
|
// //
|
24 |
|
|
//------------------------------------------------------------------//
|
25 |
|
|
// Revisions: //
|
26 |
|
|
// Ver 0.0.0.1 May , 2005 Under Development //
|
27 |
|
|
// Ver 0.0.0.2 Jun 08, 2005 Modulized 'UserLines' //
|
28 |
|
|
// //
|
29 |
|
|
//==================================================================//
|
30 |
|
|
|
31 |
|
|
module Driver_MouseInput(
|
32 |
|
|
CLK_50MHZ, MASTER_RST,
|
33 |
|
|
XCOORD, YCOORD, L_BUTTON, R_BUTTON, M_BUTTON,
|
34 |
|
|
TRIGGER_LEVEL
|
35 |
|
|
);
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
//==================================================================//
|
39 |
|
|
// PARAMETER DEFINITIONS //
|
40 |
|
|
//==================================================================//
|
41 |
|
|
parameter P_trigger_clickLimit_left = 10'd556;
|
42 |
|
|
parameter P_trigger_clickLimit_right = 10'd558;
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
//==================================================================//
|
46 |
|
|
// VARIABLE DEFINITIONS //
|
47 |
|
|
//==================================================================//
|
48 |
|
|
//----------------------//
|
49 |
|
|
// INPUTS / OUTPUTS //
|
50 |
|
|
//----------------------//
|
51 |
|
|
input CLK_50MHZ; // System wide clock
|
52 |
|
|
input MASTER_RST; // System wide reset
|
53 |
|
|
input[9:0] XCOORD; // X coordinate of the cursor
|
54 |
|
|
input[9:0] YCOORD; // Y coordinate of the cursor
|
55 |
|
|
input L_BUTTON; // Left Mouse Button Press
|
56 |
|
|
input R_BUTTON; // Right Mouse Button Press
|
57 |
|
|
input M_BUTTON; // Middle Mouse Button Press
|
58 |
|
|
output[9:0] TRIGGER_LEVEL; // Current Trigger Level
|
59 |
|
|
|
60 |
|
|
//----------------------//
|
61 |
|
|
// WIRES / NODES //
|
62 |
|
|
//----------------------//
|
63 |
|
|
wire CLK_50MHZ, MASTER_RST;
|
64 |
|
|
wire[9:0] XCOORD;
|
65 |
|
|
wire[9:0] YCOORD;
|
66 |
|
|
wire L_BUTTON, R_BUTTON, M_BUTTON;
|
67 |
|
|
wire[9:0] TRIGGER_LEVEL;
|
68 |
|
|
|
69 |
|
|
//----------------------//
|
70 |
|
|
// REGISTERS //
|
71 |
|
|
//----------------------//
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
//----------------------//
|
75 |
|
|
// TESTING //
|
76 |
|
|
//----------------------//
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
//==================================================================//
|
82 |
|
|
// FUNCTIONAL DEFINITIONS //
|
83 |
|
|
//==================================================================//
|
84 |
|
|
|
85 |
|
|
//------------------------------------------------------------------//
|
86 |
|
|
// INTERMEDIATES //
|
87 |
|
|
//------------------------------------------------------------------//
|
88 |
|
|
|
89 |
|
|
// -- LEFT BUTTON --
|
90 |
|
|
wire Lrise, Lfall;
|
91 |
|
|
reg Lbuf;
|
92 |
|
|
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
|
93 |
|
|
if(MASTER_RST == 1'b1) Lbuf <= 1'b0;
|
94 |
|
|
else Lbuf <= L_BUTTON;
|
95 |
|
|
end
|
96 |
|
|
|
97 |
|
|
assign Lrise = (!Lbuf & L_BUTTON);
|
98 |
|
|
assign Lfall = ( Lbuf & !L_BUTTON);
|
99 |
|
|
|
100 |
|
|
// -- RIGHT BUTTON --
|
101 |
|
|
wire Rrise, Rfall;
|
102 |
|
|
reg Rbuf;
|
103 |
|
|
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
|
104 |
|
|
if(MASTER_RST == 1'b1) Rbuf <= 1'b0;
|
105 |
|
|
else Rbuf <= R_BUTTON;
|
106 |
|
|
end
|
107 |
|
|
|
108 |
|
|
assign Rrise = (!Rbuf & R_BUTTON);
|
109 |
|
|
assign Rfall = ( Rbuf & !R_BUTTON);
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
// -- MIDDLE BUTTON --
|
113 |
|
|
wire Mrise, Mfall;
|
114 |
|
|
reg Mbuf;
|
115 |
|
|
always @ (posedge CLK_50MHZ or posedge MASTER_RST) begin
|
116 |
|
|
if(MASTER_RST == 1'b1) Mbuf <= 1'b0;
|
117 |
|
|
else Mbuf <= M_BUTTON;
|
118 |
|
|
end
|
119 |
|
|
|
120 |
|
|
assign Mrise = (!Mbuf & M_BUTTON);
|
121 |
|
|
assign Mfall = ( Mbuf & !M_BUTTON);
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
//------------------------------------------------------------------//
|
125 |
|
|
// USER MODIFIABLE LINES //
|
126 |
|
|
//------------------------------------------------------------------//
|
127 |
|
|
sub_UserLines set_trigger(
|
128 |
|
|
.MASTER_CLK(CLK_50MHZ), .MASTER_RST(MASTER_RST),
|
129 |
|
|
.LINE_VALUE_OUT(TRIGGER_LEVEL),
|
130 |
|
|
.BUTTON_RISE(Lrise),
|
131 |
|
|
.BUTTON_FALL(Lfall),
|
132 |
|
|
.XCOORD(XCOORD),
|
133 |
|
|
.YCOORD(YCOORD),
|
134 |
|
|
.LEFT(P_trigger_clickLimit_left),
|
135 |
|
|
.RGHT(P_trigger_clickLimit_right),
|
136 |
|
|
.BOT(TRIGGER_LEVEL-1'b1),
|
137 |
|
|
.TOP(TRIGGER_LEVEL+1'b1),
|
138 |
|
|
.SETXnY(1'b0)
|
139 |
|
|
);
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
endmodule
|
144 |
|
|
|