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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [orp/] [orp_soc/] [rtl/] [verilog/] [ethernet.old/] [eth_rxethmac.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  eth_rxethmac.v                                              ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects/ethmac/                   ////
7
////                                                              ////
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
// Revision 1.8  2002/02/16 07:15:27  mohor
47
// Testbench fixed, code simplified, unused signals removed.
48
//
49
// 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
// Revision 1.6  2002/02/15 11:17:48  mohor
53
// File format changed.
54
//
55
// Revision 1.5  2002/02/14 20:48:43  billditt
56
// Addition  of new module eth_addrcheck.v
57
//
58
// Revision 1.4  2002/01/23 10:28:16  mohor
59
// Link in the header changed.
60
//
61
// 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
// Revision 1.2  2001/09/11 14:17:00  mohor
66
// Few little NCSIM warnings fixed.
67
//
68
// 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
// 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
`include "timescale.v"
90
 
91
 
92
module eth_rxethmac (MRxClk, MRxDV, MRxD, Reset, Transmitting, MaxFL, r_IFG, HugEn, DlyCrcEn,
93
                     RxData, RxValid, RxStartFrm, RxEndFrm, ByteCnt, ByteCntEq0, ByteCntGreat2,
94
                     ByteCntMaxFrame, CrcError, StateIdle, StatePreamble, StateSFD, StateData,
95
                     MAC, r_Pro, r_Bro,r_HASH0, r_HASH1, RxAbort
96
                    );
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
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
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
output        RxAbort;
130
 
131
reg     [7:0] RxData;
132
reg           RxValid;
133
reg           RxStartFrm;
134
reg           RxEndFrm;
135
reg           Broadcast;
136
reg           Multicast;
137
reg     [8:0] CrcHash;
138
reg           CrcHashGood;
139
reg           DelayData;
140
reg     [3:0] LatchedNibble;
141
reg     [7:0] LatchedByte;
142
reg     [7:0] RxData_d;
143
reg           RxValid_d;
144
reg           RxStartFrm_d;
145
reg           RxEndFrm_d;
146
 
147
wire          MRxDEqD;
148
wire          MRxDEq5;
149
wire          StateDrop;
150
wire          ByteCntEq1;
151
wire          ByteCntEq2;
152
wire          ByteCntEq3;
153
wire          ByteCntEq4;
154
wire          ByteCntEq5;
155
wire          ByteCntEq6;
156
wire          ByteCntEq7;
157
wire          ByteCntSmall7;
158
wire   [31:0] Crc;
159
wire          Enable_Crc;
160
wire          Initialize_Crc;
161
wire    [3:0] Data_Crc;
162
wire          GenerateRxValid;
163
wire          GenerateRxStartFrm;
164
wire          GenerateRxEndFrm;
165
wire          DribbleRxEndFrm;
166
wire    [3:0] DlyCrcCnt;
167
 
168
 
169
assign MRxDEqD = MRxD == 4'hd;
170
assign MRxDEq5 = MRxD == 4'h5;
171
 
172
 
173
// Rx State Machine module
174
eth_rxstatem rxstatem1 (.MRxClk(MRxClk), .Reset(Reset), .MRxDV(MRxDV), .ByteCntEq0(ByteCntEq0),
175
                        .ByteCntGreat2(ByteCntGreat2), .Transmitting(Transmitting), .MRxDEq5(MRxDEq5),
176
                        .MRxDEqD(MRxDEqD), .IFGCounterEq24(IFGCounterEq24), .ByteCntMaxFrame(ByteCntMaxFrame),
177
                        .StateData(StateData), .StateIdle(StateIdle), .StatePreamble(StatePreamble),
178
                        .StateSFD(StateSFD), .StateDrop(StateDrop)
179
                       );
180
 
181
 
182
// Rx Counters module
183
eth_rxcounters rxcounters1 (.MRxClk(MRxClk), .Reset(Reset), .MRxDV(MRxDV), .StateIdle(StateIdle),
184
                            .StateSFD(StateSFD), .StateData(StateData), .StateDrop(StateDrop),
185
                            .StatePreamble(StatePreamble), .MRxDEqD(MRxDEqD), .DlyCrcEn(DlyCrcEn),
186
                            .DlyCrcCnt(DlyCrcCnt), .Transmitting(Transmitting), .MaxFL(MaxFL), .r_IFG(r_IFG),
187
                            .HugEn(HugEn), .IFGCounterEq24(IFGCounterEq24), .ByteCntEq0(ByteCntEq0),
188
                            .ByteCntEq1(ByteCntEq1), .ByteCntEq2(ByteCntEq2), .ByteCntEq3(ByteCntEq3),
189
                            .ByteCntEq4(ByteCntEq4), .ByteCntEq5(ByteCntEq5), .ByteCntEq6(ByteCntEq6),
190
                            .ByteCntEq7(ByteCntEq7), .ByteCntGreat2(ByteCntGreat2),
191
                            .ByteCntSmall7(ByteCntSmall7), .ByteCntMaxFrame(ByteCntMaxFrame),
192
                            .ByteCnt(ByteCnt)
193
                           );
194
 
195
// Rx Address Check
196
 
197
eth_rxaddrcheck rxaddrcheck1
198
              (.MRxClk(MRxClk),         .Reset( Reset),          .RxData(RxData),
199
               .Broadcast (Broadcast),  .r_Bro (r_Bro),          .r_Pro(r_Pro),
200
               .ByteCntEq6(ByteCntEq6), .ByteCntEq7(ByteCntEq7), .ByteCntEq2(ByteCntEq2),
201
               .ByteCntEq3(ByteCntEq3), .ByteCntEq4(ByteCntEq4), .ByteCntEq5(ByteCntEq5),
202
               .HASH0(r_HASH0),         .HASH1(r_HASH1),
203
               .CrcHash(CrcHash[5:0]),  .CrcHashGood(CrcHashGood),.StateData(StateData),
204
               .Multicast(Multicast),   .MAC(MAC),               .RxAbort(RxAbort),
205
               .RxEndFrm(RxEndFrm)
206
              );
207
 
208
 
209
assign Enable_Crc = MRxDV & (|StateData & ~ByteCntMaxFrame);
210
assign Initialize_Crc = StateSFD | DlyCrcEn & (|DlyCrcCnt[3:0]) & DlyCrcCnt[3:0] < 4'h9;
211
 
212
assign Data_Crc[0] = MRxD[3];
213
assign Data_Crc[1] = MRxD[2];
214
assign Data_Crc[2] = MRxD[1];
215
assign Data_Crc[3] = MRxD[0];
216
 
217
 
218
// Connecting module Crc
219
eth_crc crcrx (.Clk(MRxClk), .Reset(Reset), .Data(Data_Crc), .Enable(Enable_Crc), .Initialize(Initialize_Crc),
220
               .Crc(Crc), .CrcError(CrcError)
221
              );
222
 
223
 
224
 
225
// Latching CRC for use in the hash table
226
 
227
always @ (posedge MRxClk)
228
begin
229
  CrcHashGood <= #Tp StateData[0] & ByteCntEq6;
230
end
231
 
232
always @ (posedge MRxClk)
233
begin
234
  if(Reset | StateIdle)
235
    CrcHash[8:0] <= #Tp 9'h0;
236
  else
237
  if(StateData[0] & ByteCntEq6)
238
    CrcHash[8:0] <= #Tp Crc[31:23];
239
end
240
 
241
 
242
// Output byte stream
243
always @ (posedge MRxClk or posedge Reset)
244
begin
245
  if(Reset)
246
    begin
247
      RxData_d[7:0]      <= #Tp 8'h0;
248
      DelayData          <= #Tp 1'b0;
249
      LatchedNibble[3:0] <= #Tp 4'h0;
250
      LatchedByte[7:0]   <= #Tp 8'h0;
251
      RxData[7:0]        <= #Tp 8'h0;
252
    end
253
  else
254
    begin
255
      LatchedNibble[3:0] <= #Tp MRxD[3:0];                        // Latched nibble
256
      LatchedByte[7:0]   <= #Tp {MRxD[3:0], LatchedNibble[3:0]};  // Latched byte
257
      DelayData          <= #Tp StateData[0];
258
 
259
      if(GenerateRxValid)
260
        RxData_d[7:0] <= #Tp LatchedByte[7:0] & {8{|StateData}};  // Data goes through only in data state 
261
      else
262
      if(~DelayData)
263
        RxData_d[7:0] <= #Tp 8'h0;                                // Delaying data to be valid for two cycles. Zero when not active.
264
 
265
      RxData[7:0] <= #Tp RxData_d[7:0];                           // Output data byte
266
    end
267
end
268
 
269
 
270
 
271
always @ (posedge MRxClk or posedge Reset)
272
begin
273
  if(Reset)
274
    Broadcast <= #Tp 1'b0;
275
  else
276
    begin
277
      if(StateData[0] & ~(&LatchedByte[7:0]) & ByteCntSmall7)
278
        Broadcast <= #Tp 1'b0;
279
      else
280
      if(StateData[0] & (&LatchedByte[7:0]) & ByteCntEq1)
281
        Broadcast <= #Tp 1'b1;
282
      else
283
      if(RxAbort | RxEndFrm)
284
        Broadcast <= #Tp 1'b0;
285
    end
286
end
287
 
288
 
289
always @ (posedge MRxClk or posedge Reset)
290
begin
291
  if(Reset)
292
    Multicast <= #Tp 1'b0;
293
  else
294
    begin
295
      if(Reset)
296
        Multicast <= #Tp 1'b0;
297
      else
298
      if(StateData[0] & ByteCntEq1 & LatchedByte == 8'h01)
299
        Multicast <= #Tp 1'b1;
300
    else if(RxAbort | RxEndFrm)
301
      Multicast <= #Tp 1'b0;
302
    end
303
end
304
 
305
 
306
assign GenerateRxValid = StateData[0] & (~ByteCntEq0 | DlyCrcCnt >= 4'h3);
307
 
308
always @ (posedge MRxClk or posedge Reset)
309
begin
310
  if(Reset)
311
    begin
312
      RxValid_d <= #Tp 1'b0;
313
      RxValid   <= #Tp 1'b0;
314
    end
315
  else
316
    begin
317
      RxValid_d <= #Tp GenerateRxValid;
318
      RxValid   <= #Tp RxValid_d;
319
    end
320
end
321
 
322
 
323
assign GenerateRxStartFrm = StateData[0] & (ByteCntEq1 & ~DlyCrcEn | DlyCrcCnt == 4'h3 & DlyCrcEn);
324
 
325
always @ (posedge MRxClk or posedge Reset)
326
begin
327
  if(Reset)
328
    begin
329
      RxStartFrm_d <= #Tp 1'b0;
330
      RxStartFrm   <= #Tp 1'b0;
331
    end
332
  else
333
    begin
334
      RxStartFrm_d <= #Tp GenerateRxStartFrm;
335
      RxStartFrm   <= #Tp RxStartFrm_d;
336
    end
337
end
338
 
339
 
340
assign GenerateRxEndFrm = StateData[0] & (~MRxDV & ByteCntGreat2 | ByteCntMaxFrame);
341
assign DribbleRxEndFrm  = StateData[1] &  ~MRxDV & ByteCntGreat2;
342
 
343
 
344
always @ (posedge MRxClk or posedge Reset)
345
begin
346
  if(Reset)
347
    begin
348
      RxEndFrm_d <= #Tp 1'b0;
349
      RxEndFrm   <= #Tp 1'b0;
350
    end
351
  else
352
    begin
353
      RxEndFrm_d <= #Tp GenerateRxEndFrm;
354
      RxEndFrm   <= #Tp RxEndFrm_d | DribbleRxEndFrm;
355
    end
356
end
357
 
358
 
359
endmodule

powered by: WebSVN 2.1.0

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