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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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