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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [rtl/] [verilog/] [stats_sm.v] - Blame information for rev 24

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 antanguay
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "wishbone.v"                                      ////
4
////                                                              ////
5
////  This file is part of the "10GE MAC" project                 ////
6
////  http://www.opencores.org/cores/xge_mac/                     ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - A. Tanguay (antanguay@opencores.org)                  ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
 
39
`include "defines.v"
40
 
41
module stats_sm(/*AUTOARG*/
42
  // Outputs
43
  stats_tx_octets, stats_tx_pkts, stats_rx_octets, stats_rx_pkts,
44
  // Inputs
45
  wb_clk_i, wb_rst_i, txsfifo_rdata, txsfifo_rempty, rxsfifo_rdata,
46
  rxsfifo_rempty
47
  );
48
 
49
 
50
input         wb_clk_i;
51
input         wb_rst_i;
52
 
53
input  [13:0] txsfifo_rdata;
54
input         txsfifo_rempty;
55
 
56
input  [13:0] rxsfifo_rdata;
57
input         rxsfifo_rempty;
58
 
59
output [31:0] stats_tx_octets;
60
output [31:0] stats_tx_pkts;
61
 
62
output [31:0] stats_rx_octets;
63
output [31:0] stats_rx_pkts;
64
 
65
/*AUTOREG*/
66
// Beginning of automatic regs (for this module's undeclared outputs)
67
reg [31:0]              stats_rx_octets;
68
reg [31:0]              stats_rx_pkts;
69
reg [31:0]              stats_tx_octets;
70
reg [31:0]              stats_tx_pkts;
71
// End of automatics
72
 
73
 
74
/*AUTOWIRE*/
75
 
76
reg           txsfifo_rempty_d1;
77
reg           rxsfifo_rempty_d1;
78
 
79
reg [31:0]    next_stats_tx_octets;
80
reg [31:0]    next_stats_tx_pkts;
81
 
82
reg [31:0]    next_stats_rx_octets;
83
reg [31:0]    next_stats_rx_pkts;
84
 
85
always @(posedge wb_clk_i or posedge wb_rst_i) begin
86
 
87
    if (wb_rst_i == 1'b1) begin
88
 
89
        txsfifo_rempty_d1 <= 1'b1;
90
        rxsfifo_rempty_d1 <= 1'b1;
91
 
92
        stats_tx_octets <= 32'b0;
93
        stats_tx_pkts <= 32'b0;
94
 
95
        stats_rx_octets <= 32'b0;
96
        stats_rx_pkts <= 32'b0;
97
 
98
    end
99
    else begin
100
 
101
        txsfifo_rempty_d1 <= txsfifo_rempty;
102
        rxsfifo_rempty_d1 <= rxsfifo_rempty;
103
 
104
        stats_tx_octets <= next_stats_tx_octets;
105
        stats_tx_pkts <= next_stats_tx_pkts;
106
 
107
        stats_rx_octets <= next_stats_rx_octets;
108
        stats_rx_pkts <= next_stats_rx_pkts;
109
 
110
    end
111
 
112
end
113
 
114
always @(/*AS*/rxsfifo_rdata or rxsfifo_rempty_d1 or stats_rx_octets
115
         or stats_rx_pkts or stats_tx_octets or stats_tx_pkts
116
         or txsfifo_rdata or txsfifo_rempty_d1) begin
117
 
118
    next_stats_tx_octets = stats_tx_octets;
119
    next_stats_tx_pkts = stats_tx_pkts;
120
 
121
    next_stats_rx_octets = stats_rx_octets;
122
    next_stats_rx_pkts = stats_rx_pkts;
123
 
124
    if (!txsfifo_rempty_d1) begin
125
        next_stats_tx_octets = stats_tx_octets + {18'b0, txsfifo_rdata};
126
        next_stats_tx_pkts = stats_tx_pkts + 32'b1;
127
    end
128
 
129
    if (!rxsfifo_rempty_d1) begin
130
        next_stats_rx_octets = stats_rx_octets + {18'b0, rxsfifo_rdata};
131
        next_stats_rx_pkts = stats_rx_pkts + 32'b1;
132
    end
133
 
134
end
135
 
136
endmodule

powered by: WebSVN 2.1.0

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