OpenCores
URL https://opencores.org/ocsvn/gpio/gpio/trunk

Subversion Repositories gpio

[/] [gpio/] [tags/] [rel_4/] [rtl/] [verilog/] [gpio_top.v] - Blame information for rev 31

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  WISHBONE General-Purpose I/O                                ////
4
////                                                              ////
5
////  This file is part of the GPIO project                       ////
6
////  http://www.opencores.org/cores/gpio/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Implementation of GPIO IP core according to                 ////
10
////  GPIO IP core specification document.                        ////
11
////                                                              ////
12
////  To Do:                                                      ////
13
////   Nothing                                                    ////
14
////                                                              ////
15
////  Author(s):                                                  ////
16
////      - Damjan Lampret, lampret@opencores.org                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48 31 lampret
// Revision 1.12  2002/11/11 21:36:28  lampret
49
// Added ifdef to remove mux from clk_pad_i if mux is not allowed. This also removes RGPIO_CTRL[NEC].
50
//
51 29 lampret
// Revision 1.11  2002/03/13 20:56:28  lampret
52
// Removed zero padding as per Avi Shamli suggestion.
53
//
54 26 lampret
// Revision 1.10  2002/03/13 20:47:57  lampret
55
// Ports changed per Ran Aviram suggestions.
56
//
57 25 lampret
// Revision 1.9  2002/03/09 03:43:27  lampret
58
// Interrupt is asserted only when an input changes (code patch by Jacob Gorban)
59
//
60 24 lampret
// Revision 1.8  2002/01/14 19:06:28  lampret
61
// Changed registered WISHBONE outputs wb_ack_o/wb_err_o to follow WB specification.
62
//
63 23 lampret
// Revision 1.7  2001/12/25 17:21:21  lampret
64
// Fixed two typos.
65
//
66 22 lampret
// Revision 1.6  2001/12/25 17:12:35  lampret
67
// Added RGPIO_INTS.
68
//
69 21 lampret
// Revision 1.5  2001/12/12 20:35:53  lampret
70
// Fixing style.
71
//
72 20 lampret
// Revision 1.4  2001/12/12 07:12:58  lampret
73
// Fixed bug when wb_inta_o is registered (GPIO_WB_REGISTERED_OUTPUTS)
74
//
75 19 lampret
// Revision 1.3  2001/11/15 02:24:37  lampret
76
// Added GPIO_REGISTERED_WB_OUTPUTS, GPIO_REGISTERED_IO_OUTPUTS and GPIO_NO_NEGEDGE_FLOPS.
77
//
78 17 lampret
// Revision 1.2  2001/10/31 02:26:51  lampret
79
// Fixed wb_err_o.
80
//
81 15 lampret
// Revision 1.1  2001/09/18 18:49:07  lampret
82
// Changed top level ptc into gpio_top. Changed defines.v into gpio_defines.v.
83
//
84 14 lampret
// Revision 1.1  2001/08/21 21:39:28  lampret
85
// Changed directory structure, port names and drfines.
86
//
87
// Revision 1.2  2001/07/14 20:39:26  lampret
88
// Better configurability.
89
//
90
// Revision 1.1  2001/06/05 07:45:26  lampret
91
// Added initial RTL and test benches. There are still some issues with these files.
92
//
93
//
94
 
95
// synopsys translate_off
96
`include "timescale.v"
97
// synopsys translate_on
98
`include "gpio_defines.v"
99
 
100
module gpio_top(
101
        // WISHBONE Interface
102
        wb_clk_i, wb_rst_i, wb_cyc_i, wb_adr_i, wb_dat_i, wb_sel_i, wb_we_i, wb_stb_i,
103
        wb_dat_o, wb_ack_o, wb_err_o, wb_inta_o,
104
 
105
        // Auxiliary inputs interface
106
        aux_i,
107
 
108
        // External GPIO Interface
109 25 lampret
        ext_pad_i, clk_pad_i, ext_pad_o, ext_padoen_o
110 14 lampret
);
111
 
112
parameter dw = 32;
113
parameter aw = `GPIO_ADDRHH+1;
114
parameter gw = `GPIO_IOS;
115
 
116
//
117
// WISHBONE Interface
118
//
119
input                   wb_clk_i;       // Clock
120
input                   wb_rst_i;       // Reset
121
input                   wb_cyc_i;       // cycle valid input
122
input   [aw-1:0] wb_adr_i;       // address bus inputs
123
input   [dw-1:0] wb_dat_i;       // input data bus
124
input   [3:0]            wb_sel_i;       // byte select inputs
125
input                   wb_we_i;        // indicates write transfer
126
input                   wb_stb_i;       // strobe input
127
output  [dw-1:0] wb_dat_o;       // output data bus
128
output                  wb_ack_o;       // normal termination
129
output                  wb_err_o;       // termination w/ error
130
output                  wb_inta_o;      // Interrupt request output
131
 
132
// Auxiliary Inputs Interface
133
input   [gw-1:0] aux_i;          // Auxiliary inputs
134
 
135
//
136
// External GPIO Interface
137
//
138 25 lampret
input   [gw-1:0] ext_pad_i;      // GPIO Inputs
139
input                   clk_pad_i;      // GPIO Eclk
140
output  [gw-1:0] ext_pad_o;      // GPIO Outputs
141
output  [gw-1:0] ext_padoen_o;   // GPIO output drivers enables
142 14 lampret
 
143
`ifdef GPIO_IMPLEMENTED
144
 
145
//
146
// GPIO Input Register (or no register)
147
//
148
`ifdef GPIO_RGPIO_IN
149
reg     [gw-1:0] rgpio_in;       // RGPIO_IN register
150
`else
151
wire    [gw-1:0] rgpio_in;       // No register
152
`endif
153
 
154
//
155
// GPIO Output Register (or no register)
156
//
157
`ifdef GPIO_RGPIO_OUT
158
reg     [gw-1:0] rgpio_out;      // RGPIO_OUT register
159
`else
160
wire    [gw-1:0] rgpio_out;      // No register
161
`endif
162
 
163
//
164
// GPIO Output Driver Enable Register (or no register)
165
//
166
`ifdef GPIO_RGPIO_OE
167
reg     [gw-1:0] rgpio_oe;       // RGPIO_OE register
168
`else
169
wire    [gw-1:0] rgpio_oe;       // No register
170
`endif
171
 
172
//
173
// GPIO Interrupt Enable Register (or no register)
174
//
175
`ifdef GPIO_RGPIO_INTE
176
reg     [gw-1:0] rgpio_inte;     // RGPIO_INTE register
177
`else
178
wire    [gw-1:0] rgpio_inte;     // No register
179
`endif
180
 
181
//
182
// GPIO Positive edge Triggered Register (or no register)
183
//
184
`ifdef GPIO_RGPIO_PTRIG
185
reg     [gw-1:0] rgpio_ptrig;    // RGPIO_PTRIG register
186
`else
187
wire    [gw-1:0] rgpio_ptrig;    // No register
188
`endif
189
 
190
//
191
// GPIO Auxiliary select Register (or no register)
192
//
193
`ifdef GPIO_RGPIO_AUX
194
reg     [gw-1:0] rgpio_aux;      // RGPIO_AUX register
195
`else
196
wire    [gw-1:0] rgpio_aux;      // No register
197
`endif
198
 
199
//
200
// GPIO Control Register (or no register)
201
//
202
`ifdef GPIO_RGPIO_CTRL
203
reg     [3:0]            rgpio_ctrl;     // RGPIO_CTRL register
204
`else
205
wire    [3:0]            rgpio_ctrl;     // No register
206
`endif
207
 
208
//
209 21 lampret
// GPIO Interrupt Status Register (or no register)
210
//
211
`ifdef GPIO_RGPIO_INTS
212
reg     [gw-1:0] rgpio_ints;     // RGPIO_INTS register
213
`else
214
wire    [gw-1:0] rgpio_ints;     // No register
215
`endif
216
 
217
//
218 14 lampret
// Internal wires & regs
219
//
220
wire                    rgpio_out_sel;  // RGPIO_OUT select
221
wire                    rgpio_oe_sel;   // RGPIO_OE select
222
wire                    rgpio_inte_sel; // RGPIO_INTE select
223
wire                    rgpio_ptrig_sel;// RGPIO_PTRIG select
224
wire                    rgpio_aux_sel;  // RGPIO_AUX select
225
wire                    rgpio_ctrl_sel; // RGPIO_CTRL select
226 21 lampret
wire                    rgpio_ints_sel; // RGPIO_INTS select
227 14 lampret
wire                    latch_clk;      // Latch clock
228
wire                    full_decoding;  // Full address decoding qualification
229 17 lampret
wire    [gw-1:0] in_muxed;       // Muxed inputs
230
wire                    wb_ack;         // WB Acknowledge
231
wire                    wb_err;         // WB Error
232
wire                    wb_inta;        // WB Interrupt
233
reg     [dw-1:0] wb_dat;         // WB Data out
234
`ifdef GPIO_REGISTERED_WB_OUTPUTS
235
reg                     wb_ack_o;       // WB Acknowledge
236
reg                     wb_err_o;       // WB Error
237
reg                     wb_inta_o;      // WB Interrupt
238
reg     [dw-1:0] wb_dat_o;       // WB Data out
239
`endif
240
wire    [gw-1:0] out_pad;        // GPIO Outputs
241
`ifdef GPIO_REGISTERED_IO_OUTPUTS
242 25 lampret
reg     [gw-1:0] ext_pad_o;      // GPIO Outputs
243 17 lampret
`endif
244
wire    [gw-1:0] extc_in;        // Muxed inputs sampled by external clock
245
wire                    pext_clk;       // External clock for posedge flops
246
reg     [gw-1:0] pextc_sampled;  // Posedge external clock sampled inputs
247
`ifdef GPIO_NO_NEGEDGE_FLOPS
248
`else
249
reg     [gw-1:0] nextc_sampled;  // Negedge external clock sampled inputs
250
`endif
251 14 lampret
 
252
//
253
// All WISHBONE transfer terminations are successful except when:
254
// a) full address decoding is enabled and address doesn't match
255
//    any of the GPIO registers
256
// b) wb_sel_i evaluation is enabled and one of the wb_sel_i inputs is zero
257
//
258 17 lampret
 
259
//
260
// WB Acknowledge
261
//
262
assign wb_ack = wb_cyc_i & wb_stb_i & !wb_err_o;
263
 
264
//
265
// Optional registration of WB Ack
266
//
267
`ifdef GPIO_REGISTERED_WB_OUTPUTS
268
always @(posedge wb_clk_i or posedge wb_rst_i)
269
        if (wb_rst_i)
270
                wb_ack_o <= #1 1'b0;
271
        else
272 23 lampret
                wb_ack_o <= #1 wb_ack & ~wb_ack_o;
273 17 lampret
`else
274
assign wb_ack_o = wb_ack;
275
`endif
276
 
277
//
278
// WB Error
279
//
280 14 lampret
`ifdef GPIO_FULL_DECODE
281
`ifdef GPIO_STRICT_32BIT_ACCESS
282 17 lampret
assign wb_err = wb_cyc_i & wb_stb_i & (!full_decoding | (wb_sel_i != 4'b1111));
283 14 lampret
`else
284 17 lampret
assign wb_err = wb_cyc_i & wb_stb_i & !full_decoding;
285 14 lampret
`endif
286
`else
287
`ifdef GPIO_STRICT_32BIT_ACCESS
288 17 lampret
assign wb_err = wb_cyc_i & wb_stb_i & (wb_sel_i != 4'b1111);
289 14 lampret
`else
290 17 lampret
assign wb_err = 1'b0;
291 14 lampret
`endif
292
`endif
293
 
294
//
295 17 lampret
// Optional registration of WB error
296 14 lampret
//
297 17 lampret
`ifdef GPIO_REGISTERED_WB_OUTPUTS
298
always @(posedge wb_clk_i or posedge wb_rst_i)
299
        if (wb_rst_i)
300
                wb_err_o <= #1 1'b0;
301
        else
302 23 lampret
                wb_err_o <= #1 wb_err & ~wb_err_o;
303 17 lampret
`else
304
assign wb_err_o = wb_err;
305
`endif
306 14 lampret
 
307
//
308
// Full address decoder
309
//
310
`ifdef GPIO_FULL_DECODE
311
assign full_decoding = (wb_adr_i[`GPIO_ADDRHH:`GPIO_ADDRHL] == {`GPIO_ADDRHH-`GPIO_ADDRHL+1{1'b0}}) &
312
                        (wb_adr_i[`GPIO_ADDRLH:`GPIO_ADDRLL] == {`GPIO_ADDRLH-`GPIO_ADDRLL+1{1'b0}});
313
`else
314
assign full_decoding = 1'b1;
315
`endif
316
 
317
//
318
// GPIO registers address decoder
319
//
320
assign rgpio_out_sel = wb_cyc_i & wb_stb_i & (wb_adr_i[`GPIO_OFS_BITS] == `GPIO_RGPIO_OUT) & full_decoding;
321
assign rgpio_oe_sel = wb_cyc_i & wb_stb_i & (wb_adr_i[`GPIO_OFS_BITS] == `GPIO_RGPIO_OE) & full_decoding;
322
assign rgpio_inte_sel = wb_cyc_i & wb_stb_i & (wb_adr_i[`GPIO_OFS_BITS] == `GPIO_RGPIO_INTE) & full_decoding;
323
assign rgpio_ptrig_sel = wb_cyc_i & wb_stb_i & (wb_adr_i[`GPIO_OFS_BITS] == `GPIO_RGPIO_PTRIG) & full_decoding;
324
assign rgpio_aux_sel = wb_cyc_i & wb_stb_i & (wb_adr_i[`GPIO_OFS_BITS] == `GPIO_RGPIO_AUX) & full_decoding;
325
assign rgpio_ctrl_sel = wb_cyc_i & wb_stb_i & (wb_adr_i[`GPIO_OFS_BITS] == `GPIO_RGPIO_CTRL) & full_decoding;
326 21 lampret
assign rgpio_ints_sel = wb_cyc_i & wb_stb_i & (wb_adr_i[`GPIO_OFS_BITS] == `GPIO_RGPIO_INTS) & full_decoding;
327 14 lampret
 
328
//
329
// Write to RGPIO_CTRL or update of RGPIO_CTRL[INT] bit
330
//
331
`ifdef GPIO_RGPIO_CTRL
332
always @(posedge wb_clk_i or posedge wb_rst_i)
333
        if (wb_rst_i)
334
                rgpio_ctrl <= #1 4'b0;
335
        else if (rgpio_ctrl_sel && wb_we_i)
336
                rgpio_ctrl <= #1 wb_dat_i[3:0];
337
        else if (rgpio_ctrl[`GPIO_RGPIO_CTRL_INTE])
338 21 lampret
                rgpio_ctrl[`GPIO_RGPIO_CTRL_INTS] <= #1 rgpio_ctrl[`GPIO_RGPIO_CTRL_INTS] | wb_inta_o;
339 14 lampret
`else
340
assign rgpio_ctrl = 4'h01;      // RGPIO_CTRL[EN] = 1
341
`endif
342
 
343
//
344
// Write to RGPIO_OUT
345
//
346
`ifdef GPIO_RGPIO_OUT
347
always @(posedge wb_clk_i or posedge wb_rst_i)
348
        if (wb_rst_i)
349
                rgpio_out <= #1 {gw{1'b0}};
350
        else if (rgpio_out_sel && wb_we_i)
351
                rgpio_out <= #1 wb_dat_i[gw-1:0];
352
`else
353 17 lampret
assign rgpio_out = `GPIO_DEF_RGPIO_OUT; // RGPIO_OUT = 0x0
354 14 lampret
`endif
355
 
356
//
357 17 lampret
// Write to RGPIO_OE. Bits in RGPIO_OE are stored inverted.
358 14 lampret
//
359
`ifdef GPIO_RGPIO_OE
360
always @(posedge wb_clk_i or posedge wb_rst_i)
361
        if (wb_rst_i)
362
                rgpio_oe <= #1 {gw{1'b0}};
363
        else if (rgpio_oe_sel && wb_we_i)
364 17 lampret
                rgpio_oe <= #1 ~wb_dat_i[gw-1:0];
365 14 lampret
`else
366
assign rgpio_oe = `GPIO_DEF_RPGIO_OE;   // RGPIO_OE = 0x0
367
`endif
368
 
369
//
370
// Write to RGPIO_INTE
371
//
372
`ifdef GPIO_RGPIO_INTE
373
always @(posedge wb_clk_i or posedge wb_rst_i)
374
        if (wb_rst_i)
375
                rgpio_inte <= #1 {gw{1'b0}};
376
        else if (rgpio_inte_sel && wb_we_i)
377
                rgpio_inte <= #1 wb_dat_i[gw-1:0];
378
`else
379
assign rgpio_inte = `GPIO_DEF_RPGIO_INTE;       // RGPIO_INTE = 0x0
380
`endif
381
 
382
//
383
// Write to RGPIO_PTRIG
384
//
385
`ifdef GPIO_RGPIO_PTRIG
386
always @(posedge wb_clk_i or posedge wb_rst_i)
387
        if (wb_rst_i)
388
                rgpio_ptrig <= #1 {gw{1'b0}};
389
        else if (rgpio_ptrig_sel && wb_we_i)
390
                rgpio_ptrig <= #1 wb_dat_i[gw-1:0];
391
`else
392
assign rgpio_ptrig = `GPIO_DEF_RPGIO_PTRIG;     // RGPIO_PTRIG = 0x0
393
`endif
394
 
395
//
396
// Write to RGPIO_AUX
397
//
398
`ifdef GPIO_RGPIO_AUX
399
always @(posedge wb_clk_i or posedge wb_rst_i)
400
        if (wb_rst_i)
401
                rgpio_aux <= #1 {gw{1'b0}};
402
        else if (rgpio_aux_sel && wb_we_i)
403
                rgpio_aux <= #1 wb_dat_i[gw-1:0];
404
`else
405
assign rgpio_aux = `GPIO_DEF_RPGIO_AUX; // RGPIO_AUX = 0x0
406
`endif
407
 
408
//
409
// Latch into RGPIO_IN
410
//
411
`ifdef GPIO_RGPIO_IN
412 17 lampret
always @(posedge wb_clk_i or posedge wb_rst_i)
413 14 lampret
        if (wb_rst_i)
414
                rgpio_in <= #1 {gw{1'b0}};
415
        else
416 17 lampret
                rgpio_in <= #1 in_muxed;
417 14 lampret
`else
418 17 lampret
assign rgpio_in = in_muxed;
419 14 lampret
`endif
420
 
421
//
422 17 lampret
// Mux inputs directly from input pads with inputs sampled by external clock
423 14 lampret
//
424 25 lampret
assign in_muxed = rgpio_ctrl[`GPIO_RGPIO_CTRL_ECLK] ? extc_in : ext_pad_i;
425 17 lampret
 
426
//
427
// Posedge pext_clk is inverted by NEC bit if negedge flops are not allowed.
428
// If negedge flops are allowed, pext_clk only clocks posedge flops.
429
//
430
`ifdef GPIO_NO_NEGEDGE_FLOPS
431 29 lampret
`ifdef GPIO_NO_CLKPAD_LOGIC
432
assign pext_clk = clk_pad_i;
433
`else
434 25 lampret
assign pext_clk = rgpio_ctrl[`GPIO_RGPIO_CTRL_NEC] ? ~clk_pad_i : clk_pad_i;
435 29 lampret
`endif
436 17 lampret
`else
437 25 lampret
assign pext_clk = clk_pad_i;
438 17 lampret
`endif
439
 
440
//
441
// If negedge flops are allowed, ext_in is mux of negedge and posedge external clocked flops.
442
//
443
`ifdef GPIO_NO_NEGEDGE_FLOPS
444
assign extc_in = pextc_sampled;
445
`else
446
assign extc_in = rgpio_ctrl[`GPIO_RGPIO_CTRL_NEC] ? nextc_sampled : pextc_sampled;
447
`endif
448
 
449
//
450
// Latch using posedge external clock
451
//
452
always @(posedge pext_clk or posedge wb_rst_i)
453
        if (wb_rst_i)
454
                pextc_sampled <= #1 {gw{1'b0}};
455
        else
456 25 lampret
                pextc_sampled <= #1 ext_pad_i;
457 17 lampret
 
458
//
459
// Latch using negedge external clock
460
//
461
`ifdef GPIO_NO_NEGEDGE_FLOPS
462
`else
463 25 lampret
always @(negedge clk_pad_i or posedge wb_rst_i)
464 17 lampret
        if (wb_rst_i)
465
                nextc_sampled <= #1 {gw{1'b0}};
466
        else
467 25 lampret
                nextc_sampled <= #1 ext_pad_i;
468 17 lampret
`endif
469
 
470
//
471
// Mux all registers when doing a read of GPIO registers
472
//
473 14 lampret
always @(wb_adr_i or rgpio_in or rgpio_out or rgpio_oe or rgpio_inte or
474 22 lampret
                rgpio_ptrig or rgpio_aux or rgpio_ctrl or rgpio_ints)
475 14 lampret
        case (wb_adr_i[`GPIO_OFS_BITS]) // synopsys full_case parallel_case
476
`ifdef GPIO_READREGS
477
                `GPIO_RGPIO_OUT: begin
478 26 lampret
                        wb_dat[dw-1:0] = rgpio_out;
479 14 lampret
                end
480
                `GPIO_RGPIO_OE: begin
481 26 lampret
                        wb_dat[dw-1:0] = ~rgpio_oe;
482 14 lampret
                end
483
                `GPIO_RGPIO_INTE: begin
484 26 lampret
                        wb_dat[dw-1:0] = rgpio_inte;
485 14 lampret
                end
486
                `GPIO_RGPIO_PTRIG: begin
487 26 lampret
                        wb_dat[dw-1:0] = rgpio_ptrig;
488 14 lampret
                end
489
                `GPIO_RGPIO_AUX: begin
490 26 lampret
                        wb_dat[dw-1:0] = rgpio_aux;
491 14 lampret
                end
492
                `GPIO_RGPIO_CTRL: begin
493 20 lampret
                        wb_dat[3:0] = rgpio_ctrl;
494
                        wb_dat[dw-1:4] = {dw-4{1'b0}};
495 14 lampret
                end
496
`endif
497 21 lampret
                `GPIO_RGPIO_INTS: begin
498 26 lampret
                        wb_dat[dw-1:0] = rgpio_ints;
499 21 lampret
                end
500 14 lampret
                default: begin
501 26 lampret
                        wb_dat[dw-1:0] = rgpio_in;
502 14 lampret
                end
503
        endcase
504
 
505
//
506 17 lampret
// WB data output
507
//
508
`ifdef GPIO_REGISTERED_WB_OUTPUTS
509
always @(posedge wb_clk_i or posedge wb_rst_i)
510
        if (wb_rst_i)
511
                wb_dat_o <= #1 {dw{1'b0}};
512
        else
513
                wb_dat_o <= #1 wb_dat;
514
`else
515
assign wb_dat_o = wb_dat;
516
`endif
517
 
518
//
519 21 lampret
// RGPIO_INTS
520
//
521
`ifdef GPIO_RGPIO_INTS
522
always @(posedge wb_clk_i or posedge wb_rst_i)
523
        if (wb_rst_i)
524
                rgpio_ints <= #1 {gw{1'b0}};
525
        else if (rgpio_ints_sel && wb_we_i)
526
                rgpio_ints <= #1 wb_dat_i[gw-1:0];
527 31 lampret
        else if (rgpio_ctrl[`GPIO_RGPIO_CTRL_INTE])
528
                rgpio_ints <= #1 (rgpio_ints | ((ext_pad_i ^ rgpio_in) & ~(ext_pad_i ^ rgpio_ptrig)) & rgpio_inte);
529 21 lampret
`else
530 31 lampret
assign rgpio_ints = (rgpio_ints | ((ext_pad_i ^ rgpio_in) & ~(ext_pad_i ^ rgpio_ptrig)) & rgpio_inte);
531 21 lampret
`endif
532
 
533
//
534 14 lampret
// Generate interrupt request
535
//
536 21 lampret
assign wb_inta = |rgpio_ints ? rgpio_ctrl[`GPIO_RGPIO_CTRL_INTE] : 1'b0;
537 14 lampret
 
538
//
539 17 lampret
// Optional registration of WB interrupt
540 14 lampret
//
541 17 lampret
`ifdef GPIO_REGISTERED_WB_OUTPUTS
542
always @(posedge wb_clk_i or posedge wb_rst_i)
543
        if (wb_rst_i)
544 19 lampret
                wb_inta_o <= #1 1'b0;
545 17 lampret
        else
546
                wb_inta_o <= #1 wb_inta;
547
`else
548
assign wb_inta_o = wb_inta;
549
`endif
550 14 lampret
 
551
//
552 17 lampret
// Output enables are RGPIO_OE bits
553 14 lampret
//
554 25 lampret
assign ext_padoen_o = rgpio_oe;
555 14 lampret
 
556 17 lampret
//
557
// Generate GPIO outputs
558
//
559
assign out_pad = rgpio_out & ~rgpio_aux | aux_i & rgpio_aux;
560
 
561
//
562
// Optional registration of GPIO outputs
563
//
564
`ifdef GPIO_REGISTERED_IO_OUTPUTS
565
always @(posedge wb_clk_i or posedge wb_rst_i)
566
        if (wb_rst_i)
567 25 lampret
                ext_pad_o <= #1 {gw{1'b0}};
568 17 lampret
        else
569 25 lampret
                ext_pad_o <= #1 out_pad;
570 14 lampret
`else
571 25 lampret
assign ext_pad_o = out_pad;
572 17 lampret
`endif
573 14 lampret
 
574 17 lampret
`else
575
 
576 14 lampret
//
577
// When GPIO is not implemented, drive all outputs as would when RGPIO_CTRL
578
// is cleared and WISHBONE transfers complete with errors
579
//
580
assign wb_inta_o = 1'b0;
581
assign wb_ack_o = 1'b0;
582
assign wb_err_o = wb_cyc_i & wb_stb_i;
583 25 lampret
assign ext_padoen_o = {gw{1'b1}};
584
assign ext_pad_o = {gw{1'b0}};
585 14 lampret
 
586
//
587
// Read GPIO registers
588
//
589
assign wb_dat_o = {dw{1'b0}};
590
 
591
`endif
592
 
593
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.