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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [ethmac/] [eth_registers.v] - Blame information for rev 682

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

Line No. Rev Author Line
1 6 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_registers.v                                             ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 570 olof
////  http://www.opencores.org/project,ethmac                     ////
7 6 julius
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Igor Mohor (igorM@opencores.org)                      ////
10
////                                                              ////
11
////  All additional information is avaliable in the Readme.txt   ////
12
////  file.                                                       ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2001, 2002 Authors                             ////
17
////                                                              ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS Revision History
42
//
43 403 julius
// $Log: not supported by cvs2svn $
44 6 julius
// Revision 1.28  2004/04/26 15:26:23  igorm
45
// - Bug connected to the TX_BD_NUM_Wr signal fixed (bug came in with the
46
//   previous update of the core.
47
// - TxBDAddress is set to 0 after the TX is enabled in the MODER register.
48
// - RxBDAddress is set to r_TxBDNum<<1 after the RX is enabled in the MODER
49
//   register. (thanks to Mathias and Torbjorn)
50
// - Multicast reception was fixed. Thanks to Ulrich Gries
51
//
52
// Revision 1.27  2004/04/26 11:42:17  igorm
53
// TX_BD_NUM_Wr error fixed. Error was entered with the last check-in.
54
//
55
// Revision 1.26  2003/11/12 18:24:59  tadejm
56
// WISHBONE slave changed and tested from only 32-bit accesss to byte access.
57
//
58
// Revision 1.25  2003/04/18 16:26:25  mohor
59
// RxBDAddress was updated also when value to r_TxBDNum was written with
60
// greater value than allowed.
61
//
62
// Revision 1.24  2002/11/22 01:57:06  mohor
63
// Rx Flow control fixed. CF flag added to the RX buffer descriptor. RxAbort
64
// synchronized.
65
//
66
// Revision 1.23  2002/11/19 18:13:49  mohor
67
// r_MiiMRst is not used for resetting the MIIM module. wb_rst used instead.
68
//
69
// Revision 1.22  2002/11/14 18:37:20  mohor
70
// r_Rst signal does not reset any module any more and is removed from the design.
71
//
72
// Revision 1.21  2002/09/10 10:35:23  mohor
73
// Ethernet debug registers removed.
74
//
75
// Revision 1.20  2002/09/04 18:40:25  mohor
76
// ETH_TXCTRL and ETH_RXCTRL registers added. Interrupts related to
77
// the control frames connected.
78
//
79
// Revision 1.19  2002/08/19 16:01:40  mohor
80
// Only values smaller or equal to 0x80 can be written to TX_BD_NUM register.
81
// r_TxEn and r_RxEn depend on the limit values of the TX_BD_NUMOut.
82
//
83
// Revision 1.18  2002/08/16 22:28:23  mohor
84
// Syntax error fixed.
85
//
86
// Revision 1.17  2002/08/16 22:23:03  mohor
87
// Syntax error fixed.
88
//
89
// Revision 1.16  2002/08/16 22:14:22  mohor
90
// Synchronous reset added to all registers. Defines used for width. r_MiiMRst
91
// changed from bit position 10 to 9.
92
//
93
// Revision 1.15  2002/08/14 18:26:37  mohor
94
// LinkFailRegister is reflecting the status of the PHY's link fail status bit.
95
//
96
// Revision 1.14  2002/04/22 14:03:44  mohor
97
// Interrupts are visible in the ETH_INT_SOURCE regardless if they are enabled
98
// or not.
99
//
100
// Revision 1.13  2002/02/26 16:18:09  mohor
101
// Reset values are passed to registers through parameters
102
//
103
// Revision 1.12  2002/02/17 13:23:42  mohor
104
// Define missmatch fixed.
105
//
106
// Revision 1.11  2002/02/16 14:03:44  mohor
107
// Registered trimmed. Unused registers removed.
108
//
109
// Revision 1.10  2002/02/15 11:08:25  mohor
110
// File format fixed a bit.
111
//
112
// Revision 1.9  2002/02/14 20:19:41  billditt
113
// Modified for Address Checking,
114
// addition of eth_addrcheck.v
115
//
116
// Revision 1.8  2002/02/12 17:01:19  mohor
117
// HASH0 and HASH1 registers added. 
118
 
119
// Revision 1.7  2002/01/23 10:28:16  mohor
120
// Link in the header changed.
121
//
122
// Revision 1.6  2001/12/05 15:00:16  mohor
123
// RX_BD_NUM changed to TX_BD_NUM (holds number of TX descriptors
124
// instead of the number of RX descriptors).
125
//
126
// Revision 1.5  2001/12/05 10:22:19  mohor
127
// ETH_RX_BD_ADR register deleted. ETH_RX_BD_NUM is used instead.
128
//
129
// Revision 1.4  2001/10/19 08:43:51  mohor
130
// eth_timescale.v changed to timescale.v This is done because of the
131
// simulation of the few cores in a one joined project.
132
//
133
// Revision 1.3  2001/10/18 12:07:11  mohor
134
// Status signals changed, Adress decoding changed, interrupt controller
135
// added.
136
//
137
// Revision 1.2  2001/09/24 15:02:56  mohor
138
// Defines changed (All precede with ETH_). Small changes because some
139
// tools generate warnings when two operands are together. Synchronization
140
// between two clocks domains in eth_wishbonedma.v is changed (due to ASIC
141
// demands).
142
//
143
// Revision 1.1  2001/08/06 14:44:29  mohor
144
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
145
// Include files fixed to contain no path.
146
// File names and module names changed ta have a eth_ prologue in the name.
147
// File eth_timescale.v is used to define timescale
148
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
149
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
150
// and Mdo_OE. The bidirectional signal must be created on the top level. This
151
// is done due to the ASIC tools.
152
//
153
// Revision 1.2  2001/08/02 09:25:31  mohor
154
// Unconnected signals are now connected.
155
//
156
// Revision 1.1  2001/07/30 21:23:42  mohor
157
// Directory structure changed. Files checked and joind together.
158
//
159
//
160
//
161
//
162
//
163
//
164
 
165 409 julius
`include "ethmac_defines.v"
166 6 julius
`include "timescale.v"
167
 
168
 
169
module eth_registers( DataIn, Address, Rw, Cs, Clk, Reset, DataOut,
170
                      r_RecSmall, r_Pad, r_HugEn, r_CrcEn, r_DlyCrcEn,
171
                      r_FullD, r_ExDfrEn, r_NoBckof, r_LoopBck, r_IFG,
172
                      r_Pro, r_Iam, r_Bro, r_NoPre, r_TxEn, r_RxEn,
173
                      TxB_IRQ, TxE_IRQ, RxB_IRQ, RxE_IRQ, Busy_IRQ,
174
                      r_IPGT, r_IPGR1, r_IPGR2, r_MinFL, r_MaxFL, r_MaxRet,
175
                      r_CollValid, r_TxFlow, r_RxFlow, r_PassAll,
176
                      r_MiiNoPre, r_ClkDiv, r_WCtrlData, r_RStat, r_ScanStat,
177
                      r_RGAD, r_FIAD, r_CtrlData, NValid_stat, Busy_stat,
178
                      LinkFail, r_MAC, WCtrlDataStart, RStatStart,
179
                      UpdateMIIRX_DATAReg, Prsd, r_TxBDNum, int_o,
180 403 julius
                      r_HASH0, r_HASH1, r_TxPauseTV, r_TxPauseRq, RstTxPauseRq, TxCtrlEndFrm,
181
                      dbg_dat, // jb
182 6 julius
                      StartTxDone, TxClk, RxClk, SetPauseTimer
183
                    );
184
 
185
input [31:0] DataIn;
186
input [7:0] Address;
187
 
188
input Rw;
189
input [3:0] Cs;
190
input Clk;
191
input Reset;
192
 
193
input WCtrlDataStart;
194
input RStatStart;
195
 
196
input UpdateMIIRX_DATAReg;
197
input [15:0] Prsd;
198
 
199
output [31:0] DataOut;
200
reg    [31:0] DataOut;
201
 
202
output r_RecSmall;
203
output r_Pad;
204
output r_HugEn;
205
output r_CrcEn;
206
output r_DlyCrcEn;
207
output r_FullD;
208
output r_ExDfrEn;
209
output r_NoBckof;
210
output r_LoopBck;
211
output r_IFG;
212
output r_Pro;
213
output r_Iam;
214
output r_Bro;
215
output r_NoPre;
216
output r_TxEn;
217
output r_RxEn;
218
output [31:0] r_HASH0;
219
output [31:0] r_HASH1;
220
 
221
input TxB_IRQ;
222
input TxE_IRQ;
223
input RxB_IRQ;
224
input RxE_IRQ;
225
input Busy_IRQ;
226
 
227
output [6:0] r_IPGT;
228
 
229
output [6:0] r_IPGR1;
230
 
231
output [6:0] r_IPGR2;
232
 
233
output [15:0] r_MinFL;
234
output [15:0] r_MaxFL;
235
 
236
output [3:0] r_MaxRet;
237
output [5:0] r_CollValid;
238
 
239
output r_TxFlow;
240
output r_RxFlow;
241
output r_PassAll;
242
 
243
output r_MiiNoPre;
244
output [7:0] r_ClkDiv;
245
 
246
output r_WCtrlData;
247
output r_RStat;
248
output r_ScanStat;
249
 
250
output [4:0] r_RGAD;
251
output [4:0] r_FIAD;
252
 
253
output [15:0]r_CtrlData;
254
 
255
 
256
input NValid_stat;
257
input Busy_stat;
258
input LinkFail;
259
 
260
output [47:0]r_MAC;
261
output [7:0] r_TxBDNum;
262
output       int_o;
263
output [15:0]r_TxPauseTV;
264
output       r_TxPauseRq;
265
input        RstTxPauseRq;
266
input        TxCtrlEndFrm;
267
input        StartTxDone;
268
input        TxClk;
269
input        RxClk;
270
input        SetPauseTimer;
271
 
272 403 julius
input [31:0] dbg_dat; // debug data input - JB
273
 
274
 
275 6 julius
reg          irq_txb;
276
reg          irq_txe;
277
reg          irq_rxb;
278
reg          irq_rxe;
279
reg          irq_busy;
280
reg          irq_txc;
281
reg          irq_rxc;
282
 
283
reg SetTxCIrq_txclk;
284
reg SetTxCIrq_sync1, SetTxCIrq_sync2, SetTxCIrq_sync3;
285
reg SetTxCIrq;
286
reg ResetTxCIrq_sync1, ResetTxCIrq_sync2;
287
 
288
reg SetRxCIrq_rxclk;
289
reg SetRxCIrq_sync1, SetRxCIrq_sync2, SetRxCIrq_sync3;
290
reg SetRxCIrq;
291
reg ResetRxCIrq_sync1;
292
reg ResetRxCIrq_sync2;
293
reg ResetRxCIrq_sync3;
294
 
295
wire [3:0] Write =   Cs  & {4{Rw}};
296
wire       Read  = (|Cs) &   ~Rw;
297
 
298
wire MODER_Sel      = (Address == `ETH_MODER_ADR       );
299
wire INT_SOURCE_Sel = (Address == `ETH_INT_SOURCE_ADR  );
300
wire INT_MASK_Sel   = (Address == `ETH_INT_MASK_ADR    );
301
wire IPGT_Sel       = (Address == `ETH_IPGT_ADR        );
302
wire IPGR1_Sel      = (Address == `ETH_IPGR1_ADR       );
303
wire IPGR2_Sel      = (Address == `ETH_IPGR2_ADR       );
304
wire PACKETLEN_Sel  = (Address == `ETH_PACKETLEN_ADR   );
305
wire COLLCONF_Sel   = (Address == `ETH_COLLCONF_ADR    );
306
 
307
wire CTRLMODER_Sel  = (Address == `ETH_CTRLMODER_ADR   );
308
wire MIIMODER_Sel   = (Address == `ETH_MIIMODER_ADR    );
309
wire MIICOMMAND_Sel = (Address == `ETH_MIICOMMAND_ADR  );
310
wire MIIADDRESS_Sel = (Address == `ETH_MIIADDRESS_ADR  );
311
wire MIITX_DATA_Sel = (Address == `ETH_MIITX_DATA_ADR  );
312
wire MAC_ADDR0_Sel  = (Address == `ETH_MAC_ADDR0_ADR   );
313
wire MAC_ADDR1_Sel  = (Address == `ETH_MAC_ADDR1_ADR   );
314
wire HASH0_Sel      = (Address == `ETH_HASH0_ADR       );
315
wire HASH1_Sel      = (Address == `ETH_HASH1_ADR       );
316
wire TXCTRL_Sel     = (Address == `ETH_TX_CTRL_ADR     );
317
wire RXCTRL_Sel     = (Address == `ETH_RX_CTRL_ADR     );
318 403 julius
wire DBG_REG_Sel  = (Address == `ETH_DBG_ADR   ); // JB
319 6 julius
wire TX_BD_NUM_Sel  = (Address == `ETH_TX_BD_NUM_ADR   );
320
 
321
 
322 403 julius
 
323 6 julius
wire [2:0] MODER_Wr;
324
wire [0:0] INT_SOURCE_Wr;
325
wire [0:0] INT_MASK_Wr;
326
wire [0:0] IPGT_Wr;
327
wire [0:0] IPGR1_Wr;
328
wire [0:0] IPGR2_Wr;
329
wire [3:0] PACKETLEN_Wr;
330
wire [2:0] COLLCONF_Wr;
331
wire [0:0] CTRLMODER_Wr;
332
wire [1:0] MIIMODER_Wr;
333
wire [0:0] MIICOMMAND_Wr;
334
wire [1:0] MIIADDRESS_Wr;
335
wire [1:0] MIITX_DATA_Wr;
336
wire       MIIRX_DATA_Wr;
337
wire [3:0] MAC_ADDR0_Wr;
338
wire [1:0] MAC_ADDR1_Wr;
339
wire [3:0] HASH0_Wr;
340
wire [3:0] HASH1_Wr;
341
wire [2:0] TXCTRL_Wr;
342
wire [0:0] TX_BD_NUM_Wr;
343
 
344
assign MODER_Wr[0]       = Write[0]  & MODER_Sel;
345
assign MODER_Wr[1]       = Write[1]  & MODER_Sel;
346
assign MODER_Wr[2]       = Write[2]  & MODER_Sel;
347
assign INT_SOURCE_Wr[0]  = Write[0]  & INT_SOURCE_Sel;
348
assign INT_MASK_Wr[0]    = Write[0]  & INT_MASK_Sel;
349
assign IPGT_Wr[0]        = Write[0]  & IPGT_Sel;
350
assign IPGR1_Wr[0]       = Write[0]  & IPGR1_Sel;
351
assign IPGR2_Wr[0]       = Write[0]  & IPGR2_Sel;
352
assign PACKETLEN_Wr[0]   = Write[0]  & PACKETLEN_Sel;
353
assign PACKETLEN_Wr[1]   = Write[1]  & PACKETLEN_Sel;
354
assign PACKETLEN_Wr[2]   = Write[2]  & PACKETLEN_Sel;
355
assign PACKETLEN_Wr[3]   = Write[3]  & PACKETLEN_Sel;
356
assign COLLCONF_Wr[0]    = Write[0]  & COLLCONF_Sel;
357
assign COLLCONF_Wr[1]    = 1'b0;  // Not used
358
assign COLLCONF_Wr[2]    = Write[2]  & COLLCONF_Sel;
359
 
360
assign CTRLMODER_Wr[0]   = Write[0]  & CTRLMODER_Sel;
361
assign MIIMODER_Wr[0]    = Write[0]  & MIIMODER_Sel;
362
assign MIIMODER_Wr[1]    = Write[1]  & MIIMODER_Sel;
363
assign MIICOMMAND_Wr[0]  = Write[0]  & MIICOMMAND_Sel;
364
assign MIIADDRESS_Wr[0]  = Write[0]  & MIIADDRESS_Sel;
365
assign MIIADDRESS_Wr[1]  = Write[1]  & MIIADDRESS_Sel;
366
assign MIITX_DATA_Wr[0]  = Write[0]  & MIITX_DATA_Sel;
367
assign MIITX_DATA_Wr[1]  = Write[1]  & MIITX_DATA_Sel;
368
assign MIIRX_DATA_Wr     = UpdateMIIRX_DATAReg;
369
assign MAC_ADDR0_Wr[0]   = Write[0]  & MAC_ADDR0_Sel;
370
assign MAC_ADDR0_Wr[1]   = Write[1]  & MAC_ADDR0_Sel;
371
assign MAC_ADDR0_Wr[2]   = Write[2]  & MAC_ADDR0_Sel;
372
assign MAC_ADDR0_Wr[3]   = Write[3]  & MAC_ADDR0_Sel;
373
assign MAC_ADDR1_Wr[0]   = Write[0]  & MAC_ADDR1_Sel;
374
assign MAC_ADDR1_Wr[1]   = Write[1]  & MAC_ADDR1_Sel;
375
assign HASH0_Wr[0]       = Write[0]  & HASH0_Sel;
376
assign HASH0_Wr[1]       = Write[1]  & HASH0_Sel;
377
assign HASH0_Wr[2]       = Write[2]  & HASH0_Sel;
378
assign HASH0_Wr[3]       = Write[3]  & HASH0_Sel;
379
assign HASH1_Wr[0]       = Write[0]  & HASH1_Sel;
380
assign HASH1_Wr[1]       = Write[1]  & HASH1_Sel;
381
assign HASH1_Wr[2]       = Write[2]  & HASH1_Sel;
382
assign HASH1_Wr[3]       = Write[3]  & HASH1_Sel;
383
assign TXCTRL_Wr[0]      = Write[0]  & TXCTRL_Sel;
384
assign TXCTRL_Wr[1]      = Write[1]  & TXCTRL_Sel;
385
assign TXCTRL_Wr[2]      = Write[2]  & TXCTRL_Sel;
386
assign TX_BD_NUM_Wr[0]   = Write[0]  & TX_BD_NUM_Sel & (DataIn<='h80);
387
 
388
 
389
 
390
wire [31:0] MODEROut;
391
wire [31:0] INT_SOURCEOut;
392
wire [31:0] INT_MASKOut;
393
wire [31:0] IPGTOut;
394
wire [31:0] IPGR1Out;
395
wire [31:0] IPGR2Out;
396
wire [31:0] PACKETLENOut;
397
wire [31:0] COLLCONFOut;
398
wire [31:0] CTRLMODEROut;
399
wire [31:0] MIIMODEROut;
400
wire [31:0] MIICOMMANDOut;
401
wire [31:0] MIIADDRESSOut;
402
wire [31:0] MIITX_DATAOut;
403
wire [31:0] MIIRX_DATAOut;
404
wire [31:0] MIISTATUSOut;
405
wire [31:0] MAC_ADDR0Out;
406
wire [31:0] MAC_ADDR1Out;
407
wire [31:0] TX_BD_NUMOut;
408
wire [31:0] HASH0Out;
409
wire [31:0] HASH1Out;
410
wire [31:0] TXCTRLOut;
411 403 julius
wire [31:0] DBGOut;    // JB
412 6 julius
 
413
// MODER Register
414
eth_register #(`ETH_MODER_WIDTH_0, `ETH_MODER_DEF_0)        MODER_0
415
  (
416
   .DataIn    (DataIn[`ETH_MODER_WIDTH_0 - 1:0]),
417
   .DataOut   (MODEROut[`ETH_MODER_WIDTH_0 - 1:0]),
418
   .Write     (MODER_Wr[0]),
419
   .Clk       (Clk),
420 403 julius
   .Reset     (Reset),
421
   .SyncReset (1'b0)
422 6 julius
  );
423
eth_register #(`ETH_MODER_WIDTH_1, `ETH_MODER_DEF_1)        MODER_1
424
  (
425
   .DataIn    (DataIn[`ETH_MODER_WIDTH_1 + 7:8]),
426
   .DataOut   (MODEROut[`ETH_MODER_WIDTH_1 + 7:8]),
427
   .Write     (MODER_Wr[1]),
428
   .Clk       (Clk),
429 403 julius
   .Reset     (Reset),
430
   .SyncReset (1'b0)
431 6 julius
  );
432
eth_register #(`ETH_MODER_WIDTH_2, `ETH_MODER_DEF_2)        MODER_2
433
  (
434
   .DataIn    (DataIn[`ETH_MODER_WIDTH_2 + 15:16]),
435
   .DataOut   (MODEROut[`ETH_MODER_WIDTH_2 + 15:16]),
436
   .Write     (MODER_Wr[2]),
437
   .Clk       (Clk),
438 403 julius
   .Reset     (Reset),
439
   .SyncReset (1'b0)
440 6 julius
  );
441
assign MODEROut[31:`ETH_MODER_WIDTH_2 + 16] = 0;
442
 
443
// INT_MASK Register
444
eth_register #(`ETH_INT_MASK_WIDTH_0, `ETH_INT_MASK_DEF_0)  INT_MASK_0
445
  (
446
   .DataIn    (DataIn[`ETH_INT_MASK_WIDTH_0 - 1:0]),
447
   .DataOut   (INT_MASKOut[`ETH_INT_MASK_WIDTH_0 - 1:0]),
448
   .Write     (INT_MASK_Wr[0]),
449
   .Clk       (Clk),
450 403 julius
   .Reset     (Reset),
451
   .SyncReset (1'b0)
452 6 julius
  );
453
assign INT_MASKOut[31:`ETH_INT_MASK_WIDTH_0] = 0;
454 403 julius
 
455 6 julius
// IPGT Register
456
eth_register #(`ETH_IPGT_WIDTH_0, `ETH_IPGT_DEF_0)          IPGT_0
457
  (
458
   .DataIn    (DataIn[`ETH_IPGT_WIDTH_0 - 1:0]),
459
   .DataOut   (IPGTOut[`ETH_IPGT_WIDTH_0 - 1:0]),
460
   .Write     (IPGT_Wr[0]),
461
   .Clk       (Clk),
462 403 julius
   .Reset     (Reset),
463
   .SyncReset (1'b0)
464 6 julius
  );
465
assign IPGTOut[31:`ETH_IPGT_WIDTH_0] = 0;
466 403 julius
 
467 6 julius
// IPGR1 Register
468
eth_register #(`ETH_IPGR1_WIDTH_0, `ETH_IPGR1_DEF_0)        IPGR1_0
469
  (
470
   .DataIn    (DataIn[`ETH_IPGR1_WIDTH_0 - 1:0]),
471
   .DataOut   (IPGR1Out[`ETH_IPGR1_WIDTH_0 - 1:0]),
472
   .Write     (IPGR1_Wr[0]),
473
   .Clk       (Clk),
474 403 julius
   .Reset     (Reset),
475
   .SyncReset (1'b0)
476 6 julius
  );
477
assign IPGR1Out[31:`ETH_IPGR1_WIDTH_0] = 0;
478
 
479
// IPGR2 Register
480
eth_register #(`ETH_IPGR2_WIDTH_0, `ETH_IPGR2_DEF_0)        IPGR2_0
481
  (
482
   .DataIn    (DataIn[`ETH_IPGR2_WIDTH_0 - 1:0]),
483
   .DataOut   (IPGR2Out[`ETH_IPGR2_WIDTH_0 - 1:0]),
484
   .Write     (IPGR2_Wr[0]),
485
   .Clk       (Clk),
486 403 julius
   .Reset     (Reset),
487
   .SyncReset (1'b0)
488 6 julius
  );
489
assign IPGR2Out[31:`ETH_IPGR2_WIDTH_0] = 0;
490
 
491
// PACKETLEN Register
492
eth_register #(`ETH_PACKETLEN_WIDTH_0, `ETH_PACKETLEN_DEF_0) PACKETLEN_0
493
  (
494
   .DataIn    (DataIn[`ETH_PACKETLEN_WIDTH_0 - 1:0]),
495
   .DataOut   (PACKETLENOut[`ETH_PACKETLEN_WIDTH_0 - 1:0]),
496
   .Write     (PACKETLEN_Wr[0]),
497
   .Clk       (Clk),
498 403 julius
   .Reset     (Reset),
499
   .SyncReset (1'b0)
500 6 julius
  );
501
eth_register #(`ETH_PACKETLEN_WIDTH_1, `ETH_PACKETLEN_DEF_1) PACKETLEN_1
502
  (
503
   .DataIn    (DataIn[`ETH_PACKETLEN_WIDTH_1 + 7:8]),
504
   .DataOut   (PACKETLENOut[`ETH_PACKETLEN_WIDTH_1 + 7:8]),
505
   .Write     (PACKETLEN_Wr[1]),
506
   .Clk       (Clk),
507 403 julius
   .Reset     (Reset),
508
   .SyncReset (1'b0)
509 6 julius
  );
510
eth_register #(`ETH_PACKETLEN_WIDTH_2, `ETH_PACKETLEN_DEF_2) PACKETLEN_2
511
  (
512
   .DataIn    (DataIn[`ETH_PACKETLEN_WIDTH_2 + 15:16]),
513
   .DataOut   (PACKETLENOut[`ETH_PACKETLEN_WIDTH_2 + 15:16]),
514
   .Write     (PACKETLEN_Wr[2]),
515
   .Clk       (Clk),
516 403 julius
   .Reset     (Reset),
517
   .SyncReset (1'b0)
518 6 julius
  );
519
eth_register #(`ETH_PACKETLEN_WIDTH_3, `ETH_PACKETLEN_DEF_3) PACKETLEN_3
520
  (
521
   .DataIn    (DataIn[`ETH_PACKETLEN_WIDTH_3 + 23:24]),
522
   .DataOut   (PACKETLENOut[`ETH_PACKETLEN_WIDTH_3 + 23:24]),
523
   .Write     (PACKETLEN_Wr[3]),
524
   .Clk       (Clk),
525 403 julius
   .Reset     (Reset),
526
   .SyncReset (1'b0)
527 6 julius
  );
528
 
529
// COLLCONF Register
530
eth_register #(`ETH_COLLCONF_WIDTH_0, `ETH_COLLCONF_DEF_0)   COLLCONF_0
531
  (
532
   .DataIn    (DataIn[`ETH_COLLCONF_WIDTH_0 - 1:0]),
533
   .DataOut   (COLLCONFOut[`ETH_COLLCONF_WIDTH_0 - 1:0]),
534
   .Write     (COLLCONF_Wr[0]),
535
   .Clk       (Clk),
536 403 julius
   .Reset     (Reset),
537
   .SyncReset (1'b0)
538 6 julius
  );
539
eth_register #(`ETH_COLLCONF_WIDTH_2, `ETH_COLLCONF_DEF_2)   COLLCONF_2
540
  (
541
   .DataIn    (DataIn[`ETH_COLLCONF_WIDTH_2 + 15:16]),
542
   .DataOut   (COLLCONFOut[`ETH_COLLCONF_WIDTH_2 + 15:16]),
543
   .Write     (COLLCONF_Wr[2]),
544
   .Clk       (Clk),
545 403 julius
   .Reset     (Reset),
546
   .SyncReset (1'b0)
547 6 julius
  );
548
assign COLLCONFOut[15:`ETH_COLLCONF_WIDTH_0] = 0;
549
assign COLLCONFOut[31:`ETH_COLLCONF_WIDTH_2 + 16] = 0;
550
 
551
// TX_BD_NUM Register
552
eth_register #(`ETH_TX_BD_NUM_WIDTH_0, `ETH_TX_BD_NUM_DEF_0) TX_BD_NUM_0
553
  (
554
   .DataIn    (DataIn[`ETH_TX_BD_NUM_WIDTH_0 - 1:0]),
555
   .DataOut   (TX_BD_NUMOut[`ETH_TX_BD_NUM_WIDTH_0 - 1:0]),
556
   .Write     (TX_BD_NUM_Wr[0]),
557
   .Clk       (Clk),
558 403 julius
   .Reset     (Reset),
559
   .SyncReset (1'b0)
560 6 julius
  );
561
assign TX_BD_NUMOut[31:`ETH_TX_BD_NUM_WIDTH_0] = 0;
562
 
563
// CTRLMODER Register
564
eth_register #(`ETH_CTRLMODER_WIDTH_0, `ETH_CTRLMODER_DEF_0)  CTRLMODER_0
565
  (
566
   .DataIn    (DataIn[`ETH_CTRLMODER_WIDTH_0 - 1:0]),
567
   .DataOut   (CTRLMODEROut[`ETH_CTRLMODER_WIDTH_0 - 1:0]),
568
   .Write     (CTRLMODER_Wr[0]),
569
   .Clk       (Clk),
570 403 julius
   .Reset     (Reset),
571
   .SyncReset (1'b0)
572 6 julius
  );
573
assign CTRLMODEROut[31:`ETH_CTRLMODER_WIDTH_0] = 0;
574
 
575
// MIIMODER Register
576
eth_register #(`ETH_MIIMODER_WIDTH_0, `ETH_MIIMODER_DEF_0)    MIIMODER_0
577
  (
578
   .DataIn    (DataIn[`ETH_MIIMODER_WIDTH_0 - 1:0]),
579
   .DataOut   (MIIMODEROut[`ETH_MIIMODER_WIDTH_0 - 1:0]),
580
   .Write     (MIIMODER_Wr[0]),
581
   .Clk       (Clk),
582 403 julius
   .Reset     (Reset),
583
   .SyncReset (1'b0)
584 6 julius
  );
585
eth_register #(`ETH_MIIMODER_WIDTH_1, `ETH_MIIMODER_DEF_1)    MIIMODER_1
586
  (
587
   .DataIn    (DataIn[`ETH_MIIMODER_WIDTH_1 + 7:8]),
588
   .DataOut   (MIIMODEROut[`ETH_MIIMODER_WIDTH_1 + 7:8]),
589
   .Write     (MIIMODER_Wr[1]),
590
   .Clk       (Clk),
591 403 julius
   .Reset     (Reset),
592
   .SyncReset (1'b0)
593 6 julius
  );
594
assign MIIMODEROut[31:`ETH_MIIMODER_WIDTH_1 + 8] = 0;
595
 
596
// MIICOMMAND Register
597
eth_register #(1, 0)                                      MIICOMMAND0
598
  (
599
   .DataIn    (DataIn[0]),
600
   .DataOut   (MIICOMMANDOut[0]),
601
   .Write     (MIICOMMAND_Wr[0]),
602
   .Clk       (Clk),
603 403 julius
   .Reset     (Reset),
604
   .SyncReset (1'b0)
605 6 julius
  );
606
eth_register #(1, 0)                                      MIICOMMAND1
607
  (
608
   .DataIn    (DataIn[1]),
609
   .DataOut   (MIICOMMANDOut[1]),
610
   .Write     (MIICOMMAND_Wr[0]),
611
   .Clk       (Clk),
612 403 julius
   .Reset     (Reset),
613
   .SyncReset (RStatStart)
614 6 julius
  );
615
eth_register #(1, 0)                                      MIICOMMAND2
616
  (
617
   .DataIn    (DataIn[2]),
618
   .DataOut   (MIICOMMANDOut[2]),
619
   .Write     (MIICOMMAND_Wr[0]),
620
   .Clk       (Clk),
621 403 julius
   .Reset     (Reset),
622
   .SyncReset (WCtrlDataStart)
623 6 julius
  );
624
assign MIICOMMANDOut[31:`ETH_MIICOMMAND_WIDTH_0] = 29'h0;
625
 
626
// MIIADDRESSRegister
627
eth_register #(`ETH_MIIADDRESS_WIDTH_0, `ETH_MIIADDRESS_DEF_0) MIIADDRESS_0
628
  (
629
   .DataIn    (DataIn[`ETH_MIIADDRESS_WIDTH_0 - 1:0]),
630
   .DataOut   (MIIADDRESSOut[`ETH_MIIADDRESS_WIDTH_0 - 1:0]),
631
   .Write     (MIIADDRESS_Wr[0]),
632
   .Clk       (Clk),
633 403 julius
   .Reset     (Reset),
634
   .SyncReset (1'b0)
635 6 julius
  );
636
eth_register #(`ETH_MIIADDRESS_WIDTH_1, `ETH_MIIADDRESS_DEF_1) MIIADDRESS_1
637
  (
638
   .DataIn    (DataIn[`ETH_MIIADDRESS_WIDTH_1 + 7:8]),
639
   .DataOut   (MIIADDRESSOut[`ETH_MIIADDRESS_WIDTH_1 + 7:8]),
640
   .Write     (MIIADDRESS_Wr[1]),
641
   .Clk       (Clk),
642 403 julius
   .Reset     (Reset),
643
   .SyncReset (1'b0)
644 6 julius
  );
645
assign MIIADDRESSOut[7:`ETH_MIIADDRESS_WIDTH_0] = 0;
646
assign MIIADDRESSOut[31:`ETH_MIIADDRESS_WIDTH_1 + 8] = 0;
647
 
648
// MIITX_DATA Register
649
eth_register #(`ETH_MIITX_DATA_WIDTH_0, `ETH_MIITX_DATA_DEF_0) MIITX_DATA_0
650
  (
651
   .DataIn    (DataIn[`ETH_MIITX_DATA_WIDTH_0 - 1:0]),
652
   .DataOut   (MIITX_DATAOut[`ETH_MIITX_DATA_WIDTH_0 - 1:0]),
653
   .Write     (MIITX_DATA_Wr[0]),
654
   .Clk       (Clk),
655 403 julius
   .Reset     (Reset),
656
   .SyncReset (1'b0)
657 6 julius
  );
658
eth_register #(`ETH_MIITX_DATA_WIDTH_1, `ETH_MIITX_DATA_DEF_1) MIITX_DATA_1
659
  (
660
   .DataIn    (DataIn[`ETH_MIITX_DATA_WIDTH_1 + 7:8]),
661
   .DataOut   (MIITX_DATAOut[`ETH_MIITX_DATA_WIDTH_1 + 7:8]),
662
   .Write     (MIITX_DATA_Wr[1]),
663
   .Clk       (Clk),
664 403 julius
   .Reset     (Reset),
665
   .SyncReset (1'b0)
666 6 julius
  );
667
assign MIITX_DATAOut[31:`ETH_MIITX_DATA_WIDTH_1 + 8] = 0;
668
 
669
// MIIRX_DATA Register
670
eth_register #(`ETH_MIIRX_DATA_WIDTH, `ETH_MIIRX_DATA_DEF) MIIRX_DATA
671
  (
672
   .DataIn    (Prsd[`ETH_MIIRX_DATA_WIDTH-1:0]),
673
   .DataOut   (MIIRX_DATAOut[`ETH_MIIRX_DATA_WIDTH-1:0]),
674
   .Write     (MIIRX_DATA_Wr), // not written from WB
675
   .Clk       (Clk),
676 403 julius
   .Reset     (Reset),
677
   .SyncReset (1'b0)
678 6 julius
  );
679
assign MIIRX_DATAOut[31:`ETH_MIIRX_DATA_WIDTH] = 0;
680
 
681
// MAC_ADDR0 Register
682
eth_register #(`ETH_MAC_ADDR0_WIDTH_0, `ETH_MAC_ADDR0_DEF_0)  MAC_ADDR0_0
683
  (
684
   .DataIn    (DataIn[`ETH_MAC_ADDR0_WIDTH_0 - 1:0]),
685
   .DataOut   (MAC_ADDR0Out[`ETH_MAC_ADDR0_WIDTH_0 - 1:0]),
686
   .Write     (MAC_ADDR0_Wr[0]),
687
   .Clk       (Clk),
688 403 julius
   .Reset     (Reset),
689
   .SyncReset (1'b0)
690 6 julius
  );
691
eth_register #(`ETH_MAC_ADDR0_WIDTH_1, `ETH_MAC_ADDR0_DEF_1)  MAC_ADDR0_1
692
  (
693
   .DataIn    (DataIn[`ETH_MAC_ADDR0_WIDTH_1 + 7:8]),
694
   .DataOut   (MAC_ADDR0Out[`ETH_MAC_ADDR0_WIDTH_1 + 7:8]),
695
   .Write     (MAC_ADDR0_Wr[1]),
696
   .Clk       (Clk),
697 403 julius
   .Reset     (Reset),
698
   .SyncReset (1'b0)
699 6 julius
  );
700
eth_register #(`ETH_MAC_ADDR0_WIDTH_2, `ETH_MAC_ADDR0_DEF_2)  MAC_ADDR0_2
701
  (
702
   .DataIn    (DataIn[`ETH_MAC_ADDR0_WIDTH_2 + 15:16]),
703
   .DataOut   (MAC_ADDR0Out[`ETH_MAC_ADDR0_WIDTH_2 + 15:16]),
704
   .Write     (MAC_ADDR0_Wr[2]),
705
   .Clk       (Clk),
706 403 julius
   .Reset     (Reset),
707
   .SyncReset (1'b0)
708 6 julius
  );
709
eth_register #(`ETH_MAC_ADDR0_WIDTH_3, `ETH_MAC_ADDR0_DEF_3)  MAC_ADDR0_3
710
  (
711
   .DataIn    (DataIn[`ETH_MAC_ADDR0_WIDTH_3 + 23:24]),
712
   .DataOut   (MAC_ADDR0Out[`ETH_MAC_ADDR0_WIDTH_3 + 23:24]),
713
   .Write     (MAC_ADDR0_Wr[3]),
714
   .Clk       (Clk),
715 403 julius
   .Reset     (Reset),
716
   .SyncReset (1'b0)
717 6 julius
  );
718
 
719
// MAC_ADDR1 Register
720
eth_register #(`ETH_MAC_ADDR1_WIDTH_0, `ETH_MAC_ADDR1_DEF_0)  MAC_ADDR1_0
721
  (
722
   .DataIn    (DataIn[`ETH_MAC_ADDR1_WIDTH_0 - 1:0]),
723
   .DataOut   (MAC_ADDR1Out[`ETH_MAC_ADDR1_WIDTH_0 - 1:0]),
724
   .Write     (MAC_ADDR1_Wr[0]),
725
   .Clk       (Clk),
726 403 julius
   .Reset     (Reset),
727
   .SyncReset (1'b0)
728 6 julius
  );
729
eth_register #(`ETH_MAC_ADDR1_WIDTH_1, `ETH_MAC_ADDR1_DEF_1)  MAC_ADDR1_1
730
  (
731
   .DataIn    (DataIn[`ETH_MAC_ADDR1_WIDTH_1 + 7:8]),
732
   .DataOut   (MAC_ADDR1Out[`ETH_MAC_ADDR1_WIDTH_1 + 7:8]),
733
   .Write     (MAC_ADDR1_Wr[1]),
734
   .Clk       (Clk),
735 403 julius
   .Reset     (Reset),
736
   .SyncReset (1'b0)
737 6 julius
  );
738
assign MAC_ADDR1Out[31:`ETH_MAC_ADDR1_WIDTH_1 + 8] = 0;
739 403 julius
 
740 6 julius
// RXHASH0 Register
741
eth_register #(`ETH_HASH0_WIDTH_0, `ETH_HASH0_DEF_0)          RXHASH0_0
742
  (
743
   .DataIn    (DataIn[`ETH_HASH0_WIDTH_0 - 1:0]),
744
   .DataOut   (HASH0Out[`ETH_HASH0_WIDTH_0 - 1:0]),
745
   .Write     (HASH0_Wr[0]),
746
   .Clk       (Clk),
747 403 julius
   .Reset     (Reset),
748
   .SyncReset (1'b0)
749 6 julius
  );
750
eth_register #(`ETH_HASH0_WIDTH_1, `ETH_HASH0_DEF_1)          RXHASH0_1
751
  (
752
   .DataIn    (DataIn[`ETH_HASH0_WIDTH_1 + 7:8]),
753
   .DataOut   (HASH0Out[`ETH_HASH0_WIDTH_1 + 7:8]),
754
   .Write     (HASH0_Wr[1]),
755
   .Clk       (Clk),
756 403 julius
   .Reset     (Reset),
757
   .SyncReset (1'b0)
758 6 julius
  );
759
eth_register #(`ETH_HASH0_WIDTH_2, `ETH_HASH0_DEF_2)          RXHASH0_2
760
  (
761
   .DataIn    (DataIn[`ETH_HASH0_WIDTH_2 + 15:16]),
762
   .DataOut   (HASH0Out[`ETH_HASH0_WIDTH_2 + 15:16]),
763
   .Write     (HASH0_Wr[2]),
764
   .Clk       (Clk),
765 403 julius
   .Reset     (Reset),
766
   .SyncReset (1'b0)
767 6 julius
  );
768
eth_register #(`ETH_HASH0_WIDTH_3, `ETH_HASH0_DEF_3)          RXHASH0_3
769
  (
770
   .DataIn    (DataIn[`ETH_HASH0_WIDTH_3 + 23:24]),
771
   .DataOut   (HASH0Out[`ETH_HASH0_WIDTH_3 + 23:24]),
772
   .Write     (HASH0_Wr[3]),
773
   .Clk       (Clk),
774 403 julius
   .Reset     (Reset),
775
   .SyncReset (1'b0)
776 6 julius
  );
777 403 julius
 
778 6 julius
// RXHASH1 Register
779
eth_register #(`ETH_HASH1_WIDTH_0, `ETH_HASH1_DEF_0)          RXHASH1_0
780
  (
781
   .DataIn    (DataIn[`ETH_HASH1_WIDTH_0 - 1:0]),
782
   .DataOut   (HASH1Out[`ETH_HASH1_WIDTH_0 - 1:0]),
783
   .Write     (HASH1_Wr[0]),
784
   .Clk       (Clk),
785 403 julius
   .Reset     (Reset),
786
   .SyncReset (1'b0)
787 6 julius
  );
788
eth_register #(`ETH_HASH1_WIDTH_1, `ETH_HASH1_DEF_1)          RXHASH1_1
789
  (
790
   .DataIn    (DataIn[`ETH_HASH1_WIDTH_1 + 7:8]),
791
   .DataOut   (HASH1Out[`ETH_HASH1_WIDTH_1 + 7:8]),
792
   .Write     (HASH1_Wr[1]),
793
   .Clk       (Clk),
794 403 julius
   .Reset     (Reset),
795
   .SyncReset (1'b0)
796 6 julius
  );
797
eth_register #(`ETH_HASH1_WIDTH_2, `ETH_HASH1_DEF_2)          RXHASH1_2
798
  (
799
   .DataIn    (DataIn[`ETH_HASH1_WIDTH_2 + 15:16]),
800
   .DataOut   (HASH1Out[`ETH_HASH1_WIDTH_2 + 15:16]),
801
   .Write     (HASH1_Wr[2]),
802
   .Clk       (Clk),
803 403 julius
   .Reset     (Reset),
804
   .SyncReset (1'b0)
805 6 julius
  );
806
eth_register #(`ETH_HASH1_WIDTH_3, `ETH_HASH1_DEF_3)          RXHASH1_3
807
  (
808
   .DataIn    (DataIn[`ETH_HASH1_WIDTH_3 + 23:24]),
809
   .DataOut   (HASH1Out[`ETH_HASH1_WIDTH_3 + 23:24]),
810
   .Write     (HASH1_Wr[3]),
811
   .Clk       (Clk),
812 403 julius
   .Reset     (Reset),
813
   .SyncReset (1'b0)
814 6 julius
  );
815 403 julius
 
816 6 julius
// TXCTRL Register
817
eth_register #(`ETH_TX_CTRL_WIDTH_0, `ETH_TX_CTRL_DEF_0)  TXCTRL_0
818
  (
819
   .DataIn    (DataIn[`ETH_TX_CTRL_WIDTH_0 - 1:0]),
820
   .DataOut   (TXCTRLOut[`ETH_TX_CTRL_WIDTH_0 - 1:0]),
821
   .Write     (TXCTRL_Wr[0]),
822
   .Clk       (Clk),
823 403 julius
   .Reset     (Reset),
824
   .SyncReset (1'b0)
825 6 julius
  );
826
eth_register #(`ETH_TX_CTRL_WIDTH_1, `ETH_TX_CTRL_DEF_1)  TXCTRL_1
827
  (
828
   .DataIn    (DataIn[`ETH_TX_CTRL_WIDTH_1 + 7:8]),
829
   .DataOut   (TXCTRLOut[`ETH_TX_CTRL_WIDTH_1 + 7:8]),
830
   .Write     (TXCTRL_Wr[1]),
831
   .Clk       (Clk),
832 403 julius
   .Reset     (Reset),
833
   .SyncReset (1'b0)
834 6 julius
  );
835
eth_register #(`ETH_TX_CTRL_WIDTH_2, `ETH_TX_CTRL_DEF_2)  TXCTRL_2 // Request bit is synchronously reset
836
  (
837
   .DataIn    (DataIn[`ETH_TX_CTRL_WIDTH_2 + 15:16]),
838
   .DataOut   (TXCTRLOut[`ETH_TX_CTRL_WIDTH_2 + 15:16]),
839
   .Write     (TXCTRL_Wr[2]),
840
   .Clk       (Clk),
841 403 julius
   .Reset     (Reset),
842
   .SyncReset (RstTxPauseRq)
843 6 julius
  );
844
assign TXCTRLOut[31:`ETH_TX_CTRL_WIDTH_2 + 16] = 0;
845
 
846
 
847 403 julius
 
848 6 julius
// Reading data from registers
849
always @ (Address       or Read           or MODEROut       or INT_SOURCEOut  or
850
          INT_MASKOut   or IPGTOut        or IPGR1Out       or IPGR2Out       or
851
          PACKETLENOut  or COLLCONFOut    or CTRLMODEROut   or MIIMODEROut    or
852
          MIICOMMANDOut or MIIADDRESSOut  or MIITX_DATAOut  or MIIRX_DATAOut  or
853
          MIISTATUSOut  or MAC_ADDR0Out   or MAC_ADDR1Out   or TX_BD_NUMOut   or
854
          HASH0Out      or HASH1Out       or TXCTRLOut
855
         )
856
begin
857
  if(Read)  // read
858
    begin
859
      case(Address)
860 439 julius
        `ETH_MODER_ADR        :  DataOut=MODEROut;
861
        `ETH_INT_SOURCE_ADR   :  DataOut=INT_SOURCEOut;
862
        `ETH_INT_MASK_ADR     :  DataOut=INT_MASKOut;
863
        `ETH_IPGT_ADR         :  DataOut=IPGTOut;
864
        `ETH_IPGR1_ADR        :  DataOut=IPGR1Out;
865
        `ETH_IPGR2_ADR        :  DataOut=IPGR2Out;
866
        `ETH_PACKETLEN_ADR    :  DataOut=PACKETLENOut;
867
        `ETH_COLLCONF_ADR     :  DataOut=COLLCONFOut;
868
        `ETH_CTRLMODER_ADR    :  DataOut=CTRLMODEROut;
869
        `ETH_MIIMODER_ADR     :  DataOut=MIIMODEROut;
870
        `ETH_MIICOMMAND_ADR   :  DataOut=MIICOMMANDOut;
871
        `ETH_MIIADDRESS_ADR   :  DataOut=MIIADDRESSOut;
872
        `ETH_MIITX_DATA_ADR   :  DataOut=MIITX_DATAOut;
873
        `ETH_MIIRX_DATA_ADR   :  DataOut=MIIRX_DATAOut;
874
        `ETH_MIISTATUS_ADR    :  DataOut=MIISTATUSOut;
875
        `ETH_MAC_ADDR0_ADR    :  DataOut=MAC_ADDR0Out;
876
        `ETH_MAC_ADDR1_ADR    :  DataOut=MAC_ADDR1Out;
877
        `ETH_TX_BD_NUM_ADR    :  DataOut=TX_BD_NUMOut;
878
        `ETH_HASH0_ADR        :  DataOut=HASH0Out;
879
        `ETH_HASH1_ADR        :  DataOut=HASH1Out;
880
        `ETH_TX_CTRL_ADR      :  DataOut=TXCTRLOut;
881
        `ETH_DBG_ADR          :  DataOut=dbg_dat; // debug data out -- JB
882
        default:             DataOut=32'h0;
883 6 julius
      endcase
884
    end
885
  else
886 439 julius
    DataOut=32'h0;
887 6 julius
end
888
 
889
 
890
assign r_RecSmall         = MODEROut[16];
891
assign r_Pad              = MODEROut[15];
892
assign r_HugEn            = MODEROut[14];
893
assign r_CrcEn            = MODEROut[13];
894 439 julius
assign r_DlyCrcEn         = /*MODEROut[12]*/1'b0; // Synthesis bugfix JB
895 6 julius
// assign r_Rst           = MODEROut[11];   This signal is not used any more
896
assign r_FullD            = MODEROut[10];
897
assign r_ExDfrEn          = MODEROut[9];
898
assign r_NoBckof          = MODEROut[8];
899
assign r_LoopBck          = MODEROut[7];
900
assign r_IFG              = MODEROut[6];
901
assign r_Pro              = MODEROut[5];
902
assign r_Iam              = MODEROut[4];
903
assign r_Bro              = MODEROut[3];
904
assign r_NoPre            = MODEROut[2];
905
assign r_TxEn             = MODEROut[1] & (TX_BD_NUMOut>0);     // Transmission is enabled when there is at least one TxBD.
906
assign r_RxEn             = MODEROut[0] & (TX_BD_NUMOut<'h80);  // Reception is enabled when there is  at least one RxBD.
907
 
908
assign r_IPGT[6:0]        = IPGTOut[6:0];
909
 
910
assign r_IPGR1[6:0]       = IPGR1Out[6:0];
911
 
912
assign r_IPGR2[6:0]       = IPGR2Out[6:0];
913
 
914
assign r_MinFL[15:0]      = PACKETLENOut[31:16];
915
assign r_MaxFL[15:0]      = PACKETLENOut[15:0];
916
 
917
assign r_MaxRet[3:0]      = COLLCONFOut[19:16];
918
assign r_CollValid[5:0]   = COLLCONFOut[5:0];
919
 
920
assign r_TxFlow           = CTRLMODEROut[2];
921
assign r_RxFlow           = CTRLMODEROut[1];
922
assign r_PassAll          = CTRLMODEROut[0];
923
 
924
assign r_MiiNoPre         = MIIMODEROut[8];
925
assign r_ClkDiv[7:0]      = MIIMODEROut[7:0];
926
 
927
assign r_WCtrlData        = MIICOMMANDOut[2];
928
assign r_RStat            = MIICOMMANDOut[1];
929
assign r_ScanStat         = MIICOMMANDOut[0];
930
 
931
assign r_RGAD[4:0]        = MIIADDRESSOut[12:8];
932
assign r_FIAD[4:0]        = MIIADDRESSOut[4:0];
933
 
934
assign r_CtrlData[15:0]   = MIITX_DATAOut[15:0];
935
 
936
assign MIISTATUSOut[31:`ETH_MIISTATUS_WIDTH] = 0;
937
assign MIISTATUSOut[2]    = NValid_stat         ;
938
assign MIISTATUSOut[1]    = Busy_stat           ;
939
assign MIISTATUSOut[0]    = LinkFail            ;
940
 
941
assign r_MAC[31:0]        = MAC_ADDR0Out[31:0];
942
assign r_MAC[47:32]       = MAC_ADDR1Out[15:0];
943
assign r_HASH1[31:0]      = HASH1Out;
944
assign r_HASH0[31:0]      = HASH0Out;
945
 
946
assign r_TxBDNum[7:0]     = TX_BD_NUMOut[7:0];
947
 
948
assign r_TxPauseTV[15:0]  = TXCTRLOut[15:0];
949
assign r_TxPauseRq        = TXCTRLOut[16];
950
 
951
 
952
// Synchronizing TxC Interrupt
953
always @ (posedge TxClk or posedge Reset)
954
begin
955
  if(Reset)
956 403 julius
    SetTxCIrq_txclk <= 1'b0;
957 6 julius
  else
958
  if(TxCtrlEndFrm & StartTxDone & r_TxFlow)
959 403 julius
    SetTxCIrq_txclk <= 1'b1;
960 6 julius
  else
961
  if(ResetTxCIrq_sync2)
962 403 julius
    SetTxCIrq_txclk <= 1'b0;
963 6 julius
end
964
 
965
 
966
always @ (posedge Clk or posedge Reset)
967
begin
968
  if(Reset)
969 403 julius
    SetTxCIrq_sync1 <= 1'b0;
970 6 julius
  else
971 403 julius
    SetTxCIrq_sync1 <= SetTxCIrq_txclk;
972 6 julius
end
973
 
974
always @ (posedge Clk or posedge Reset)
975
begin
976
  if(Reset)
977 403 julius
    SetTxCIrq_sync2 <= 1'b0;
978 6 julius
  else
979 403 julius
    SetTxCIrq_sync2 <= SetTxCIrq_sync1;
980 6 julius
end
981
 
982
always @ (posedge Clk or posedge Reset)
983
begin
984
  if(Reset)
985 403 julius
    SetTxCIrq_sync3 <= 1'b0;
986 6 julius
  else
987 403 julius
    SetTxCIrq_sync3 <= SetTxCIrq_sync2;
988 6 julius
end
989
 
990
always @ (posedge Clk or posedge Reset)
991
begin
992
  if(Reset)
993 403 julius
    SetTxCIrq <= 1'b0;
994 6 julius
  else
995 403 julius
    SetTxCIrq <= SetTxCIrq_sync2 & ~SetTxCIrq_sync3;
996 6 julius
end
997
 
998
always @ (posedge TxClk or posedge Reset)
999
begin
1000
  if(Reset)
1001 403 julius
    ResetTxCIrq_sync1 <= 1'b0;
1002 6 julius
  else
1003 403 julius
    ResetTxCIrq_sync1 <= SetTxCIrq_sync2;
1004 6 julius
end
1005
 
1006
always @ (posedge TxClk or posedge Reset)
1007
begin
1008
  if(Reset)
1009 403 julius
    ResetTxCIrq_sync2 <= 1'b0;
1010 6 julius
  else
1011 403 julius
    ResetTxCIrq_sync2 <= SetTxCIrq_sync1;
1012 6 julius
end
1013
 
1014
 
1015
// Synchronizing RxC Interrupt
1016
always @ (posedge RxClk or posedge Reset)
1017
begin
1018
  if(Reset)
1019 403 julius
    SetRxCIrq_rxclk <= 1'b0;
1020 6 julius
  else
1021
  if(SetPauseTimer & r_RxFlow)
1022 403 julius
    SetRxCIrq_rxclk <= 1'b1;
1023 6 julius
  else
1024
  if(ResetRxCIrq_sync2 & (~ResetRxCIrq_sync3))
1025 403 julius
    SetRxCIrq_rxclk <= 1'b0;
1026 6 julius
end
1027
 
1028
 
1029
always @ (posedge Clk or posedge Reset)
1030
begin
1031
  if(Reset)
1032 403 julius
    SetRxCIrq_sync1 <= 1'b0;
1033 6 julius
  else
1034 403 julius
    SetRxCIrq_sync1 <= SetRxCIrq_rxclk;
1035 6 julius
end
1036
 
1037
always @ (posedge Clk or posedge Reset)
1038
begin
1039
  if(Reset)
1040 403 julius
    SetRxCIrq_sync2 <= 1'b0;
1041 6 julius
  else
1042 403 julius
    SetRxCIrq_sync2 <= SetRxCIrq_sync1;
1043 6 julius
end
1044
 
1045
always @ (posedge Clk or posedge Reset)
1046
begin
1047
  if(Reset)
1048 403 julius
    SetRxCIrq_sync3 <= 1'b0;
1049 6 julius
  else
1050 403 julius
    SetRxCIrq_sync3 <= SetRxCIrq_sync2;
1051 6 julius
end
1052
 
1053
always @ (posedge Clk or posedge Reset)
1054
begin
1055
  if(Reset)
1056 403 julius
    SetRxCIrq <= 1'b0;
1057 6 julius
  else
1058 403 julius
    SetRxCIrq <= SetRxCIrq_sync2 & ~SetRxCIrq_sync3;
1059 6 julius
end
1060
 
1061
always @ (posedge RxClk or posedge Reset)
1062
begin
1063
  if(Reset)
1064 403 julius
    ResetRxCIrq_sync1 <= 1'b0;
1065 6 julius
  else
1066 403 julius
    ResetRxCIrq_sync1 <= SetRxCIrq_sync2;
1067 6 julius
end
1068
 
1069
always @ (posedge RxClk or posedge Reset)
1070
begin
1071
  if(Reset)
1072 403 julius
    ResetRxCIrq_sync2 <= 1'b0;
1073 6 julius
  else
1074 403 julius
    ResetRxCIrq_sync2 <= ResetRxCIrq_sync1;
1075 6 julius
end
1076
 
1077
always @ (posedge RxClk or posedge Reset)
1078
begin
1079
  if(Reset)
1080 403 julius
    ResetRxCIrq_sync3 <= 1'b0;
1081 6 julius
  else
1082 403 julius
    ResetRxCIrq_sync3 <= ResetRxCIrq_sync2;
1083 6 julius
end
1084
 
1085
 
1086
 
1087
// Interrupt generation
1088
always @ (posedge Clk or posedge Reset)
1089
begin
1090
  if(Reset)
1091
    irq_txb <= 1'b0;
1092
  else
1093
  if(TxB_IRQ)
1094 403 julius
    irq_txb <=  1'b1;
1095 6 julius
  else
1096
  if(INT_SOURCE_Wr[0] & DataIn[0])
1097 403 julius
    irq_txb <=  1'b0;
1098 6 julius
end
1099
 
1100
always @ (posedge Clk or posedge Reset)
1101
begin
1102
  if(Reset)
1103
    irq_txe <= 1'b0;
1104
  else
1105
  if(TxE_IRQ)
1106 403 julius
    irq_txe <=  1'b1;
1107 6 julius
  else
1108
  if(INT_SOURCE_Wr[0] & DataIn[1])
1109 403 julius
    irq_txe <=  1'b0;
1110 6 julius
end
1111
 
1112
always @ (posedge Clk or posedge Reset)
1113
begin
1114
  if(Reset)
1115
    irq_rxb <= 1'b0;
1116
  else
1117
  if(RxB_IRQ)
1118 403 julius
    irq_rxb <=  1'b1;
1119 6 julius
  else
1120
  if(INT_SOURCE_Wr[0] & DataIn[2])
1121 403 julius
    irq_rxb <=  1'b0;
1122 6 julius
end
1123
 
1124
always @ (posedge Clk or posedge Reset)
1125
begin
1126
  if(Reset)
1127
    irq_rxe <= 1'b0;
1128
  else
1129
  if(RxE_IRQ)
1130 403 julius
    irq_rxe <=  1'b1;
1131 6 julius
  else
1132
  if(INT_SOURCE_Wr[0] & DataIn[3])
1133 403 julius
    irq_rxe <=  1'b0;
1134 6 julius
end
1135
 
1136
always @ (posedge Clk or posedge Reset)
1137
begin
1138
  if(Reset)
1139
    irq_busy <= 1'b0;
1140
  else
1141
  if(Busy_IRQ)
1142 403 julius
    irq_busy <=  1'b1;
1143 6 julius
  else
1144
  if(INT_SOURCE_Wr[0] & DataIn[4])
1145 403 julius
    irq_busy <=  1'b0;
1146 6 julius
end
1147
 
1148
always @ (posedge Clk or posedge Reset)
1149
begin
1150
  if(Reset)
1151
    irq_txc <= 1'b0;
1152
  else
1153
  if(SetTxCIrq)
1154 403 julius
    irq_txc <=  1'b1;
1155 6 julius
  else
1156
  if(INT_SOURCE_Wr[0] & DataIn[5])
1157 403 julius
    irq_txc <=  1'b0;
1158 6 julius
end
1159
 
1160
always @ (posedge Clk or posedge Reset)
1161
begin
1162
  if(Reset)
1163
    irq_rxc <= 1'b0;
1164
  else
1165
  if(SetRxCIrq)
1166 403 julius
    irq_rxc <=  1'b1;
1167 6 julius
  else
1168
  if(INT_SOURCE_Wr[0] & DataIn[6])
1169 403 julius
    irq_rxc <=  1'b0;
1170 6 julius
end
1171
 
1172
// Generating interrupt signal
1173
assign int_o = irq_txb  & INT_MASKOut[0] |
1174
               irq_txe  & INT_MASKOut[1] |
1175
               irq_rxb  & INT_MASKOut[2] |
1176
               irq_rxe  & INT_MASKOut[3] |
1177
               irq_busy & INT_MASKOut[4] |
1178
               irq_txc  & INT_MASKOut[5] |
1179
               irq_rxc  & INT_MASKOut[6] ;
1180
 
1181
// For reading interrupt status
1182
assign INT_SOURCEOut = {{(32-`ETH_INT_SOURCE_WIDTH_0){1'b0}}, irq_rxc, irq_txc, irq_busy, irq_rxe, irq_rxb, irq_txe, irq_txb};
1183
 
1184
 
1185
 
1186
endmodule

powered by: WebSVN 2.1.0

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