1 |
2 |
acastong |
//rx_farend_cnt_l3.cpp
|
2 |
|
|
|
3 |
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
4 |
|
|
* Version: MPL 1.1
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
7 |
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
8 |
|
|
* the License. You may obtain a copy of the License at
|
9 |
|
|
* http://www.mozilla.org/MPL/
|
10 |
|
|
*
|
11 |
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
12 |
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
13 |
|
|
* for the specific language governing rights and limitations under the
|
14 |
|
|
* License.
|
15 |
|
|
*
|
16 |
|
|
* The Original Code is HyperTransport Tunnel IP Core.
|
17 |
|
|
*
|
18 |
|
|
* The Initial Developer of the Original Code is
|
19 |
|
|
* Ecole Polytechnique de Montreal.
|
20 |
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
21 |
|
|
* the Initial Developer. All Rights Reserved.
|
22 |
|
|
*
|
23 |
|
|
* Contributor(s):
|
24 |
|
|
* Jean-Francois Belanger
|
25 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
26 |
|
|
*
|
27 |
|
|
* Alternatively, the contents of this file may be used under the terms
|
28 |
|
|
* of the Polytechnique HyperTransport Tunnel IP Core Source Code License
|
29 |
|
|
* (the "PHTICSCL License", see the file PHTICSCL.txt), in which case the
|
30 |
|
|
* provisions of PHTICSCL License are applicable instead of those
|
31 |
|
|
* above. If you wish to allow use of your version of this file only
|
32 |
|
|
* under the terms of the PHTICSCL License and not to allow others to use
|
33 |
|
|
* your version of this file under the MPL, indicate your decision by
|
34 |
|
|
* deleting the provisions above and replace them with the notice and
|
35 |
|
|
* other provisions required by the PHTICSCL License. If you do not delete
|
36 |
|
|
* the provisions above, a recipient may use your version of this file
|
37 |
|
|
* under either the MPL or the PHTICSCL License."
|
38 |
|
|
*
|
39 |
|
|
* ***** END LICENSE BLOCK ***** */
|
40 |
|
|
|
41 |
|
|
#include "rx_farend_cnt_l3.h"
|
42 |
|
|
|
43 |
|
|
rx_farend_cnt_l3::rx_farend_cnt_l3(sc_module_name name) : sc_module(name)
|
44 |
|
|
{
|
45 |
|
|
// generate est un thread
|
46 |
|
|
SC_METHOD(compte_buffer);
|
47 |
|
|
sensitive_pos << clock;
|
48 |
|
|
sensitive_neg << resetx;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
void rx_farend_cnt_l3::compte_buffer( void ) {
|
53 |
|
|
//When reset, reinitialize the buffer count
|
54 |
|
|
if (resetx.read() == false) {
|
55 |
|
|
for (int i=0 ;i < 6 ; i++) {
|
56 |
|
|
buffercount[i] = 0;
|
57 |
|
|
}
|
58 |
|
|
fwd_next_node_buffer_status_ro = "000000";
|
59 |
|
|
} else {
|
60 |
|
|
#ifdef RETRY_MODE_ENABLED
|
61 |
|
|
//During a retry sequence, the next node buffer count is reinitialized
|
62 |
|
|
if(clear_farend_count.read() == true){
|
63 |
|
|
for (int i=0 ;i < 6 ; i++) {
|
64 |
|
|
buffercount[i] = 0;
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
else
|
68 |
|
|
#endif
|
69 |
|
|
{
|
70 |
|
|
//Increase the count when a nop is received
|
71 |
|
|
sc_uint<FAREND_BUFFER_COUNT_SIZE + 1> buffercount_tmp[6] ;
|
72 |
|
|
if ( cd_nop_received_fc == true) {
|
73 |
|
|
|
74 |
|
|
//Temporary array of count which is one bit larger than the registry to allow
|
75 |
|
|
//overflow, which can then be saturated
|
76 |
|
|
|
77 |
|
|
//increment then buffercount according to the nop received
|
78 |
|
|
|
79 |
|
|
//response data
|
80 |
|
|
buffercount_tmp[0] = buffercount[0].read() + (cd_nopinfo_fc.read().range(7,6)).to_uint();
|
81 |
|
|
//response command
|
82 |
|
|
buffercount_tmp[1] = buffercount[1].read() + (cd_nopinfo_fc.read().range(5,4)).to_uint();
|
83 |
|
|
//non-posted data
|
84 |
|
|
buffercount_tmp[2] = buffercount[2].read() +
|
85 |
|
|
(cd_nopinfo_fc.read().range(11,10)).to_uint();
|
86 |
|
|
//non-posted command
|
87 |
|
|
buffercount_tmp[3] = buffercount[3].read() + (cd_nopinfo_fc.read().range(9,8)).to_uint();
|
88 |
|
|
//posted data
|
89 |
|
|
buffercount_tmp[4] = buffercount[4].read() + (cd_nopinfo_fc.read().range(3,2)).to_uint();
|
90 |
|
|
//posted command
|
91 |
|
|
buffercount_tmp[5] = buffercount[5].read() + (cd_nopinfo_fc.read().range(1,0)).to_uint();
|
92 |
|
|
} else {
|
93 |
|
|
for(int n = 0; n < 6; n++) {
|
94 |
|
|
buffercount_tmp[n] = buffercount[n].read();
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
//saturate the integer if the increment caused an overflow
|
99 |
|
|
for (int n = 0 ;n < 6 ; n++) {
|
100 |
|
|
if(buffercount_tmp[n][FAREND_BUFFER_COUNT_SIZE] == true) {
|
101 |
|
|
buffercount_tmp[n] = FAREND_BUFFER_COUNT_MAX_VALUE;
|
102 |
|
|
} else {
|
103 |
|
|
buffercount_tmp[n] = buffercount_tmp[n].range(FAREND_BUFFER_COUNT_SIZE - 1,0);
|
104 |
|
|
}
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
//Decrease the count when packet nop is sent
|
109 |
|
|
for (int n = 0 ;n < 6 ; n++) {
|
110 |
|
|
|
111 |
|
|
//decrement the buffercount if it is of the type being sent
|
112 |
|
|
if (current_sent_type.read()[n] == true ) {
|
113 |
|
|
buffercount_tmp[n] = buffercount_tmp[n] - 1;
|
114 |
|
|
}
|
115 |
|
|
buffercount[n] = buffercount_tmp[n];
|
116 |
|
|
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
//Output the result
|
120 |
|
|
sc_bv<6> fwd_next_node_buffer_status_ro_tmp;
|
121 |
|
|
for (int i=0 ;i < 6 ; i++) {
|
122 |
|
|
if (buffercount[i].read() != 0 ) {
|
123 |
|
|
fwd_next_node_buffer_status_ro_tmp[i] = true;
|
124 |
|
|
} else {
|
125 |
|
|
|
126 |
|
|
fwd_next_node_buffer_status_ro_tmp[i] = false;
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
fwd_next_node_buffer_status_ro = fwd_next_node_buffer_status_ro_tmp;
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
|