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

Subversion Repositories ethmac10g

[/] [ethmac10g/] [trunk/] [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 69 fisher5090
////                                                              ////
3
//// MODULE NAME: Frame Length Checker                            ////
4
////                                                              ////
5 39 fisher5090
//// DESCRIPTION: Frame Length Checker of  10 Gigabit             ////
6 69 fisher5090
////     Ethernet MAC. Many statistics are implemented            ////
7 39 fisher5090
////     here.                                                    ////
8 69 fisher5090
////                                                              ////
9 39 fisher5090
//// This file is part of the 10 Gigabit Ethernet IP core project ////
10 69 fisher5090
////  http://www.opencores.org/projects/ethmac10g/                ////
11
////                                                              ////
12
//// AUTHOR(S):                                                   ////
13
//// Zheng Cao                                                    ////
14
////                                                              ////
15 39 fisher5090
//////////////////////////////////////////////////////////////////////
16 69 fisher5090
////                                                              ////
17
//// Copyright (c) 2005 AUTHORS.  All rights reserved.            ////
18
////                                                              ////
19 39 fisher5090
//// 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 69 fisher5090
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40 39 fisher5090
//////////////////////////////////////////////////////////////////////
41
//
42
// CVS REVISION HISTORY:
43
//
44
// $Log: not supported by cvs2svn $
45 69 fisher5090
// Revision 1.1.1.1  2006/05/31 05:59:42  Zheng Cao
46
// first version
47
//
48 39 fisher5090
// Revision 1.1  2005/12/25 16:43:10  Zheng Cao
49
// 
50
// 
51
//
52
//////////////////////////////////////////////////////////////////////
53
 
54
`include "timescale.v"
55
`include "xgiga_define.v"
56
 
57
module rxLenTypChecker(rxclk, reset, get_terminator, terminator_location, jumbo_enable, tagged_frame,
58
       frame_cnt, vlan_enable,length_error,large_error, small_error, padded_frame, length_65_127,
59 69 fisher5090
       length_128_255, length_256_511, length_512_1023, length_1024_max,jumbo_frame);
60
 
61
    input  rxclk;
62
    input  reset;
63 39 fisher5090
    input  jumbo_enable; //Enable jumbo frame recieving
64 69 fisher5090
    input  vlan_enable;  //VLAN mode enable bit
65 39 fisher5090
    input  tagged_frame;         //number of 64bits DATA field of tagged frame contains
66 69 fisher5090
    input  get_terminator;
67
    input[`COUNTER_WIDTH-1:0] frame_cnt;
68
    input[2:0] terminator_location;
69 39 fisher5090
 
70 69 fisher5090
    output length_error;
71
    output large_error;
72
    output small_error;
73
    output padded_frame;
74
    output length_65_127;
75
    output length_128_255;
76
    output length_256_511;
77
    output length_512_1023;
78
    output length_1024_max;
79
    output jumbo_frame;
80
 
81
    parameter TP =1 ;
82 39 fisher5090
 
83 69 fisher5090
    reg [2:0]location_reg;
84
    always@(posedge rxclk or posedge reset)begin
85
         if (reset)
86
           location_reg <=#TP 0;
87
         else if(get_terminator)
88
           location_reg <=#TP terminator_location;
89
         else
90
           location_reg <=#TP location_reg;
91
         end
92 39 fisher5090
 
93 69 fisher5090
    reg large_error;
94
    always@(posedge rxclk or posedge reset)begin
95
         if(reset)
96
           large_error <=#TP 1'b0;
97
         else if(tagged_frame & vlan_enable) begin
98
             if ((frame_cnt == `MAX_TAG_LENGTH) & (location_reg > `MAX_TAG_BITS_MORE))
99
                large_error <=#TP 1'b1;
100
             else if ((frame_cnt > `MAX_TAG_LENGTH) & ~jumbo_enable)
101
                large_error <=#TP 1'b1;
102
             else if(frame_cnt > `MAX_JUMBO_LENGTH)
103
                large_error <=#TP 1'b1;
104
             else
105
                large_error <=#TP 1'b0;
106
         end
107
         else begin
108
             if ((frame_cnt == `MAX_VALID_LENGTH) & (location_reg > `MAX_VALID_BITS_MORE))
109
               large_error <=#TP 1'b1;
110
             else if((frame_cnt > `MAX_VALID_LENGTH) & ~jumbo_enable)
111
               large_error <=#TP 1'b1;
112
             else if(frame_cnt > `MAX_JUMBO_LENGTH)
113
               large_error <=#TP 1'b1;
114
             else
115
               large_error <=#TP 1'b0;
116
         end
117
    end
118 39 fisher5090
 
119 69 fisher5090
    reg small_error;
120
    always@(posedge rxclk or posedge reset) begin
121
         if(reset)
122
           small_error <=#TP 0;
123
    else
124
           small_error <=#TP get_terminator & (frame_cnt< `MIN_VALID_LENGTH);
125
    end
126 39 fisher5090
 
127 69 fisher5090
    wire length_error;
128
    assign length_error = small_error | large_error;
129
 
130
    /////////////////////////////////////////////////
131
    // Statistic signals
132
    /////////////////////////////////////////////////    
133
 
134
    ///////////////////////////////////
135
    // 64byte frame received OK
136
    ///////////////////////////////////
137 39 fisher5090
 
138 69 fisher5090
    reg padded_frame;
139
    always@(posedge rxclk or posedge reset) begin
140
          if(reset)
141
            padded_frame <=#TP 0;
142
          else
143
            padded_frame <=#TP get_terminator & (frame_cnt==`MIN_VALID_LENGTH);
144
    end
145 39 fisher5090
 
146 69 fisher5090
    ///////////////////////////////////
147
    // 65-127 byte Frame Received OK
148
    ///////////////////////////////////
149 39 fisher5090
 
150 69 fisher5090
    reg length_65_127;
151
    always@(posedge rxclk or posedge reset) begin
152
          if(reset)
153
            length_65_127 <=#TP 0;
154
          else
155
            length_65_127 <=#TP get_terminator & (frame_cnt>`MIN_VALID_LENGTH) & (frame_cnt <=127);
156
    end
157 39 fisher5090
 
158 69 fisher5090
    ///////////////////////////////////
159
    // 128-255 byte Frame Received OK
160
    ///////////////////////////////////
161 39 fisher5090
 
162 69 fisher5090
    reg length_128_255;
163
    always@(posedge rxclk or posedge reset) begin
164
         if(reset)
165
           length_128_255 <=#TP 0;
166
         else
167
           length_128_255 <=#TP get_terminator & (frame_cnt>128) & (frame_cnt <=255);
168
    end
169 39 fisher5090
 
170 69 fisher5090
    ///////////////////////////////////
171
    // 256-511 byte Frame Received OK
172
    ///////////////////////////////////
173 39 fisher5090
 
174 69 fisher5090
    reg length_256_511;
175
    always@(posedge rxclk or posedge reset) begin
176
         if(reset)
177
           length_256_511 <=#TP 0;
178
         else
179
           length_256_511 <=#TP get_terminator & (frame_cnt>256) & (frame_cnt <=511);
180
    end
181 39 fisher5090
 
182 69 fisher5090
    ///////////////////////////////////
183
    // 512-1023 byte Frame Received OK
184
    ///////////////////////////////////
185 39 fisher5090
 
186 69 fisher5090
    reg length_512_1023;
187
    always@(posedge rxclk or posedge reset) begin
188
         if(reset)
189
           length_512_1023 <=#TP 0;
190
         else
191
           length_512_1023 <=#TP get_terminator & (frame_cnt>512) & (frame_cnt <=1023);
192
    end
193 39 fisher5090
 
194 69 fisher5090
    ///////////////////////////////////
195
    // 1024-max byte Frame Received OK
196
    ///////////////////////////////////
197 39 fisher5090
 
198 69 fisher5090
    reg length_1024_max;
199
    always@(posedge rxclk or posedge reset) begin
200
         if(reset)
201
           length_1024_max <=#TP 0;
202
         else
203
           length_1024_max <=#TP get_terminator & (frame_cnt>1024) & (frame_cnt <=`MAX_VALID_LENGTH);
204
    end
205 39 fisher5090
 
206 69 fisher5090
    //////////////////////////////////////////////
207
    // Count for Control Frames Received OK
208
    //////////////////////////////////////////////
209
    //how to indicate a control frame(not clearly specificated in 802.3
210 39 fisher5090
 
211 69 fisher5090
    ///////////////////////////////////////////////
212
    // Count for Oversize Frames Received OK
213
    ///////////////////////////////////////////////
214
 
215
    reg jumbo_frame;
216
    always@(posedge rxclk or posedge reset) begin
217
         if(reset)
218
           jumbo_frame <=#TP 0;
219
         else
220
           jumbo_frame <=#TP get_terminator & jumbo_enable & (frame_cnt > `MAX_VALID_LENGTH) & (frame_cnt < `MAX_JUMBO_LENGTH);
221
    end
222 39 fisher5090
 
223
endmodule

powered by: WebSVN 2.1.0

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