1 |
21 |
qaztronic |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// WISHBONE GPIO Definitions ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the GPIO project ////
|
6 |
|
|
//// http://www.opencores.org/cores/gpio/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Description ////
|
9 |
|
|
//// GPIO IP Definitions. ////
|
10 |
|
|
//// ////
|
11 |
|
|
//// To Do: ////
|
12 |
|
|
//// Nothing ////
|
13 |
|
|
//// ////
|
14 |
|
|
//// Author(s): ////
|
15 |
|
|
//// - Damjan Lampret, lampret@opencores.org ////
|
16 |
|
|
//// ////
|
17 |
|
|
//////////////////////////////////////////////////////////////////////
|
18 |
|
|
//// ////
|
19 |
|
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
20 |
|
|
//// ////
|
21 |
|
|
//// This source file may be used and distributed without ////
|
22 |
|
|
//// restriction provided that this copyright statement is not ////
|
23 |
|
|
//// removed from the file and that any derivative work contains ////
|
24 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
25 |
|
|
//// ////
|
26 |
|
|
//// This source file is free software; you can redistribute it ////
|
27 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
28 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
29 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
30 |
|
|
//// later version. ////
|
31 |
|
|
//// ////
|
32 |
|
|
//// This source is distributed in the hope that it will be ////
|
33 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
34 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
35 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
36 |
|
|
//// details. ////
|
37 |
|
|
//// ////
|
38 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
39 |
|
|
//// Public License along with this source; if not, download it ////
|
40 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
41 |
|
|
//// ////
|
42 |
|
|
//////////////////////////////////////////////////////////////////////
|
43 |
|
|
//
|
44 |
|
|
// CVS Revision History
|
45 |
|
|
//
|
46 |
|
|
// $Log: gpio_defines.v,v $
|
47 |
|
|
// Revision 1.1 2009/03/25 22:16:56 kenagy
|
48 |
|
|
// no message
|
49 |
|
|
//
|
50 |
|
|
// Revision 1.2 2009/03/05 19:11:54 kenagy
|
51 |
|
|
// no message
|
52 |
|
|
//
|
53 |
|
|
// Revision 1.1 2009/03/05 00:12:58 kenagy
|
54 |
|
|
// no message
|
55 |
|
|
//
|
56 |
|
|
// Revision 1.9 2004/07/16 08:57:05 simont
|
57 |
|
|
// Reorganize core, add synchronization flops.
|
58 |
|
|
//
|
59 |
|
|
// Revision 1.8 2003/12/17 13:00:52 gorand
|
60 |
|
|
// added ECLK and NEC registers, all tests passed.
|
61 |
|
|
//
|
62 |
|
|
// Revision 1.7 2003/12/01 17:10:44 simons
|
63 |
|
|
// ifndef directive is not supported by all tools.
|
64 |
|
|
//
|
65 |
|
|
// Revision 1.6 2003/11/06 13:59:07 gorand
|
66 |
|
|
// added support for 8-bit access to registers.
|
67 |
|
|
//
|
68 |
|
|
// Revision 1.2 2003/10/02 18:54:35 simons
|
69 |
|
|
// GPIO signals muxed with other peripherals, higland_board fixed.
|
70 |
|
|
//
|
71 |
|
|
// Revision 1.1.1.1 2003/06/24 09:09:23 simons
|
72 |
|
|
// This files were moved here from toplevel folder.
|
73 |
|
|
//
|
74 |
|
|
// Revision 1.1.1.1 2003/06/11 18:51:13 simons
|
75 |
|
|
// Initial import.
|
76 |
|
|
//
|
77 |
|
|
// Revision 1.5 2002/11/11 21:36:28 lampret
|
78 |
|
|
// Added ifdef to remove mux from clk_pad_i if mux is not allowed. This also removes RGPIO_CTRL[NEC].
|
79 |
|
|
//
|
80 |
|
|
// Revision 1.4 2002/05/06 18:25:31 lampret
|
81 |
|
|
// negedge flops are enabled by default.
|
82 |
|
|
//
|
83 |
|
|
// Revision 1.3 2001/12/25 17:12:35 lampret
|
84 |
|
|
// Added RGPIO_INTS.
|
85 |
|
|
//
|
86 |
|
|
// Revision 1.2 2001/11/15 02:24:37 lampret
|
87 |
|
|
// Added GPIO_REGISTERED_WB_OUTPUTS, GPIO_REGISTERED_IO_OUTPUTS and GPIO_NO_NEGEDGE_FLOPS.
|
88 |
|
|
//
|
89 |
|
|
// Revision 1.1 2001/09/18 18:49:07 lampret
|
90 |
|
|
// Changed top level ptc into gpio_top. Changed defines.v into gpio_defines.v.
|
91 |
|
|
//
|
92 |
|
|
// Revision 1.1 2001/08/21 21:39:28 lampret
|
93 |
|
|
// Changed directory structure, port names and drfines.
|
94 |
|
|
//
|
95 |
|
|
// Revision 1.3 2001/07/15 00:21:10 lampret
|
96 |
|
|
// Registers can be omitted and will have certain default values
|
97 |
|
|
//
|
98 |
|
|
// Revision 1.2 2001/07/14 20:39:26 lampret
|
99 |
|
|
// Better configurability.
|
100 |
|
|
//
|
101 |
|
|
// Revision 1.1 2001/06/05 07:45:26 lampret
|
102 |
|
|
// Added initial RTL and test benches. There are still some issues with these files.
|
103 |
|
|
//
|
104 |
|
|
//
|
105 |
|
|
|
106 |
|
|
//
|
107 |
|
|
// Number of GPIO I/O signals
|
108 |
|
|
//
|
109 |
|
|
// This is the most important parameter of the GPIO IP core. It defines how many
|
110 |
|
|
// I/O signals core has. Range is from 1 to 32. If more than 32 I/O signals are
|
111 |
|
|
// required, use several instances of GPIO IP core.
|
112 |
|
|
//
|
113 |
|
|
// Default is 16.
|
114 |
|
|
//
|
115 |
|
|
`define GPIO_IOS 32
|
116 |
|
|
|
117 |
|
|
//depending on number of GPIO_IOS, define this...
|
118 |
|
|
// for example: if there is 26 GPIO_IOS, define GPIO_LINES26
|
119 |
|
|
//
|
120 |
|
|
|
121 |
|
|
`define GPIO_LINES32
|
122 |
|
|
|
123 |
|
|
//
|
124 |
|
|
// Undefine this one if you don't want to remove GPIO block from your design
|
125 |
|
|
// but you also don't need it. When it is undefined, all GPIO ports still
|
126 |
|
|
// remain valid and the core can be synthesized however internally there is
|
127 |
|
|
// no GPIO funationality.
|
128 |
|
|
//
|
129 |
|
|
// Defined by default (duhh !).
|
130 |
|
|
//
|
131 |
|
|
`define GPIO_IMPLEMENTED
|
132 |
|
|
|
133 |
|
|
//
|
134 |
|
|
// Define to register all WISHBONE outputs.
|
135 |
|
|
//
|
136 |
|
|
// Register outputs if you are using GPIO core as a block and synthesizing
|
137 |
|
|
// and place&routing it separately from the rest of the system.
|
138 |
|
|
//
|
139 |
|
|
// If you do not need registered outputs, you can save some area by not defining
|
140 |
|
|
// this macro. By default it is defined.
|
141 |
|
|
//
|
142 |
|
|
`define GPIO_REGISTERED_WB_OUTPUTS
|
143 |
|
|
|
144 |
|
|
//
|
145 |
|
|
// Define to register all GPIO pad outputs.
|
146 |
|
|
//
|
147 |
|
|
// Register outputs if you are using GPIO core as a block and synthesizing
|
148 |
|
|
// and place&routing it separately from the rest of the system.
|
149 |
|
|
//
|
150 |
|
|
// If you do not need registered outputs, you can save some area by not defining
|
151 |
|
|
// this macro. By default it is defined.
|
152 |
|
|
//
|
153 |
|
|
`define GPIO_REGISTERED_IO_OUTPUTS
|
154 |
|
|
|
155 |
|
|
//
|
156 |
|
|
// Implement aux feature. If this define is not defined also aux_i port and
|
157 |
|
|
// RGPIO_AUX register will be removed
|
158 |
|
|
//
|
159 |
|
|
// Defined by default.
|
160 |
|
|
//
|
161 |
|
|
`define GPIO_AUX_IMPLEMENT
|
162 |
|
|
|
163 |
|
|
//
|
164 |
|
|
// If this is not defined clk_pad_i will be removed. Input lines will be lached on
|
165 |
|
|
// positive edge of system clock
|
166 |
|
|
// if disabled defines GPIO_NO_NEGEDGE_FLOPS, GPIO_NO_CLKPAD_LOGIC will have no effect.
|
167 |
|
|
//
|
168 |
|
|
// Defined by default.
|
169 |
|
|
//
|
170 |
|
|
`define GPIO_CLKPAD
|
171 |
|
|
|
172 |
|
|
//
|
173 |
|
|
// Define to avoid using negative edge clock flip-flops for external clock
|
174 |
|
|
// (caused by NEC register. Instead an inverted external clock with
|
175 |
|
|
// positive edge clock flip-flops will be used.
|
176 |
|
|
// This define don't have any effect if GPIO_CLKPAD is not defined and if GPIO_SYNC_IN_CLK is defined
|
177 |
|
|
//
|
178 |
|
|
// By default it is not defined.
|
179 |
|
|
//
|
180 |
|
|
//`define GPIO_NO_NEGEDGE_FLOPS
|
181 |
|
|
|
182 |
|
|
//
|
183 |
|
|
// If GPIO_NO_NEGEDGE_FLOPS is defined, a mux needs to be placed on external clock
|
184 |
|
|
// clk_pad_i to implement RGPIO_CTRL[NEC] functionality. If no mux is allowed on
|
185 |
|
|
// clock signal, enable the following define.
|
186 |
|
|
// This define don't have any effect if GPIO_CLKPAD is not defined and if GPIO_SYNC_IN_CLK is defined
|
187 |
|
|
//
|
188 |
|
|
// By default it is not defined.
|
189 |
|
|
//
|
190 |
|
|
//`define GPIO_NO_CLKPAD_LOGIC
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
//
|
194 |
|
|
// synchronization defines
|
195 |
|
|
//
|
196 |
|
|
// Two synchronization flops to input lineis added.
|
197 |
|
|
// system clock synchronization.
|
198 |
|
|
//
|
199 |
|
|
`define GPIO_SYNC_IN_WB
|
200 |
|
|
|
201 |
|
|
//
|
202 |
|
|
// Add synchronization flops to external clock input line. Gpio will have just one clock domain,
|
203 |
|
|
// everithing will be synchronized to wishbone clock. External clock muas be at least 2-3x slower
|
204 |
|
|
// as systam clock.
|
205 |
|
|
//
|
206 |
|
|
`define GPIO_SYNC_CLK_WB
|
207 |
|
|
|
208 |
|
|
//
|
209 |
|
|
// Add synchronization to input pads. synchronization to external clock.
|
210 |
|
|
// Don't hawe any effect if GPIO_SYNC_CLK_WB is defined.
|
211 |
|
|
//
|
212 |
|
|
//`define GPIO_SYNC_IN_CLK
|
213 |
|
|
|
214 |
|
|
//
|
215 |
|
|
// Add synchronization flops between system clock and external clock.
|
216 |
|
|
// Only possible if external clock is enabled and clock synchroization is disabled.
|
217 |
|
|
//
|
218 |
|
|
//`define GPIO_SYNC_IN_CLK_WB
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
//
|
223 |
|
|
// Undefine if you don't need to read GPIO registers except for RGPIO_IN register.
|
224 |
|
|
// When it is undefined all reads of GPIO registers return RGPIO_IN register. This
|
225 |
|
|
// is usually useful if you want really small area (for example when implemented in
|
226 |
|
|
// FPGA).
|
227 |
|
|
//
|
228 |
|
|
// To follow GPIO IP core specification document this one must be defined. Also to
|
229 |
|
|
// successfully run the test bench it must be defined. By default it is defined.
|
230 |
|
|
//
|
231 |
|
|
`define GPIO_READREGS
|
232 |
|
|
|
233 |
|
|
//
|
234 |
|
|
// Full WISHBONE address decoding
|
235 |
|
|
//
|
236 |
|
|
// It is is undefined, partial WISHBONE address decoding is performed.
|
237 |
|
|
// Undefine it if you need to save some area.
|
238 |
|
|
//
|
239 |
|
|
// By default it is defined.
|
240 |
|
|
//
|
241 |
|
|
`define GPIO_FULL_DECODE
|
242 |
|
|
|
243 |
|
|
//
|
244 |
|
|
// Strict 32-bit WISHBONE access
|
245 |
|
|
//
|
246 |
|
|
// If this one is defined, all WISHBONE accesses must be 32-bit. If it is
|
247 |
|
|
// not defined, err_o is asserted whenever 8- or 16-bit access is made.
|
248 |
|
|
// Undefine it if you need to save some area.
|
249 |
|
|
//
|
250 |
|
|
// By default it is defined.
|
251 |
|
|
//
|
252 |
|
|
//`define GPIO_STRICT_32BIT_ACCESS
|
253 |
|
|
//
|
254 |
|
|
`ifdef GPIO_STRICT_32BIT_ACCESS
|
255 |
|
|
`else
|
256 |
|
|
// added by gorand :
|
257 |
|
|
// if GPIO_STRICT_32BIT_ACCESS is not defined,
|
258 |
|
|
// depending on number of gpio I/O lines, the following are defined :
|
259 |
|
|
// if the number of I/O lines is in range 1-8, GPIO_WB_BYTES1 is defined,
|
260 |
|
|
// if the number of I/O lines is in range 9-16, GPIO_WB_BYTES2 is defined,
|
261 |
|
|
// if the number of I/O lines is in range 17-24, GPIO_WB_BYTES3 is defined,
|
262 |
|
|
// if the number of I/O lines is in range 25-32, GPIO_WB_BYTES4 is defined,
|
263 |
|
|
|
264 |
|
|
`define GPIO_WB_BYTES4
|
265 |
|
|
//`define GPIO_WB_BYTES3
|
266 |
|
|
//`define GPIO_WB_BYTES2
|
267 |
|
|
//`define GPIO_WB_BYTES1
|
268 |
|
|
|
269 |
|
|
`endif
|
270 |
|
|
|
271 |
|
|
//
|
272 |
|
|
// WISHBONE address bits used for full decoding of GPIO registers.
|
273 |
|
|
//
|
274 |
|
|
`define GPIO_ADDRHH 7
|
275 |
|
|
`define GPIO_ADDRHL 6
|
276 |
|
|
`define GPIO_ADDRLH 1
|
277 |
|
|
`define GPIO_ADDRLL 0
|
278 |
|
|
|
279 |
|
|
//
|
280 |
|
|
// Bits of WISHBONE address used for partial decoding of GPIO registers.
|
281 |
|
|
//
|
282 |
|
|
// Default 5:2.
|
283 |
|
|
//
|
284 |
|
|
`define GPIO_OFS_BITS `GPIO_ADDRHL-1:`GPIO_ADDRLH+1
|
285 |
|
|
|
286 |
|
|
//
|
287 |
|
|
// Addresses of GPIO registers
|
288 |
|
|
//
|
289 |
|
|
// To comply with GPIO IP core specification document they must go from
|
290 |
|
|
// address 0 to address 0x18 in the following order: RGPIO_IN, RGPIO_OUT,
|
291 |
|
|
// RGPIO_OE, RGPIO_INTE, RGPIO_PTRIG, RGPIO_AUX and RGPIO_CTRL
|
292 |
|
|
//
|
293 |
|
|
// If particular register is not needed, it's address definition can be omitted
|
294 |
|
|
// and the register will not be implemented. Instead a fixed default value will
|
295 |
|
|
// be used.
|
296 |
|
|
//
|
297 |
|
|
`define GPIO_RGPIO_IN 4'h0 // Address 0x00
|
298 |
|
|
`define GPIO_RGPIO_OUT 4'h1 // Address 0x04
|
299 |
|
|
`define GPIO_RGPIO_OE 4'h2 // Address 0x08
|
300 |
|
|
`define GPIO_RGPIO_INTE 4'h3 // Address 0x0c
|
301 |
|
|
`define GPIO_RGPIO_PTRIG 4'h4 // Address 0x10
|
302 |
|
|
|
303 |
|
|
`ifdef GPIO_AUX_IMPLEMENT
|
304 |
|
|
`define GPIO_RGPIO_AUX 4'h5 // Address 0x14
|
305 |
|
|
`endif // GPIO_AUX_IMPLEMENT
|
306 |
|
|
|
307 |
|
|
`define GPIO_RGPIO_CTRL 4'h6 // Address 0x18
|
308 |
|
|
`define GPIO_RGPIO_INTS 4'h7 // Address 0x1c
|
309 |
|
|
|
310 |
|
|
`ifdef GPIO_CLKPAD
|
311 |
|
|
`define GPIO_RGPIO_ECLK 4'h8 // Address 0x20
|
312 |
|
|
`define GPIO_RGPIO_NEC 4'h9 // Address 0x24
|
313 |
|
|
`endif // GPIO_CLKPAD
|
314 |
|
|
|
315 |
|
|
//
|
316 |
|
|
// Default values for unimplemented GPIO registers
|
317 |
|
|
//
|
318 |
|
|
`define GPIO_DEF_RGPIO_IN `GPIO_IOS'h0
|
319 |
|
|
`define GPIO_DEF_RGPIO_OUT `GPIO_IOS'h0
|
320 |
|
|
`define GPIO_DEF_RGPIO_OE `GPIO_IOS'h0
|
321 |
|
|
`define GPIO_DEF_RGPIO_INTE `GPIO_IOS'h0
|
322 |
|
|
`define GPIO_DEF_RGPIO_PTRIG `GPIO_IOS'h0
|
323 |
|
|
`define GPIO_DEF_RGPIO_AUX `GPIO_IOS'h0
|
324 |
|
|
`define GPIO_DEF_RGPIO_CTRL `GPIO_IOS'h0
|
325 |
|
|
`define GPIO_DEF_RGPIO_ECLK `GPIO_IOS'h0
|
326 |
|
|
`define GPIO_DEF_RGPIO_NEC `GPIO_IOS'h0
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
//
|
330 |
|
|
// RGPIO_CTRL bits
|
331 |
|
|
//
|
332 |
|
|
// To comply with the GPIO IP core specification document they must go from
|
333 |
|
|
// bit 0 to bit 1 in the following order: INTE, INT
|
334 |
|
|
//
|
335 |
|
|
`define GPIO_RGPIO_CTRL_INTE 0
|
336 |
|
|
`define GPIO_RGPIO_CTRL_INTS 1
|
337 |
|
|
|
338 |
|
|
|