1 |
4 |
fisher5090 |
`timescale 1ns / 1ps
|
2 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
3 |
|
|
// Company:
|
4 |
|
|
// Engineer:
|
5 |
|
|
//
|
6 |
|
|
// Create Date: 21:23:10 11/21/05
|
7 |
|
|
// Design Name:
|
8 |
|
|
// Module Name: rxLenTypChecker
|
9 |
|
|
// Project Name:
|
10 |
|
|
// Target Device:
|
11 |
|
|
// Tool versions:
|
12 |
|
|
// Description:
|
13 |
|
|
//
|
14 |
|
|
// Dependencies:
|
15 |
|
|
//
|
16 |
|
|
// Revision:
|
17 |
|
|
// Revision 0.01 - File Created
|
18 |
|
|
// Additional Comments: Length/Type:
|
19 |
|
|
// 1. <64: Length, we should remove PAD
|
20 |
|
|
// 2. >=64, <= 1518: Length, valid frame, we don't need remove PAD(0x2E, 0x5DC)
|
21 |
|
|
// 3. >=1518: <9k+18: Length, jumbo frame, if supported (0x5DC, 0x2400)
|
22 |
|
|
// 4. >9k+18, = 0x8100: Type, Tagged frame
|
23 |
|
|
// 5. >9k+18, = 0x8808: Type, pause frame
|
24 |
|
|
|
25 |
|
|
// |<------------------------------ Data Field ---------------------------->|
|
26 |
|
|
// |<------------- True Data Field --------------> <-----Padded bits------->|
|
27 |
|
|
// |____________________________|_________________|
|
28 |
|
|
// | | |
|
29 |
|
|
// | small_integer_cnt * 64 | small_bits_more |
|
30 |
|
|
// |____________________________|_________________|____
|
31 |
|
|
// |___________________________________________________|_____________________
|
32 |
|
|
// | | |
|
33 |
|
|
// | integer_cnt * 64 | bits_more |
|
34 |
|
|
// |___________________________________________________|____________________|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
|
39 |
|
|
module rxLenTypChecker(lt_data, tagged_len, jumbo_enable, tagged_frame, pause_frame, small_frame,
|
40 |
|
|
len_invalid, integer_cnt, small_integer_cnt, bits_more, inband_fcs,
|
41 |
|
|
small_bits_more, vlan_enable );
|
42 |
|
|
|
43 |
|
|
input[15:0] lt_data; //Length or Type field of a frame
|
44 |
|
|
input[15:0] tagged_len; //Actual length carried with tagged frame
|
45 |
|
|
input jumbo_enable; //Enable jumbo frame recieving
|
46 |
|
|
input inband_fcs; //In-band FCS
|
47 |
|
|
input vlan_enable; //VLAN mode enable bit
|
48 |
|
|
|
49 |
|
|
output pause_frame; //Indicate that current frame is a pause frame (a kind of control frame)
|
50 |
|
|
output small_frame;
|
51 |
|
|
output len_invalid; //Indicate that current frame is not an valid frame
|
52 |
|
|
|
53 |
|
|
output[12:0] integer_cnt; //number of 64bits DATA field contains
|
54 |
|
|
output[12:0] small_integer_cnt; //number of 64bits real DATA field contains(without pad part)
|
55 |
|
|
|
56 |
|
|
output tagged_frame; //number of 64bits DATA field of tagged frame contains
|
57 |
|
|
|
58 |
|
|
output[2:0] bits_more; //number that is less than 64bits(whole data field)
|
59 |
|
|
output[2:0] small_bits_more; //number that is less than 64bits(unpadded data field)
|
60 |
|
|
|
61 |
|
|
wire[15:0] current_len;
|
62 |
|
|
wire[15:0] current_cnt;
|
63 |
|
|
wire small_frame;
|
64 |
|
|
wire tagged_frame;
|
65 |
|
|
|
66 |
|
|
parameter TP =1 ;
|
67 |
|
|
|
68 |
|
|
assign current_len = tagged_frame?(tagged_len+2):(lt_data-2); //Data field length
|
69 |
|
|
|
70 |
|
|
assign current_cnt = current_len >> 3; //the number of 64bits data field has
|
71 |
|
|
|
72 |
|
|
assign padded_frame = (current_len[15:6]==0) & (~current_len[5] | (current_len[5] & ~current_len[4]));
|
73 |
|
|
|
74 |
|
|
assign small_frame = padded_frame & ~inband_fcs; //padded frame
|
75 |
|
|
|
76 |
|
|
assign bits_more = padded_frame? 4 :current_len[2:0]; // bits that is not 64bits enough
|
77 |
|
|
|
78 |
|
|
assign small_bits_more = current_len[2:0];// for situation smaller than 64
|
79 |
|
|
|
80 |
|
|
assign integer_cnt = padded_frame? 5 :current_cnt[12:0];
|
81 |
|
|
|
82 |
|
|
assign small_integer_cnt = current_cnt[12:0];
|
83 |
|
|
|
84 |
|
|
assign tagged_frame = (lt_data==16'h8100) & vlan_enable;
|
85 |
|
|
|
86 |
|
|
assign pause_frame = (lt_data==16'h8808);
|
87 |
|
|
|
88 |
|
|
assign len_invalid = ((~jumbo_enable & (lt_data > 1500)) & ~(tagged_frame|pause_frame)) | (~vlan_enable & tagged_frame);
|
89 |
|
|
//not a large frame(except LT is type interpretion) when jumbo is not enabled, not a tagged frame when vlan is not enbaled
|
90 |
|
|
endmodule
|