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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_registers.v] - Blame information for rev 244

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_registers.v                                             ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6 37 mohor
////  http://www.opencores.org/projects/ethmac/                   ////
7 15 mohor
////                                                              ////
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 147 mohor
//// Copyright (C) 2001, 2002 Authors                             ////
17 15 mohor
////                                                              ////
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
// $Log: not supported by cvs2svn $
44 244 mohor
// Revision 1.21  2002/09/10 10:35:23  mohor
45
// Ethernet debug registers removed.
46
//
47 164 mohor
// Revision 1.20  2002/09/04 18:40:25  mohor
48
// ETH_TXCTRL and ETH_RXCTRL registers added. Interrupts related to
49
// the control frames connected.
50
//
51 147 mohor
// Revision 1.19  2002/08/19 16:01:40  mohor
52
// Only values smaller or equal to 0x80 can be written to TX_BD_NUM register.
53
// r_TxEn and r_RxEn depend on the limit values of the TX_BD_NUMOut.
54
//
55 143 mohor
// Revision 1.18  2002/08/16 22:28:23  mohor
56
// Syntax error fixed.
57
//
58 141 mohor
// Revision 1.17  2002/08/16 22:23:03  mohor
59
// Syntax error fixed.
60
//
61 140 mohor
// Revision 1.16  2002/08/16 22:14:22  mohor
62
// Synchronous reset added to all registers. Defines used for width. r_MiiMRst
63
// changed from bit position 10 to 9.
64
//
65 139 mohor
// Revision 1.15  2002/08/14 18:26:37  mohor
66
// LinkFailRegister is reflecting the status of the PHY's link fail status bit.
67
//
68 132 mohor
// Revision 1.14  2002/04/22 14:03:44  mohor
69
// Interrupts are visible in the ETH_INT_SOURCE regardless if they are enabled
70
// or not.
71
//
72 102 mohor
// Revision 1.13  2002/02/26 16:18:09  mohor
73
// Reset values are passed to registers through parameters
74
//
75 74 mohor
// Revision 1.12  2002/02/17 13:23:42  mohor
76
// Define missmatch fixed.
77
//
78 69 mohor
// Revision 1.11  2002/02/16 14:03:44  mohor
79
// Registered trimmed. Unused registers removed.
80
//
81 68 mohor
// Revision 1.10  2002/02/15 11:08:25  mohor
82
// File format fixed a bit.
83
//
84 56 mohor
// Revision 1.9  2002/02/14 20:19:41  billditt
85
// Modified for Address Checking,
86
// addition of eth_addrcheck.v
87
//
88
// Revision 1.8  2002/02/12 17:01:19  mohor
89
// HASH0 and HASH1 registers added. 
90
 
91 46 mohor
// Revision 1.7  2002/01/23 10:28:16  mohor
92
// Link in the header changed.
93
//
94 37 mohor
// Revision 1.6  2001/12/05 15:00:16  mohor
95
// RX_BD_NUM changed to TX_BD_NUM (holds number of TX descriptors
96
// instead of the number of RX descriptors).
97
//
98 34 mohor
// Revision 1.5  2001/12/05 10:22:19  mohor
99
// ETH_RX_BD_ADR register deleted. ETH_RX_BD_NUM is used instead.
100
//
101 32 mohor
// Revision 1.4  2001/10/19 08:43:51  mohor
102
// eth_timescale.v changed to timescale.v This is done because of the
103
// simulation of the few cores in a one joined project.
104
//
105 22 mohor
// Revision 1.3  2001/10/18 12:07:11  mohor
106
// Status signals changed, Adress decoding changed, interrupt controller
107
// added.
108
//
109 21 mohor
// Revision 1.2  2001/09/24 15:02:56  mohor
110
// Defines changed (All precede with ETH_). Small changes because some
111
// tools generate warnings when two operands are together. Synchronization
112
// between two clocks domains in eth_wishbonedma.v is changed (due to ASIC
113
// demands).
114
//
115 20 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
116
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
117
// Include files fixed to contain no path.
118
// File names and module names changed ta have a eth_ prologue in the name.
119
// File eth_timescale.v is used to define timescale
120
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
121
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
122
// and Mdo_OE. The bidirectional signal must be created on the top level. This
123
// is done due to the ASIC tools.
124
//
125 15 mohor
// Revision 1.2  2001/08/02 09:25:31  mohor
126
// Unconnected signals are now connected.
127
//
128
// Revision 1.1  2001/07/30 21:23:42  mohor
129
// Directory structure changed. Files checked and joind together.
130
//
131
//
132
//
133
//
134
//
135
//
136
 
137
`include "eth_defines.v"
138 22 mohor
`include "timescale.v"
139 15 mohor
 
140
 
141 68 mohor
module eth_registers( DataIn, Address, Rw, Cs, Clk, Reset, DataOut,
142 15 mohor
                      r_RecSmall, r_Pad, r_HugEn, r_CrcEn, r_DlyCrcEn,
143 244 mohor
                      r_FullD, r_ExDfrEn, r_NoBckof, r_LoopBck, r_IFG,
144 21 mohor
                      r_Pro, r_Iam, r_Bro, r_NoPre, r_TxEn, r_RxEn,
145 147 mohor
                      TxB_IRQ, TxE_IRQ, RxB_IRQ, RxE_IRQ, Busy_IRQ,
146 21 mohor
                      r_IPGT, r_IPGR1, r_IPGR2, r_MinFL, r_MaxFL, r_MaxRet,
147 15 mohor
                      r_CollValid, r_TxFlow, r_RxFlow, r_PassAll,
148
                      r_MiiMRst, r_MiiNoPre, r_ClkDiv, r_WCtrlData, r_RStat, r_ScanStat,
149
                      r_RGAD, r_FIAD, r_CtrlData, NValid_stat, Busy_stat,
150
                      LinkFail, r_MAC, WCtrlDataStart, RStatStart,
151 46 mohor
                      UpdateMIIRX_DATAReg, Prsd, r_TxBDNum, TX_BD_NUM_Wr, int_o,
152 147 mohor
                      r_HASH0, r_HASH1, r_TxPauseTV, r_TxPauseRq, RstTxPauseRq, TxCtrlEndFrm,
153 164 mohor
                      StartTxDone, TxClk, RxClk, ReceivedPauseFrm
154 15 mohor
                    );
155
 
156
parameter Tp = 1;
157
 
158
input [31:0] DataIn;
159 46 mohor
input [7:0] Address;
160 15 mohor
 
161
input Rw;
162
input Cs;
163
input Clk;
164
input Reset;
165
 
166
input WCtrlDataStart;
167
input RStatStart;
168
 
169
input UpdateMIIRX_DATAReg;
170
input [15:0] Prsd;
171
 
172
output [31:0] DataOut;
173
reg    [31:0] DataOut;
174
 
175
output r_RecSmall;
176
output r_Pad;
177
output r_HugEn;
178
output r_CrcEn;
179
output r_DlyCrcEn;
180
output r_FullD;
181
output r_ExDfrEn;
182
output r_NoBckof;
183
output r_LoopBck;
184
output r_IFG;
185
output r_Pro;
186
output r_Iam;
187
output r_Bro;
188
output r_NoPre;
189
output r_TxEn;
190
output r_RxEn;
191 52 billditt
output [31:0] r_HASH0;
192
output [31:0] r_HASH1;
193 15 mohor
 
194 21 mohor
input TxB_IRQ;
195
input TxE_IRQ;
196
input RxB_IRQ;
197 74 mohor
input RxE_IRQ;
198 21 mohor
input Busy_IRQ;
199 15 mohor
 
200
output [6:0] r_IPGT;
201
 
202
output [6:0] r_IPGR1;
203
 
204
output [6:0] r_IPGR2;
205
 
206
output [15:0] r_MinFL;
207
output [15:0] r_MaxFL;
208
 
209
output [3:0] r_MaxRet;
210
output [5:0] r_CollValid;
211
 
212
output r_TxFlow;
213
output r_RxFlow;
214
output r_PassAll;
215
 
216
output r_MiiMRst;
217
output r_MiiNoPre;
218
output [7:0] r_ClkDiv;
219
 
220
output r_WCtrlData;
221
output r_RStat;
222
output r_ScanStat;
223
 
224
output [4:0] r_RGAD;
225
output [4:0] r_FIAD;
226
 
227 21 mohor
output [15:0]r_CtrlData;
228 15 mohor
 
229
 
230
input NValid_stat;
231
input Busy_stat;
232
input LinkFail;
233
 
234 21 mohor
output [47:0]r_MAC;
235 34 mohor
output [7:0] r_TxBDNum;
236
output       TX_BD_NUM_Wr;
237 21 mohor
output       int_o;
238 147 mohor
output [15:0]r_TxPauseTV;
239
output       r_TxPauseRq;
240
input        RstTxPauseRq;
241
input        TxCtrlEndFrm;
242
input        StartTxDone;
243
input        TxClk;
244
input        RxClk;
245
input        ReceivedPauseFrm;      // sinhroniziraj tale shit da bo delal interrupt. Pazi na PassAll bit
246 15 mohor
 
247 21 mohor
reg          irq_txb;
248
reg          irq_txe;
249
reg          irq_rxb;
250 74 mohor
reg          irq_rxe;
251 21 mohor
reg          irq_busy;
252 74 mohor
reg          irq_txc;
253
reg          irq_rxc;
254 15 mohor
 
255 147 mohor
reg SetTxCIrq_txclk;
256
reg SetTxCIrq_sync1, SetTxCIrq_sync2, SetTxCIrq_sync3;
257
reg SetTxCIrq;
258
reg ResetTxCIrq_sync1, ResetTxCIrq_sync2;
259
 
260
reg SetRxCIrq_rxclk;
261
reg SetRxCIrq_sync1, SetRxCIrq_sync2, SetRxCIrq_sync3;
262
reg SetRxCIrq;
263
reg ResetRxCIrq_sync1, ResetRxCIrq_sync2;
264
 
265 15 mohor
wire Write = Cs &  Rw;
266
wire Read  = Cs & ~Rw;
267
 
268 21 mohor
wire MODER_Wr       = (Address == `ETH_MODER_ADR       )  & Write;
269
wire INT_SOURCE_Wr  = (Address == `ETH_INT_SOURCE_ADR  )  & Write;
270
wire INT_MASK_Wr    = (Address == `ETH_INT_MASK_ADR    )  & Write;
271
wire IPGT_Wr        = (Address == `ETH_IPGT_ADR        )  & Write;
272
wire IPGR1_Wr       = (Address == `ETH_IPGR1_ADR       )  & Write;
273
wire IPGR2_Wr       = (Address == `ETH_IPGR2_ADR       )  & Write;
274
wire PACKETLEN_Wr   = (Address == `ETH_PACKETLEN_ADR   )  & Write;
275
wire COLLCONF_Wr    = (Address == `ETH_COLLCONF_ADR    )  & Write;
276
 
277
wire CTRLMODER_Wr   = (Address == `ETH_CTRLMODER_ADR   )  & Write;
278
wire MIIMODER_Wr    = (Address == `ETH_MIIMODER_ADR    )  & Write;
279
wire MIICOMMAND_Wr  = (Address == `ETH_MIICOMMAND_ADR  )  & Write;
280
wire MIIADDRESS_Wr  = (Address == `ETH_MIIADDRESS_ADR  )  & Write;
281
wire MIITX_DATA_Wr  = (Address == `ETH_MIITX_DATA_ADR  )  & Write;
282
wire MIIRX_DATA_Wr  = UpdateMIIRX_DATAReg;
283
wire MAC_ADDR0_Wr   = (Address == `ETH_MAC_ADDR0_ADR   )  & Write;
284
wire MAC_ADDR1_Wr   = (Address == `ETH_MAC_ADDR1_ADR   )  & Write;
285 147 mohor
wire HASH0_Wr       = (Address == `ETH_HASH0_ADR       )  & Write;
286
wire HASH1_Wr       = (Address == `ETH_HASH1_ADR       )  & Write;
287
wire TXCTRL_Wr      = (Address == `ETH_TX_CTRL_ADR     )  & Write;
288
wire RXCTRL_Wr      = (Address == `ETH_RX_CTRL_ADR     )  & Write;
289 34 mohor
assign TX_BD_NUM_Wr = (Address == `ETH_TX_BD_NUM_ADR   )  & Write;
290 15 mohor
 
291
 
292
 
293
wire [31:0] MODEROut;
294
wire [31:0] INT_SOURCEOut;
295
wire [31:0] INT_MASKOut;
296
wire [31:0] IPGTOut;
297
wire [31:0] IPGR1Out;
298
wire [31:0] IPGR2Out;
299
wire [31:0] PACKETLENOut;
300
wire [31:0] COLLCONFOut;
301
wire [31:0] CTRLMODEROut;
302
wire [31:0] MIIMODEROut;
303
wire [31:0] MIICOMMANDOut;
304
wire [31:0] MIIADDRESSOut;
305
wire [31:0] MIITX_DATAOut;
306
wire [31:0] MIIRX_DATAOut;
307
wire [31:0] MIISTATUSOut;
308
wire [31:0] MAC_ADDR0Out;
309
wire [31:0] MAC_ADDR1Out;
310 34 mohor
wire [31:0] TX_BD_NUMOut;
311 52 billditt
wire [31:0] HASH0Out;
312
wire [31:0] HASH1Out;
313 147 mohor
wire [31:0] TXCTRLOut;
314
wire [31:0] RXCTRLOut;
315 15 mohor
 
316 46 mohor
 
317 139 mohor
// MODER Register
318
eth_register #(`ETH_MODER_WIDTH, `ETH_MODER_DEF)        MODER
319
  (
320
   .DataIn    (DataIn[`ETH_MODER_WIDTH-1:0]),
321
   .DataOut   (MODEROut[`ETH_MODER_WIDTH-1:0]),
322
   .Write     (MODER_Wr),
323
   .Clk       (Clk),
324
   .Reset     (Reset),
325 141 mohor
   .SyncReset (1'b0)
326 139 mohor
  );
327
assign MODEROut[31:`ETH_MODER_WIDTH] = 0;
328 15 mohor
 
329 139 mohor
// INT_MASK Register
330
eth_register #(`ETH_INT_MASK_WIDTH, `ETH_INT_MASK_DEF)  INT_MASK
331
  (
332
   .DataIn    (DataIn[`ETH_INT_MASK_WIDTH-1:0]),
333
   .DataOut   (INT_MASKOut[`ETH_INT_MASK_WIDTH-1:0]),
334
   .Write     (INT_MASK_Wr),
335
   .Clk       (Clk),
336
   .Reset     (Reset),
337 141 mohor
   .SyncReset (1'b0)
338 139 mohor
  );
339 141 mohor
assign INT_MASKOut[31:`ETH_INT_MASK_WIDTH] = 0;
340 52 billditt
 
341 139 mohor
// IPGT Register
342
eth_register #(`ETH_IPGT_WIDTH, `ETH_IPGT_DEF)          IPGT
343
  (
344
   .DataIn    (DataIn[`ETH_IPGT_WIDTH-1:0]),
345
   .DataOut   (IPGTOut[`ETH_IPGT_WIDTH-1:0]),
346
   .Write     (IPGT_Wr),
347
   .Clk       (Clk),
348
   .Reset     (Reset),
349 141 mohor
   .SyncReset (1'b0)
350 139 mohor
  );
351
assign IPGTOut[31:`ETH_IPGT_WIDTH] = 0;
352 52 billditt
 
353 139 mohor
// IPGR1 Register
354
eth_register #(`ETH_IPGR1_WIDTH, `ETH_IPGR1_DEF)        IPGR1
355
  (
356
   .DataIn    (DataIn[`ETH_IPGR1_WIDTH-1:0]),
357
   .DataOut   (IPGR1Out[`ETH_IPGR1_WIDTH-1:0]),
358
   .Write     (IPGR1_Wr),
359
   .Clk       (Clk),
360
   .Reset     (Reset),
361 141 mohor
   .SyncReset (1'b0)
362 139 mohor
  );
363
assign IPGR1Out[31:`ETH_IPGR1_WIDTH] = 0;
364 15 mohor
 
365 139 mohor
// IPGR2 Register
366
eth_register #(`ETH_IPGR2_WIDTH, `ETH_IPGR2_DEF)        IPGR2
367
  (
368
   .DataIn    (DataIn[`ETH_IPGR2_WIDTH-1:0]),
369
   .DataOut   (IPGR2Out[`ETH_IPGR2_WIDTH-1:0]),
370
   .Write     (IPGR2_Wr),
371
   .Clk       (Clk),
372
   .Reset     (Reset),
373 141 mohor
   .SyncReset (1'b0)
374 139 mohor
  );
375
assign IPGR2Out[31:`ETH_IPGR2_WIDTH] = 0;
376 15 mohor
 
377 139 mohor
// PACKETLEN Register
378
eth_register #(`ETH_PACKETLEN_WIDTH, `ETH_PACKETLEN_DEF) PACKETLEN
379
  (
380
   .DataIn    (DataIn),
381
   .DataOut   (PACKETLENOut),
382
   .Write     (PACKETLEN_Wr),
383
   .Clk       (Clk),
384
   .Reset     (Reset),
385 141 mohor
   .SyncReset (1'b0)
386 139 mohor
  );
387 15 mohor
 
388 139 mohor
// COLLCONF Register
389
eth_register #(6, `ETH_COLLCONF0_DEF)                   COLLCONF0
390
  (
391
   .DataIn    (DataIn[5:0]),
392
   .DataOut   (COLLCONFOut[5:0]),
393
   .Write     (COLLCONF_Wr),
394
   .Clk       (Clk),
395
   .Reset     (Reset),
396 141 mohor
   .SyncReset (1'b0)
397 139 mohor
  );
398 68 mohor
assign COLLCONFOut[15:6] = 0;
399 139 mohor
 
400
eth_register #(4, `ETH_COLLCONF1_DEF)                   COLLCONF1
401
  (
402
   .DataIn    (DataIn[19:16]),
403
   .DataOut   (COLLCONFOut[19:16]),
404
   .Write     (COLLCONF_Wr),
405
   .Clk       (Clk),
406
   .Reset     (Reset),
407 141 mohor
   .SyncReset (1'b0)
408 139 mohor
  );
409 68 mohor
assign COLLCONFOut[31:20] = 0;
410 15 mohor
 
411 139 mohor
// TX_BD_NUM Register
412
eth_register #(`ETH_TX_BD_NUM_WIDTH, `ETH_TX_BD_NUM_DEF) TX_BD_NUM
413
  (
414
   .DataIn    (DataIn[`ETH_TX_BD_NUM_WIDTH-1:0]),
415
   .DataOut   (TX_BD_NUMOut[`ETH_TX_BD_NUM_WIDTH-1:0]),
416 143 mohor
   .Write     (TX_BD_NUM_Wr & (DataIn<='h80)),
417 139 mohor
   .Clk       (Clk),
418
   .Reset     (Reset),
419 141 mohor
   .SyncReset (1'b0)
420 139 mohor
  );
421
assign TX_BD_NUMOut[31:`ETH_TX_BD_NUM_WIDTH] = 0;
422 15 mohor
 
423 139 mohor
// CTRLMODER Register
424
eth_register #(`ETH_CTRLMODER_WIDTH, `ETH_CTRLMODER_DEF)  CTRLMODER2
425
  (
426
   .DataIn    (DataIn[`ETH_CTRLMODER_WIDTH-1:0]),
427
   .DataOut   (CTRLMODEROut[`ETH_CTRLMODER_WIDTH-1:0]),
428
   .Write     (CTRLMODER_Wr),
429
   .Clk       (Clk),
430
   .Reset     (Reset),
431 141 mohor
   .SyncReset (1'b0)
432 139 mohor
  );
433
assign CTRLMODEROut[31:`ETH_CTRLMODER_WIDTH] = 0;
434 15 mohor
 
435 139 mohor
// MIIMODER Register
436
eth_register #(`ETH_MIIMODER_WIDTH, `ETH_MIIMODER_DEF)    MIIMODER
437
  (
438
   .DataIn    (DataIn[`ETH_MIIMODER_WIDTH-1:0]),
439
   .DataOut   (MIIMODEROut[`ETH_MIIMODER_WIDTH-1:0]),
440
   .Write     (MIIMODER_Wr),
441
   .Clk       (Clk),
442
   .Reset     (Reset),
443 141 mohor
   .SyncReset (1'b0)
444 139 mohor
  );
445
assign MIIMODEROut[31:`ETH_MIIMODER_WIDTH] = 0;
446 68 mohor
 
447 139 mohor
// MIICOMMAND Register
448
eth_register #(1, 0)                                      MIICOMMAND0
449
  (
450
   .DataIn    (DataIn[0]),
451
   .DataOut   (MIICOMMANDOut[0]),
452
   .Write     (MIICOMMAND_Wr),
453
   .Clk       (Clk),
454
   .Reset     (Reset),
455 141 mohor
   .SyncReset (1'b0)
456 139 mohor
  );
457
 
458
eth_register #(1, 0)                                      MIICOMMAND1
459
  (
460
   .DataIn    (DataIn[1]),
461
   .DataOut   (MIICOMMANDOut[1]),
462
   .Write     (MIICOMMAND_Wr),
463
   .Clk       (Clk),
464
   .Reset     (Reset),
465
   .SyncReset (RStatStart)
466
  );
467
 
468
eth_register #(1, 0)                                      MIICOMMAND2
469
  (
470
   .DataIn    (DataIn[2]),
471
   .DataOut   (MIICOMMANDOut[2]),
472
   .Write     (MIICOMMAND_Wr),
473
   .Clk       (Clk),
474
   .Reset     (Reset),
475
   .SyncReset (WCtrlDataStart)
476
  );
477 15 mohor
assign MIICOMMANDOut[31:3] = 29'h0;
478
 
479 139 mohor
// MIIADDRESSRegister
480
eth_register #(5, `ETH_MIIADDRESS0_DEF)                   MIIADDRESS0
481
  (
482
   .DataIn    (DataIn[4:0]),
483
   .DataOut   (MIIADDRESSOut[4:0]),
484
   .Write     (MIIADDRESS_Wr),
485
   .Clk       (Clk),
486
   .Reset     (Reset),
487 141 mohor
   .SyncReset (1'b0)
488 139 mohor
  );
489 68 mohor
assign MIIADDRESSOut[7:5] = 0;
490 139 mohor
 
491
eth_register #(5, `ETH_MIIADDRESS1_DEF)                   MIIADDRESS1
492
  (
493
   .DataIn    (DataIn[12:8]),
494
   .DataOut   (MIIADDRESSOut[12:8]),
495
   .Write     (MIIADDRESS_Wr),
496
   .Clk       (Clk),
497
   .Reset     (Reset),
498 141 mohor
   .SyncReset (1'b0)
499 139 mohor
  );
500 68 mohor
assign MIIADDRESSOut[31:13] = 0;
501 15 mohor
 
502 139 mohor
// MIITX_DATA Register
503
eth_register #(`ETH_MIITX_DATA_WIDTH, `ETH_MIITX_DATA_DEF) MIITX_DATA
504
  (
505
   .DataIn    (DataIn[`ETH_MIITX_DATA_WIDTH-1:0]),
506 140 mohor
   .DataOut   (MIITX_DATAOut[`ETH_MIITX_DATA_WIDTH-1:0]),
507 139 mohor
   .Write     (MIITX_DATA_Wr),
508
   .Clk       (Clk),
509
   .Reset     (Reset),
510 141 mohor
   .SyncReset (1'b0)
511 139 mohor
  );
512
assign MIITX_DATAOut[31:`ETH_MIITX_DATA_WIDTH] = 0;
513 15 mohor
 
514 139 mohor
// MIIRX_DATA Register
515
eth_register #(`ETH_MIIRX_DATA_WIDTH, `ETH_MIIRX_DATA_DEF) MIIRX_DATA
516
  (
517
   .DataIn    (Prsd[`ETH_MIIRX_DATA_WIDTH-1:0]),
518
   .DataOut   (MIIRX_DATAOut[`ETH_MIIRX_DATA_WIDTH-1:0]),
519
   .Write     (MIIRX_DATA_Wr),
520
   .Clk       (Clk),
521
   .Reset     (Reset),
522 141 mohor
   .SyncReset (1'b0)
523 139 mohor
  );
524
assign MIIRX_DATAOut[31:`ETH_MIIRX_DATA_WIDTH] = 0;
525 15 mohor
 
526 139 mohor
// MAC_ADDR0 Register
527
eth_register #(`ETH_MAC_ADDR0_WIDTH, `ETH_MAC_ADDR0_DEF)  MAC_ADDR0
528
  (
529
   .DataIn    (DataIn),
530
   .DataOut   (MAC_ADDR0Out),
531
   .Write     (MAC_ADDR0_Wr),
532
   .Clk       (Clk),
533
   .Reset     (Reset),
534 141 mohor
   .SyncReset (1'b0)
535 139 mohor
  );
536 68 mohor
 
537 139 mohor
// MAC_ADDR1 Register
538
eth_register #(`ETH_MAC_ADDR1_WIDTH, `ETH_MAC_ADDR1_DEF)  MAC_ADDR1
539
  (
540
   .DataIn    (DataIn[`ETH_MAC_ADDR1_WIDTH-1:0]),
541
   .DataOut   (MAC_ADDR1Out[`ETH_MAC_ADDR1_WIDTH-1:0]),
542
   .Write     (MAC_ADDR1_Wr),
543
   .Clk       (Clk),
544
   .Reset     (Reset),
545 141 mohor
   .SyncReset (1'b0)
546 139 mohor
  );
547
assign MAC_ADDR1Out[31:`ETH_MAC_ADDR1_WIDTH] = 0;
548 68 mohor
 
549 139 mohor
// RXHASH0 Register
550
eth_register #(`ETH_HASH0_WIDTH, `ETH_HASH0_DEF)          RXHASH0
551
  (
552
   .DataIn    (DataIn),
553
   .DataOut   (HASH0Out),
554
   .Write     (HASH0_Wr),
555
   .Clk       (Clk),
556
   .Reset     (Reset),
557 141 mohor
   .SyncReset (1'b0)
558 139 mohor
  );
559 68 mohor
 
560 139 mohor
// RXHASH1 Register
561
eth_register #(`ETH_HASH1_WIDTH, `ETH_HASH1_DEF)          RXHASH1
562
  (
563
   .DataIn    (DataIn),
564
   .DataOut   (HASH1Out),
565
   .Write     (HASH1_Wr),
566
   .Clk       (Clk),
567
   .Reset     (Reset),
568 141 mohor
   .SyncReset (1'b0)
569 139 mohor
  );
570 68 mohor
 
571 15 mohor
 
572 147 mohor
// TXCTRL Register
573
eth_register #((`ETH_TX_CTRL_WIDTH-1), {(`ETH_TX_CTRL_WIDTH-1){1'b0}})      TXCTRL0
574
  (
575
   .DataIn    (DataIn[`ETH_TX_CTRL_WIDTH-2:0]),
576
   .DataOut   (TXCTRLOut[`ETH_TX_CTRL_WIDTH-2:0]),
577
   .Write     (TXCTRL_Wr),
578
   .Clk       (Clk),
579
   .Reset     (Reset),
580
   .SyncReset (1'b0)
581
  );
582
 
583
eth_register #(1, 1'b0)                                   TXCTRL1     // Request bit is synchronously reset
584
  (
585
   .DataIn    (DataIn[16]),
586
   .DataOut   (TXCTRLOut[16]),
587
   .Write     (TXCTRL_Wr),
588
   .Clk       (Clk),
589
   .Reset     (Reset),
590
   .SyncReset (RstTxPauseRq)
591
  );
592
assign TXCTRLOut[31:`ETH_TX_CTRL_WIDTH] = 0;
593
 
594
 
595
// RXCTRL Register
596
eth_register #(`ETH_RX_CTRL_WIDTH, `ETH_RX_CTRL_DEF)      RXCTRL
597
  (
598
   .DataIn    (DataIn[`ETH_RX_CTRL_WIDTH-1:0]),
599
   .DataOut   (RXCTRLOut[`ETH_RX_CTRL_WIDTH-1:0]),
600
   .Write     (RXCTRL_Wr),
601
   .Clk       (Clk),
602
   .Reset     (Reset),
603
   .SyncReset (1'b0)
604
  );
605
assign RXCTRLOut[31:`ETH_RX_CTRL_WIDTH] = 0;
606
 
607
 
608 139 mohor
// Reading data from registers
609
always @ (Address       or Read           or MODEROut       or INT_SOURCEOut  or
610
          INT_MASKOut   or IPGTOut        or IPGR1Out       or IPGR2Out       or
611
          PACKETLENOut  or COLLCONFOut    or CTRLMODEROut   or MIIMODEROut    or
612
          MIICOMMANDOut or MIIADDRESSOut  or MIITX_DATAOut  or MIIRX_DATAOut  or
613
          MIISTATUSOut  or MAC_ADDR0Out   or MAC_ADDR1Out   or TX_BD_NUMOut   or
614 147 mohor
          HASH0Out      or HASH1Out       or TXCTRLOut      or RXCTRLOut
615 139 mohor
         )
616 15 mohor
begin
617
  if(Read)  // read
618
    begin
619
      case(Address)
620 20 mohor
        `ETH_MODER_ADR        :  DataOut<=MODEROut;
621
        `ETH_INT_SOURCE_ADR   :  DataOut<=INT_SOURCEOut;
622
        `ETH_INT_MASK_ADR     :  DataOut<=INT_MASKOut;
623
        `ETH_IPGT_ADR         :  DataOut<=IPGTOut;
624
        `ETH_IPGR1_ADR        :  DataOut<=IPGR1Out;
625
        `ETH_IPGR2_ADR        :  DataOut<=IPGR2Out;
626
        `ETH_PACKETLEN_ADR    :  DataOut<=PACKETLENOut;
627
        `ETH_COLLCONF_ADR     :  DataOut<=COLLCONFOut;
628
        `ETH_CTRLMODER_ADR    :  DataOut<=CTRLMODEROut;
629
        `ETH_MIIMODER_ADR     :  DataOut<=MIIMODEROut;
630
        `ETH_MIICOMMAND_ADR   :  DataOut<=MIICOMMANDOut;
631
        `ETH_MIIADDRESS_ADR   :  DataOut<=MIIADDRESSOut;
632
        `ETH_MIITX_DATA_ADR   :  DataOut<=MIITX_DATAOut;
633
        `ETH_MIIRX_DATA_ADR   :  DataOut<=MIIRX_DATAOut;
634
        `ETH_MIISTATUS_ADR    :  DataOut<=MIISTATUSOut;
635
        `ETH_MAC_ADDR0_ADR    :  DataOut<=MAC_ADDR0Out;
636
        `ETH_MAC_ADDR1_ADR    :  DataOut<=MAC_ADDR1Out;
637 34 mohor
        `ETH_TX_BD_NUM_ADR    :  DataOut<=TX_BD_NUMOut;
638 56 mohor
        `ETH_HASH0_ADR        :  DataOut<=HASH0Out;
639
        `ETH_HASH1_ADR        :  DataOut<=HASH1Out;
640 147 mohor
        `ETH_TX_CTRL_ADR      :  DataOut<=TXCTRLOut;
641
        `ETH_RX_CTRL_ADR      :  DataOut<=RXCTRLOut;
642
 
643 15 mohor
        default:             DataOut<=32'h0;
644
      endcase
645
    end
646
  else
647
    DataOut<=32'h0;
648
end
649
 
650
 
651
assign r_RecSmall         = MODEROut[16];
652
assign r_Pad              = MODEROut[15];
653
assign r_HugEn            = MODEROut[14];
654
assign r_CrcEn            = MODEROut[13];
655
assign r_DlyCrcEn         = MODEROut[12];
656 244 mohor
// assign r_Rst           = MODEROut[11];   This signal is not used any more
657 15 mohor
assign r_FullD            = MODEROut[10];
658
assign r_ExDfrEn          = MODEROut[9];
659
assign r_NoBckof          = MODEROut[8];
660
assign r_LoopBck          = MODEROut[7];
661
assign r_IFG              = MODEROut[6];
662
assign r_Pro              = MODEROut[5];
663
assign r_Iam              = MODEROut[4];
664
assign r_Bro              = MODEROut[3];
665
assign r_NoPre            = MODEROut[2];
666 143 mohor
assign r_TxEn             = MODEROut[1] & (TX_BD_NUMOut>0);     // Transmission is enabled when there is at least one TxBD.
667
assign r_RxEn             = MODEROut[0] & (TX_BD_NUMOut<'h80);  // Reception is enabled when there is  at least one RxBD.
668 15 mohor
 
669
assign r_IPGT[6:0]        = IPGTOut[6:0];
670
 
671
assign r_IPGR1[6:0]       = IPGR1Out[6:0];
672
 
673
assign r_IPGR2[6:0]       = IPGR2Out[6:0];
674
 
675
assign r_MinFL[15:0]      = PACKETLENOut[31:16];
676
assign r_MaxFL[15:0]      = PACKETLENOut[15:0];
677
 
678 56 mohor
assign r_MaxRet[3:0]      = COLLCONFOut[19:16];
679
assign r_CollValid[5:0]   = COLLCONFOut[5:0];
680 15 mohor
 
681
assign r_TxFlow           = CTRLMODEROut[2];
682
assign r_RxFlow           = CTRLMODEROut[1];
683
assign r_PassAll          = CTRLMODEROut[0];
684
 
685 139 mohor
assign r_MiiMRst          = MIIMODEROut[9];
686 15 mohor
assign r_MiiNoPre         = MIIMODEROut[8];
687
assign r_ClkDiv[7:0]      = MIIMODEROut[7:0];
688
 
689
assign r_WCtrlData        = MIICOMMANDOut[2];
690
assign r_RStat            = MIICOMMANDOut[1];
691
assign r_ScanStat         = MIICOMMANDOut[0];
692
 
693
assign r_RGAD[4:0]        = MIIADDRESSOut[12:8];
694
assign r_FIAD[4:0]        = MIIADDRESSOut[4:0];
695
 
696
assign r_CtrlData[15:0]   = MIITX_DATAOut[15:0];
697
 
698 139 mohor
assign MIISTATUSOut[31:`ETH_MIISTATUS_WIDTH] = 0;
699
assign MIISTATUSOut[2]    = NValid_stat         ;
700
assign MIISTATUSOut[1]    = Busy_stat           ;
701
assign MIISTATUSOut[0]    = LinkFail            ;
702 15 mohor
 
703
assign r_MAC[31:0]        = MAC_ADDR0Out[31:0];
704
assign r_MAC[47:32]       = MAC_ADDR1Out[15:0];
705 52 billditt
assign r_HASH1[31:0]      = HASH1Out;
706
assign r_HASH0[31:0]      = HASH0Out;
707 15 mohor
 
708 147 mohor
assign r_TxBDNum[7:0]     = TX_BD_NUMOut[7:0];
709 15 mohor
 
710 147 mohor
assign r_TxPauseTV[15:0]  = TXCTRLOut[15:0];
711
assign r_TxPauseRq        = TXCTRLOut[16];
712 15 mohor
 
713 147 mohor
 
714
// Synchronizing TxC Interrupt
715
always @ (posedge TxClk or posedge Reset)
716
begin
717
  if(Reset)
718
    SetTxCIrq_txclk <=#Tp 1'b0;
719
  else
720
  if(TxCtrlEndFrm & StartTxDone & r_TxFlow)
721
    SetTxCIrq_txclk <=#Tp 1'b1;
722
  else
723
  if(ResetTxCIrq_sync2)
724
    SetTxCIrq_txclk <=#Tp 1'b0;
725
end
726
 
727
 
728
always @ (posedge Clk or posedge Reset)
729
begin
730
  if(Reset)
731
    SetTxCIrq_sync1 <=#Tp 1'b0;
732
  else
733
    SetTxCIrq_sync1 <=#Tp SetTxCIrq_txclk;
734
end
735
 
736
always @ (posedge Clk or posedge Reset)
737
begin
738
  if(Reset)
739
    SetTxCIrq_sync2 <=#Tp 1'b0;
740
  else
741
    SetTxCIrq_sync2 <=#Tp SetTxCIrq_sync1;
742
end
743
 
744
always @ (posedge Clk or posedge Reset)
745
begin
746
  if(Reset)
747
    SetTxCIrq_sync3 <=#Tp 1'b0;
748
  else
749
    SetTxCIrq_sync3 <=#Tp SetTxCIrq_sync2;
750
end
751
 
752
always @ (posedge Clk or posedge Reset)
753
begin
754
  if(Reset)
755
    SetTxCIrq <=#Tp 1'b0;
756
  else
757
    SetTxCIrq <=#Tp SetTxCIrq_sync2 & ~SetTxCIrq_sync3;
758
end
759
 
760
always @ (posedge TxClk or posedge Reset)
761
begin
762
  if(Reset)
763
    ResetTxCIrq_sync1 <=#Tp 1'b0;
764
  else
765
    ResetTxCIrq_sync1 <=#Tp SetTxCIrq_sync2;
766
end
767
 
768
always @ (posedge TxClk or posedge Reset)
769
begin
770
  if(Reset)
771
    ResetTxCIrq_sync2 <=#Tp 1'b0;
772
  else
773
    ResetTxCIrq_sync2 <=#Tp SetTxCIrq_sync1;
774
end
775
 
776
 
777
// Synchronizing RxC Interrupt
778
always @ (posedge RxClk or posedge Reset)
779
begin
780
  if(Reset)
781
    SetRxCIrq_rxclk <=#Tp 1'b0;
782
  else
783
  if(ReceivedPauseFrm & r_RxFlow)
784
    SetRxCIrq_rxclk <=#Tp 1'b1;
785
  else
786
  if(ResetRxCIrq_sync2)
787
    SetRxCIrq_rxclk <=#Tp 1'b0;
788
end
789
 
790
 
791
always @ (posedge Clk or posedge Reset)
792
begin
793
  if(Reset)
794
    SetRxCIrq_sync1 <=#Tp 1'b0;
795
  else
796
    SetRxCIrq_sync1 <=#Tp SetRxCIrq_rxclk;
797
end
798
 
799
always @ (posedge Clk or posedge Reset)
800
begin
801
  if(Reset)
802
    SetRxCIrq_sync2 <=#Tp 1'b0;
803
  else
804
    SetRxCIrq_sync2 <=#Tp SetRxCIrq_sync1;
805
end
806
 
807
always @ (posedge Clk or posedge Reset)
808
begin
809
  if(Reset)
810
    SetRxCIrq_sync3 <=#Tp 1'b0;
811
  else
812
    SetRxCIrq_sync3 <=#Tp SetRxCIrq_sync2;
813
end
814
 
815
always @ (posedge Clk or posedge Reset)
816
begin
817
  if(Reset)
818
    SetRxCIrq <=#Tp 1'b0;
819
  else
820
    SetRxCIrq <=#Tp SetRxCIrq_sync2 & ~SetRxCIrq_sync3;
821
end
822
 
823
always @ (posedge RxClk or posedge Reset)
824
begin
825
  if(Reset)
826
    ResetRxCIrq_sync1 <=#Tp 1'b0;
827
  else
828
    ResetRxCIrq_sync1 <=#Tp SetRxCIrq_sync2;
829
end
830
 
831
always @ (posedge TxClk or posedge Reset)
832
begin
833
  if(Reset)
834
    ResetRxCIrq_sync2 <=#Tp 1'b0;
835
  else
836
    ResetRxCIrq_sync2 <=#Tp SetRxCIrq_sync1;
837
end
838
 
839
 
840
 
841
 
842
 
843
 
844
 
845 21 mohor
// Interrupt generation
846
always @ (posedge Clk or posedge Reset)
847
begin
848
  if(Reset)
849
    irq_txb <= 1'b0;
850
  else
851 102 mohor
  if(TxB_IRQ)
852 21 mohor
    irq_txb <= #Tp 1'b1;
853
  else
854
  if(INT_SOURCE_Wr & DataIn[0])
855
    irq_txb <= #Tp 1'b0;
856
end
857
 
858
always @ (posedge Clk or posedge Reset)
859
begin
860
  if(Reset)
861
    irq_txe <= 1'b0;
862
  else
863 102 mohor
  if(TxE_IRQ)
864 21 mohor
    irq_txe <= #Tp 1'b1;
865
  else
866
  if(INT_SOURCE_Wr & DataIn[1])
867
    irq_txe <= #Tp 1'b0;
868
end
869
 
870
always @ (posedge Clk or posedge Reset)
871
begin
872
  if(Reset)
873
    irq_rxb <= 1'b0;
874
  else
875 102 mohor
  if(RxB_IRQ)
876 21 mohor
    irq_rxb <= #Tp 1'b1;
877
  else
878
  if(INT_SOURCE_Wr & DataIn[2])
879
    irq_rxb <= #Tp 1'b0;
880
end
881
 
882
always @ (posedge Clk or posedge Reset)
883
begin
884
  if(Reset)
885 74 mohor
    irq_rxe <= 1'b0;
886 21 mohor
  else
887 102 mohor
  if(RxE_IRQ)
888 74 mohor
    irq_rxe <= #Tp 1'b1;
889 21 mohor
  else
890
  if(INT_SOURCE_Wr & DataIn[3])
891 74 mohor
    irq_rxe <= #Tp 1'b0;
892 21 mohor
end
893
 
894
always @ (posedge Clk or posedge Reset)
895
begin
896
  if(Reset)
897
    irq_busy <= 1'b0;
898
  else
899 102 mohor
  if(Busy_IRQ)
900 21 mohor
    irq_busy <= #Tp 1'b1;
901
  else
902
  if(INT_SOURCE_Wr & DataIn[4])
903
    irq_busy <= #Tp 1'b0;
904
end
905
 
906 74 mohor
always @ (posedge Clk or posedge Reset)
907
begin
908
  if(Reset)
909
    irq_txc <= 1'b0;
910
  else
911 147 mohor
  if(SetTxCIrq)
912 74 mohor
    irq_txc <= #Tp 1'b1;
913
  else
914
  if(INT_SOURCE_Wr & DataIn[5])
915
    irq_txc <= #Tp 1'b0;
916
end
917
 
918
always @ (posedge Clk or posedge Reset)
919
begin
920
  if(Reset)
921
    irq_rxc <= 1'b0;
922
  else
923 147 mohor
  if(SetRxCIrq)
924 74 mohor
    irq_rxc <= #Tp 1'b1;
925
  else
926
  if(INT_SOURCE_Wr & DataIn[6])
927
    irq_rxc <= #Tp 1'b0;
928
end
929
 
930 21 mohor
// Generating interrupt signal
931 102 mohor
assign int_o = irq_txb  & INT_MASKOut[0] |
932
               irq_txe  & INT_MASKOut[1] |
933
               irq_rxb  & INT_MASKOut[2] |
934
               irq_rxe  & INT_MASKOut[3] |
935
               irq_busy & INT_MASKOut[4] |
936
               irq_txc  & INT_MASKOut[5] |
937
               irq_rxc  & INT_MASKOut[6] ;
938 21 mohor
 
939
// For reading interrupt status
940 139 mohor
assign INT_SOURCEOut = {{(32-`ETH_INT_SOURCE_WIDTH){1'b0}}, irq_rxc, irq_txc, irq_busy, irq_rxe, irq_rxb, irq_txe, irq_txb};
941 21 mohor
 
942
 
943
 
944 15 mohor
endmodule

powered by: WebSVN 2.1.0

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