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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_7/] [rtl/] [verilog/] [eth_rxethmac.v] - Blame information for rev 15

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

powered by: WebSVN 2.1.0

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