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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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