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

Subversion Repositories ethmac

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

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

powered by: WebSVN 2.1.0

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