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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_17/] [rtl/] [verilog/] [eth_rxethmac.v] - Blame information for rev 18

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
////  http://www.opencores.org/cores/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 18 mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
47
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
48
// Include files fixed to contain no path.
49
// File names and module names changed ta have a eth_ prologue in the name.
50
// File eth_timescale.v is used to define timescale
51
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
52
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
53
// and Mdo_OE. The bidirectional signal must be created on the top level. This
54
// is done due to the ASIC tools.
55
//
56 15 mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
57
// Directory structure changed. Files checked and joind together.
58
//
59
// Revision 1.1  2001/06/27 21:26:19  mohor
60
// Initial release of the RxEthMAC module.
61
//
62
//
63
//
64
//
65
//
66
 
67
`include "eth_timescale.v"
68
 
69
 
70
module eth_rxethmac (MRxClk, MRxDV, MRxD, Reset, Transmitting, MaxFL, r_IFG, HugEn, DlyCrcEn,
71
                     RxData, RxValid, RxStartFrm, RxEndFrm, CrcHash, CrcHashGood, Broadcast,
72
                     Multicast, ByteCnt, ByteCntEq0, ByteCntGreat2, ByteCntMaxFrame,
73
                     CrcError, StateIdle, StatePreamble, StateSFD, StateData
74
                    );
75
 
76
parameter Tp = 1;
77
 
78
 
79
 
80
input         MRxClk;
81
input         MRxDV;
82
input   [3:0] MRxD;
83
input         Transmitting;
84
input         HugEn;
85
input         DlyCrcEn;
86
input  [15:0] MaxFL;
87
input         r_IFG;
88
input         Reset;
89
 
90
output  [7:0] RxData;
91
output        RxValid;
92
output        RxStartFrm;
93
output        RxEndFrm;
94
output  [8:0] CrcHash;
95
output        CrcHashGood;
96
output        Broadcast;
97
output        Multicast;
98
output [15:0] ByteCnt;
99
output        ByteCntEq0;
100
output        ByteCntGreat2;
101
output        ByteCntMaxFrame;
102
output        CrcError;
103
output        StateIdle;
104
output        StatePreamble;
105
output        StateSFD;
106
output  [1:0] StateData;
107
 
108
reg     [7:0] RxData;
109
reg           RxValid;
110
reg           RxStartFrm;
111
reg           RxEndFrm;
112
reg           Broadcast;
113
reg           Multicast;
114
reg     [8:0] CrcHash;
115
reg           CrcHashGood;
116
reg           DelayData;
117
reg     [3:0] LatchedNibble;
118
reg     [7:0] LatchedByte;
119
reg     [7:0] RxData_d;
120
reg           RxValid_d;
121
reg           RxStartFrm_d;
122
reg           RxEndFrm_d;
123
 
124
wire          MRxDEqD;
125
wire          MRxDEq5;
126
wire          StateDrop;
127
wire          ByteCntEq1;
128
wire          ByteCntEq6;
129
wire          ByteCntSmall7;
130
wire   [31:0] Crc;
131
wire          Enable_Crc;
132
wire          Initialize_Crc;
133
wire    [3:0] Data_Crc;
134
wire          GenerateRxValid;
135
wire          GenerateRxStartFrm;
136
wire          GenerateRxEndFrm;
137
wire          DribbleRxEndFrm;
138
wire    [3:0] DlyCrcCnt;
139
 
140
 
141
 
142
assign MRxDEqD = MRxD == 4'hd;
143
assign MRxDEq5 = MRxD == 4'h5;
144
 
145
 
146
// Rx State Machine module
147
eth_rxstatem rxstatem1 (.MRxClk(MRxClk), .Reset(Reset), .MRxDV(MRxDV), .ByteCntEq0(ByteCntEq0),
148
                        .ByteCntGreat2(ByteCntGreat2), .Transmitting(Transmitting), .MRxDEq5(MRxDEq5),
149
                        .MRxDEqD(MRxDEqD), .IFGCounterEq24(IFGCounterEq24), .ByteCntMaxFrame(ByteCntMaxFrame),
150
                        .StateData(StateData), .StateIdle(StateIdle), .StatePreamble(StatePreamble),
151
                        .StateSFD(StateSFD), .StateDrop(StateDrop)
152
                       );
153
 
154
 
155
// Rx Counters module
156
eth_rxcounters rxcounters1 (.MRxClk(MRxClk), .Reset(Reset), .MRxDV(MRxDV), .StateIdle(StateIdle),
157
                            .StateSFD(StateSFD), .StateData(StateData), .StateDrop(StateDrop),
158
                            .StatePreamble(StatePreamble), .MRxDEqD(MRxDEqD), .DlyCrcEn(DlyCrcEn),
159
                            .DlyCrcCnt(DlyCrcCnt), .Transmitting(Transmitting), .MaxFL(MaxFL), .r_IFG(r_IFG),
160
                            .HugEn(HugEn), .IFGCounterEq24(IFGCounterEq24), .ByteCntEq0(ByteCntEq0),
161
                            .ByteCntEq1(ByteCntEq1), .ByteCntEq6(ByteCntEq6), .ByteCntGreat2(ByteCntGreat2),
162
                            .ByteCntSmall7(ByteCntSmall7), .ByteCntMaxFrame(ByteCntMaxFrame),
163
                            .ByteCnt(ByteCnt)
164
                           );
165
 
166
 
167
 
168
assign Enable_Crc = MRxDV & (|StateData & ~ByteCntMaxFrame);
169
assign Initialize_Crc = StateSFD | DlyCrcEn & (|DlyCrcCnt[3:0]) & DlyCrcCnt[3:0] < 4'h9;
170
 
171
assign Data_Crc[0] = MRxD[3];
172
assign Data_Crc[1] = MRxD[2];
173
assign Data_Crc[2] = MRxD[1];
174
assign Data_Crc[3] = MRxD[0];
175
 
176
 
177
// Connecting module Crc
178
eth_crc crcrx (.Clk(MRxClk), .Reset(Reset), .Data(Data_Crc), .Enable(Enable_Crc), .Initialize(Initialize_Crc),
179
               .Crc(Crc), .CrcError(CrcError)
180
          );
181
 
182
 
183
 
184
// Latching CRC for use in the hash table
185
 
186
always @ (posedge MRxClk)
187
begin
188
  CrcHashGood <= #Tp StateData[0] & ByteCntEq6;
189
end
190
 
191
always @ (posedge MRxClk)
192
begin
193
  if(Reset | StateIdle)
194
    CrcHash[8:0] <= #Tp 9'h0;
195
  else
196
  if(StateData[0] & ByteCntEq6)
197
    CrcHash[8:0] <= #Tp Crc[31:23];
198
end
199
 
200
 
201
// Output byte stream
202
always @ (posedge MRxClk or posedge Reset)
203
begin
204
  if(Reset)
205
    begin
206
      RxData_d[7:0]      <= #Tp 8'h0;
207
      DelayData          <= #Tp 1'b0;
208
      LatchedNibble[3:0] <= #Tp 4'h0;
209
      LatchedByte[7:0]   <= #Tp 8'h0;
210
      RxData[7:0]        <= #Tp 8'h0;
211
    end
212
  else
213
    begin
214
      LatchedNibble[3:0] <= #Tp MRxD[3:0];                        // Latched nibble
215
      LatchedByte[7:0]   <= #Tp {MRxD[3:0], LatchedNibble[3:0]};  // Latched byte
216
      DelayData          <= #Tp StateData[0];
217
 
218
      if(GenerateRxValid)
219
        RxData_d[7:0] <= #Tp LatchedByte[7:0] & {8{|StateData}};  // Data goes through only in data state 
220
      else
221
      if(~DelayData)
222
        RxData_d[7:0] <= #Tp 8'h0;                                // Delaying data to be valid for two cycles. Zero when not active.
223
 
224
      RxData[7:0] <= #Tp RxData_d[7:0];                           // Output data byte
225
    end
226
end
227
 
228
 
229
 
230
always @ (posedge MRxClk or posedge Reset)
231
begin
232
  if(Reset)
233
    Broadcast <= #Tp 1'b0;
234
  else
235
    begin
236
      if(StateData[0] & ~(&LatchedByte[7:0]) & ByteCntSmall7)
237
        Broadcast <= #Tp 1'b0;
238
      else
239 18 mohor
      if(StateData[0] & (&LatchedByte[7:0]) & ByteCntEq1)
240 15 mohor
        Broadcast <= #Tp 1'b1;
241
    end
242
end
243
 
244
 
245
always @ (posedge MRxClk or posedge Reset)
246
begin
247
  if(Reset)
248
    Multicast <= #Tp 1'b0;
249
  else
250
    begin
251
      if(Reset)
252
        Multicast <= #Tp 1'b0;
253
      else
254
      if(StateData[0] & ByteCntEq1)
255
        Multicast <= #Tp LatchedByte[0];
256
    end
257
end
258
 
259
 
260
assign GenerateRxValid = StateData[0] & (~ByteCntEq0 | DlyCrcCnt >= 4'h3);
261
 
262
always @ (posedge MRxClk or posedge Reset)
263
begin
264
  if(Reset)
265
    begin
266
      RxValid_d <= #Tp 1'b0;
267
      RxValid   <= #Tp 1'b0;
268
    end
269
  else
270
    begin
271
      RxValid_d <= #Tp GenerateRxValid;
272
      RxValid   <= #Tp RxValid_d;
273
    end
274
end
275
 
276
 
277
assign GenerateRxStartFrm = StateData[0] & (ByteCntEq1 & ~DlyCrcEn | DlyCrcCnt == 4'h3 & DlyCrcEn);
278
 
279
always @ (posedge MRxClk or posedge Reset)
280
begin
281
  if(Reset)
282
    begin
283
      RxStartFrm_d <= #Tp 1'b0;
284
      RxStartFrm   <= #Tp 1'b0;
285
    end
286
  else
287
    begin
288
      RxStartFrm_d <= #Tp GenerateRxStartFrm;
289
      RxStartFrm   <= #Tp RxStartFrm_d;
290
    end
291
end
292
 
293
 
294
assign GenerateRxEndFrm = StateData[0] & (~MRxDV & ByteCntGreat2 | ByteCntMaxFrame);
295
assign DribbleRxEndFrm  = StateData[1] &  ~MRxDV & ByteCntGreat2;
296
 
297
 
298
always @ (posedge MRxClk or posedge Reset)
299
begin
300
  if(Reset)
301
    begin
302
      RxEndFrm_d <= #Tp 1'b0;
303
      RxEndFrm   <= #Tp 1'b0;
304
    end
305
  else
306
    begin
307
      RxEndFrm_d <= #Tp GenerateRxEndFrm;
308
      RxEndFrm   <= #Tp RxEndFrm_d | DribbleRxEndFrm;
309
    end
310
end
311
 
312
 
313
endmodule

powered by: WebSVN 2.1.0

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