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

Subversion Repositories gpio

[/] [gpio/] [tags/] [rel_9/] [rtl/] [verilog/] [gpio_top.v] - Blame information for rev 24

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

powered by: WebSVN 2.1.0

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