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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [actel_m1a3pl_dev_kit/] [rtl/] [verilog/] [openmsp430/] [periph/] [omsp_gpio.v] - Blame information for rev 143

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

Line No. Rev Author Line
1 80 olivier.gi
//----------------------------------------------------------------------------
2 136 olivier.gi
// Copyright (C) 2009 , Olivier Girard
3 80 olivier.gi
//
4 136 olivier.gi
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions
6
// are met:
7
//     * Redistributions of source code must retain the above copyright
8
//       notice, this list of conditions and the following disclaimer.
9
//     * Redistributions in binary form must reproduce the above copyright
10
//       notice, this list of conditions and the following disclaimer in the
11
//       documentation and/or other materials provided with the distribution.
12
//     * Neither the name of the authors nor the names of its contributors
13
//       may be used to endorse or promote products derived from this software
14
//       without specific prior written permission.
15 80 olivier.gi
//
16 136 olivier.gi
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26
// THE POSSIBILITY OF SUCH DAMAGE
27 80 olivier.gi
//
28
//----------------------------------------------------------------------------
29
//
30
// *File Name: omsp_gpio.v
31
// 
32
// *Module Description:
33
//                       Digital I/O interface
34
//
35
// *Author(s):
36
//              - Olivier Girard,    olgirard@gmail.com
37
//
38
//----------------------------------------------------------------------------
39 111 olivier.gi
// $Rev: 103 $
40 80 olivier.gi
// $LastChangedBy: olivier.girard $
41 111 olivier.gi
// $LastChangedDate: 2011-03-05 15:44:48 +0100 (Sat, 05 Mar 2011) $
42 80 olivier.gi
//----------------------------------------------------------------------------
43
 
44
module  omsp_gpio (
45
 
46
// OUTPUTs
47
    irq_port1,                      // Port 1 interrupt
48
    irq_port2,                      // Port 2 interrupt
49
    p1_dout,                        // Port 1 data output
50
    p1_dout_en,                     // Port 1 data output enable
51
    p1_sel,                         // Port 1 function select
52
    p2_dout,                        // Port 2 data output
53
    p2_dout_en,                     // Port 2 data output enable
54
    p2_sel,                         // Port 2 function select
55
    p3_dout,                        // Port 3 data output
56
    p3_dout_en,                     // Port 3 data output enable
57
    p3_sel,                         // Port 3 function select
58
    p4_dout,                        // Port 4 data output
59
    p4_dout_en,                     // Port 4 data output enable
60
    p4_sel,                         // Port 4 function select
61
    p5_dout,                        // Port 5 data output
62
    p5_dout_en,                     // Port 5 data output enable
63
    p5_sel,                         // Port 5 function select
64
    p6_dout,                        // Port 6 data output
65
    p6_dout_en,                     // Port 6 data output enable
66
    p6_sel,                         // Port 6 function select
67
    per_dout,                       // Peripheral data output
68
 
69
// INPUTs
70
    mclk,                           // Main system clock
71
    p1_din,                         // Port 1 data input
72
    p2_din,                         // Port 2 data input
73
    p3_din,                         // Port 3 data input
74
    p4_din,                         // Port 4 data input
75
    p5_din,                         // Port 5 data input
76
    p6_din,                         // Port 6 data input
77
    per_addr,                       // Peripheral address
78
    per_din,                        // Peripheral data input
79
    per_en,                         // Peripheral enable (high active)
80 107 olivier.gi
    per_we,                         // Peripheral write enable (high active)
81 111 olivier.gi
    puc_rst                         // Main system reset
82 80 olivier.gi
);
83
 
84
// PARAMETERs
85
//============
86
parameter           P1_EN = 1'b1;   // Enable Port 1
87
parameter           P2_EN = 1'b1;   // Enable Port 2
88
parameter           P3_EN = 1'b0;   // Enable Port 3
89
parameter           P4_EN = 1'b0;   // Enable Port 4
90
parameter           P5_EN = 1'b0;   // Enable Port 5
91
parameter           P6_EN = 1'b0;   // Enable Port 6
92
 
93
 
94
// OUTPUTs
95
//=========
96
output              irq_port1;      // Port 1 interrupt
97
output              irq_port2;      // Port 2 interrupt
98
output        [7:0] p1_dout;        // Port 1 data output
99
output        [7:0] p1_dout_en;     // Port 1 data output enable
100
output        [7:0] p1_sel;         // Port 1 function select
101
output        [7:0] p2_dout;        // Port 2 data output
102
output        [7:0] p2_dout_en;     // Port 2 data output enable
103
output        [7:0] p2_sel;         // Port 2 function select
104
output        [7:0] p3_dout;        // Port 3 data output
105
output        [7:0] p3_dout_en;     // Port 3 data output enable
106
output        [7:0] p3_sel;         // Port 3 function select
107
output        [7:0] p4_dout;        // Port 4 data output
108
output        [7:0] p4_dout_en;     // Port 4 data output enable
109
output        [7:0] p4_sel;         // Port 4 function select
110
output        [7:0] p5_dout;        // Port 5 data output
111
output        [7:0] p5_dout_en;     // Port 5 data output enable
112
output        [7:0] p5_sel;         // Port 5 function select
113
output        [7:0] p6_dout;        // Port 6 data output
114
output        [7:0] p6_dout_en;     // Port 6 data output enable
115
output        [7:0] p6_sel;         // Port 6 function select
116
output       [15:0] per_dout;       // Peripheral data output
117
 
118
// INPUTs
119
//=========
120
input               mclk;           // Main system clock
121
input         [7:0] p1_din;         // Port 1 data input
122
input         [7:0] p2_din;         // Port 2 data input
123
input         [7:0] p3_din;         // Port 3 data input
124
input         [7:0] p4_din;         // Port 4 data input
125
input         [7:0] p5_din;         // Port 5 data input
126
input         [7:0] p6_din;         // Port 6 data input
127 111 olivier.gi
input        [13:0] per_addr;       // Peripheral address
128 80 olivier.gi
input        [15:0] per_din;        // Peripheral data input
129
input               per_en;         // Peripheral enable (high active)
130 107 olivier.gi
input         [1:0] per_we;         // Peripheral write enable (high active)
131 111 olivier.gi
input               puc_rst;        // Main system reset
132 80 olivier.gi
 
133
 
134
//=============================================================================
135
// 1)  PARAMETER DECLARATION
136
//=============================================================================
137
 
138
// Masks
139 111 olivier.gi
parameter              P1_EN_MSK   = {8{P1_EN[0]}};
140
parameter              P2_EN_MSK   = {8{P2_EN[0]}};
141
parameter              P3_EN_MSK   = {8{P3_EN[0]}};
142
parameter              P4_EN_MSK   = {8{P4_EN[0]}};
143
parameter              P5_EN_MSK   = {8{P5_EN[0]}};
144
parameter              P6_EN_MSK   = {8{P6_EN[0]}};
145 80 olivier.gi
 
146 111 olivier.gi
// Register base address (must be aligned to decoder bit width)
147
parameter       [14:0] BASE_ADDR   = 15'h0000;
148 80 olivier.gi
 
149 111 olivier.gi
// Decoder bit width (defines how many bits are considered for address decoding)
150
parameter              DEC_WD      =  6;
151
 
152
// Register addresses offset
153
parameter [DEC_WD-1:0] P1IN        = 'h20,                    // Port 1
154
                       P1OUT       = 'h21,
155
                       P1DIR       = 'h22,
156
                       P1IFG       = 'h23,
157
                       P1IES       = 'h24,
158
                       P1IE        = 'h25,
159
                       P1SEL       = 'h26,
160
                       P2IN        = 'h28,                    // Port 2
161
                       P2OUT       = 'h29,
162
                       P2DIR       = 'h2A,
163
                       P2IFG       = 'h2B,
164
                       P2IES       = 'h2C,
165
                       P2IE        = 'h2D,
166
                       P2SEL       = 'h2E,
167
                       P3IN        = 'h18,                    // Port 3
168
                       P3OUT       = 'h19,
169
                       P3DIR       = 'h1A,
170
                       P3SEL       = 'h1B,
171
                       P4IN        = 'h1C,                    // Port 4
172
                       P4OUT       = 'h1D,
173
                       P4DIR       = 'h1E,
174
                       P4SEL       = 'h1F,
175
                       P5IN        = 'h30,                    // Port 5
176
                       P5OUT       = 'h31,
177
                       P5DIR       = 'h32,
178
                       P5SEL       = 'h33,
179
                       P6IN        = 'h34,                    // Port 6
180
                       P6OUT       = 'h35,
181
                       P6DIR       = 'h36,
182
                       P6SEL       = 'h37;
183
 
184
// Register one-hot decoder utilities
185 136 olivier.gi
parameter              DEC_SZ      =  (1 << DEC_WD);
186 111 olivier.gi
parameter [DEC_SZ-1:0] BASE_REG    =  {{DEC_SZ-1{1'b0}}, 1'b1};
187
 
188 80 olivier.gi
// Register one-hot decoder
189 111 olivier.gi
parameter [DEC_SZ-1:0] P1IN_D      =  (BASE_REG << P1IN),     // Port 1
190
                       P1OUT_D     =  (BASE_REG << P1OUT),
191
                       P1DIR_D     =  (BASE_REG << P1DIR),
192
                       P1IFG_D     =  (BASE_REG << P1IFG),
193
                       P1IES_D     =  (BASE_REG << P1IES),
194
                       P1IE_D      =  (BASE_REG << P1IE),
195
                       P1SEL_D     =  (BASE_REG << P1SEL),
196
                       P2IN_D      =  (BASE_REG << P2IN),     // Port 2
197
                       P2OUT_D     =  (BASE_REG << P2OUT),
198
                       P2DIR_D     =  (BASE_REG << P2DIR),
199
                       P2IFG_D     =  (BASE_REG << P2IFG),
200
                       P2IES_D     =  (BASE_REG << P2IES),
201
                       P2IE_D      =  (BASE_REG << P2IE),
202
                       P2SEL_D     =  (BASE_REG << P2SEL),
203
                       P3IN_D      =  (BASE_REG << P3IN),     // Port 3
204
                       P3OUT_D     =  (BASE_REG << P3OUT),
205
                       P3DIR_D     =  (BASE_REG << P3DIR),
206
                       P3SEL_D     =  (BASE_REG << P3SEL),
207
                       P4IN_D      =  (BASE_REG << P4IN),     // Port 4
208
                       P4OUT_D     =  (BASE_REG << P4OUT),
209
                       P4DIR_D     =  (BASE_REG << P4DIR),
210
                       P4SEL_D     =  (BASE_REG << P4SEL),
211
                       P5IN_D      =  (BASE_REG << P5IN),     // Port 5
212
                       P5OUT_D     =  (BASE_REG << P5OUT),
213
                       P5DIR_D     =  (BASE_REG << P5DIR),
214
                       P5SEL_D     =  (BASE_REG << P5SEL),
215
                       P6IN_D      =  (BASE_REG << P6IN),     // Port 6
216
                       P6OUT_D     =  (BASE_REG << P6OUT),
217
                       P6DIR_D     =  (BASE_REG << P6DIR),
218
                       P6SEL_D     =  (BASE_REG << P6SEL);
219 80 olivier.gi
 
220
 
221
//============================================================================
222
// 2)  REGISTER DECODER
223
//============================================================================
224
 
225 111 olivier.gi
// Local register selection
226
wire              reg_sel      =  per_en & (per_addr[13:DEC_WD-1]==BASE_ADDR[14:DEC_WD]);
227
 
228
// Register local address
229
wire [DEC_WD-1:0] reg_addr     =  {1'b0, per_addr[DEC_WD-2:0]};
230
 
231 80 olivier.gi
// Register address decode
232 111 olivier.gi
wire [DEC_SZ-1:0] reg_dec      =  (P1IN_D   &  {DEC_SZ{(reg_addr==(P1IN  >>1))  &  P1_EN[0]}})  |
233
                                  (P1OUT_D  &  {DEC_SZ{(reg_addr==(P1OUT >>1))  &  P1_EN[0]}})  |
234
                                  (P1DIR_D  &  {DEC_SZ{(reg_addr==(P1DIR >>1))  &  P1_EN[0]}})  |
235
                                  (P1IFG_D  &  {DEC_SZ{(reg_addr==(P1IFG >>1))  &  P1_EN[0]}})  |
236
                                  (P1IES_D  &  {DEC_SZ{(reg_addr==(P1IES >>1))  &  P1_EN[0]}})  |
237
                                  (P1IE_D   &  {DEC_SZ{(reg_addr==(P1IE  >>1))  &  P1_EN[0]}})  |
238
                                  (P1SEL_D  &  {DEC_SZ{(reg_addr==(P1SEL >>1))  &  P1_EN[0]}})  |
239
                                  (P2IN_D   &  {DEC_SZ{(reg_addr==(P2IN  >>1))  &  P2_EN[0]}})  |
240
                                  (P2OUT_D  &  {DEC_SZ{(reg_addr==(P2OUT >>1))  &  P2_EN[0]}})  |
241
                                  (P2DIR_D  &  {DEC_SZ{(reg_addr==(P2DIR >>1))  &  P2_EN[0]}})  |
242
                                  (P2IFG_D  &  {DEC_SZ{(reg_addr==(P2IFG >>1))  &  P2_EN[0]}})  |
243
                                  (P2IES_D  &  {DEC_SZ{(reg_addr==(P2IES >>1))  &  P2_EN[0]}})  |
244
                                  (P2IE_D   &  {DEC_SZ{(reg_addr==(P2IE  >>1))  &  P2_EN[0]}})  |
245
                                  (P2SEL_D  &  {DEC_SZ{(reg_addr==(P2SEL >>1))  &  P2_EN[0]}})  |
246
                                  (P3IN_D   &  {DEC_SZ{(reg_addr==(P3IN  >>1))  &  P3_EN[0]}})  |
247
                                  (P3OUT_D  &  {DEC_SZ{(reg_addr==(P3OUT >>1))  &  P3_EN[0]}})  |
248
                                  (P3DIR_D  &  {DEC_SZ{(reg_addr==(P3DIR >>1))  &  P3_EN[0]}})  |
249
                                  (P3SEL_D  &  {DEC_SZ{(reg_addr==(P3SEL >>1))  &  P3_EN[0]}})  |
250
                                  (P4IN_D   &  {DEC_SZ{(reg_addr==(P4IN  >>1))  &  P4_EN[0]}})  |
251
                                  (P4OUT_D  &  {DEC_SZ{(reg_addr==(P4OUT >>1))  &  P4_EN[0]}})  |
252
                                  (P4DIR_D  &  {DEC_SZ{(reg_addr==(P4DIR >>1))  &  P4_EN[0]}})  |
253
                                  (P4SEL_D  &  {DEC_SZ{(reg_addr==(P4SEL >>1))  &  P4_EN[0]}})  |
254
                                  (P5IN_D   &  {DEC_SZ{(reg_addr==(P5IN  >>1))  &  P5_EN[0]}})  |
255
                                  (P5OUT_D  &  {DEC_SZ{(reg_addr==(P5OUT >>1))  &  P5_EN[0]}})  |
256
                                  (P5DIR_D  &  {DEC_SZ{(reg_addr==(P5DIR >>1))  &  P5_EN[0]}})  |
257
                                  (P5SEL_D  &  {DEC_SZ{(reg_addr==(P5SEL >>1))  &  P5_EN[0]}})  |
258
                                  (P6IN_D   &  {DEC_SZ{(reg_addr==(P6IN  >>1))  &  P6_EN[0]}})  |
259
                                  (P6OUT_D  &  {DEC_SZ{(reg_addr==(P6OUT >>1))  &  P6_EN[0]}})  |
260
                                  (P6DIR_D  &  {DEC_SZ{(reg_addr==(P6DIR >>1))  &  P6_EN[0]}})  |
261
                                  (P6SEL_D  &  {DEC_SZ{(reg_addr==(P6SEL >>1))  &  P6_EN[0]}});
262 80 olivier.gi
 
263
// Read/Write probes
264 111 olivier.gi
wire              reg_lo_write =  per_we[0] & reg_sel;
265
wire              reg_hi_write =  per_we[1] & reg_sel;
266
wire              reg_read     = ~|per_we   & reg_sel;
267 80 olivier.gi
 
268
// Read/Write vectors
269 111 olivier.gi
wire [DEC_SZ-1:0] reg_hi_wr    = reg_dec & {DEC_SZ{reg_hi_write}};
270
wire [DEC_SZ-1:0] reg_lo_wr    = reg_dec & {DEC_SZ{reg_lo_write}};
271
wire [DEC_SZ-1:0] reg_rd       = reg_dec & {DEC_SZ{reg_read}};
272 80 olivier.gi
 
273
//============================================================================
274
// 3) REGISTERS
275
//============================================================================
276
 
277
// P1IN Register
278
//---------------
279 111 olivier.gi
wire [7:0] p1in;
280 80 olivier.gi
 
281 136 olivier.gi
omsp_sync_cell sync_cell_p1in_0 (.data_out(p1in[0]), .data_in(p1_din[0] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
282
omsp_sync_cell sync_cell_p1in_1 (.data_out(p1in[1]), .data_in(p1_din[1] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
283
omsp_sync_cell sync_cell_p1in_2 (.data_out(p1in[2]), .data_in(p1_din[2] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
284
omsp_sync_cell sync_cell_p1in_3 (.data_out(p1in[3]), .data_in(p1_din[3] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
285
omsp_sync_cell sync_cell_p1in_4 (.data_out(p1in[4]), .data_in(p1_din[4] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
286
omsp_sync_cell sync_cell_p1in_5 (.data_out(p1in[5]), .data_in(p1_din[5] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
287
omsp_sync_cell sync_cell_p1in_6 (.data_out(p1in[6]), .data_in(p1_din[6] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
288
omsp_sync_cell sync_cell_p1in_7 (.data_out(p1in[7]), .data_in(p1_din[7] & P1_EN[0]), .clk(mclk), .rst(puc_rst));
289 80 olivier.gi
 
290
 
291
// P1OUT Register
292
//----------------
293
reg  [7:0] p1out;
294
 
295 111 olivier.gi
wire       p1out_wr  = P1OUT[0] ? reg_hi_wr[P1OUT] : reg_lo_wr[P1OUT];
296
wire [7:0] p1out_nxt = P1OUT[0] ? per_din[15:8]    : per_din[7:0];
297 80 olivier.gi
 
298 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
299
  if (puc_rst)        p1out <=  8'h00;
300 80 olivier.gi
  else if (p1out_wr)  p1out <=  p1out_nxt & P1_EN_MSK;
301
 
302
assign p1_dout = p1out;
303
 
304
 
305
// P1DIR Register
306
//----------------
307
reg  [7:0] p1dir;
308
 
309 111 olivier.gi
wire       p1dir_wr  = P1DIR[0] ? reg_hi_wr[P1DIR] : reg_lo_wr[P1DIR];
310
wire [7:0] p1dir_nxt = P1DIR[0] ? per_din[15:8]    : per_din[7:0];
311 80 olivier.gi
 
312 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
313
  if (puc_rst)        p1dir <=  8'h00;
314 80 olivier.gi
  else if (p1dir_wr)  p1dir <=  p1dir_nxt & P1_EN_MSK;
315
 
316
assign p1_dout_en = p1dir;
317
 
318
 
319
// P1IFG Register
320
//----------------
321
reg  [7:0] p1ifg;
322
 
323 111 olivier.gi
wire       p1ifg_wr  = P1IFG[0] ? reg_hi_wr[P1IFG] : reg_lo_wr[P1IFG];
324
wire [7:0] p1ifg_nxt = P1IFG[0] ? per_din[15:8]    : per_din[7:0];
325 80 olivier.gi
wire [7:0] p1ifg_set;
326
 
327 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
328
  if (puc_rst)        p1ifg <=  8'h00;
329 80 olivier.gi
  else if (p1ifg_wr)  p1ifg <=  (p1ifg_nxt | p1ifg_set) & P1_EN_MSK;
330
  else                p1ifg <=  (p1ifg     | p1ifg_set) & P1_EN_MSK;
331
 
332
// P1IES Register
333
//----------------
334
reg  [7:0] p1ies;
335
 
336 111 olivier.gi
wire       p1ies_wr  = P1IES[0] ? reg_hi_wr[P1IES] : reg_lo_wr[P1IES];
337
wire [7:0] p1ies_nxt = P1IES[0] ? per_din[15:8]    : per_din[7:0];
338 80 olivier.gi
 
339 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
340
  if (puc_rst)        p1ies <=  8'h00;
341 80 olivier.gi
  else if (p1ies_wr)  p1ies <=  p1ies_nxt & P1_EN_MSK;
342
 
343
 
344
// P1IE Register
345
//----------------
346
reg  [7:0] p1ie;
347
 
348 111 olivier.gi
wire       p1ie_wr  = P1IE[0] ? reg_hi_wr[P1IE] : reg_lo_wr[P1IE];
349
wire [7:0] p1ie_nxt = P1IE[0] ? per_din[15:8]   : per_din[7:0];
350 80 olivier.gi
 
351 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
352
  if (puc_rst)       p1ie <=  8'h00;
353 80 olivier.gi
  else if (p1ie_wr)  p1ie <=  p1ie_nxt & P1_EN_MSK;
354
 
355
 
356
// P1SEL Register
357
//----------------
358
reg  [7:0] p1sel;
359
 
360 111 olivier.gi
wire       p1sel_wr  = P1SEL[0] ? reg_hi_wr[P1SEL] : reg_lo_wr[P1SEL];
361
wire [7:0] p1sel_nxt = P1SEL[0] ? per_din[15:8]    : per_din[7:0];
362 80 olivier.gi
 
363 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
364
  if (puc_rst)       p1sel <=  8'h00;
365 80 olivier.gi
  else if (p1sel_wr) p1sel <=  p1sel_nxt & P1_EN_MSK;
366
 
367
assign p1_sel = p1sel;
368
 
369
 
370
// P2IN Register
371
//---------------
372 111 olivier.gi
wire [7:0] p2in;
373 80 olivier.gi
 
374 136 olivier.gi
omsp_sync_cell sync_cell_p2in_0 (.data_out(p2in[0]), .data_in(p2_din[0] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
375
omsp_sync_cell sync_cell_p2in_1 (.data_out(p2in[1]), .data_in(p2_din[1] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
376
omsp_sync_cell sync_cell_p2in_2 (.data_out(p2in[2]), .data_in(p2_din[2] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
377
omsp_sync_cell sync_cell_p2in_3 (.data_out(p2in[3]), .data_in(p2_din[3] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
378
omsp_sync_cell sync_cell_p2in_4 (.data_out(p2in[4]), .data_in(p2_din[4] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
379
omsp_sync_cell sync_cell_p2in_5 (.data_out(p2in[5]), .data_in(p2_din[5] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
380
omsp_sync_cell sync_cell_p2in_6 (.data_out(p2in[6]), .data_in(p2_din[6] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
381
omsp_sync_cell sync_cell_p2in_7 (.data_out(p2in[7]), .data_in(p2_din[7] & P2_EN[0]), .clk(mclk), .rst(puc_rst));
382 80 olivier.gi
 
383
 
384
// P2OUT Register
385
//----------------
386
reg  [7:0] p2out;
387
 
388 111 olivier.gi
wire       p2out_wr  = P2OUT[0] ? reg_hi_wr[P2OUT] : reg_lo_wr[P2OUT];
389
wire [7:0] p2out_nxt = P2OUT[0] ? per_din[15:8]    : per_din[7:0];
390 80 olivier.gi
 
391 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
392
  if (puc_rst)        p2out <=  8'h00;
393 80 olivier.gi
  else if (p2out_wr)  p2out <=  p2out_nxt & P2_EN_MSK;
394
 
395
assign p2_dout = p2out;
396
 
397
 
398
// P2DIR Register
399
//----------------
400
reg  [7:0] p2dir;
401
 
402 111 olivier.gi
wire       p2dir_wr  = P2DIR[0] ? reg_hi_wr[P2DIR] : reg_lo_wr[P2DIR];
403
wire [7:0] p2dir_nxt = P2DIR[0] ? per_din[15:8]    : per_din[7:0];
404 80 olivier.gi
 
405 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
406
  if (puc_rst)        p2dir <=  8'h00;
407 80 olivier.gi
  else if (p2dir_wr)  p2dir <=  p2dir_nxt & P2_EN_MSK;
408
 
409
assign p2_dout_en = p2dir;
410
 
411
 
412
// P2IFG Register
413
//----------------
414
reg  [7:0] p2ifg;
415
 
416 111 olivier.gi
wire       p2ifg_wr  = P2IFG[0] ? reg_hi_wr[P2IFG] : reg_lo_wr[P2IFG];
417
wire [7:0] p2ifg_nxt = P2IFG[0] ? per_din[15:8]    : per_din[7:0];
418 80 olivier.gi
wire [7:0] p2ifg_set;
419
 
420 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
421
  if (puc_rst)        p2ifg <=  8'h00;
422 80 olivier.gi
  else if (p2ifg_wr)  p2ifg <=  (p2ifg_nxt | p2ifg_set) & P2_EN_MSK;
423
  else                p2ifg <=  (p2ifg     | p2ifg_set) & P2_EN_MSK;
424
 
425
 
426
// P2IES Register
427
//----------------
428
reg  [7:0] p2ies;
429
 
430 111 olivier.gi
wire       p2ies_wr  = P2IES[0] ? reg_hi_wr[P2IES] : reg_lo_wr[P2IES];
431
wire [7:0] p2ies_nxt = P2IES[0] ? per_din[15:8]    : per_din[7:0];
432 80 olivier.gi
 
433 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
434
  if (puc_rst)        p2ies <=  8'h00;
435 80 olivier.gi
  else if (p2ies_wr)  p2ies <=  p2ies_nxt & P2_EN_MSK;
436
 
437
 
438
// P2IE Register
439
//----------------
440
reg  [7:0] p2ie;
441
 
442 111 olivier.gi
wire       p2ie_wr  = P2IE[0] ? reg_hi_wr[P2IE] : reg_lo_wr[P2IE];
443
wire [7:0] p2ie_nxt = P2IE[0] ? per_din[15:8]   : per_din[7:0];
444 80 olivier.gi
 
445 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
446
  if (puc_rst)       p2ie <=  8'h00;
447 80 olivier.gi
  else if (p2ie_wr)  p2ie <=  p2ie_nxt & P2_EN_MSK;
448
 
449
 
450
// P2SEL Register
451
//----------------
452
reg  [7:0] p2sel;
453
 
454 111 olivier.gi
wire       p2sel_wr  = P2SEL[0] ? reg_hi_wr[P2SEL] : reg_lo_wr[P2SEL];
455
wire [7:0] p2sel_nxt = P2SEL[0] ? per_din[15:8]    : per_din[7:0];
456 80 olivier.gi
 
457 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
458
  if (puc_rst)       p2sel <=  8'h00;
459 80 olivier.gi
  else if (p2sel_wr) p2sel <=  p2sel_nxt & P2_EN_MSK;
460
 
461
assign p2_sel = p2sel;
462
 
463
 
464
// P3IN Register
465
//---------------
466 111 olivier.gi
wire  [7:0] p3in;
467 80 olivier.gi
 
468 136 olivier.gi
omsp_sync_cell sync_cell_p3in_0 (.data_out(p3in[0]), .data_in(p3_din[0] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
469
omsp_sync_cell sync_cell_p3in_1 (.data_out(p3in[1]), .data_in(p3_din[1] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
470
omsp_sync_cell sync_cell_p3in_2 (.data_out(p3in[2]), .data_in(p3_din[2] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
471
omsp_sync_cell sync_cell_p3in_3 (.data_out(p3in[3]), .data_in(p3_din[3] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
472
omsp_sync_cell sync_cell_p3in_4 (.data_out(p3in[4]), .data_in(p3_din[4] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
473
omsp_sync_cell sync_cell_p3in_5 (.data_out(p3in[5]), .data_in(p3_din[5] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
474
omsp_sync_cell sync_cell_p3in_6 (.data_out(p3in[6]), .data_in(p3_din[6] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
475
omsp_sync_cell sync_cell_p3in_7 (.data_out(p3in[7]), .data_in(p3_din[7] & P3_EN[0]), .clk(mclk), .rst(puc_rst));
476 80 olivier.gi
 
477
 
478
// P3OUT Register
479
//----------------
480
reg  [7:0] p3out;
481
 
482 111 olivier.gi
wire       p3out_wr  = P3OUT[0] ? reg_hi_wr[P3OUT] : reg_lo_wr[P3OUT];
483
wire [7:0] p3out_nxt = P3OUT[0] ? per_din[15:8]    : per_din[7:0];
484 80 olivier.gi
 
485 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
486
  if (puc_rst)        p3out <=  8'h00;
487 80 olivier.gi
  else if (p3out_wr)  p3out <=  p3out_nxt & P3_EN_MSK;
488
 
489
assign p3_dout = p3out;
490
 
491
 
492
// P3DIR Register
493
//----------------
494
reg  [7:0] p3dir;
495
 
496 111 olivier.gi
wire       p3dir_wr  = P3DIR[0] ? reg_hi_wr[P3DIR] : reg_lo_wr[P3DIR];
497
wire [7:0] p3dir_nxt = P3DIR[0] ? per_din[15:8]    : per_din[7:0];
498 80 olivier.gi
 
499 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
500
  if (puc_rst)        p3dir <=  8'h00;
501 80 olivier.gi
  else if (p3dir_wr)  p3dir <=  p3dir_nxt & P3_EN_MSK;
502
 
503
assign p3_dout_en = p3dir;
504
 
505
 
506
// P3SEL Register
507
//----------------
508
reg  [7:0] p3sel;
509
 
510 111 olivier.gi
wire       p3sel_wr  = P3SEL[0] ? reg_hi_wr[P3SEL] : reg_lo_wr[P3SEL];
511
wire [7:0] p3sel_nxt = P3SEL[0] ? per_din[15:8]    : per_din[7:0];
512 80 olivier.gi
 
513 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
514
  if (puc_rst)       p3sel <=  8'h00;
515 80 olivier.gi
  else if (p3sel_wr) p3sel <=  p3sel_nxt & P3_EN_MSK;
516
 
517
assign p3_sel = p3sel;
518
 
519
 
520
// P4IN Register
521
//---------------
522 111 olivier.gi
wire  [7:0] p4in;
523 80 olivier.gi
 
524 136 olivier.gi
omsp_sync_cell sync_cell_p4in_0 (.data_out(p4in[0]), .data_in(p4_din[0] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
525
omsp_sync_cell sync_cell_p4in_1 (.data_out(p4in[1]), .data_in(p4_din[1] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
526
omsp_sync_cell sync_cell_p4in_2 (.data_out(p4in[2]), .data_in(p4_din[2] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
527
omsp_sync_cell sync_cell_p4in_3 (.data_out(p4in[3]), .data_in(p4_din[3] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
528
omsp_sync_cell sync_cell_p4in_4 (.data_out(p4in[4]), .data_in(p4_din[4] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
529
omsp_sync_cell sync_cell_p4in_5 (.data_out(p4in[5]), .data_in(p4_din[5] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
530
omsp_sync_cell sync_cell_p4in_6 (.data_out(p4in[6]), .data_in(p4_din[6] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
531
omsp_sync_cell sync_cell_p4in_7 (.data_out(p4in[7]), .data_in(p4_din[7] & P4_EN[0]), .clk(mclk), .rst(puc_rst));
532 80 olivier.gi
 
533
 
534
// P4OUT Register
535
//----------------
536
reg  [7:0] p4out;
537
 
538 111 olivier.gi
wire       p4out_wr  = P4OUT[0] ? reg_hi_wr[P4OUT] : reg_lo_wr[P4OUT];
539
wire [7:0] p4out_nxt = P4OUT[0] ? per_din[15:8]    : per_din[7:0];
540 80 olivier.gi
 
541 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
542
  if (puc_rst)        p4out <=  8'h00;
543 80 olivier.gi
  else if (p4out_wr)  p4out <=  p4out_nxt & P4_EN_MSK;
544
 
545
assign p4_dout = p4out;
546
 
547
 
548
// P4DIR Register
549
//----------------
550
reg  [7:0] p4dir;
551
 
552 111 olivier.gi
wire       p4dir_wr  = P4DIR[0] ? reg_hi_wr[P4DIR] : reg_lo_wr[P4DIR];
553
wire [7:0] p4dir_nxt = P4DIR[0] ? per_din[15:8]    : per_din[7:0];
554 80 olivier.gi
 
555 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
556
  if (puc_rst)        p4dir <=  8'h00;
557 80 olivier.gi
  else if (p4dir_wr)  p4dir <=  p4dir_nxt & P4_EN_MSK;
558
 
559
assign p4_dout_en = p4dir;
560
 
561
 
562
// P4SEL Register
563
//----------------
564
reg  [7:0] p4sel;
565
 
566 111 olivier.gi
wire       p4sel_wr  = P4SEL[0] ? reg_hi_wr[P4SEL] : reg_lo_wr[P4SEL];
567
wire [7:0] p4sel_nxt = P4SEL[0] ? per_din[15:8]    : per_din[7:0];
568 80 olivier.gi
 
569 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
570
  if (puc_rst)       p4sel <=  8'h00;
571 80 olivier.gi
  else if (p4sel_wr) p4sel <=  p4sel_nxt & P4_EN_MSK;
572
 
573
assign p4_sel = p4sel;
574
 
575
 
576
// P5IN Register
577
//---------------
578 111 olivier.gi
wire  [7:0] p5in;
579 80 olivier.gi
 
580 136 olivier.gi
omsp_sync_cell sync_cell_p5in_0 (.data_out(p5in[0]), .data_in(p5_din[0] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
581
omsp_sync_cell sync_cell_p5in_1 (.data_out(p5in[1]), .data_in(p5_din[1] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
582
omsp_sync_cell sync_cell_p5in_2 (.data_out(p5in[2]), .data_in(p5_din[2] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
583
omsp_sync_cell sync_cell_p5in_3 (.data_out(p5in[3]), .data_in(p5_din[3] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
584
omsp_sync_cell sync_cell_p5in_4 (.data_out(p5in[4]), .data_in(p5_din[4] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
585
omsp_sync_cell sync_cell_p5in_5 (.data_out(p5in[5]), .data_in(p5_din[5] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
586
omsp_sync_cell sync_cell_p5in_6 (.data_out(p5in[6]), .data_in(p5_din[6] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
587
omsp_sync_cell sync_cell_p5in_7 (.data_out(p5in[7]), .data_in(p5_din[7] & P5_EN[0]), .clk(mclk), .rst(puc_rst));
588 80 olivier.gi
 
589
 
590
// P5OUT Register
591
//----------------
592
reg  [7:0] p5out;
593
 
594 111 olivier.gi
wire       p5out_wr  = P5OUT[0] ? reg_hi_wr[P5OUT] : reg_lo_wr[P5OUT];
595
wire [7:0] p5out_nxt = P5OUT[0] ? per_din[15:8]    : per_din[7:0];
596 80 olivier.gi
 
597 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
598
  if (puc_rst)        p5out <=  8'h00;
599 80 olivier.gi
  else if (p5out_wr)  p5out <=  p5out_nxt & P5_EN_MSK;
600
 
601
assign p5_dout = p5out;
602
 
603
 
604
// P5DIR Register
605
//----------------
606
reg  [7:0] p5dir;
607
 
608 111 olivier.gi
wire       p5dir_wr  = P5DIR[0] ? reg_hi_wr[P5DIR] : reg_lo_wr[P5DIR];
609
wire [7:0] p5dir_nxt = P5DIR[0] ? per_din[15:8]    : per_din[7:0];
610 80 olivier.gi
 
611 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
612
  if (puc_rst)        p5dir <=  8'h00;
613 80 olivier.gi
  else if (p5dir_wr)  p5dir <=  p5dir_nxt & P5_EN_MSK;
614
 
615
assign p5_dout_en = p5dir;
616
 
617
 
618
// P5SEL Register
619
//----------------
620
reg  [7:0] p5sel;
621
 
622 111 olivier.gi
wire       p5sel_wr  = P5SEL[0] ? reg_hi_wr[P5SEL] : reg_lo_wr[P5SEL];
623
wire [7:0] p5sel_nxt = P5SEL[0] ? per_din[15:8]    : per_din[7:0];
624 80 olivier.gi
 
625 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
626
  if (puc_rst)       p5sel <=  8'h00;
627 80 olivier.gi
  else if (p5sel_wr) p5sel <=  p5sel_nxt & P5_EN_MSK;
628
 
629
assign p5_sel = p5sel;
630
 
631
 
632
// P6IN Register
633
//---------------
634 111 olivier.gi
wire  [7:0] p6in;
635 80 olivier.gi
 
636 136 olivier.gi
omsp_sync_cell sync_cell_p6in_0 (.data_out(p6in[0]), .data_in(p6_din[0] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
637
omsp_sync_cell sync_cell_p6in_1 (.data_out(p6in[1]), .data_in(p6_din[1] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
638
omsp_sync_cell sync_cell_p6in_2 (.data_out(p6in[2]), .data_in(p6_din[2] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
639
omsp_sync_cell sync_cell_p6in_3 (.data_out(p6in[3]), .data_in(p6_din[3] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
640
omsp_sync_cell sync_cell_p6in_4 (.data_out(p6in[4]), .data_in(p6_din[4] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
641
omsp_sync_cell sync_cell_p6in_5 (.data_out(p6in[5]), .data_in(p6_din[5] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
642
omsp_sync_cell sync_cell_p6in_6 (.data_out(p6in[6]), .data_in(p6_din[6] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
643
omsp_sync_cell sync_cell_p6in_7 (.data_out(p6in[7]), .data_in(p6_din[7] & P6_EN[0]), .clk(mclk), .rst(puc_rst));
644 80 olivier.gi
 
645
 
646
// P6OUT Register
647
//----------------
648
reg  [7:0] p6out;
649
 
650 111 olivier.gi
wire       p6out_wr  = P6OUT[0] ? reg_hi_wr[P6OUT] : reg_lo_wr[P6OUT];
651
wire [7:0] p6out_nxt = P6OUT[0] ? per_din[15:8]    : per_din[7:0];
652 80 olivier.gi
 
653 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
654
  if (puc_rst)        p6out <=  8'h00;
655 80 olivier.gi
  else if (p6out_wr)  p6out <=  p6out_nxt & P6_EN_MSK;
656
 
657
assign p6_dout = p6out;
658
 
659
 
660
// P6DIR Register
661
//----------------
662
reg  [7:0] p6dir;
663
 
664 111 olivier.gi
wire       p6dir_wr  = P6DIR[0] ? reg_hi_wr[P6DIR] : reg_lo_wr[P6DIR];
665
wire [7:0] p6dir_nxt = P6DIR[0] ? per_din[15:8]    : per_din[7:0];
666 80 olivier.gi
 
667 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
668
  if (puc_rst)        p6dir <=  8'h00;
669 80 olivier.gi
  else if (p6dir_wr)  p6dir <=  p6dir_nxt & P6_EN_MSK;
670
 
671
assign p6_dout_en = p6dir;
672
 
673
 
674
// P6SEL Register
675
//----------------
676
reg  [7:0] p6sel;
677
 
678 111 olivier.gi
wire       p6sel_wr  = P6SEL[0] ? reg_hi_wr[P6SEL] : reg_lo_wr[P6SEL];
679
wire [7:0] p6sel_nxt = P6SEL[0] ? per_din[15:8]    : per_din[7:0];
680 80 olivier.gi
 
681 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
682
  if (puc_rst)       p6sel <=  8'h00;
683 80 olivier.gi
  else if (p6sel_wr) p6sel <=  p6sel_nxt & P6_EN_MSK;
684
 
685
assign p6_sel = p6sel;
686
 
687
 
688
 
689
//============================================================================
690
// 4) INTERRUPT GENERATION
691
//============================================================================
692
 
693
// Port 1 interrupt
694
//------------------
695
 
696
// Delay input
697
reg    [7:0] p1in_dly;
698 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
699
  if (puc_rst)  p1in_dly <=  8'h00;
700 80 olivier.gi
  else          p1in_dly <=  p1in & P1_EN_MSK;
701
 
702
// Edge detection
703
wire   [7:0] p1in_re   =   p1in & ~p1in_dly;
704
wire   [7:0] p1in_fe   =  ~p1in &  p1in_dly;
705
 
706
// Set interrupt flag
707
assign       p1ifg_set = {p1ies[7] ? p1in_fe[7] : p1in_re[7],
708
                          p1ies[6] ? p1in_fe[6] : p1in_re[6],
709
                          p1ies[5] ? p1in_fe[5] : p1in_re[5],
710
                          p1ies[4] ? p1in_fe[4] : p1in_re[4],
711
                          p1ies[3] ? p1in_fe[3] : p1in_re[3],
712
                          p1ies[2] ? p1in_fe[2] : p1in_re[2],
713
                          p1ies[1] ? p1in_fe[1] : p1in_re[1],
714
                          p1ies[0] ? p1in_fe[0] : p1in_re[0]} & P1_EN_MSK;
715
 
716
// Generate CPU interrupt
717
assign       irq_port1 = |(p1ie & p1ifg) & P1_EN[0];
718
 
719
 
720
// Port 1 interrupt
721
//------------------
722
 
723
// Delay input
724
reg    [7:0] p2in_dly;
725 111 olivier.gi
always @ (posedge mclk or posedge puc_rst)
726
  if (puc_rst)  p2in_dly <=  8'h00;
727 80 olivier.gi
  else          p2in_dly <=  p2in & P2_EN_MSK;
728
 
729
// Edge detection
730
wire   [7:0] p2in_re   =   p2in & ~p2in_dly;
731
wire   [7:0] p2in_fe   =  ~p2in &  p2in_dly;
732
 
733
// Set interrupt flag
734
assign       p2ifg_set = {p2ies[7] ? p2in_fe[7] : p2in_re[7],
735
                          p2ies[6] ? p2in_fe[6] : p2in_re[6],
736
                          p2ies[5] ? p2in_fe[5] : p2in_re[5],
737
                          p2ies[4] ? p2in_fe[4] : p2in_re[4],
738
                          p2ies[3] ? p2in_fe[3] : p2in_re[3],
739
                          p2ies[2] ? p2in_fe[2] : p2in_re[2],
740
                          p2ies[1] ? p2in_fe[1] : p2in_re[1],
741
                          p2ies[0] ? p2in_fe[0] : p2in_re[0]} & P2_EN_MSK;
742
 
743
// Generate CPU interrupt
744
assign      irq_port2 = |(p2ie & p2ifg) & P2_EN[0];
745
 
746
 
747
//============================================================================
748
// 5) DATA OUTPUT GENERATION
749
//============================================================================
750
 
751
// Data output mux
752 111 olivier.gi
wire [15:0] p1in_rd   = {8'h00, (p1in  & {8{reg_rd[P1IN]}})}  << (8 & {4{P1IN[0]}});
753
wire [15:0] p1out_rd  = {8'h00, (p1out & {8{reg_rd[P1OUT]}})} << (8 & {4{P1OUT[0]}});
754
wire [15:0] p1dir_rd  = {8'h00, (p1dir & {8{reg_rd[P1DIR]}})} << (8 & {4{P1DIR[0]}});
755
wire [15:0] p1ifg_rd  = {8'h00, (p1ifg & {8{reg_rd[P1IFG]}})} << (8 & {4{P1IFG[0]}});
756
wire [15:0] p1ies_rd  = {8'h00, (p1ies & {8{reg_rd[P1IES]}})} << (8 & {4{P1IES[0]}});
757
wire [15:0] p1ie_rd   = {8'h00, (p1ie  & {8{reg_rd[P1IE]}})}  << (8 & {4{P1IE[0]}});
758
wire [15:0] p1sel_rd  = {8'h00, (p1sel & {8{reg_rd[P1SEL]}})} << (8 & {4{P1SEL[0]}});
759
wire [15:0] p2in_rd   = {8'h00, (p2in  & {8{reg_rd[P2IN]}})}  << (8 & {4{P2IN[0]}});
760
wire [15:0] p2out_rd  = {8'h00, (p2out & {8{reg_rd[P2OUT]}})} << (8 & {4{P2OUT[0]}});
761
wire [15:0] p2dir_rd  = {8'h00, (p2dir & {8{reg_rd[P2DIR]}})} << (8 & {4{P2DIR[0]}});
762
wire [15:0] p2ifg_rd  = {8'h00, (p2ifg & {8{reg_rd[P2IFG]}})} << (8 & {4{P2IFG[0]}});
763
wire [15:0] p2ies_rd  = {8'h00, (p2ies & {8{reg_rd[P2IES]}})} << (8 & {4{P2IES[0]}});
764
wire [15:0] p2ie_rd   = {8'h00, (p2ie  & {8{reg_rd[P2IE]}})}  << (8 & {4{P2IE[0]}});
765
wire [15:0] p2sel_rd  = {8'h00, (p2sel & {8{reg_rd[P2SEL]}})} << (8 & {4{P2SEL[0]}});
766
wire [15:0] p3in_rd   = {8'h00, (p3in  & {8{reg_rd[P3IN]}})}  << (8 & {4{P3IN[0]}});
767
wire [15:0] p3out_rd  = {8'h00, (p3out & {8{reg_rd[P3OUT]}})} << (8 & {4{P3OUT[0]}});
768
wire [15:0] p3dir_rd  = {8'h00, (p3dir & {8{reg_rd[P3DIR]}})} << (8 & {4{P3DIR[0]}});
769
wire [15:0] p3sel_rd  = {8'h00, (p3sel & {8{reg_rd[P3SEL]}})} << (8 & {4{P3SEL[0]}});
770
wire [15:0] p4in_rd   = {8'h00, (p4in  & {8{reg_rd[P4IN]}})}  << (8 & {4{P4IN[0]}});
771
wire [15:0] p4out_rd  = {8'h00, (p4out & {8{reg_rd[P4OUT]}})} << (8 & {4{P4OUT[0]}});
772
wire [15:0] p4dir_rd  = {8'h00, (p4dir & {8{reg_rd[P4DIR]}})} << (8 & {4{P4DIR[0]}});
773
wire [15:0] p4sel_rd  = {8'h00, (p4sel & {8{reg_rd[P4SEL]}})} << (8 & {4{P4SEL[0]}});
774
wire [15:0] p5in_rd   = {8'h00, (p5in  & {8{reg_rd[P5IN]}})}  << (8 & {4{P5IN[0]}});
775
wire [15:0] p5out_rd  = {8'h00, (p5out & {8{reg_rd[P5OUT]}})} << (8 & {4{P5OUT[0]}});
776
wire [15:0] p5dir_rd  = {8'h00, (p5dir & {8{reg_rd[P5DIR]}})} << (8 & {4{P5DIR[0]}});
777
wire [15:0] p5sel_rd  = {8'h00, (p5sel & {8{reg_rd[P5SEL]}})} << (8 & {4{P5SEL[0]}});
778
wire [15:0] p6in_rd   = {8'h00, (p6in  & {8{reg_rd[P6IN]}})}  << (8 & {4{P6IN[0]}});
779
wire [15:0] p6out_rd  = {8'h00, (p6out & {8{reg_rd[P6OUT]}})} << (8 & {4{P6OUT[0]}});
780
wire [15:0] p6dir_rd  = {8'h00, (p6dir & {8{reg_rd[P6DIR]}})} << (8 & {4{P6DIR[0]}});
781
wire [15:0] p6sel_rd  = {8'h00, (p6sel & {8{reg_rd[P6SEL]}})} << (8 & {4{P6SEL[0]}});
782 80 olivier.gi
 
783
wire [15:0] per_dout  =  p1in_rd   |
784
                         p1out_rd  |
785
                         p1dir_rd  |
786
                         p1ifg_rd  |
787
                         p1ies_rd  |
788
                         p1ie_rd   |
789
                         p1sel_rd  |
790
                         p2in_rd   |
791
                         p2out_rd  |
792
                         p2dir_rd  |
793
                         p2ifg_rd  |
794
                         p2ies_rd  |
795
                         p2ie_rd   |
796
                         p2sel_rd  |
797
                         p3in_rd   |
798
                         p3out_rd  |
799
                         p3dir_rd  |
800
                         p3sel_rd  |
801
                         p4in_rd   |
802
                         p4out_rd  |
803
                         p4dir_rd  |
804
                         p4sel_rd  |
805
                         p5in_rd   |
806
                         p5out_rd  |
807
                         p5dir_rd  |
808
                         p5sel_rd  |
809
                         p6in_rd   |
810
                         p6out_rd  |
811
                         p6dir_rd  |
812
                         p6sel_rd;
813
 
814
endmodule // omsp_gpio

powered by: WebSVN 2.1.0

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