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

Subversion Repositories ethmac

[/] [ethmac/] [trunk/] [rtl/] [verilog/] [eth_rxethmac.v] - Blame information for rev 250

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

Line No. Rev Author Line
1 15 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_rxethmac.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
////      - Novan Hartadi (novan@vlsi.itb.ac.id)                  ////
11
////      - Mahmud Galela (mgalela@vlsi.itb.ac.id)                ////
12
////                                                              ////
13
////  All additional information is avaliable in the Readme.txt   ////
14
////  file.                                                       ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2001 Authors                                   ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46 250 mohor
// Revision 1.8  2002/02/16 07:15:27  mohor
47
// Testbench fixed, code simplified, unused signals removed.
48
//
49 65 mohor
// Revision 1.7  2002/02/15 13:44:28  mohor
50
// RxAbort is an output. No need to have is declared as wire.
51
//
52 62 mohor
// Revision 1.6  2002/02/15 11:17:48  mohor
53
// File format changed.
54
//
55 58 mohor
// Revision 1.5  2002/02/14 20:48:43  billditt
56
// Addition  of new module eth_addrcheck.v
57
//
58 53 billditt
// Revision 1.4  2002/01/23 10:28:16  mohor
59
// Link in the header changed.
60
//
61 37 mohor
// Revision 1.3  2001/10/19 08:43:51  mohor
62
// eth_timescale.v changed to timescale.v This is done because of the
63
// simulation of the few cores in a one joined project.
64
//
65 22 mohor
// Revision 1.2  2001/09/11 14:17:00  mohor
66
// Few little NCSIM warnings fixed.
67
//
68 18 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
69
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
70
// Include files fixed to contain no path.
71
// File names and module names changed ta have a eth_ prologue in the name.
72
// File eth_timescale.v is used to define timescale
73
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
74
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
75
// and Mdo_OE. The bidirectional signal must be created on the top level. This
76
// is done due to the ASIC tools.
77
//
78 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
79
// Directory structure changed. Files checked and joind together.
80
//
81
// Revision 1.1  2001/06/27 21:26:19  mohor
82
// Initial release of the RxEthMAC module.
83
//
84
//
85
//
86
//
87
//
88
 
89 22 mohor
`include "timescale.v"
90 15 mohor
 
91
 
92
module eth_rxethmac (MRxClk, MRxDV, MRxD, Reset, Transmitting, MaxFL, r_IFG, HugEn, DlyCrcEn,
93 65 mohor
                     RxData, RxValid, RxStartFrm, RxEndFrm, ByteCnt, ByteCntEq0, ByteCntGreat2,
94
                     ByteCntMaxFrame, CrcError, StateIdle, StatePreamble, StateSFD, StateData,
95 250 mohor
                     MAC, r_Pro, r_Bro,r_HASH0, r_HASH1, RxAbort, AddressMiss
96 15 mohor
                    );
97
 
98
parameter Tp = 1;
99
 
100
 
101
 
102
input         MRxClk;
103
input         MRxDV;
104
input   [3:0] MRxD;
105
input         Transmitting;
106
input         HugEn;
107
input         DlyCrcEn;
108
input  [15:0] MaxFL;
109
input         r_IFG;
110
input         Reset;
111 53 billditt
input  [47:0] MAC;     //  Station Address  
112
input         r_Bro;   //  broadcast disable
113
input         r_Pro;   //  promiscuous enable 
114
input [31:0]  r_HASH0; //  lower 4 bytes Hash Table
115
input [31:0]  r_HASH1; //  upper 4 bytes Hash Table
116 15 mohor
output  [7:0] RxData;
117
output        RxValid;
118
output        RxStartFrm;
119
output        RxEndFrm;
120
output [15:0] ByteCnt;
121
output        ByteCntEq0;
122
output        ByteCntGreat2;
123
output        ByteCntMaxFrame;
124
output        CrcError;
125
output        StateIdle;
126
output        StatePreamble;
127
output        StateSFD;
128
output  [1:0] StateData;
129 53 billditt
output        RxAbort;
130 250 mohor
output        AddressMiss;
131 15 mohor
 
132
reg     [7:0] RxData;
133
reg           RxValid;
134
reg           RxStartFrm;
135
reg           RxEndFrm;
136
reg           Broadcast;
137
reg           Multicast;
138
reg     [8:0] CrcHash;
139
reg           CrcHashGood;
140
reg           DelayData;
141
reg     [3:0] LatchedNibble;
142
reg     [7:0] LatchedByte;
143
reg     [7:0] RxData_d;
144
reg           RxValid_d;
145
reg           RxStartFrm_d;
146
reg           RxEndFrm_d;
147
 
148
wire          MRxDEqD;
149
wire          MRxDEq5;
150
wire          StateDrop;
151
wire          ByteCntEq1;
152 53 billditt
wire          ByteCntEq2;
153
wire          ByteCntEq3;
154
wire          ByteCntEq4;
155
wire          ByteCntEq5;
156 15 mohor
wire          ByteCntEq6;
157 53 billditt
wire          ByteCntEq7;
158 15 mohor
wire          ByteCntSmall7;
159
wire   [31:0] Crc;
160
wire          Enable_Crc;
161
wire          Initialize_Crc;
162
wire    [3:0] Data_Crc;
163
wire          GenerateRxValid;
164
wire          GenerateRxStartFrm;
165
wire          GenerateRxEndFrm;
166
wire          DribbleRxEndFrm;
167
wire    [3:0] DlyCrcCnt;
168
 
169
 
170
assign MRxDEqD = MRxD == 4'hd;
171
assign MRxDEq5 = MRxD == 4'h5;
172
 
173
 
174
// Rx State Machine module
175
eth_rxstatem rxstatem1 (.MRxClk(MRxClk), .Reset(Reset), .MRxDV(MRxDV), .ByteCntEq0(ByteCntEq0),
176
                        .ByteCntGreat2(ByteCntGreat2), .Transmitting(Transmitting), .MRxDEq5(MRxDEq5),
177
                        .MRxDEqD(MRxDEqD), .IFGCounterEq24(IFGCounterEq24), .ByteCntMaxFrame(ByteCntMaxFrame),
178
                        .StateData(StateData), .StateIdle(StateIdle), .StatePreamble(StatePreamble),
179
                        .StateSFD(StateSFD), .StateDrop(StateDrop)
180
                       );
181
 
182
 
183
// Rx Counters module
184
eth_rxcounters rxcounters1 (.MRxClk(MRxClk), .Reset(Reset), .MRxDV(MRxDV), .StateIdle(StateIdle),
185
                            .StateSFD(StateSFD), .StateData(StateData), .StateDrop(StateDrop),
186
                            .StatePreamble(StatePreamble), .MRxDEqD(MRxDEqD), .DlyCrcEn(DlyCrcEn),
187
                            .DlyCrcCnt(DlyCrcCnt), .Transmitting(Transmitting), .MaxFL(MaxFL), .r_IFG(r_IFG),
188
                            .HugEn(HugEn), .IFGCounterEq24(IFGCounterEq24), .ByteCntEq0(ByteCntEq0),
189 58 mohor
                            .ByteCntEq1(ByteCntEq1), .ByteCntEq2(ByteCntEq2), .ByteCntEq3(ByteCntEq3),
190
                            .ByteCntEq4(ByteCntEq4), .ByteCntEq5(ByteCntEq5), .ByteCntEq6(ByteCntEq6),
191
                            .ByteCntEq7(ByteCntEq7), .ByteCntGreat2(ByteCntGreat2),
192 15 mohor
                            .ByteCntSmall7(ByteCntSmall7), .ByteCntMaxFrame(ByteCntMaxFrame),
193
                            .ByteCnt(ByteCnt)
194
                           );
195
 
196 53 billditt
// Rx Address Check
197 15 mohor
 
198 58 mohor
eth_rxaddrcheck rxaddrcheck1
199
              (.MRxClk(MRxClk),         .Reset( Reset),          .RxData(RxData),
200
               .Broadcast (Broadcast),  .r_Bro (r_Bro),          .r_Pro(r_Pro),
201
               .ByteCntEq6(ByteCntEq6), .ByteCntEq7(ByteCntEq7), .ByteCntEq2(ByteCntEq2),
202
               .ByteCntEq3(ByteCntEq3), .ByteCntEq4(ByteCntEq4), .ByteCntEq5(ByteCntEq5),
203
               .HASH0(r_HASH0),         .HASH1(r_HASH1),
204
               .CrcHash(CrcHash[5:0]),  .CrcHashGood(CrcHashGood),.StateData(StateData),
205
               .Multicast(Multicast),   .MAC(MAC),               .RxAbort(RxAbort),
206 250 mohor
               .RxEndFrm(RxEndFrm),     .AddressMiss(AddressMiss)
207 58 mohor
              );
208 15 mohor
 
209 53 billditt
 
210 15 mohor
assign Enable_Crc = MRxDV & (|StateData & ~ByteCntMaxFrame);
211
assign Initialize_Crc = StateSFD | DlyCrcEn & (|DlyCrcCnt[3:0]) & DlyCrcCnt[3:0] < 4'h9;
212
 
213
assign Data_Crc[0] = MRxD[3];
214
assign Data_Crc[1] = MRxD[2];
215
assign Data_Crc[2] = MRxD[1];
216
assign Data_Crc[3] = MRxD[0];
217
 
218
 
219
// Connecting module Crc
220
eth_crc crcrx (.Clk(MRxClk), .Reset(Reset), .Data(Data_Crc), .Enable(Enable_Crc), .Initialize(Initialize_Crc),
221
               .Crc(Crc), .CrcError(CrcError)
222 58 mohor
              );
223 15 mohor
 
224
 
225
 
226
// Latching CRC for use in the hash table
227
 
228
always @ (posedge MRxClk)
229
begin
230
  CrcHashGood <= #Tp StateData[0] & ByteCntEq6;
231
end
232
 
233
always @ (posedge MRxClk)
234
begin
235
  if(Reset | StateIdle)
236
    CrcHash[8:0] <= #Tp 9'h0;
237
  else
238
  if(StateData[0] & ByteCntEq6)
239
    CrcHash[8:0] <= #Tp Crc[31:23];
240
end
241
 
242
 
243
// Output byte stream
244
always @ (posedge MRxClk or posedge Reset)
245
begin
246
  if(Reset)
247
    begin
248
      RxData_d[7:0]      <= #Tp 8'h0;
249
      DelayData          <= #Tp 1'b0;
250
      LatchedNibble[3:0] <= #Tp 4'h0;
251
      LatchedByte[7:0]   <= #Tp 8'h0;
252
      RxData[7:0]        <= #Tp 8'h0;
253
    end
254
  else
255
    begin
256
      LatchedNibble[3:0] <= #Tp MRxD[3:0];                        // Latched nibble
257
      LatchedByte[7:0]   <= #Tp {MRxD[3:0], LatchedNibble[3:0]};  // Latched byte
258
      DelayData          <= #Tp StateData[0];
259
 
260
      if(GenerateRxValid)
261
        RxData_d[7:0] <= #Tp LatchedByte[7:0] & {8{|StateData}};  // Data goes through only in data state 
262
      else
263
      if(~DelayData)
264
        RxData_d[7:0] <= #Tp 8'h0;                                // Delaying data to be valid for two cycles. Zero when not active.
265
 
266
      RxData[7:0] <= #Tp RxData_d[7:0];                           // Output data byte
267
    end
268
end
269
 
270
 
271
 
272
always @ (posedge MRxClk or posedge Reset)
273
begin
274
  if(Reset)
275
    Broadcast <= #Tp 1'b0;
276
  else
277
    begin
278
      if(StateData[0] & ~(&LatchedByte[7:0]) & ByteCntSmall7)
279
        Broadcast <= #Tp 1'b0;
280
      else
281 18 mohor
      if(StateData[0] & (&LatchedByte[7:0]) & ByteCntEq1)
282 15 mohor
        Broadcast <= #Tp 1'b1;
283 58 mohor
      else
284
      if(RxAbort | RxEndFrm)
285
        Broadcast <= #Tp 1'b0;
286 15 mohor
    end
287
end
288
 
289
 
290
always @ (posedge MRxClk or posedge Reset)
291
begin
292
  if(Reset)
293
    Multicast <= #Tp 1'b0;
294
  else
295
    begin
296
      if(Reset)
297
        Multicast <= #Tp 1'b0;
298
      else
299 53 billditt
      if(StateData[0] & ByteCntEq1 & LatchedByte == 8'h01)
300
        Multicast <= #Tp 1'b1;
301 58 mohor
    else if(RxAbort | RxEndFrm)
302
      Multicast <= #Tp 1'b0;
303 15 mohor
    end
304
end
305
 
306
 
307
assign GenerateRxValid = StateData[0] & (~ByteCntEq0 | DlyCrcCnt >= 4'h3);
308
 
309
always @ (posedge MRxClk or posedge Reset)
310
begin
311
  if(Reset)
312
    begin
313
      RxValid_d <= #Tp 1'b0;
314
      RxValid   <= #Tp 1'b0;
315
    end
316
  else
317
    begin
318
      RxValid_d <= #Tp GenerateRxValid;
319
      RxValid   <= #Tp RxValid_d;
320
    end
321
end
322
 
323
 
324
assign GenerateRxStartFrm = StateData[0] & (ByteCntEq1 & ~DlyCrcEn | DlyCrcCnt == 4'h3 & DlyCrcEn);
325
 
326
always @ (posedge MRxClk or posedge Reset)
327
begin
328
  if(Reset)
329
    begin
330
      RxStartFrm_d <= #Tp 1'b0;
331
      RxStartFrm   <= #Tp 1'b0;
332
    end
333
  else
334
    begin
335
      RxStartFrm_d <= #Tp GenerateRxStartFrm;
336
      RxStartFrm   <= #Tp RxStartFrm_d;
337
    end
338
end
339
 
340
 
341
assign GenerateRxEndFrm = StateData[0] & (~MRxDV & ByteCntGreat2 | ByteCntMaxFrame);
342
assign DribbleRxEndFrm  = StateData[1] &  ~MRxDV & ByteCntGreat2;
343
 
344
 
345
always @ (posedge MRxClk or posedge Reset)
346
begin
347
  if(Reset)
348
    begin
349
      RxEndFrm_d <= #Tp 1'b0;
350
      RxEndFrm   <= #Tp 1'b0;
351
    end
352
  else
353
    begin
354
      RxEndFrm_d <= #Tp GenerateRxEndFrm;
355
      RxEndFrm   <= #Tp RxEndFrm_d | DribbleRxEndFrm;
356
    end
357
end
358
 
359
 
360
endmodule

powered by: WebSVN 2.1.0

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