1 |
27 |
smpickett |
//==================================================================//
|
2 |
|
|
// File: sub_UserBoxes.v //
|
3 |
|
|
// Version: 0.0.0.1 //
|
4 |
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -//
|
5 |
|
|
// Copyright (C) Stephen Pickett //
|
6 |
|
|
// Jul 15, 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 |
|
|
// //
|
27 |
|
|
//==================================================================//
|
28 |
|
|
|
29 |
|
|
module sub_UserTimeScaleBox(
|
30 |
|
|
MASTER_CLK, MASTER_RST,
|
31 |
|
|
VALUE_OUT,
|
32 |
|
|
BUTTON_RISE, BUTTON_FALL,
|
33 |
|
|
XCOORD, YCOORD
|
34 |
|
|
);
|
35 |
|
|
|
36 |
|
|
//==================================================================//
|
37 |
|
|
// DEFINITIONS //
|
38 |
|
|
//==================================================================//
|
39 |
|
|
parameter P_UPleft = 10'h99;
|
40 |
|
|
parameter P_UPright = 10'h9D;
|
41 |
|
|
parameter P_UPbot = 10'h1E8;
|
42 |
|
|
parameter P_UPtop = 10'h1EE;
|
43 |
|
|
parameter P_DNleft = 10'h9F;
|
44 |
|
|
parameter P_DNright = 10'hA3;
|
45 |
|
|
parameter P_DNbot = 10'h1E8;
|
46 |
|
|
parameter P_DNtop = 10'h1EE;
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
//==================================================================//
|
51 |
|
|
// VARIABLE DEFINITIONS //
|
52 |
|
|
//==================================================================//
|
53 |
|
|
//----------------------//
|
54 |
|
|
// INPUTS / OUTPUTS //
|
55 |
|
|
//----------------------//
|
56 |
|
|
input MASTER_CLK; // global master clock
|
57 |
|
|
input MASTER_RST; // global master reset
|
58 |
|
|
input[9:0] XCOORD, YCOORD; // X and Y coordinates of the current mouse
|
59 |
|
|
// position. See the documentation for details
|
60 |
|
|
input BUTTON_RISE; // Trigger has risen
|
61 |
|
|
input BUTTON_FALL; // Trigger has fallen
|
62 |
|
|
|
63 |
|
|
output[3:0] VALUE_OUT; //
|
64 |
|
|
|
65 |
|
|
//----------------------//
|
66 |
|
|
// NODES //
|
67 |
|
|
//----------------------//
|
68 |
|
|
wire MASTER_CLK, MASTER_RST;
|
69 |
|
|
wire[9:0] XCOORD, YCOORD;
|
70 |
|
|
wire BUTTON_RISE, BUTTON_FALL;
|
71 |
|
|
|
72 |
|
|
reg[3:0] VALUE_OUT;
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
//==================================================================//
|
78 |
|
|
// T E S T I N G //
|
79 |
|
|
//==================================================================//
|
80 |
|
|
// NOTHING TO TEST
|
81 |
|
|
|
82 |
|
|
//==================================================================//
|
83 |
|
|
// FUNCTIONAL DEFINITIONS //
|
84 |
|
|
//==================================================================//
|
85 |
|
|
wire in_range_up, in_range_dn;
|
86 |
|
|
|
87 |
|
|
assign in_range_up = (((YCOORD >= P_UPbot) && (YCOORD <= P_UPtop)) && ((XCOORD >= P_UPleft && XCOORD <= P_UPright)));
|
88 |
|
|
assign in_range_dn = (((YCOORD >= P_DNbot) && (YCOORD <= P_DNtop)) && ((XCOORD >= P_DNleft && XCOORD <= P_DNright)));
|
89 |
|
|
|
90 |
|
|
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
|
91 |
|
|
if(MASTER_RST)
|
92 |
|
|
VALUE_OUT <= 4'b0;
|
93 |
|
|
else if(BUTTON_RISE && in_range_up)
|
94 |
|
|
VALUE_OUT <= VALUE_OUT + 1;
|
95 |
|
|
else if(BUTTON_RISE && in_range_dn)
|
96 |
|
|
VALUE_OUT <= VALUE_OUT - 1;
|
97 |
|
|
else
|
98 |
|
|
VALUE_OUT <= VALUE_OUT;
|
99 |
|
|
end
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
endmodule
|
103 |
|
|
|
104 |
|
|
//==================================================================//
|
105 |
|
|
//==================================================================//
|
106 |
|
|
//==================================================================//
|
107 |
|
|
//==================================================================//
|
108 |
|
|
//==================================================================//
|
109 |
|
|
//==================================================================//
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
module sub_UserTriggerStyleBox(
|
113 |
|
|
MASTER_CLK, MASTER_RST,
|
114 |
|
|
VALUE_OUT,
|
115 |
|
|
BUTTON_RISE, BUTTON_FALL,
|
116 |
|
|
XCOORD, YCOORD
|
117 |
|
|
);
|
118 |
|
|
|
119 |
|
|
//==================================================================//
|
120 |
|
|
// DEFINITIONS //
|
121 |
|
|
//==================================================================//
|
122 |
|
|
parameter P_RISEleft = 10'h39;
|
123 |
|
|
parameter P_RISEright = 10'h3D;
|
124 |
|
|
parameter P_RISEbot = 10'h1DF;
|
125 |
|
|
parameter P_RISEtop = 10'h1E5;
|
126 |
|
|
parameter P_FALLleft = 10'h3F;
|
127 |
|
|
parameter P_FALLright = 10'h43;
|
128 |
|
|
parameter P_FALLbot = 10'h1DF;
|
129 |
|
|
parameter P_FALLtop = 10'h1E5;
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
//==================================================================//
|
134 |
|
|
// VARIABLE DEFINITIONS //
|
135 |
|
|
//==================================================================//
|
136 |
|
|
//----------------------//
|
137 |
|
|
// INPUTS / OUTPUTS //
|
138 |
|
|
//----------------------//
|
139 |
|
|
input MASTER_CLK; // global master clock
|
140 |
|
|
input MASTER_RST; // global master reset
|
141 |
|
|
input[9:0] XCOORD, YCOORD; // X and Y coordinates of the current mouse
|
142 |
|
|
// position. See the documentation for details
|
143 |
|
|
input BUTTON_RISE; // Trigger has risen
|
144 |
|
|
input BUTTON_FALL; // Trigger has fallen
|
145 |
|
|
|
146 |
|
|
output[1:0] VALUE_OUT; //
|
147 |
|
|
|
148 |
|
|
//----------------------//
|
149 |
|
|
// NODES //
|
150 |
|
|
//----------------------//
|
151 |
|
|
wire MASTER_CLK, MASTER_RST;
|
152 |
|
|
wire[9:0] XCOORD, YCOORD;
|
153 |
|
|
wire BUTTON_RISE, BUTTON_FALL;
|
154 |
|
|
|
155 |
|
|
reg[1:0] VALUE_OUT;
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
//==================================================================//
|
161 |
|
|
// T E S T I N G //
|
162 |
|
|
//==================================================================//
|
163 |
|
|
// NOTHING TO TEST
|
164 |
|
|
|
165 |
|
|
//==================================================================//
|
166 |
|
|
// FUNCTIONAL DEFINITIONS //
|
167 |
|
|
//==================================================================//
|
168 |
|
|
wire in_range_rise, in_range_fall;
|
169 |
|
|
|
170 |
|
|
assign in_range_rise = (((YCOORD >= P_RISEbot) && (YCOORD <= P_RISEtop)) && ((XCOORD >= P_RISEleft && XCOORD <= P_RISEright)));
|
171 |
|
|
assign in_range_fall = (((YCOORD >= P_FALLbot) && (YCOORD <= P_FALLtop)) && ((XCOORD >= P_FALLleft && XCOORD <= P_FALLright)));
|
172 |
|
|
|
173 |
|
|
always @ (posedge MASTER_CLK or posedge MASTER_RST) begin
|
174 |
|
|
if(MASTER_RST)
|
175 |
|
|
VALUE_OUT <= 2'b00;
|
176 |
|
|
else if(BUTTON_RISE && in_range_rise)
|
177 |
|
|
VALUE_OUT <= 2'b00;
|
178 |
|
|
else if(BUTTON_RISE && in_range_fall)
|
179 |
|
|
VALUE_OUT <= 2'b01;
|
180 |
|
|
else
|
181 |
|
|
VALUE_OUT <= VALUE_OUT;
|
182 |
|
|
end
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
endmodule
|
186 |
|
|
|
187 |
|
|
|