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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [trunk/] [rtl/] [systemc/] [reordering_l2/] [final_reordering_l3.cpp] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//final_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
#include "final_reordering_l3.h"
42
 
43
#ifdef SYSTEMC_SIM
44
using namespace std;
45
#endif
46
 
47
/// Main constructor.
48
final_reordering_l3::final_reordering_l3(sc_module_name name) : sc_module(name)
49
{
50
 
51
 
52
        SC_METHOD(clocked_process);
53
        sensitive_pos << clk;
54
        sensitive_neg << resetx;
55
 
56
        SC_METHOD(output_request);
57
        sensitive << posted_packet_buffer_accepted_loaded[0]
58
                      << posted_packet_buffer_accepted_loaded[1]
59
                      << nposted_packet_buffer_accepted_loaded[0]
60
                      << nposted_packet_buffer_accepted_loaded[1]
61
                      << response_packet_buffer_accepted_loaded[0]
62
                      << response_packet_buffer_accepted_loaded[1]
63
                          << posted_packet_buffer_rejected_loaded[0]
64
                      << posted_packet_buffer_rejected_loaded[1]
65
                      << nposted_packet_buffer_rejected_loaded[0]
66
                      << nposted_packet_buffer_rejected_loaded[1]
67
                      << response_packet_buffer_rejected_loaded[0]
68
                      << response_packet_buffer_rejected_loaded[1]
69
                          << fetched_packet_vc[0] << fetched_packet_vc[1]
70
                          << fetched_packet_available[0]
71
                          << fetched_packet_available[1];
72
 
73
        SC_METHOD(find_next_packet_buf_workaround);
74
        sensitive << posted_packet_buffer_accepted_loaded[0]
75
                      << posted_packet_buffer_accepted_loaded[1]
76
                      << nposted_packet_buffer_accepted_loaded[0]
77
                      << nposted_packet_buffer_accepted_loaded[1]
78
                      << response_packet_buffer_accepted_loaded[0]
79
                      << response_packet_buffer_accepted_loaded[1]
80
                          << posted_packet_buffer_rejected_loaded[0]
81
                      << posted_packet_buffer_rejected_loaded[1]
82
                      << nposted_packet_buffer_rejected_loaded[0]
83
                      << nposted_packet_buffer_rejected_loaded[1]
84
                      << response_packet_buffer_rejected_loaded[0]
85
                      << response_packet_buffer_rejected_loaded[1]
86
                          << posted_packet_buffer_accepted[0]
87
                      << posted_packet_buffer_accepted[1]
88
                      << nposted_packet_buffer_accepted[0]
89
                      << nposted_packet_buffer_accepted[1]
90
                      << response_packet_buffer_accepted[0]
91
                      << response_packet_buffer_accepted[1]
92
                          << posted_packet_buffer_rejected[0]
93
                      << posted_packet_buffer_rejected[1]
94
                      << nposted_packet_buffer_rejected[0]
95
                      << nposted_packet_buffer_rejected[1]
96
                      << response_packet_buffer_rejected[0]
97
                      << response_packet_buffer_rejected[1]
98
                          << posted_packet_wait_count_accepted[0]
99
                          << posted_packet_wait_count_accepted[1]
100
                          << nposted_packet_wait_count_accepted[0]
101
                          << nposted_packet_wait_count_accepted[1]
102
                          << response_packet_wait_count_accepted[0]
103
                          << response_packet_wait_count_accepted[1]
104
                          << posted_packet_wait_count_rejected[0]
105
                          << posted_packet_wait_count_rejected[1]
106
                          << nposted_packet_wait_count_rejected[0]
107
                          << nposted_packet_wait_count_rejected[1]
108
                          << response_packet_wait_count_rejected[0]
109
                          << response_packet_wait_count_rejected[1]
110
                          ;
111
}
112
 
113
void final_reordering_l3::doFinalReorderingFWD(void){
114
 
115
    //syn_ControlPacketComplete rc_packet;
116
        sc_uint<LOG2_NB_OF_BUFFERS+1> response_refid;
117
 
118
    //syn_ControlPacketComplete pc_packet;
119
        sc_uint<LOG2_NB_OF_BUFFERS+1> posted_nposted_refid;
120
        sc_uint<LOG2_NB_OF_BUFFERS+1> posted_response_refid;
121
 
122
        //syn_ControlPacketComplete npc_packet;
123
        sc_uint<LOG2_NB_OF_BUFFERS+1> nposted_refid;
124
 
125
        // Select the response packet
126
        bool rc_packet_available = response_packet_buffer_rejected_loaded[0].read() ||
127
                                                           response_packet_buffer_rejected_loaded[1].read();
128
        //rc_packet.packet.range(63,32) = 0;
129
        //rc_packet.error64BitExtension = false;
130
        //rc_packet.isPartOfChain = false;
131
        if(response_packet_buffer_rejected_loaded[0].read()){
132
                //rc_packet.packet.range(31,0) =  response_packet_buffer_rejected[0].read().packet;
133
                //rc_packet.data_address = response_packet_buffer_rejected[0].read().data_address;
134
                response_refid = response_packet_buffer_rejected_refid[0].read();
135
        }
136
        else{
137
                //rc_packet.packet.range(31,0) =  response_packet_buffer_rejected[1].read().packet;
138
                //rc_packet.data_address = response_packet_buffer_rejected[1].read().data_address;
139
                response_refid = response_packet_buffer_rejected_refid[1].read();
140
        }
141
 
142
        // Select the posted packet
143
        bool pc_packet_available = posted_packet_buffer_rejected_loaded[0].read() ||
144
                                                           posted_packet_buffer_rejected_loaded[1].read();
145
        if(posted_packet_buffer_rejected_loaded[0].read()){
146
                //pc_packet =  posted_packet_buffer_rejected[0].read();
147
                posted_response_refid = posted_packet_buffer_rejected_response_refid[0].read();
148
                posted_nposted_refid = posted_packet_buffer_rejected_nposted_refid[0].read();
149
        }
150
        else{
151
                //pc_packet =  posted_packet_buffer_rejected[1].read();
152
                posted_response_refid = posted_packet_buffer_rejected_response_refid[1].read();
153
                posted_nposted_refid = posted_packet_buffer_rejected_nposted_refid[1].read();
154
        }
155
 
156
        // Select the non-posted packet
157
        bool npc_packet_available = nposted_packet_buffer_rejected_loaded[0].read() ||
158
                                                           nposted_packet_buffer_rejected_loaded[1].read();
159
        if(nposted_packet_buffer_rejected_loaded[0].read()){
160
                //npc_packet =  nposted_packet_buffer_rejected[0].read();
161
                nposted_refid = nposted_packet_buffer_rejected_refid[0].read();
162
        }
163
        else{
164
                //npc_packet =  nposted_packet_buffer_rejected[1].read();
165
                nposted_refid = nposted_packet_buffer_rejected_refid[1].read();
166
        }
167
 
168
 
169
        ////////////////////////////////////////////////////////
170
        // Compare refids to know the order the packet arrived
171
        // relatively to the posted channel
172
        ////////////////////////////////////////////////////////
173
        sc_uint<LOG2_NB_OF_BUFFERS+1> nposted_refid_compared =
174
                nposted_refid - posted_nposted_refid;
175
        bool nposted_ordering_ok = !pc_packet_available || nposted_refid_compared[LOG2_NB_OF_BUFFERS];
176
 
177
        sc_uint<LOG2_NB_OF_BUFFERS+1> response_refid_compared =
178
                response_refid - posted_response_refid;
179
        bool response_ordering_ok = !pc_packet_available || response_refid_compared[LOG2_NB_OF_BUFFERS];
180
 
181
 
182
 
183
        sc_bv<64> rc_packet_bits = rc_packet_rejected.read().packet;
184
        sc_bv<64> pc_packet_bits = pc_packet_rejected.read().packet;
185
        sc_bv<64> npc_packet_bits = npc_packet_rejected.read().packet;
186
 
187
        PacketCommand rc_packet_cmd = getPacketCommand(rc_packet_bits.range(5,0));
188
        PacketCommand pc_packet_cmd = getPacketCommand(pc_packet_bits.range(5,0));
189
        PacketCommand npc_packet_cmd = getPacketCommand(npc_packet_bits.range(5,0));
190
 
191
        bool rchasDataAssociated = hasDataAssociated(rc_packet_cmd);
192
        //Check if there is enough buffers in the next node to send the packet
193
        //and check that all data has arrived if it has an associated data packet
194
        bool rcFreeWithData = (
195
                //Check if it has data and there is room in the next buffer
196
                //for a control and data packet, if it is a packet with data
197
                (rchasDataAssociated
198
                && (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_RC_FREE_DATA]) &&
199
                (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_RC_FREE])) ||
200
                //If there is no data associated, only check if there is a
201
                //control buffer available
202
                (!rchasDataAssociated
203
                && (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_RC_FREE]) ))
204
                //If there is data associated, make sure that the data has finished
205
                //coming in
206
                 &&!(rc_packet_rejected.read().data_address == cd_data_pending_addr_ro &&
207
                rchasDataAssociated &&
208
                cd_data_pending_ro.read());
209
 
210
 
211
        bool pchasDataAssociated = hasDataAssociated(pc_packet_cmd);
212
        //Check if there is enough buffers in the next node to send the packet
213
        //and check that all data has arrived if it has an associated data packet
214
        bool pcFreeWithData = (
215
                //Check if it has data and there is room in the next buffer
216
                //for a control and data packet, if it is a packet with data
217
                (pchasDataAssociated
218
                && (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_PC_FREE_DATA]) &&
219
                (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_PC_FREE])) ||
220
                //If there is no data associated, only check if there is a
221
                //control buffer available
222
                (!pchasDataAssociated
223
                && (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_PC_FREE])))
224
                //If there is data associated, make sure that the data has finished
225
                //coming in
226
                 &&!(pc_packet_rejected.read().data_address == cd_data_pending_addr_ro &&
227
                pchasDataAssociated &&
228
                cd_data_pending_ro.read());
229
 
230
        bool npchasDataAssociated = hasDataAssociated(npc_packet_cmd);
231
        //Check if there is enough buffers in the next node to send the packet
232
        //and check that all data has arrived if it has an associated data packet
233
        bool npcFreeWithData = (
234
                //Check if it has data and there is room in the next buffer
235
                //for a control and data packet, if it is a packet with data
236
                (npchasDataAssociated
237
                && (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_NPC_FREE_DATA]) &&
238
                (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_NPC_FREE])) ||
239
                //If there is no data associated, only check if there is a
240
                //control buffer available
241
                (!npchasDataAssociated
242
                && (sc_bit)(fwd_next_node_buffer_status_ro.read()[BIT_NPC_FREE])) )
243
                //If there is data associated, make sure that the data has finished
244
                //coming in
245
                 &&!(npc_packet_rejected.read().data_address == cd_data_pending_addr_ro &&
246
                npchasDataAssociated &&
247
                cd_data_pending_ro.read());
248
 
249
 
250
 
251
        //Most important packet is Response with passPW, if there is room
252
        //in the next device
253
        /**
254
           This first condition makes it so a packet is only issued once every
255
           two cycles.  Because most packets are 64 bits, this should not cause
256
           too much slowdown.  This is done because to output a packet every cycle
257
           would require an extra buffer, at least for the posted channel.
258
        */
259
        if(rejected_output_loaded.read() && ack[FWD_DEST].read() || csr_sync.read()){
260
                out_packet_fwd = out_packet_fwd.read();
261
                out_packet_vc_fwd = out_packet_vc_fwd.read();
262
                rejected_vc_decoded = 0;
263
                out_packet_available_fwd = false;
264
                rejected_output_loaded = false;
265
        }
266
        //Most important packet is Response with passPW, if there is room
267
        //in the next device
268
        else if(rc_packet_available &&
269
                getPassPW(rc_packet_bits) &&
270
                rcFreeWithData &&
271
                (! (pcFreeWithData && pc_packet_rejected_maxwait_reached.read() ||
272
                    npcFreeWithData && npc_packet_rejected_maxwait_reached.read())
273
                        || rc_packet_rejected_maxwait_reached.read()))
274
        {
275
                out_packet_fwd = rc_packet_rejected.read();
276
                out_packet_vc_fwd = VC_RESPONSE;
277
                rejected_vc_decoded = "100";
278
                out_packet_available_fwd = true;
279
                rejected_output_loaded = true;
280
        }
281
        //After that, it's the posted channel, whatever passPW is, also if
282
        //there is room in the next device
283
        else if(pc_packet_available &&
284
                pcFreeWithData &&
285
                (! (rcFreeWithData && rc_packet_rejected_maxwait_reached.read() ||
286
                    npcFreeWithData && npc_packet_rejected_maxwait_reached.read())
287
                        || pc_packet_rejected_maxwait_reached.read()))
288
        {
289
                out_packet_fwd = pc_packet_rejected.read();
290
                out_packet_vc_fwd = VC_POSTED;
291
                rejected_vc_decoded = "001";
292
                out_packet_available_fwd = true;
293
                rejected_output_loaded = true;
294
        }
295
        //Next, we go back to the response channel if there is room in the 
296
        //next device. but also only if there are no posted request that arrived
297
        //ahead of that response packet (ordering restriction)
298
        else if(rc_packet_available &&
299
                rcFreeWithData && response_ordering_ok  &&
300
                (! (npcFreeWithData && npc_packet_rejected_maxwait_reached.read())
301
                        || rc_packet_rejected_maxwait_reached.read()))
302
        {
303
                out_packet_fwd = rc_packet_rejected.read();
304
                out_packet_vc_fwd = VC_RESPONSE;
305
                rejected_vc_decoded = "100";
306
                out_packet_available_fwd = true;
307
                rejected_output_loaded = true;
308
        }
309
        //After that, we fo with the NPC with passPW or no posted packet blocking
310
        //the transmission
311
        else if(npc_packet_available &&
312
                (getPassPW(npc_packet_bits) ||
313
                        nposted_ordering_ok) &&
314
                npcFreeWithData)
315
        {
316
                out_packet_fwd = npc_packet_rejected.read();
317
                out_packet_vc_fwd = VC_NON_POSTED;
318
                rejected_vc_decoded = "010";
319
                out_packet_available_fwd = true;
320
                rejected_output_loaded = true;
321
        }
322
        //If there is nothing, output zeros
323
        else{
324
                out_packet_fwd = out_packet_fwd.read();
325
                out_packet_vc_fwd = out_packet_vc_fwd.read();
326
                rejected_vc_decoded = 0;
327
                out_packet_available_fwd = false;
328
                rejected_output_loaded = false;
329
        }
330
}
331
 
332
 
333
void final_reordering_l3::doFinalReorderingAccepted(){
334
 
335
    //syn_ControlPacketComplete rc_packet;
336
        sc_uint<LOG2_NB_OF_BUFFERS+1> response_refid;
337
 
338
    //syn_ControlPacketComplete pc_packet;
339
        sc_uint<LOG2_NB_OF_BUFFERS+1> posted_nposted_refid;
340
        sc_uint<LOG2_NB_OF_BUFFERS+1> posted_response_refid;
341
 
342
        //syn_ControlPacketComplete npc_packet;
343
        sc_uint<LOG2_NB_OF_BUFFERS+1> nposted_refid;
344
 
345
        // Select the response packet
346
        bool rc_packet_available = response_packet_buffer_accepted_loaded[0].read() ||
347
                                                           response_packet_buffer_accepted_loaded[1].read();
348
        //rc_packet.packet.range(63,32) = 0;
349
        //rc_packet.error64BitExtension = false;
350
        //rc_packet.isPartOfChain = false;
351
        if(response_packet_buffer_accepted_loaded[0].read()){
352
                //rc_packet.packet.range(31,0) =  response_packet_buffer_accepted[0].read().packet;
353
                //rc_packet.data_address = response_packet_buffer_accepted[0].read().data_address;
354
                response_refid = response_packet_buffer_accepted_refid[0].read();
355
        }
356
        else{
357
                //rc_packet.packet.range(31,0) =  response_packet_buffer_accepted[1].read().packet;
358
                //rc_packet.data_address = response_packet_buffer_accepted[1].read().data_address;
359
                response_refid = response_packet_buffer_accepted_refid[1].read();
360
        }
361
 
362
        // Select the posted packet
363
        bool pc_packet_available = posted_packet_buffer_accepted_loaded[0].read() ||
364
                                                           posted_packet_buffer_accepted_loaded[1].read();
365
        if(posted_packet_buffer_accepted_loaded[0].read()){
366
                //pc_packet =  posted_packet_buffer_accepted[0].read();
367
                posted_response_refid = posted_packet_buffer_accepted_response_refid[0].read();
368
                posted_nposted_refid = posted_packet_buffer_accepted_nposted_refid[0].read();
369
        }
370
        else{
371
                //pc_packet =  posted_packet_buffer_accepted[1].read();
372
                posted_response_refid = posted_packet_buffer_accepted_response_refid[1].read();
373
                posted_nposted_refid = posted_packet_buffer_accepted_nposted_refid[1].read();
374
        }
375
 
376
        // Select the non-posted packet
377
        bool npc_packet_available = nposted_packet_buffer_accepted_loaded[0].read() ||
378
                                                           nposted_packet_buffer_accepted_loaded[1].read();
379
        if(nposted_packet_buffer_accepted_loaded[0].read()){
380
                //npc_packet =  nposted_packet_buffer_accepted[0].read();
381
                nposted_refid = nposted_packet_buffer_accepted_refid[0].read();
382
        }
383
        else{
384
                //npc_packet =  nposted_packet_buffer_accepted[1].read();
385
                nposted_refid = nposted_packet_buffer_accepted_refid[1].read();
386
        }
387
 
388
        ////////////////////////////////////////////////////////
389
        // Compare refids to know the order the packet arrived
390
        // relatively to the posted channel
391
        ////////////////////////////////////////////////////////
392
        sc_uint<LOG2_NB_OF_BUFFERS+1> nposted_refid_compared =
393
                nposted_refid - posted_nposted_refid;
394
        bool nposted_ordering_ok = !pc_packet_available || nposted_refid_compared[LOG2_NB_OF_BUFFERS];
395
 
396
        sc_uint<LOG2_NB_OF_BUFFERS+1> response_refid_compared =
397
                response_refid - posted_response_refid;
398
        bool response_ordering_ok = !pc_packet_available || response_refid_compared[LOG2_NB_OF_BUFFERS];
399
 
400
        sc_bv<64> rc_packet_bits = rc_packet_accepted.read().packet;
401
        sc_bv<64> pc_packet_bits = pc_packet_accepted.read().packet;
402
        sc_bv<64> npc_packet_bits = npc_packet_accepted.read().packet;
403
 
404
        PacketCommand rc_packet_cmd = getPacketCommand(rc_packet_bits.range(5,0));
405
        PacketCommand pc_packet_cmd = getPacketCommand(pc_packet_bits.range(5,0));
406
        PacketCommand npc_packet_cmd = getPacketCommand(npc_packet_bits.range(5,0));
407
 
408
        bool rcFreeWithData =
409
                //If there is data associated, make sure that the data has finished
410
                //coming in
411
                !(rc_packet_accepted.read().data_address == cd_data_pending_addr_ro &&
412
                hasDataAssociated(rc_packet_cmd) &&
413
                cd_data_pending_ro.read());
414
 
415
        bool pcFreeWithData =
416
                //If there is data associated, make sure that the data has finished
417
                //coming in
418
                !(pc_packet_accepted.read().data_address == cd_data_pending_addr_ro &&
419
                hasDataAssociated(pc_packet_cmd) &&
420
                cd_data_pending_ro.read());
421
 
422
        bool npcFreeWithData =
423
                //If there is data associated, make sure that the data has finished
424
                //coming in
425
                 !(npc_packet_accepted.read().data_address == cd_data_pending_addr_ro &&
426
                hasDataAssociated(npc_packet_cmd) &&
427
                cd_data_pending_ro.read());
428
 
429
        //Most important packet is Response with passPW 
430
        /**
431
           This first condition makes it so a packet is only issued once every
432
           two cycles.  Because most packets are 64 bits, this should not cause
433
           too much slowdown.  This is done because to output a packet every cycle
434
           would require an extra buffer, at least for the posted channel.
435
        */
436
        if(accepted_output_loaded.read() &&
437
                (ack[UI_DEST].read() || ack[CSR_DEST].read() || csr_sync.read()) ){
438
                out_packet_accepted = out_packet_accepted.read();
439
                out_packet_available_ui = false;
440
                out_packet_available_csr = false;
441
                accepted_output_loaded = false;
442
                accepted_vc_decoded = "000";
443
        }
444
        else if(rc_packet_available &&
445
                getPassPW(rc_packet_bits) &&
446
                rcFreeWithData &&
447
                (! (pcFreeWithData && pc_packet_accepted_maxwait_reached.read() ||
448
                    npcFreeWithData && npc_packet_accepted_maxwait_reached.read())
449
                        || rc_packet_accepted_maxwait_reached.read()))
450
        {
451
                out_packet_accepted = rc_packet_accepted.read();
452
                out_packet_available_ui = true;
453
                out_packet_available_csr = false;
454
                accepted_output_loaded = true;
455
                accepted_vc_decoded = "100";
456
        }
457
        //After that, it's the posted channel, whatever passPW is, also if
458
        //there is room in the next device
459
        else if(pc_packet_available &&
460
                pcFreeWithData &&
461
                (! (rcFreeWithData && rc_packet_accepted_maxwait_reached.read() ||
462
                    npcFreeWithData && npc_packet_accepted_maxwait_reached.read())
463
                        || pc_packet_accepted_maxwait_reached.read()))
464
        {
465
                out_packet_accepted = pc_packet_accepted.read();
466
                bool pc_packet_goes_to_csr =
467
                        request_goes_to_csr(pc_packet_bits);
468
                out_packet_available_ui = !pc_packet_goes_to_csr;
469
                out_packet_available_csr = pc_packet_goes_to_csr;
470
                accepted_output_loaded = true;
471
                accepted_vc_decoded = "001";
472
        }
473
        //Next, we go back to the response channel  if there are no posted request waiting
474
        //to be sent that aren't selected because it's data is not fully arrived
475
        else if(rc_packet_available &&
476
                rcFreeWithData && response_ordering_ok  &&
477
                (! (npcFreeWithData && npc_packet_accepted_maxwait_reached.read())
478
                        || rc_packet_accepted_maxwait_reached.read()))
479
        {
480
                out_packet_accepted = rc_packet_accepted.read();
481
                out_packet_available_ui = true;
482
                out_packet_available_csr = false;
483
                accepted_output_loaded = true;
484
                accepted_vc_decoded = "100";
485
        }
486
        //After that, we fo with the NPC with passPW or non passPW if not packets
487
        //in posted
488
        else if(npc_packet_available &&
489
                (getPassPW(npc_packet_bits) ||
490
                        nposted_ordering_ok)&&
491
                npcFreeWithData)
492
        {
493
                out_packet_accepted = npc_packet_accepted.read();
494
                bool npc_packet_goes_to_csr =
495
                        request_goes_to_csr(npc_packet_bits);
496
 
497
                out_packet_available_ui = !npc_packet_goes_to_csr;
498
                out_packet_available_csr = npc_packet_goes_to_csr;
499
                accepted_output_loaded = true;
500
                accepted_vc_decoded = "010";
501
        }
502
        //If there is nothing, output zeros
503
        else{
504
                out_packet_accepted = out_packet_accepted.read();
505
                out_packet_available_ui = false;
506
                out_packet_available_csr = false;
507
                accepted_output_loaded = false;
508
                accepted_vc_decoded = "000";
509
        }
510
}
511
 
512
void final_reordering_l3::updateBufferContent(){
513
        //////////////////////////////////////////////////////////////
514
        // Manage accepted registers
515
        //////////////////////////////////////////////////////////////
516
 
517
        // Posted channel registers
518
        posted_packet_buffer_accepted_loaded[0] =
519
                        (posted_packet_buffer_accepted_loaded[0].read() ||
520
                        posted_packet_buffer_accepted_loaded[1].read() ||
521
                        fetched_packet_available[ACCEPTED_DEST].read() &&
522
                        fetched_packet_vc[ACCEPTED_DEST].read() == VC_POSTED)
523
                                &&
524
                        !((ack[UI_DEST].read() || ack[CSR_DEST].read()) && (sc_bit)accepted_vc_decoded.read()[0]);
525
 
526
        bool increment_posted_accepted = registered_ack_accepted.read() &&
527
                !(sc_bit)registered_accepted_vc_decoded.read()[VC_POSTED];
528
        bool posted_accepted_counter_saturate[2];
529
        posted_accepted_counter_saturate[0] = posted_packet_wait_count_accepted[0].read() == MAX_PASSPW_COUNT;
530
        posted_accepted_counter_saturate[1] = posted_packet_wait_count_accepted[1].read() == MAX_PASSPW_COUNT;
531
 
532
        if(!posted_packet_buffer_accepted_loaded[0].read()){
533
                if(posted_packet_buffer_accepted_loaded[1].read()){
534
                        posted_packet_buffer_accepted[0] = posted_packet_buffer_accepted[1];
535
                        posted_packet_wait_count_accepted[0] = posted_packet_wait_count_accepted[1].read() +
536
                                sc_uint<1>(increment_posted_accepted && !posted_accepted_counter_saturate[1]);
537
                        posted_packet_buffer_accepted_nposted_refid[0] =
538
                                posted_packet_buffer_accepted_nposted_refid[1];
539
                        posted_packet_buffer_accepted_response_refid[0] =
540
                                posted_packet_buffer_accepted_response_refid[1];
541
                }
542
                else{
543
                        posted_packet_buffer_accepted[0] = fetched_packet[ACCEPTED_DEST];
544
                        posted_packet_wait_count_accepted[0] = 0;
545
                        posted_packet_buffer_accepted_nposted_refid[0] =
546
                                fetched_packet_nposted_refid[ACCEPTED_DEST];
547
                        posted_packet_buffer_accepted_response_refid[0] =
548
                                fetched_packet_response_refid[ACCEPTED_DEST];
549
                }
550
        }
551
        else{
552
                posted_packet_wait_count_accepted[0] = posted_packet_wait_count_accepted[0].read() +
553
                        sc_uint<1>(increment_posted_accepted && !posted_accepted_counter_saturate[0]);
554
        }
555
 
556
        posted_packet_buffer_accepted_loaded[1] = !posted_requested[ACCEPTED_DEST].read();
557
 
558
 
559
        if(!posted_packet_buffer_accepted_loaded[1].read()){
560
                posted_packet_buffer_accepted[1] = fetched_packet[ACCEPTED_DEST];
561
                posted_packet_wait_count_accepted[1] = 0;
562
                posted_packet_buffer_accepted_nposted_refid[1] =
563
                        fetched_packet_nposted_refid[ACCEPTED_DEST];
564
                posted_packet_buffer_accepted_response_refid[1] =
565
                        fetched_packet_response_refid[ACCEPTED_DEST];
566
        }
567
        else{
568
                posted_packet_wait_count_accepted[1] = posted_packet_wait_count_accepted[1].read() +
569
                        sc_uint<1>(increment_posted_accepted && !posted_accepted_counter_saturate[1]);
570
        }
571
 
572
        // NON-Posted channel registers
573
        nposted_packet_buffer_accepted_loaded[0] =
574
                        (nposted_packet_buffer_accepted_loaded[0].read() ||
575
                        nposted_packet_buffer_accepted_loaded[1].read() ||
576
                        fetched_packet_available[ACCEPTED_DEST].read() &&
577
                        fetched_packet_vc[ACCEPTED_DEST].read() == VC_NON_POSTED)
578
                                &&
579
                        !((ack[UI_DEST].read() || ack[CSR_DEST].read()) && (sc_bit)accepted_vc_decoded.read()[1]);
580
 
581
        bool increment_nposted_accepted = registered_ack_accepted.read() &&
582
                !(sc_bit)registered_accepted_vc_decoded.read()[VC_NON_POSTED];
583
        bool nposted_counter_saturate[2];
584
        nposted_counter_saturate[0] = nposted_packet_wait_count_accepted[0].read() == 3;
585
        nposted_counter_saturate[1] = nposted_packet_wait_count_accepted[1].read() == 3;
586
 
587
        if(!nposted_packet_buffer_accepted_loaded[0].read()){
588
                if(nposted_packet_buffer_accepted_loaded[1].read()){
589
                        nposted_packet_buffer_accepted[0] = nposted_packet_buffer_accepted[1];
590
                        nposted_packet_wait_count_accepted[0] = nposted_packet_wait_count_accepted[1].read() +
591
                                sc_uint<1>(increment_nposted_accepted && !nposted_counter_saturate[1]);
592
                        nposted_packet_buffer_accepted_refid[0] =
593
                                nposted_packet_buffer_accepted_refid[1];
594
                }
595
                else{
596
                        nposted_packet_buffer_accepted[0] = fetched_packet[ACCEPTED_DEST];
597
                        nposted_packet_wait_count_accepted[0] = 0;
598
                        nposted_packet_buffer_accepted_refid[0] =
599
                                fetched_packet_nposted_refid[ACCEPTED_DEST];
600
                }
601
        }
602
        else{
603
                nposted_packet_wait_count_accepted[0] = nposted_packet_wait_count_accepted[0].read() +
604
                        sc_uint<1>(increment_nposted_accepted && !nposted_counter_saturate[0]);
605
        }
606
 
607
        nposted_packet_buffer_accepted_loaded[1] = !nposted_requested[ACCEPTED_DEST].read();
608
 
609
        if(!nposted_packet_buffer_accepted_loaded[1].read()){
610
                nposted_packet_buffer_accepted[1] = fetched_packet[ACCEPTED_DEST];
611
                nposted_packet_wait_count_accepted[1] = 0;
612
                nposted_packet_buffer_accepted_refid[1] =
613
                        fetched_packet_nposted_refid[ACCEPTED_DEST];
614
        }
615
        else{
616
                nposted_packet_wait_count_accepted[1] = nposted_packet_wait_count_accepted[1].read() +
617
                        sc_uint<1>(increment_nposted_accepted && !nposted_counter_saturate[1]);
618
        }
619
 
620
        // Response channel registers
621
        response_packet_buffer_accepted_loaded[0] =
622
                        (response_packet_buffer_accepted_loaded[0].read() ||
623
                        response_packet_buffer_accepted_loaded[1].read() ||
624
                        fetched_packet_available[ACCEPTED_DEST].read() &&
625
                        fetched_packet_vc[ACCEPTED_DEST].read() == VC_RESPONSE)
626
                                &&
627
                        !((ack[UI_DEST].read() || ack[CSR_DEST].read()) && (sc_bit)accepted_vc_decoded.read()[2]);
628
 
629
        bool increment_response_accepted =  registered_ack_accepted.read() &&
630
                !(sc_bit)registered_accepted_vc_decoded.read()[VC_RESPONSE];
631
        bool response_counter_saturate[2];
632
        response_counter_saturate[0] = response_packet_wait_count_accepted[0].read() == 3;
633
        response_counter_saturate[1] = response_packet_wait_count_accepted[1].read() == 3;
634
 
635
 
636
        syn_ResponseControlPacketComplete acceptedInputResponsePacket;
637
        sc_bv<64> fetched_accepted_packet_bits = fetched_packet[ACCEPTED_DEST].read().packet;
638
        acceptedInputResponsePacket.packet = fetched_accepted_packet_bits.range(31,0);
639
        acceptedInputResponsePacket.data_address = fetched_packet[ACCEPTED_DEST].read().data_address;
640
 
641
        if(!response_packet_buffer_accepted_loaded[0].read()){
642
                if(response_packet_buffer_accepted_loaded[1].read()){
643
                        response_packet_buffer_accepted[0] = response_packet_buffer_accepted[1];
644
                        response_packet_wait_count_accepted[0] = response_packet_wait_count_accepted[1].read() +
645
                                sc_uint<1>(increment_response_accepted && !response_counter_saturate[1]);
646
                        response_packet_buffer_accepted_refid[0] =
647
                                response_packet_buffer_accepted_refid[1];
648
                }
649
                else{
650
                        response_packet_buffer_accepted[0] = acceptedInputResponsePacket;
651
                        response_packet_wait_count_accepted[0] = 0;
652
                        response_packet_buffer_accepted_refid[0] =
653
                                fetched_packet_nposted_refid[ACCEPTED_DEST];
654
                }
655
        }
656
        else{
657
                response_packet_wait_count_accepted[0] = response_packet_wait_count_accepted[0].read() +
658
                        sc_uint<1>(increment_response_accepted && !response_counter_saturate[0]);
659
        }
660
 
661
        response_packet_buffer_accepted_loaded[1] = !response_requested[ACCEPTED_DEST].read();
662
 
663
        if(!response_packet_buffer_accepted_loaded[1].read()){
664
                response_packet_buffer_accepted[1] = acceptedInputResponsePacket;
665
                response_packet_wait_count_accepted[1] = 0;
666
                response_packet_buffer_accepted_refid[1] =
667
                        fetched_packet_nposted_refid[ACCEPTED_DEST];
668
        }
669
        else{
670
                response_packet_wait_count_accepted[1] = response_packet_wait_count_accepted[1].read() +
671
                        sc_uint<1>(increment_response_accepted && !response_counter_saturate[1]);
672
        }
673
 
674
 
675
        //////////////////////////////////////////////////////////////
676
        // Manage rejected registers
677
        //////////////////////////////////////////////////////////////
678
 
679
        // Posted channel registers
680
        posted_packet_buffer_rejected_loaded[0] =
681
                        (posted_packet_buffer_rejected_loaded[0].read() ||
682
                        posted_packet_buffer_rejected_loaded[1].read() ||
683
                        fetched_packet_available[FWD_DEST].read() &&
684
                        fetched_packet_vc[FWD_DEST].read() == VC_POSTED)
685
                                &&
686
                        !(ack[FWD_DEST].read() && (sc_bit)rejected_vc_decoded.read()[0]);
687
 
688
        bool increment_posted_rejected = registered_ack_rejected.read() &&
689
                !(sc_bit)registered_rejected_vc_decoded.read()[VC_POSTED];
690
        bool posted_rejected_counter_saturate[2];
691
        posted_rejected_counter_saturate[0] = posted_packet_wait_count_rejected[0].read() == MAX_PASSPW_COUNT;
692
        posted_rejected_counter_saturate[1] = posted_packet_wait_count_rejected[1].read() == MAX_PASSPW_COUNT;
693
 
694
        if(!posted_packet_buffer_rejected_loaded[0].read()){
695
                if(posted_packet_buffer_rejected_loaded[1].read()){
696
                        posted_packet_buffer_rejected[0] = posted_packet_buffer_rejected[1];
697
                        posted_packet_wait_count_rejected[0] = posted_packet_wait_count_rejected[1].read() +
698
                                sc_uint<1>(increment_posted_rejected && !posted_rejected_counter_saturate[1]);
699
                        posted_packet_buffer_rejected_nposted_refid[0] =
700
                                posted_packet_buffer_rejected_nposted_refid[1];
701
                        posted_packet_buffer_rejected_response_refid[0] =
702
                                posted_packet_buffer_rejected_response_refid[1];
703
                }
704
                else{
705
                        posted_packet_buffer_rejected[0] = fetched_packet[FWD_DEST];
706
                        posted_packet_wait_count_rejected[0] = 0;
707
                        posted_packet_buffer_rejected_nposted_refid[0] =
708
                                fetched_packet_nposted_refid[FWD_DEST];
709
                        posted_packet_buffer_rejected_response_refid[0] =
710
                                fetched_packet_response_refid[FWD_DEST];
711
                }
712
        }
713
        else{
714
                posted_packet_wait_count_rejected[0] = posted_packet_wait_count_rejected[0].read() +
715
                        sc_uint<1>(increment_posted_rejected && !posted_rejected_counter_saturate[0]);
716
        }
717
 
718
        posted_packet_buffer_rejected_loaded[1] = !posted_requested[FWD_DEST].read();
719
 
720
        if(!posted_packet_buffer_rejected_loaded[1].read()){
721
                posted_packet_buffer_rejected[1] = fetched_packet[FWD_DEST];
722
                posted_packet_wait_count_rejected[1] = 0;
723
                posted_packet_buffer_rejected_nposted_refid[1] =
724
                        fetched_packet_nposted_refid[FWD_DEST];
725
                posted_packet_buffer_rejected_response_refid[1] =
726
                        fetched_packet_response_refid[FWD_DEST];
727
        }
728
        else{
729
                posted_packet_wait_count_rejected[1] = posted_packet_wait_count_rejected[1].read() +
730
                        sc_uint<1>(increment_posted_rejected && !posted_rejected_counter_saturate[1]);
731
        }
732
 
733
        // NON-Posted channel registers
734
        nposted_packet_buffer_rejected_loaded[0] =
735
                        (nposted_packet_buffer_rejected_loaded[0].read() ||
736
                        nposted_packet_buffer_rejected_loaded[1].read() ||
737
                        fetched_packet_available[FWD_DEST].read() &&
738
                        fetched_packet_vc[FWD_DEST].read() == VC_NON_POSTED)
739
                                &&
740
                        !(ack[FWD_DEST].read() && (sc_bit)rejected_vc_decoded.read()[1]);
741
 
742
        bool increment_nposted_rejected = registered_ack_rejected.read() &&
743
                !(sc_bit)registered_rejected_vc_decoded.read()[VC_NON_POSTED];
744
        bool nposted_rejected_counter_saturate[2];
745
        nposted_rejected_counter_saturate[0] = nposted_packet_wait_count_rejected[0].read() == MAX_PASSPW_COUNT;
746
        nposted_rejected_counter_saturate[1] = nposted_packet_wait_count_rejected[1].read() == MAX_PASSPW_COUNT;
747
 
748
        if(!nposted_packet_buffer_rejected_loaded[0].read()){
749
                if(nposted_packet_buffer_rejected_loaded[1].read()){
750
                        nposted_packet_buffer_rejected[0] = nposted_packet_buffer_rejected[1];
751
                        nposted_packet_wait_count_rejected[0] = nposted_packet_wait_count_rejected[1].read() +
752
                                sc_uint<1>(increment_nposted_rejected && !nposted_rejected_counter_saturate[1]);
753
                        nposted_packet_buffer_rejected_refid[0] =
754
                                nposted_packet_buffer_rejected_refid[1];
755
                }
756
                else{
757
                        nposted_packet_buffer_rejected[0] = fetched_packet[FWD_DEST];
758
                        nposted_packet_wait_count_rejected[0] = 0;
759
                        nposted_packet_buffer_rejected_refid[0] =
760
                                fetched_packet_nposted_refid[FWD_DEST];
761
                }
762
        }
763
        else{
764
                nposted_packet_wait_count_rejected[0] = nposted_packet_wait_count_rejected[0].read() +
765
                        sc_uint<1>(increment_nposted_rejected && !nposted_rejected_counter_saturate[0]);
766
        }
767
 
768
        nposted_packet_buffer_rejected_loaded[1] = !nposted_requested[FWD_DEST].read();
769
 
770
        if(!nposted_packet_buffer_rejected_loaded[1].read()){
771
                nposted_packet_buffer_rejected[1] = fetched_packet[FWD_DEST];
772
                nposted_packet_wait_count_rejected[1] = 0;
773
                nposted_packet_buffer_rejected_refid[1] =
774
                        fetched_packet_nposted_refid[FWD_DEST];
775
        }
776
        else{
777
                nposted_packet_wait_count_rejected[1] = nposted_packet_wait_count_rejected[1].read() +
778
                        sc_uint<1>(increment_nposted_rejected && !nposted_rejected_counter_saturate[1]);
779
        }
780
 
781
        // Response channel registers
782
        response_packet_buffer_rejected_loaded[0] =
783
                        (response_packet_buffer_rejected_loaded[0].read() ||
784
                        response_packet_buffer_rejected_loaded[1].read() ||
785
                        fetched_packet_available[FWD_DEST].read() &&
786
                        fetched_packet_vc[FWD_DEST].read() == VC_RESPONSE)
787
                                &&
788
                        !(ack[FWD_DEST].read() && (sc_bit)rejected_vc_decoded.read()[2]);
789
 
790
        bool increment_response_rejected = registered_ack_rejected.read() &&
791
                !(sc_bit)registered_rejected_vc_decoded.read()[VC_RESPONSE];
792
        bool response_rejected_counter_saturate[2];
793
        response_rejected_counter_saturate[0] = response_packet_wait_count_rejected[0].read() == MAX_PASSPW_COUNT;
794
        response_rejected_counter_saturate[1] = response_packet_wait_count_rejected[1].read() == MAX_PASSPW_COUNT;
795
 
796
        syn_ResponseControlPacketComplete rejectedInputResponsePacket;
797
        sc_bv<64> fetched_rejected_packet_bits = fetched_packet[FWD_DEST].read().packet;
798
        rejectedInputResponsePacket.packet = fetched_rejected_packet_bits.range(31,0);
799
        rejectedInputResponsePacket.data_address = fetched_packet[FWD_DEST].read().data_address;
800
 
801
        if(!response_packet_buffer_rejected_loaded[0].read()){
802
                if(response_packet_buffer_rejected_loaded[1].read()){
803
                        response_packet_buffer_rejected[0] = response_packet_buffer_rejected[1];
804
                        response_packet_wait_count_rejected[0] = response_packet_wait_count_rejected[1].read() +
805
                                sc_uint<1>(increment_response_rejected && !response_rejected_counter_saturate[1]);
806
                        response_packet_buffer_rejected_refid[0] =
807
                                response_packet_buffer_rejected_refid[1];
808
                }
809
                else{
810
                        response_packet_buffer_rejected[0] = rejectedInputResponsePacket;
811
                        response_packet_wait_count_rejected[0] = 0;
812
                        response_packet_buffer_rejected_refid[0] =
813
                                fetched_packet_nposted_refid[FWD_DEST];
814
                }
815
        }
816
        else{
817
                response_packet_wait_count_rejected[0] = response_packet_wait_count_rejected[0].read() +
818
                        sc_uint<1>(increment_response_rejected && !response_rejected_counter_saturate[0]);
819
        }
820
 
821
        response_packet_buffer_rejected_loaded[1] = !response_requested[FWD_DEST].read();
822
 
823
        if(!response_packet_buffer_rejected_loaded[1].read()){
824
                response_packet_buffer_rejected[1] = rejectedInputResponsePacket;
825
                response_packet_wait_count_rejected[1] = 0;
826
                response_packet_buffer_rejected_refid[1] =
827
                        fetched_packet_nposted_refid[FWD_DEST];
828
        }
829
        else{
830
                response_packet_wait_count_rejected[1] = response_packet_wait_count_rejected[1].read() +
831
                        sc_uint<1>(increment_response_rejected && !response_rejected_counter_saturate[1]);
832
        }
833
 
834
}
835
 
836
 
837
void final_reordering_l3::clocked_process(){
838
        if(!resetx.read()){
839
                syn_ControlPacketComplete default_syn_packet_complete;
840
                initialize_syn_ControlPacketComplete(default_syn_packet_complete);
841
 
842
                syn_ResponseControlPacketComplete default_response_syn_packet_complete;
843
                initialize_syn_ResponseControlPacketComplete(default_response_syn_packet_complete);
844
 
845
                out_packet_fwd = default_syn_packet_complete;
846
                out_packet_vc_fwd = 0;
847
                out_packet_accepted = default_syn_packet_complete;
848
                accepted_output_loaded = false;
849
                rejected_output_loaded = false;
850
                out_packet_available_csr = false;
851
                out_packet_available_ui = false;
852
                out_packet_available_fwd = false;
853
                accepted_vc_decoded = 0;
854
                rejected_vc_decoded = 0;
855
 
856
                for(int depth = 0; depth < 2; depth++){
857
                        posted_packet_buffer_accepted[depth] = default_syn_packet_complete;
858
                        posted_packet_wait_count_accepted[depth] = 0;
859
                        posted_packet_buffer_accepted_loaded[depth] = false;
860
                        posted_packet_buffer_accepted_nposted_refid[depth] = 0;
861
                        posted_packet_buffer_accepted_response_refid[depth] = 0;
862
 
863
                        nposted_packet_buffer_accepted[depth] = default_syn_packet_complete;
864
                        nposted_packet_wait_count_accepted[depth] = 0;
865
                        nposted_packet_buffer_accepted_loaded[depth] = false;
866
                        nposted_packet_buffer_accepted_refid[depth] = 0;
867
 
868
                        response_packet_buffer_accepted[depth] = default_response_syn_packet_complete;
869
                        response_packet_wait_count_accepted[depth] = 0;
870
                        response_packet_buffer_accepted_loaded[depth] = false;
871
                        response_packet_buffer_accepted_refid[depth] = 0;
872
 
873
                        posted_packet_buffer_rejected[depth] = default_syn_packet_complete;
874
                        posted_packet_wait_count_rejected[depth] = 0;
875
                        posted_packet_buffer_rejected_loaded[depth] = false;
876
                        posted_packet_buffer_rejected_nposted_refid[depth] = 0;
877
                        posted_packet_buffer_rejected_response_refid[depth] = 0;
878
 
879
                        nposted_packet_buffer_rejected[depth] = default_syn_packet_complete;
880
                        nposted_packet_wait_count_rejected[depth] = 0;
881
                        nposted_packet_buffer_rejected_loaded[depth] = false;
882
                        nposted_packet_buffer_rejected_refid[depth] = 0;
883
 
884
                        response_packet_buffer_rejected[depth] = default_response_syn_packet_complete;
885
                        response_packet_wait_count_rejected[depth] = 0;
886
                        response_packet_buffer_rejected_loaded[depth] = false;
887
                        response_packet_buffer_rejected_refid[depth] = 0;
888
                }
889
 
890
                registered_accepted_vc_decoded = 0;
891
                registered_rejected_vc_decoded = 0;
892
                registered_ack_rejected = false;
893
                registered_ack_accepted = false;
894
        }
895
        else{
896
                doFinalReorderingFWD();
897
                doFinalReorderingAccepted();
898
                updateBufferContent();
899
 
900
                registered_accepted_vc_decoded = accepted_vc_decoded;
901
                registered_rejected_vc_decoded = rejected_vc_decoded;
902
                registered_ack_rejected = ack[FWD_DEST].read();
903
                registered_ack_accepted = ack[UI_DEST].read() || ack[CSR_DEST].read();
904
        }
905
}
906
 
907
void final_reordering_l3::output_request(){
908
        posted_requested[ACCEPTED_DEST] =
909
                         !((posted_packet_buffer_accepted_loaded[0].read() &&
910
                         posted_packet_buffer_accepted_loaded[1].read()) ||
911
                                (fetched_packet_available[ACCEPTED_DEST].read() &&
912
                                fetched_packet_vc[ACCEPTED_DEST].read() == VC_POSTED) &&
913
                                (posted_packet_buffer_accepted_loaded[0].read() ^
914
                                 posted_packet_buffer_accepted_loaded[1].read()));
915
 
916
        posted_requested[FWD_DEST] =
917
                         !((posted_packet_buffer_rejected_loaded[0].read() &&
918
                         posted_packet_buffer_rejected_loaded[1].read()) ||
919
                                (fetched_packet_available[FWD_DEST].read() &&
920
                                fetched_packet_vc[FWD_DEST].read() == VC_POSTED) &&
921
                                (posted_packet_buffer_rejected_loaded[0].read() ^
922
                                 posted_packet_buffer_rejected_loaded[1].read()));
923
 
924
        nposted_requested[ACCEPTED_DEST] =
925
                         !((nposted_packet_buffer_accepted_loaded[0].read() &&
926
                         nposted_packet_buffer_accepted_loaded[1].read()) ||
927
                                (fetched_packet_available[ACCEPTED_DEST].read() &&
928
                                fetched_packet_vc[ACCEPTED_DEST].read() == VC_NON_POSTED) &&
929
                                (nposted_packet_buffer_accepted_loaded[0].read() ^
930
                                 nposted_packet_buffer_accepted_loaded[1].read()));
931
 
932
        nposted_requested[FWD_DEST] =
933
                         !((nposted_packet_buffer_rejected_loaded[0].read() &&
934
                         nposted_packet_buffer_rejected_loaded[1].read()) ||
935
                                (fetched_packet_available[FWD_DEST].read() &&
936
                                fetched_packet_vc[FWD_DEST].read() == VC_NON_POSTED) &&
937
                                (nposted_packet_buffer_rejected_loaded[0].read() ^
938
                                 nposted_packet_buffer_rejected_loaded[1].read()));
939
 
940
        response_requested[ACCEPTED_DEST] =
941
                         !((response_packet_buffer_accepted_loaded[0].read() &&
942
                         response_packet_buffer_accepted_loaded[1].read()) ||
943
                                (fetched_packet_available[ACCEPTED_DEST].read() &&
944
                                fetched_packet_vc[ACCEPTED_DEST].read() == VC_RESPONSE) &&
945
                                (response_packet_buffer_accepted_loaded[0].read() ^
946
                                 response_packet_buffer_accepted_loaded[1].read()));
947
 
948
        response_requested[FWD_DEST] =
949
                         !((response_packet_buffer_rejected_loaded[0].read() &&
950
                         response_packet_buffer_rejected_loaded[1].read()) ||
951
                                (fetched_packet_available[FWD_DEST].read() &&
952
                                fetched_packet_vc[FWD_DEST].read() == VC_RESPONSE) &&
953
                                (response_packet_buffer_rejected_loaded[0].read() ^
954
                                 response_packet_buffer_rejected_loaded[1].read()));
955
}
956
 
957
void final_reordering_l3::find_next_packet_buf_workaround(){
958
        //This function checks for the next packets to send.
959
        //Yes, this could be done in the registered process, but
960
        //the %!@$^% compiler to verilog generates invalid code
961
        //when done in the same process because it generates
962
        //unsized concatenations.  By forcing the result to
963
        //be in a signal, the right operation is done.
964
 
965
        ////////////////////////////////////
966
        // Rejected
967
        ////////////////////////////////////
968
 
969
    syn_ControlPacketComplete rc_packet_rejected_tmp;
970
 
971
        initialize_syn_ControlPacketComplete(rc_packet_rejected_tmp);
972
        if(response_packet_buffer_rejected_loaded[0].read()){
973
                rc_packet_rejected_tmp.packet.range(31,0) =  response_packet_buffer_rejected[0].read().packet;
974
                rc_packet_rejected_tmp.data_address = response_packet_buffer_rejected[0].read().data_address;
975
                rc_packet_rejected_maxwait_reached = response_packet_wait_count_rejected[0].read() == MAX_PASSPW_COUNT;
976
        }
977
        else{
978
                rc_packet_rejected_tmp.packet.range(31,0) =  response_packet_buffer_rejected[1].read().packet;
979
                rc_packet_rejected_tmp.data_address = response_packet_buffer_rejected[1].read().data_address;
980
                rc_packet_rejected_maxwait_reached = response_packet_wait_count_rejected[1].read() == MAX_PASSPW_COUNT &&
981
                        response_packet_buffer_rejected_loaded[1].read();
982
        }
983
        rc_packet_rejected = rc_packet_rejected_tmp;
984
 
985
        // Select the posted packet
986
        if(posted_packet_buffer_rejected_loaded[0].read()){
987
                pc_packet_rejected =  posted_packet_buffer_rejected[0].read();
988
                pc_packet_rejected_maxwait_reached = posted_packet_wait_count_rejected[0].read() == MAX_PASSPW_COUNT;
989
        }
990
        else{
991
                pc_packet_rejected =  posted_packet_buffer_rejected[1].read();
992
                pc_packet_rejected_maxwait_reached = posted_packet_wait_count_rejected[1].read() == MAX_PASSPW_COUNT &&
993
                        posted_packet_buffer_rejected_loaded[1].read();
994
        }
995
 
996
        // Select the non-posted packet
997
        if(nposted_packet_buffer_rejected_loaded[0].read()){
998
                npc_packet_rejected =  nposted_packet_buffer_rejected[0].read();
999
                npc_packet_rejected_maxwait_reached = posted_packet_wait_count_rejected[0].read() == MAX_PASSPW_COUNT;
1000
        }
1001
        else{
1002
                npc_packet_rejected =  nposted_packet_buffer_rejected[1].read();
1003
                npc_packet_rejected_maxwait_reached = posted_packet_wait_count_rejected[0].read() == MAX_PASSPW_COUNT &&
1004
                        nposted_packet_buffer_rejected_loaded[1].read();
1005
        }
1006
 
1007
        ////////////////////////////////////
1008
        // Accepted
1009
        ////////////////////////////////////
1010
 
1011
    syn_ControlPacketComplete rc_packet_accepted_tmp;
1012
 
1013
        initialize_syn_ControlPacketComplete(rc_packet_accepted_tmp);
1014
        if(response_packet_buffer_accepted_loaded[0].read()){
1015
                rc_packet_accepted_tmp.packet.range(31,0) =  response_packet_buffer_accepted[0].read().packet;
1016
                rc_packet_accepted_tmp.data_address = response_packet_buffer_accepted[0].read().data_address;
1017
                rc_packet_accepted_maxwait_reached = response_packet_wait_count_accepted[0].read() == MAX_PASSPW_COUNT;
1018
        }
1019
        else{
1020
                rc_packet_accepted_tmp.packet.range(31,0) =  response_packet_buffer_accepted[1].read().packet;
1021
                rc_packet_accepted_tmp.data_address = response_packet_buffer_accepted[1].read().data_address;
1022
                rc_packet_accepted_maxwait_reached = response_packet_wait_count_accepted[1].read() == MAX_PASSPW_COUNT &&
1023
                        response_packet_buffer_accepted_loaded[1].read();
1024
        }
1025
        rc_packet_accepted = rc_packet_accepted_tmp;
1026
 
1027
        if(posted_packet_buffer_accepted_loaded[0].read()){
1028
                pc_packet_accepted =  posted_packet_buffer_accepted[0].read();
1029
                pc_packet_accepted_maxwait_reached = posted_packet_wait_count_accepted[0].read() == MAX_PASSPW_COUNT;
1030
        }
1031
        else{
1032
                pc_packet_accepted =  posted_packet_buffer_accepted[1].read();
1033
                pc_packet_accepted_maxwait_reached =
1034
                        posted_packet_wait_count_accepted[1].read() == MAX_PASSPW_COUNT &&
1035
                        posted_packet_buffer_accepted_loaded[1].read();
1036
        }
1037
 
1038
        if(nposted_packet_buffer_accepted_loaded[0].read()){
1039
                npc_packet_accepted =  nposted_packet_buffer_accepted[0].read();
1040
                npc_packet_accepted_maxwait_reached = posted_packet_wait_count_accepted[0].read() == MAX_PASSPW_COUNT;
1041
        }
1042
        else{
1043
                npc_packet_accepted = nposted_packet_buffer_accepted[1].read();
1044
                npc_packet_accepted_maxwait_reached = posted_packet_wait_count_accepted[1].read() == MAX_PASSPW_COUNT &&
1045
                        nposted_packet_buffer_accepted_loaded[1].read();
1046
        }
1047
 
1048
}
1049
 
1050
 
1051
// Determine if the current buffer goes to the CSR
1052
bool final_reordering_l3::request_goes_to_csr(const sc_bv<64> &pkt) const
1053
{
1054
        /** No need to check if the packet is upstream of if it was a 64 bit error
1055
        since those cases were ruled out in the entrance reordering     */
1056
        sc_bv<16> csr_top_addr = "1111110111111110";
1057
        sc_bv<16> pkt_top_addr = pkt.range(63,48);
1058
 
1059
        if (pkt_top_addr == csr_top_addr
1060
                        /* No need to check this either as this is also tested in the entrance reordering
1061
                        && pkt.range(39,35) == unit_id.read()
1062
                        && request_getCompatOrIsoc(pkt) == false*/)
1063
                return true;
1064
        else
1065
                return false;
1066
}
1067
 
1068
#ifndef SYSTEMC_SIM
1069
#include "../core_synth/synth_control_packet.cpp"
1070
#endif
1071
 

powered by: WebSVN 2.1.0

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