1 |
2 |
acastong |
//entrance_reordering_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 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
25 |
|
|
* Laurent Aubray
|
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 |
|
|
|
42 |
|
|
#include "entrance_reordering_l3.h"
|
43 |
|
|
|
44 |
|
|
entrance_reordering_l3::entrance_reordering_l3(sc_module_name name) : sc_module(name){
|
45 |
|
|
SC_METHOD(packet_directing);
|
46 |
|
|
sensitive << in_packet << packet_available << csr_io_space_enable
|
47 |
|
|
#ifdef ENABLE_DIRECTROUTE
|
48 |
|
|
<< csr_direct_route_enable
|
49 |
|
|
#endif
|
50 |
|
|
<< unit_id << csr_memory_space_enable
|
51 |
|
|
<< increment_nposted_refid_upon_posted_accepted << nposted_refid_accepted
|
52 |
|
|
<< increment_response_refid_upon_posted_accepted << response_refid_accepted
|
53 |
|
|
<< increment_nposted_refid_upon_posted_rejected << nposted_refid_rejected
|
54 |
|
|
<< increment_response_refid_upon_posted_rejected << response_refid_rejected;
|
55 |
|
|
|
56 |
|
|
SC_METHOD(clocked_process);
|
57 |
|
|
sensitive_pos(clk);
|
58 |
|
|
sensitive_neg(resetx);
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
void entrance_reordering_l3::clocked_process(){
|
62 |
|
|
if(!resetx.read()){
|
63 |
|
|
increment_nposted_refid_upon_posted_accepted = false;
|
64 |
|
|
nposted_refid_accepted = 0;
|
65 |
|
|
increment_response_refid_upon_posted_accepted = false;
|
66 |
|
|
response_refid_accepted = 0;
|
67 |
|
|
increment_nposted_refid_upon_posted_rejected = false;
|
68 |
|
|
nposted_refid_rejected = 0;
|
69 |
|
|
increment_response_refid_upon_posted_rejected = false;
|
70 |
|
|
response_refid_rejected = 0;
|
71 |
|
|
}
|
72 |
|
|
else{
|
73 |
|
|
sc_bv<64> in_packet_bits = in_packet.read().packet;
|
74 |
|
|
|
75 |
|
|
increment_nposted_refid_upon_posted_rejected = increment_nposted_refid_upon_posted_rejected.read() &&
|
76 |
|
|
!(destination_pc[FWD_DEST].read() && packet_available.read())
|
77 |
|
|
|| (destination_npc[FWD_DEST].read() && packet_available.read() && !(sc_bit)in_packet_bits[15]);
|
78 |
|
|
increment_response_refid_upon_posted_rejected = increment_response_refid_upon_posted_rejected.read() &&
|
79 |
|
|
!(destination_pc[FWD_DEST].read() && packet_available.read())
|
80 |
|
|
|| (destination_rc[FWD_DEST].read() && packet_available.read() && !(sc_bit)in_packet_bits[15]);
|
81 |
|
|
nposted_refid_rejected = new_packet_nposted_refid_rejected.read();
|
82 |
|
|
response_refid_rejected = new_packet_response_refid_rejected.read();
|
83 |
|
|
|
84 |
|
|
increment_nposted_refid_upon_posted_accepted = increment_nposted_refid_upon_posted_accepted.read() &&
|
85 |
|
|
!(destination_pc[ACCEPTED_DEST].read() && packet_available.read())
|
86 |
|
|
|| (destination_npc[ACCEPTED_DEST].read() && packet_available.read() && !(sc_bit)in_packet_bits[15]);
|
87 |
|
|
increment_response_refid_upon_posted_accepted = increment_response_refid_upon_posted_accepted.read() &&
|
88 |
|
|
!(destination_pc[ACCEPTED_DEST].read() && packet_available.read())
|
89 |
|
|
|| (destination_rc[ACCEPTED_DEST].read() && packet_available.read() && !(sc_bit)in_packet_bits[15]);
|
90 |
|
|
nposted_refid_accepted = new_packet_nposted_refid_accepted.read();
|
91 |
|
|
response_refid_accepted = new_packet_response_refid_accepted.read();
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
void entrance_reordering_l3::packet_directing(void)
|
98 |
|
|
{
|
99 |
|
|
//Give default values to signals
|
100 |
|
|
for(int n = 0; n < 2; n++){
|
101 |
|
|
new_packet_available[n] = false;
|
102 |
|
|
|
103 |
|
|
destination_pc[n] = false;
|
104 |
|
|
destination_npc[n] = false;
|
105 |
|
|
destination_rc[n] = false;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
//Default values
|
109 |
|
|
new_packet_available[VC_POSTED] = false;
|
110 |
|
|
new_packet_available[VC_NON_POSTED] = false;
|
111 |
|
|
new_packet_available[VC_RESPONSE] = false;
|
112 |
|
|
|
113 |
|
|
//Well, directly send the packet to the virtual channels
|
114 |
|
|
sc_bv<64> in_packet_bits = in_packet.read().packet;
|
115 |
|
|
sc_bv<BUFFERS_ADDRESS_WIDTH> in_packet_data_addr = in_packet.read().data_address;
|
116 |
|
|
|
117 |
|
|
#ifdef ENABLE_REORDERING
|
118 |
|
|
new_packet_passPW = (sc_bit)in_packet_bits[15];
|
119 |
|
|
new_packet_chain = (sc_bit)in_packet_bits[19];
|
120 |
|
|
sc_uint<4> seqid_tmp;
|
121 |
|
|
seqid_tmp.range(1,0) = (sc_bv<2>)in_packet_bits.range(14,13);
|
122 |
|
|
seqid_tmp.range(3,2) = (sc_bv<2>)in_packet_bits.range(7,6);
|
123 |
|
|
new_packet_seqid = seqid_tmp;
|
124 |
|
|
|
125 |
|
|
sc_uint<5> unitID = getUnitID(in_packet.read().packet);
|
126 |
|
|
new_packet_clumped_unitid = clumped_unit_id[unitID].read();
|
127 |
|
|
#endif
|
128 |
|
|
|
129 |
|
|
/// Sends the incoming packet to the proper VC.
|
130 |
|
|
|
131 |
|
|
//Analyze basic packet features
|
132 |
|
|
sc_bv<64> pkt = in_packet.read().packet;
|
133 |
|
|
bool error64BitExtension = in_packet.read().error64BitExtension;
|
134 |
|
|
PacketCommand cmd = getPacketCommand(pkt.range(5,0));
|
135 |
|
|
VirtualChannel vc = getVirtualChannel(pkt, cmd);
|
136 |
|
|
|
137 |
|
|
#ifdef RETRY_MODE_ENABLED
|
138 |
|
|
//Output the VC so that the nophandler can know from which VC to free a flow control credit
|
139 |
|
|
//when a stomped packet is received (available is not asserted in that case, but the packet
|
140 |
|
|
//is valid
|
141 |
|
|
input_packet_vc = vc;
|
142 |
|
|
#endif
|
143 |
|
|
|
144 |
|
|
//The destinations that will be set
|
145 |
|
|
//bool destinationCsr = false;
|
146 |
|
|
bool request_goes_csr_or_user = request_goes_to_csr(pkt,error64BitExtension,cmd) ||
|
147 |
|
|
request_goes_to_user(pkt,error64BitExtension,cmd);
|
148 |
|
|
bool destination_accepted_posted_nposted = request_goes_csr_or_user || (cmd == BROADCAST);
|
149 |
|
|
bool destination_forward_posted_nposted = !request_goes_csr_or_user || (cmd == BROADCAST);
|
150 |
|
|
|
151 |
|
|
bool destination_accepted_response = response_goes_to_user(pkt);
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
// Grab the packet and direct it to the proper VC, depending on it's VC
|
155 |
|
|
bool vc_is_posted = vc == VC_POSTED;
|
156 |
|
|
bool destination_pc_accepted = destination_accepted_posted_nposted && vc_is_posted && packet_available.read();
|
157 |
|
|
bool destination_pc_fwd = destination_forward_posted_nposted && vc_is_posted && packet_available.read();
|
158 |
|
|
new_packet_available[VC_POSTED] = vc_is_posted && packet_available.read();
|
159 |
|
|
|
160 |
|
|
bool vc_is_nposted = vc == VC_NON_POSTED;
|
161 |
|
|
bool destination_npc_accepted = destination_accepted_posted_nposted && vc_is_nposted && packet_available.read();
|
162 |
|
|
bool destination_npc_fwd = destination_forward_posted_nposted && vc_is_nposted && packet_available.read();
|
163 |
|
|
new_packet_available[VC_NON_POSTED] = vc_is_nposted && packet_available.read();
|
164 |
|
|
|
165 |
|
|
bool vc_is_response = vc == VC_RESPONSE;
|
166 |
|
|
bool destination_rc_accepted = destination_accepted_response && vc_is_response && packet_available.read();
|
167 |
|
|
bool destination_rc_fwd = !destination_accepted_response && vc_is_response && packet_available.read();
|
168 |
|
|
new_packet_available[VC_RESPONSE] = vc_is_response && packet_available.read();
|
169 |
|
|
|
170 |
|
|
//Output what was calculated
|
171 |
|
|
destination_pc[ACCEPTED_DEST] = destination_pc_accepted;
|
172 |
|
|
destination_pc[FWD_DEST] = destination_pc_fwd;
|
173 |
|
|
destination_npc[ACCEPTED_DEST] = destination_npc_accepted;
|
174 |
|
|
destination_npc[FWD_DEST] = destination_npc_fwd;
|
175 |
|
|
destination_rc[ACCEPTED_DEST] = destination_rc_accepted;
|
176 |
|
|
destination_rc[FWD_DEST] = destination_rc_fwd;
|
177 |
|
|
|
178 |
|
|
//Use it to find if packet is accepted or not
|
179 |
|
|
bool in_packet_forward_tmp = destination_pc_fwd || destination_npc_fwd || destination_rc_fwd;
|
180 |
|
|
bool in_packet_accepted_tmp = destination_pc_accepted || destination_npc_accepted || destination_rc_accepted;
|
181 |
|
|
|
182 |
|
|
//Output the new refids for forward (rejected) destination
|
183 |
|
|
sc_uint<LOG2_NB_OF_BUFFERS+1> new_packet_nposted_refid_rejected_tmp;
|
184 |
|
|
sc_uint<LOG2_NB_OF_BUFFERS+1> new_packet_response_refid_rejected_tmp;
|
185 |
|
|
if(packet_available.read() && vc_is_posted &&
|
186 |
|
|
increment_nposted_refid_upon_posted_rejected.read() && in_packet_forward_tmp)
|
187 |
|
|
new_packet_nposted_refid_rejected_tmp = nposted_refid_rejected.read()+1;
|
188 |
|
|
else
|
189 |
|
|
new_packet_nposted_refid_rejected_tmp = nposted_refid_rejected.read();
|
190 |
|
|
if(packet_available.read() && vc_is_posted &&
|
191 |
|
|
increment_response_refid_upon_posted_rejected.read() && in_packet_forward_tmp)
|
192 |
|
|
new_packet_response_refid_rejected_tmp = response_refid_rejected.read()+1;
|
193 |
|
|
else
|
194 |
|
|
new_packet_response_refid_rejected_tmp = response_refid_rejected.read();
|
195 |
|
|
|
196 |
|
|
//Output the new refids for accepted destination
|
197 |
|
|
sc_uint<LOG2_NB_OF_BUFFERS+1> new_packet_nposted_refid_accepted_tmp;
|
198 |
|
|
sc_uint<LOG2_NB_OF_BUFFERS+1> new_packet_response_refid_accepted_tmp;
|
199 |
|
|
if(packet_available.read() && vc_is_posted &&
|
200 |
|
|
increment_nposted_refid_upon_posted_accepted.read() && in_packet_accepted_tmp)
|
201 |
|
|
new_packet_nposted_refid_accepted_tmp = nposted_refid_accepted.read()+1;
|
202 |
|
|
else
|
203 |
|
|
new_packet_nposted_refid_accepted_tmp = nposted_refid_accepted.read();
|
204 |
|
|
if(packet_available.read() && vc_is_posted &&
|
205 |
|
|
increment_response_refid_upon_posted_accepted.read() && in_packet_accepted_tmp)
|
206 |
|
|
new_packet_response_refid_accepted_tmp = response_refid_accepted.read()+1;
|
207 |
|
|
else
|
208 |
|
|
new_packet_response_refid_accepted_tmp = response_refid_accepted.read();
|
209 |
|
|
|
210 |
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
211 |
|
|
// Packet content, from this point (entrance reordering), is divided in two.
|
212 |
|
|
// A first part is sent to registers which can reorder the packets. The strict
|
213 |
|
|
// minimum number of bits is sent to registers because of their expensive nature.
|
214 |
|
|
//
|
215 |
|
|
// The rest of the packet is sent to an embedded memory. Fields of the packets which
|
216 |
|
|
// are sent to the registers can now be re-used to minimize the width of data sent
|
217 |
|
|
// to the embedded memory. Which bits can be re-used depends on the packet type.
|
218 |
|
|
// This part packs the most information depending on the virtual channel of the packet.
|
219 |
|
|
//
|
220 |
|
|
// Fields of packets that can be used are fields that are either reserved or sent to the
|
221 |
|
|
// registers :
|
222 |
|
|
// For Posted and non-posted packets
|
223 |
|
|
// -seqID is sent to registers : bits 7..6 and 14..13
|
224 |
|
|
// -passPW is sent to registers : bit 15
|
225 |
|
|
// For Response packets
|
226 |
|
|
// -Reserved bits : 6 and 13
|
227 |
|
|
// -passPW : 15
|
228 |
|
|
// -constant : command bits 5..2
|
229 |
|
|
// -unused bits : 63..32
|
230 |
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
231 |
|
|
|
232 |
|
|
//LOG2_NB_OF_BUFFERS
|
233 |
|
|
sc_bv<CMD_BUFFER_MEM_WIDTH> ro_command_packet_wr_data_tmp;
|
234 |
|
|
ro_command_packet_wr_data_tmp.range(63,0) = in_packet.read().packet;
|
235 |
|
|
|
236 |
|
|
#ifndef ENABLE_REORDERING
|
237 |
|
|
ro_command_packet_wr_data_tmp[64] = in_packet.read().error64BitExtension;
|
238 |
|
|
ro_command_packet_wr_data_tmp.range(BUFFERS_ADDRESS_WIDTH+64,65) = in_packet_data_addr;
|
239 |
|
|
ro_command_packet_wr_data_tmp.range(LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+65,BUFFERS_ADDRESS_WIDTH+65) = new_packet_nposted_refid_rejected_tmp;
|
240 |
|
|
ro_command_packet_wr_data_tmp.range(2 * LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+66,LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+66) = new_packet_response_refid_rejected_tmp;
|
241 |
|
|
ro_command_packet_wr_data_tmp.range(3 * LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+67,2*LOG2_NB_OF_BUFFERS + BUFFERS_ADDRESS_WIDTH+67) = new_packet_nposted_refid_accepted_tmp;
|
242 |
|
|
ro_command_packet_wr_data_tmp.range(4 * LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+68,3 * LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+68) = new_packet_response_refid_accepted_tmp;
|
243 |
|
|
#else
|
244 |
|
|
//Store error64bit at passPW position
|
245 |
|
|
ro_command_packet_wr_data_tmp[15] = in_packet.read().error64BitExtension;
|
246 |
|
|
//Store the refid
|
247 |
|
|
//For other field, place differently depending on if it is a response or not
|
248 |
|
|
if(vc == VC_RESPONSE){
|
249 |
|
|
#if LOG2_NB_OF_BUFFERS < 5
|
250 |
|
|
ro_command_packet_wr_data_tmp.range(1 + BUFFERS_ADDRESS_WIDTH,2) = in_packet_data_addr;
|
251 |
|
|
#else
|
252 |
|
|
ro_command_packet_wr_data_tmp.range(5,2) = in_packet_data_addr.range(3,0);
|
253 |
|
|
ro_command_packet_wr_data_tmp.range(27 + BUFFERS_ADDRESS_WIDTH,32) =
|
254 |
|
|
in_packet_data_addr.range(BUFFERS_ADDRESS_WIDTH-1,4);
|
255 |
|
|
#endif
|
256 |
|
|
#if BUFFERS_ADDRESS_WIDTH < 5
|
257 |
|
|
if(in_packet_forward_tmp)
|
258 |
|
|
ro_command_packet_wr_data_tmp.range(LOG2_NB_OF_BUFFERS+64,64) = new_packet_response_refid_rejected_tmp;
|
259 |
|
|
else
|
260 |
|
|
ro_command_packet_wr_data_tmp.range(LOG2_NB_OF_BUFFERS+64,64) = new_packet_response_refid_accepted_tmp;
|
261 |
|
|
#else
|
262 |
|
|
if(in_packet_forward_tmp)
|
263 |
|
|
ro_command_packet_wr_data_tmp.range(60+LOG2_NB_OF_BUFFERS + BUFFERS_ADDRESS_WIDTH,60+BUFFERS_ADDRESS_WIDTH) = new_packet_response_refid_rejected_tmp;
|
264 |
|
|
else
|
265 |
|
|
ro_command_packet_wr_data_tmp.range(60+LOG2_NB_OF_BUFFERS + BUFFERS_ADDRESS_WIDTH,60+BUFFERS_ADDRESS_WIDTH) = new_packet_response_refid_accepted_tmp;
|
266 |
|
|
#endif
|
267 |
|
|
}
|
268 |
|
|
else{
|
269 |
|
|
#if BUFFERS_ADDRESS_WIDTH < 3
|
270 |
|
|
ro_command_packet_wr_data_tmp.range(BUFFERS_ADDRESS_WIDTH+5,6) = in_packet_data_addr;
|
271 |
|
|
#elif BUFFERS_ADDRESS_WIDTH < 5
|
272 |
|
|
ro_command_packet_wr_data_tmp.range(7,6) = in_packet_data_addr.range(1,0);
|
273 |
|
|
ro_command_packet_wr_data_tmp.range(BUFFERS_ADDRESS_WIDTH+10,13) = in_packet_data_addr.range(BUFFERS_ADDRESS_WIDTH-1,2);
|
274 |
|
|
#else
|
275 |
|
|
ro_command_packet_wr_data_tmp.range(7,6) = in_packet_data_addr.range(1,0);
|
276 |
|
|
ro_command_packet_wr_data_tmp.range(14,13) = in_packet_data_addr.range(3,2);
|
277 |
|
|
ro_command_packet_wr_data_tmp.range(59+BUFFERS_ADDRESS_WIDTH,64) = in_packet_data_addr.range(BUFFERS_ADDRESS_WIDTH-1,4);
|
278 |
|
|
#endif
|
279 |
|
|
#if BUFFERS_ADDRESS_WIDTH < 5
|
280 |
|
|
if(in_packet_forward_tmp)
|
281 |
|
|
ro_command_packet_wr_data_tmp.range(LOG2_NB_OF_BUFFERS+64,64) = new_packet_nposted_refid_rejected_tmp;
|
282 |
|
|
else
|
283 |
|
|
ro_command_packet_wr_data_tmp.range(LOG2_NB_OF_BUFFERS+64,64) = new_packet_nposted_refid_accepted_tmp;
|
284 |
|
|
#else
|
285 |
|
|
if(in_packet_forward_tmp)
|
286 |
|
|
ro_command_packet_wr_data_tmp.range(60+LOG2_NB_OF_BUFFERS + BUFFERS_ADDRESS_WIDTH,60+BUFFERS_ADDRESS_WIDTH) = new_packet_nposted_refid_rejected_tmp;
|
287 |
|
|
else
|
288 |
|
|
ro_command_packet_wr_data_tmp.range(60+LOG2_NB_OF_BUFFERS + BUFFERS_ADDRESS_WIDTH,60+BUFFERS_ADDRESS_WIDTH) = new_packet_nposted_refid_accepted_tmp;
|
289 |
|
|
#endif
|
290 |
|
|
}
|
291 |
|
|
#endif
|
292 |
|
|
ro_command_packet_wr_data = ro_command_packet_wr_data_tmp;
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
// Determine if the current buffer goes to the CSR
|
296 |
|
|
bool entrance_reordering_l3::request_goes_to_csr(sc_bv<64> &pkt, bool error64BitExtension,
|
297 |
|
|
const PacketCommand &cmd)
|
298 |
|
|
{
|
299 |
|
|
sc_bv<5> unitID = getUnitID(pkt);
|
300 |
|
|
/**
|
301 |
|
|
If the packet had a 64 bit extension or if the request is upstream,
|
302 |
|
|
the in both case the packet is forwarded. In the case of a 64 bit
|
303 |
|
|
error, even if the packet is sent to the forward side, the packet will\
|
304 |
|
|
not be forwarded but will be handled by the error handler.
|
305 |
|
|
*/
|
306 |
|
|
sc_bv<16> csr_top_addr = "1111110111111110";
|
307 |
|
|
sc_bv<40> pkt_top_addr = getRequestAddr(pkt,cmd);
|
308 |
|
|
if (!error64BitExtension && request_isDownstream(unitID) &&
|
309 |
|
|
sc_bv<16>(pkt_top_addr.range(39,24)) == csr_top_addr
|
310 |
|
|
&& pkt_top_addr.range(15,11) == unit_id.read()
|
311 |
|
|
&& request_getCompatOrIsoc(pkt) == false)
|
312 |
|
|
{
|
313 |
|
|
return true;
|
314 |
|
|
}
|
315 |
|
|
else
|
316 |
|
|
return false;
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
// Determine if the current buffer goes to the User
|
320 |
|
|
bool entrance_reordering_l3::request_goes_to_user(sc_bv<64> &pkt, bool error64BitExtension,
|
321 |
|
|
const PacketCommand &cmd)
|
322 |
|
|
{
|
323 |
|
|
//default value
|
324 |
|
|
bool request_goes_to_user_return_val = false;
|
325 |
|
|
|
326 |
|
|
//Extract some information from the packet
|
327 |
|
|
sc_bv<40> request_addr = getRequestAddr(pkt,cmd);
|
328 |
|
|
sc_bv<5> pkt_unidID = getUnitID(pkt);
|
329 |
|
|
|
330 |
|
|
#ifdef ENABLE_DIRECTROUTE
|
331 |
|
|
//Check if it's from direct_route
|
332 |
|
|
sc_bv<6> direct_route_interdict_top_addr = "111111";
|
333 |
|
|
//Is the packet coming from a direcroute enable unitID?
|
334 |
|
|
bool from_direct_route_enabled = (sc_bit)csr_direct_route_enable.read()[
|
335 |
|
|
(sc_uint<5>) pkt_unidID];
|
336 |
|
|
//There is range of addresses which are not allowed for directroute traffic
|
337 |
|
|
//FD_0000_0000_0000h - FF_FFFF_FFFFh
|
338 |
|
|
bool dr_interdict_zone = request_addr.range(39,34) == direct_route_interdict_top_addr &&
|
339 |
|
|
((sc_bit)request_addr[33] || (sc_bit)request_addr[32]);
|
340 |
|
|
#endif
|
341 |
|
|
|
342 |
|
|
bool barAddress = isBarAddress(request_addr);
|
343 |
|
|
|
344 |
|
|
sc_bv<12> messaging_top_addr = "111111100000";
|
345 |
|
|
sc_bv<4> messaging_cmd_part = "1011";
|
346 |
|
|
|
347 |
|
|
// If The packet is a broadcast, we don't care about the address
|
348 |
|
|
/* Commented because a broadcast is dectected higher in the hierarchy
|
349 |
|
|
(before this function is actually called)
|
350 |
|
|
if(cmd == BROADCAST)
|
351 |
|
|
{
|
352 |
|
|
request_goes_to_user_return_val = true;
|
353 |
|
|
}
|
354 |
|
|
// In the case of a downstream or directroute packet
|
355 |
|
|
else */
|
356 |
|
|
|
357 |
|
|
//To go to user, the packet must either be downstream
|
358 |
|
|
//or from a directroute enabled source
|
359 |
|
|
request_goes_to_user_return_val = ((request_isDownstream(pkt_unidID)
|
360 |
|
|
#ifdef ENABLE_DIRECTROUTE
|
361 |
|
|
|| (from_direct_route_enabled && !dr_interdict_zone)
|
362 |
|
|
#endif
|
363 |
|
|
)&& !error64BitExtension) &&
|
364 |
|
|
|
365 |
|
|
(
|
366 |
|
|
// We verify if the address is in the User range
|
367 |
|
|
(barAddress &&
|
368 |
|
|
// We verify if the Compat bit == 0
|
369 |
|
|
request_getCompatOrIsoc(pkt) == false
|
370 |
|
|
// and we verify if the packet is a write or a read
|
371 |
|
|
&& (cmd == WRITE ||
|
372 |
|
|
cmd == READ || cmd == ATOMIC))
|
373 |
|
|
||
|
374 |
|
|
//device messaging goes to user
|
375 |
|
|
(sc_bv<12>(request_addr.range(39,28)) == messaging_top_addr
|
376 |
|
|
&& request_addr.range(15,11) == unit_id.read() &&
|
377 |
|
|
/*posted write*/ pkt.range(5,2) == messaging_cmd_part)
|
378 |
|
|
);
|
379 |
|
|
|
380 |
|
|
return request_goes_to_user_return_val;
|
381 |
|
|
}
|
382 |
|
|
|
383 |
|
|
// We check if the address correspond to a range described by a csr_bar register
|
384 |
|
|
bool entrance_reordering_l3::isBarAddress( const sc_bv<40>& address)
|
385 |
|
|
{
|
386 |
|
|
bool found_bar_bar[NbRegsBars];
|
387 |
|
|
bool found_bar = false;
|
388 |
|
|
|
389 |
|
|
found_bar_bar[0] = (address.range(39, Header_BarLowerPos0) == csr_bar[0].read().range(39,Header_BarLowerPos0)
|
390 |
|
|
&& (Header_BarIOSpace[0] && csr_io_space_enable.read() || !Header_BarIOSpace[0] && csr_memory_space_enable.read()));
|
391 |
|
|
|
392 |
|
|
#if (NbRegsBars > 1)
|
393 |
|
|
found_bar_bar[1] = (address.range(39, Header_BarLowerPos1) == csr_bar[1].read().range(39,Header_BarLowerPos1)
|
394 |
|
|
&& (Header_BarIOSpace[1] && csr_io_space_enable.read() || !Header_BarIOSpace[1] && csr_memory_space_enable.read()));
|
395 |
|
|
#endif
|
396 |
|
|
|
397 |
|
|
#if (NbRegsBars > 2)
|
398 |
|
|
found_bar_bar[2] = (address.range(39, Header_BarLowerPos2) == csr_bar[2].read().range(39,Header_BarLowerPos2)
|
399 |
|
|
&& (Header_BarIOSpace[2] && csr_io_space_enable.read() || !Header_BarIOSpace[2] && csr_memory_space_enable.read()));
|
400 |
|
|
#endif
|
401 |
|
|
|
402 |
|
|
#if (NbRegsBars > 3)
|
403 |
|
|
found_bar_bar[3] = (address.range(39, Header_BarLowerPos3) == csr_bar[3].read().range(39,Header_BarLowerPos3)
|
404 |
|
|
&& (Header_BarIOSpace[3] && csr_io_space_enable.read() || !Header_BarIOSpace[3] && csr_memory_space_enable.read()));
|
405 |
|
|
#endif
|
406 |
|
|
|
407 |
|
|
#if (NbRegsBars > 4)
|
408 |
|
|
found_bar_bar[4] = (address.range(39, Header_BarLowerPos4) == csr_bar[4].read().range(39,Header_BarLowerPos4)
|
409 |
|
|
&& (Header_BarIOSpace[4] && csr_io_space_enable.read() || !Header_BarIOSpace[4] && csr_memory_space_enable.read()));
|
410 |
|
|
#endif
|
411 |
|
|
|
412 |
|
|
#if (NbRegsBars > 5)
|
413 |
|
|
found_bar_bar[5] = (address.range(39, Header_BarLowerPos5) == csr_bar[5].read().range(39,Header_BarLowerPos5)
|
414 |
|
|
&& (Header_BarIOSpace[5] && csr_io_space_enable.read() || !Header_BarIOSpace[5] && csr_memory_space_enable.read()));
|
415 |
|
|
#endif
|
416 |
|
|
|
417 |
|
|
for(int n = 0; n < NbRegsBars; n++)
|
418 |
|
|
found_bar = found_bar || found_bar_bar[n];
|
419 |
|
|
return found_bar;
|
420 |
|
|
}
|
421 |
|
|
|
422 |
|
|
// Determine if the current buffer goes to the User
|
423 |
|
|
bool entrance_reordering_l3::response_goes_to_user(sc_bv<64> &pkt)
|
424 |
|
|
{
|
425 |
|
|
// We verify the unit_id and the bridge bit
|
426 |
|
|
if (sc_bv<5>(getUnitID(pkt)) == unit_id.read()
|
427 |
|
|
&& pkt[14] == true)
|
428 |
|
|
return true;
|
429 |
|
|
else
|
430 |
|
|
return false;
|
431 |
|
|
}
|
432 |
|
|
|
433 |
|
|
bool entrance_reordering_l3::request_isDownstream(sc_bv<5> &pkt_unidID){
|
434 |
|
|
sc_uint<2> tmp_lower_unitID = (sc_bv<2>)pkt_unidID.range(1,0);
|
435 |
|
|
//Equivalent of: not_clumped_0 = pkt_unidID < 4;
|
436 |
|
|
bool not_clumped_0 = !((sc_bit)pkt_unidID[4] || (sc_bit)pkt_unidID[3] || (sc_bit)pkt_unidID[2]);
|
437 |
|
|
|
438 |
|
|
if (not_clumped_0 && (sc_uint<5>)(clumped_unit_id[tmp_lower_unitID].read()) == 0)
|
439 |
|
|
return true;
|
440 |
|
|
else
|
441 |
|
|
return false;
|
442 |
|
|
|
443 |
|
|
}
|
444 |
|
|
|
445 |
|
|
#ifndef SYSTEMC_SIM
|
446 |
|
|
#include "../core_synth/synth_control_packet.cpp"
|
447 |
|
|
#endif
|
448 |
|
|
|