1 |
4 |
fisher5090 |
`timescale 1ns / 1ps
|
2 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
3 |
|
|
// Company:
|
4 |
|
|
// Engineer:
|
5 |
|
|
//
|
6 |
|
|
// Create Date: 17:21:58 11/24/05
|
7 |
|
|
// Design Name:
|
8 |
|
|
// Module Name: rxNumCounter
|
9 |
|
|
// Project Name:
|
10 |
|
|
// Target Device:
|
11 |
|
|
// Tool versions:
|
12 |
|
|
// Description: This module only deals with cycles with 64bits
|
13 |
|
|
//
|
14 |
|
|
// Dependencies:
|
15 |
|
|
//
|
16 |
|
|
// Revision:
|
17 |
|
|
// Revision 0.01 - File Created
|
18 |
|
|
// Additional Comments:
|
19 |
|
|
//
|
20 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
21 |
|
|
|
22 |
|
|
module rxNumCounter(rxclk, reset, start_data_cnt, start_tagged_cnt, small_frame,
|
23 |
|
|
integer_cnt, small_integer_cnt, end_data_cnt, tagged_frame,
|
24 |
|
|
end_small_cnt, end_tagged_cnt);
|
25 |
|
|
|
26 |
|
|
input rxclk; //receive clk
|
27 |
|
|
input reset; //globe reset
|
28 |
|
|
|
29 |
|
|
input start_data_cnt; //start to count data field
|
30 |
|
|
input start_tagged_cnt; //start to count tagged frame
|
31 |
|
|
|
32 |
|
|
input small_frame;
|
33 |
|
|
input tagged_frame;
|
34 |
|
|
|
35 |
|
|
input[12:0] integer_cnt; //number of 64bits DATA field contains
|
36 |
|
|
input[12:0] small_integer_cnt;//number of 64bits real DATA field contains(without pad part)
|
37 |
|
|
|
38 |
|
|
output end_data_cnt; //end of data field(only 64bits aligned data)
|
39 |
|
|
output end_small_cnt; //end of true data field of small frame(only 64bits aligned data)
|
40 |
|
|
output end_tagged_cnt; //end of true data field of tagged frame(only 64bits aligned data)
|
41 |
|
|
|
42 |
|
|
wire end_cnt;
|
43 |
|
|
wire[12:0] data_cnt;
|
44 |
|
|
wire[12:0] tagged_data_cnt;
|
45 |
|
|
wire end_normal_data_cnt;
|
46 |
|
|
|
47 |
|
|
// Data counter
|
48 |
|
|
// used in rxReceiveData field,
|
49 |
|
|
// this counter is used for frames whose length is larger than 64
|
50 |
|
|
// Of course it also count actual bytes of frames whose length is shorter than 64.
|
51 |
|
|
counter data_counter(.clk(rxclk), .reset(reset), .load(end_cnt), .en(start_data_cnt), .value(data_cnt));
|
52 |
|
|
defparam data_counter.WIDTH = 13;
|
53 |
|
|
|
54 |
|
|
counter tagged_counter(.clk(rxclk), .reset(reset), .load(end_tagged_cnt), .en(start_tagged_cnt), .value(tagged_data_cnt));
|
55 |
|
|
defparam tagged_counter.WIDTH = 13;
|
56 |
|
|
|
57 |
|
|
assign end_cnt = end_data_cnt | start_tagged_cnt | ~start_data_cnt;
|
58 |
|
|
|
59 |
|
|
assign end_normal_data_cnt = (data_cnt == integer_cnt);
|
60 |
|
|
|
61 |
|
|
assign end_small_cnt = small_frame & (data_cnt == small_integer_cnt);
|
62 |
|
|
|
63 |
|
|
assign end_tagged_cnt = tagged_frame & (tagged_data_cnt == integer_cnt);
|
64 |
|
|
|
65 |
|
|
assign end_data_cnt = end_tagged_cnt | end_normal_data_cnt;
|
66 |
|
|
|
67 |
|
|
endmodule
|