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

Subversion Repositories ethmac10g

[/] [ethmac10g/] [tags/] [V10/] [rtl/] [verilog/] [rx_engine/] [rxLenTypChecker.v] - Blame information for rev 72

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 fisher5090
//////////////////////////////////////////////////////////////////////
2
////                                                                                                                                                                    ////
3
//// MODULE NAME: Frame Length Checker                                                                          ////
4
////                                                                                                                                                                    ////
5
//// DESCRIPTION: Frame Length Checker of  10 Gigabit             ////
6
////     Ethernet MAC. Many statistics are implemented                          ////
7
////     here.                                                    ////
8
////                                                                                                                                                                    ////
9
//// This file is part of the 10 Gigabit Ethernet IP core project ////
10
////  http://www.opencores.org/projects/ethmac10g/                                              ////
11
////                                                                                                                                                                    ////
12
//// AUTHOR(S):                                                                                                                                 ////
13
//// Zheng Cao                                                               ////
14
////                                                                                                    ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                                                                                                                                    ////
17
//// Copyright (c) 2005 AUTHORS.  All rights reserved.                     ////
18
////                                                                                                                                                                    ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                                                   ////
39
////                                                                                                                                                                    ////
40
//////////////////////////////////////////////////////////////////////
41
//
42
// CVS REVISION HISTORY:
43
//
44
// $Log: not supported by cvs2svn $
45
// Revision 1.1  2005/12/25 16:43:10  Zheng Cao
46
// 
47
// 
48
//
49
//////////////////////////////////////////////////////////////////////
50
 
51
`include "timescale.v"
52
`include "xgiga_define.v"
53
 
54
module rxLenTypChecker(rxclk, reset, get_terminator, terminator_location, jumbo_enable, tagged_frame,
55
       frame_cnt, vlan_enable,length_error,large_error, small_error, padded_frame, length_65_127,
56
                 length_128_255, length_256_511, length_512_1023, length_1024_max,jumbo_frame);
57
 
58
         input  rxclk;
59
         input  reset;
60
    input  jumbo_enable; //Enable jumbo frame recieving
61
         input  vlan_enable;  //VLAN mode enable bit
62
    input  tagged_frame;         //number of 64bits DATA field of tagged frame contains
63
         input  get_terminator;
64
         input[`COUNTER_WIDTH-1:0] frame_cnt;
65
         input[2:0] terminator_location;
66
 
67
         output length_error;
68
         output large_error;
69
         output small_error;
70
         output padded_frame;
71
         output length_65_127;
72
         output length_128_255;
73
         output length_256_511;
74
         output length_512_1023;
75
         output length_1024_max;
76
         output jumbo_frame;
77
 
78
         parameter TP =1 ;
79
 
80
         reg [2:0]location_reg;
81
         always@(posedge rxclk or posedge reset)begin
82
               if (reset)
83
                            location_reg <=#TP 0;
84
                         else if(get_terminator)
85
                            location_reg <=#TP terminator_location;
86
                         else
87
                            location_reg <=#TP location_reg;
88
         end
89
 
90
         reg large_error;
91
         always@(posedge rxclk or posedge reset)begin
92
               if(reset)
93
                            large_error <=#TP 1'b0;
94
                         else if(tagged_frame & vlan_enable) begin
95
                             if ((frame_cnt == `MAX_TAG_LENGTH) & (location_reg > `MAX_TAG_BITS_MORE))
96
                                     large_error <=#TP 1'b1;
97
                                  else if ((frame_cnt > `MAX_TAG_LENGTH) & ~jumbo_enable)
98
                                     large_error <=#TP 1'b1;
99
              else if(frame_cnt > `MAX_JUMBO_LENGTH)
100
                                     large_error <=#TP 1'b1;
101
                                  else
102
                                     large_error <=#TP 1'b0;
103
                         end
104
                         else begin
105
                                  if ((frame_cnt == `MAX_VALID_LENGTH) & (location_reg > `MAX_VALID_BITS_MORE))
106
                                large_error <=#TP 1'b1;
107
                             else if((frame_cnt > `MAX_VALID_LENGTH) & ~jumbo_enable)
108
                                large_error <=#TP 1'b1;
109
              else if(frame_cnt > `MAX_JUMBO_LENGTH)
110
                                     large_error <=#TP 1'b1;
111
              else
112
                                large_error <=#TP 1'b0;
113
                         end
114
         end
115
 
116
         reg small_error;
117
         always@(posedge rxclk or posedge reset) begin
118
               if(reset)
119
                           small_error <=#TP 0;
120
                         else
121
                           small_error <=#TP get_terminator & (frame_cnt< `MIN_VALID_LENGTH);
122
         end
123
 
124
         wire length_error;
125
         assign length_error = small_error | large_error;
126
 
127
         /////////////////////////////////////////////////
128
         // Statistic signals
129
         /////////////////////////////////////////////////                  
130
 
131
         ///////////////////////////////////
132
         // 64byte frame received OK
133
         ///////////////////////////////////
134
 
135
         reg padded_frame;
136
         always@(posedge rxclk or posedge reset) begin
137
                if(reset)
138
                            padded_frame <=#TP 0;
139
                          else
140
                            padded_frame <=#TP get_terminator & (frame_cnt==`MIN_VALID_LENGTH);
141
         end
142
 
143
         ///////////////////////////////////
144
         // 65-127 byte Frame Received OK
145
         ///////////////////////////////////
146
 
147
         reg length_65_127;
148
         always@(posedge rxclk or posedge reset) begin
149
                if(reset)
150
                            length_65_127 <=#TP 0;
151
                          else
152
                            length_65_127 <=#TP get_terminator & (frame_cnt>`MIN_VALID_LENGTH) & (frame_cnt <=127);
153
         end
154
 
155
         ///////////////////////////////////
156
         // 128-255 byte Frame Received OK
157
         ///////////////////////////////////
158
 
159
         reg length_128_255;
160
         always@(posedge rxclk or posedge reset) begin
161
                if(reset)
162
                            length_128_255 <=#TP 0;
163
                          else
164
                            length_128_255 <=#TP get_terminator & (frame_cnt>128) & (frame_cnt <=255);
165
         end
166
 
167
         ///////////////////////////////////
168
         // 256-511 byte Frame Received OK
169
         ///////////////////////////////////
170
 
171
         reg length_256_511;
172
         always@(posedge rxclk or posedge reset) begin
173
                if(reset)
174
                            length_256_511 <=#TP 0;
175
                          else
176
                            length_256_511 <=#TP get_terminator & (frame_cnt>256) & (frame_cnt <=511);
177
         end
178
 
179
         ///////////////////////////////////
180
         // 512-1023 byte Frame Received OK
181
         ///////////////////////////////////
182
 
183
         reg length_512_1023;
184
         always@(posedge rxclk or posedge reset) begin
185
                if(reset)
186
                            length_512_1023 <=#TP 0;
187
                          else
188
                            length_512_1023 <=#TP get_terminator & (frame_cnt>512) & (frame_cnt <=1023);
189
         end
190
 
191
         ///////////////////////////////////
192
         // 1024-max byte Frame Received OK
193
         ///////////////////////////////////
194
 
195
         reg length_1024_max;
196
         always@(posedge rxclk or posedge reset) begin
197
                if(reset)
198
                            length_1024_max <=#TP 0;
199
                          else
200
                            length_1024_max <=#TP get_terminator & (frame_cnt>1024) & (frame_cnt <=`MAX_VALID_LENGTH);
201
         end
202
 
203
         //////////////////////////////////////////////
204
         // Count for Control Frames Received OK
205
         //////////////////////////////////////////////
206
         //how to indicate a control frame(not clearly specificated in 802.3
207
 
208
         ///////////////////////////////////////////////
209
         // Count for Oversize Frames Received OK
210
         ///////////////////////////////////////////////
211
 
212
         reg jumbo_frame;
213
         always@(posedge rxclk or posedge reset) begin
214
               if(reset)
215
                                jumbo_frame <=#TP 0;
216
                         else
217
                           jumbo_frame <=#TP get_terminator & jumbo_enable & (frame_cnt > `MAX_VALID_LENGTH) & (frame_cnt < `MAX_JUMBO_LENGTH);
218
         end
219
 
220
endmodule

powered by: WebSVN 2.1.0

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