OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_c/] [synfull/] [traffic-generator/] [src/] [ProNoC_Tgen.cpp] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 alirezamon
/*
2
Copyright (c) 2014, Mario Badr
3
All rights reserved.
4
 
5
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
 
7
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
 
9
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
 
11
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
*/
13
/*
14
 * TrafficGenerator.cpp
15
 *
16
 *  Created on: 2013-01-13
17
 *      Author: mario
18
 */
19
 
20
#include <iostream>
21
#include <list>
22
#include <math.h>
23
 
24
#include "assert.h"
25
#include <map>
26
#include <list>
27
#include <set>
28
 
29
 
30
#include <fstream>
31
#include <stdio.h>
32
 
33
 
34
#include "socketstream.h"
35
#include "messages.h"
36
#include "Global.h"
37
 
38
#include "PacketQueue.h"
39
#include "ModelRead.h"
40
 
41
 
42
 
43
#include "TrafficGenerator.h"
44
 
45
 
46
typedef struct node node_t;
47
typedef struct queue queue_t;
48
 
49
struct node {
50
        node_t* prev;
51
        node_t* next;
52
        unsigned long long int prio;
53
        void* elem;
54
};
55
 
56
struct queue {
57
        node_t* head;
58
        node_t* tail;
59
};
60
 
61
 
62
 
63
int * pronoc_mapping;
64
 
65
 
66
queue_t* synful_queue_new() {
67
        queue_t* to_return = (queue_t*) malloc( sizeof(queue_t) );
68
        if( to_return == NULL ) {
69
                printf( "Failed malloc in queue_new\n" );
70
                exit(0);
71
        }
72
        to_return->head = NULL;
73
        to_return->tail = NULL;
74
        return to_return;
75
}
76
 
77
 
78
#include "synful.h"
79
 
80
 
81
 
82
bool synful_ssExit =false;
83
int synful_injection_done=0;
84
 
85
static  unsigned int  synful_max_pck;
86
static  unsigned int  synful_max_clk;
87
 
88
 
89
 
90
void synful_queue_push( queue_t* q, void* e, unsigned long long int prio ) {
91
        if( q != NULL ) {
92
                if( q->head == NULL ) {
93
                        q->head = (node_t*) malloc( sizeof(node_t) );
94
                        if( q->head == NULL ) {
95
                                printf( "Failed malloc in queue_push\n" );
96
                                exit(0);
97
                        }
98
                        q->tail = q->head;
99
                        q->head->prev = NULL;
100
                        q->head->next = NULL;
101
                        q->head->elem = e;
102
                        q->head->prio = prio;
103
                } else {
104
                        node_t* to_add = (node_t*) malloc( sizeof(node_t) );
105
                        if( to_add == NULL ) {
106
                                printf( "Failed malloc in queue_push\n" );
107
                                exit(0);
108
                        }
109
                        to_add->prio = prio;
110
                        to_add->elem = e;
111
                        node_t* behind;
112
                        for( behind = q->head; (behind != NULL) && (behind->prio < prio); behind = behind->next );
113
                        to_add->next = behind;
114
                        if( behind == NULL ) {
115
                                to_add->prev = q->tail;
116
                                q->tail->next = to_add;
117
                                q->tail = to_add;
118
                        } else if( behind == q->head ) {
119
                                to_add->prev = behind->prev;
120
                                behind->prev = to_add;
121
                                q->head = to_add;
122
                        } else {
123
                                to_add->prev = behind->prev;
124
                                to_add->prev->next = to_add;
125
                                behind->prev = to_add;
126
                        }
127
                }
128
        } else {
129
                printf( "Must initialize queue with queue_new()\n" );
130
                exit(0);
131
        }
132
}
133
 
134
 
135
 
136
 
137
using namespace std;
138
 
139
 
140
unsigned long long synful_numCycles;
141
 
142
 
143
 
144
//Set this to 0 to debug without connecting to booksim
145
#define CONNECT 0
146
 
147
 
148
queue_t** synful_inject;
149
 
150
int synful_steady_exit_activated=0;
151
 
152
 
153
static unsigned long long synful_next_interval;
154
static unsigned long long synful_next_hinterval;
155
unsigned long long synful_cycle;
156
static unsigned long int synful_total_pck_queud=0;
157
unsigned long long int synful_cntPackets = 0;
158
 
159
 
160
 
161
 
162
int synful_state = 1;
163
int synful_lastState = 1;
164
int synful_lastHState = 1;
165
 
166
int synful_messageId = 0;
167
 
168
int synful_allPacketsEjected=0;
169
 
170
//Steady state
171
map<int, map<int, int> > synful_steadyState;
172
map<int, int> synful_hSteadyState;
173
map<int, double> synful_acceptable_mse;
174
double synful_acceptable_hmse;
175
 
176
struct transaction_t {
177
    int source;
178
    int dest;
179
    int invs_sent;
180
    int acks_received;
181
    bool data_received;
182
    bool unblock_received;
183
 
184
    bool Completed() {
185
        return (invs_sent == acks_received) && data_received && unblock_received;
186
    }
187
 
188
    transaction_t() : source(-1), dest(-1), invs_sent(0), acks_received(0),
189
            data_received(false), unblock_received(false) {}
190
};
191
 
192
map<int, InjectReqMsg> synful_inTransitPackets;
193
map<int, transaction_t> synful_inTransitTransactions;
194
PacketQueue synful_packet_queue;
195
 
196
void synful_TranslateIndex(int index, int& source, int& destination) {
197
    source = (int) index / 32; //Truncate remainder
198
    destination = index - (source * 32);
199
}
200
 
201
 
202
 
203
 
204
void* _synful_checked_malloc( size_t n, const char* file, int line ) {
205
        void* ptr;
206
        ptr = malloc( n );
207
        if( ptr == NULL ) {
208
                fprintf( stderr, "ERROR: bad allocation at %s:%d\n", file, line );
209
                exit(0);
210
        }
211
        return ptr;
212
}
213
 
214
#define synful_checked_malloc(x) _synful_checked_malloc(x,__FILE__,__LINE__)
215
 
216
 
217
 
218
 
219
void synful_printPacket(InjectReqMsg msg) {
220
    cout << msg.id << " ";
221
    cout << synful_cycle << " ";
222
    cout << msg.source << " ";
223
    cout << msg.dest << " ";
224
    cout << msg.packetSize << " ";
225
    cout << msg.msgType << " ";
226
    cout << msg.coType << " ";
227
    cout << msg.address << " ";
228
    cout << synful_state;
229
    cout << endl;
230
}
231
 
232
#define SYNFUL_NUM_PACKET_TYPES  10
233
 
234
const char* synful_packet_types[] = {
235
"INITIALIZE_REQ"  ,
236
"INITIALIZE_RES"  ,
237
"STEP_REQ"        ,
238
"STEP_RES"        ,
239
"INJECT_REQ"      ,
240
"INJECT_RES"      ,
241
"EJECT_REQ"       ,
242
"EJECT_RES"       ,
243
"QUIT_REQ"        ,
244
"QUIT_RES"        ,
245
"INVALID"
246
};
247
 
248
const char* synful_packet_type_to_string( pronoc_pck_t* packet ) {
249
        if( packet->msgType < SYNFUL_NUM_PACKET_TYPES ) {
250
                return synful_packet_types[packet->msgType];
251
        } else {
252
                return synful_packet_types[SYNFUL_NUM_PACKET_TYPES];
253
        }
254
}
255
 
256
 
257
 
258
void synful_print_packet( pronoc_pck_t* packet ) {
259
        if( packet != NULL ) {
260
                printf( "  ID:%u SRC:%u DST:%u SIZ:%u TYP:%s",
261
                                packet->id, packet->source,
262
                                packet->dest, packet->packetSize, synful_packet_type_to_string(packet) );
263
 
264
                printf( "\n" );
265
        } else {
266
                printf( "WARNING: %s:%d: NULL packet printed!\n", __FILE__, __LINE__ );
267
        }
268
}
269
 
270
 
271
 
272
void synful_sendPacket(InjectReqMsg& req) {
273
    req.id = synful_messageId;
274
 
275
    if((int) req.address == -1) {
276
        req.address = synful_messageId;
277
        synful_inTransitTransactions[req.address].source = req.source;
278
        synful_inTransitTransactions[req.address].dest = req.dest;
279
        synful_inTransitTransactions[req.address].invs_sent = 0;
280
        synful_inTransitTransactions[req.address].acks_received = 0;
281
    }
282
    synful_messageId++;
283
 
284
    synful_inTransitPackets[req.id] = req;
285
    pronoc_pck_t* new_node = (pronoc_pck_t*) synful_checked_malloc( sizeof(pronoc_pck_t) );
286
    new_node->source = req.source;
287
    new_node->dest= req.dest;
288
    new_node->id= req.id;
289
    new_node->packetSize= req.packetSize;
290
    new_node->msgType=req.msgType;
291
    new_node->cycle = synful_cycle;
292
    int pronoc_id = pronoc_mapping [req.source];
293
    synful_queue_push( synful_inject[pronoc_id], new_node, synful_cycle );
294
}
295
 
296
double synful_calculate_mse(vector<double> predict, vector<double> actual) {
297
    if(predict.size() != actual.size()) {
298
        return -1;
299
    }
300
 
301
    double sum = 0;
302
    for(unsigned int i = 0; i < predict.size(); i++) {
303
        sum += (predict[i] - actual[i]) * (predict[i] - actual[i]);
304
    }
305
 
306
    return ((double) sum / predict.size());
307
}
308
 
309
bool synful_InHSteadyState(int synful_numCycles) {
310
    vector<double> predict;
311
    int sum = 0;
312
    for (map<int, int>::iterator it=synful_hSteadyState.begin();
313
            it!=synful_hSteadyState.end(); ++it) {
314
        double value =  it->second;
315
        sum+= value;
316
        predict.push_back(value);
317
    }
318
 
319
    for(unsigned int i = 0; i < predict.size(); i++) {
320
        predict[i] = ((double) predict[i] / sum);
321
    }
322
 
323
    double mse = synful_calculate_mse(predict, g_hierSState);
324
    if(mse >= 0 && mse < synful_acceptable_hmse && synful_cycle > synful_numCycles*0.3) {
325
        return true;
326
    }
327
 
328
    if(synful_cycle > synful_numCycles*0.7) {
329
        return true;
330
    }
331
 
332
    return false;
333
}
334
 
335
 
336
 
337
void synful_QueuePacket(int source, int destination, int msgType, int coType,
338
        int packetSize, int time, int address) {
339
 
340
         if((synful_total_pck_queud >=  synful_max_pck) || (synful_cycle > synful_max_clk)    ||  (synful_steady_exit_activated==1)){
341
                if(synful_injection_done!=1){
342
                        if (synful_total_pck_queud >  synful_max_pck)  cout << "Reaching max injected packet limit: " << synful_total_pck_queud << " Ending simulation: " << synful_cycle << endl;
343
                        if (synful_cycle > synful_max_clk)                 cout << "Ending simulation at max simulation clk: " << synful_cycle << endl;
344
                        if (synful_steady_exit_activated==1)           cout << "Ending simulation at steady state: " << synful_cycle << endl;
345
                }
346
                synful_injection_done=1;
347
                return;
348
         }
349
 
350
 
351
 
352
        InjectReqMsg packet;
353
    packet.source = source;
354
    packet.dest = destination;
355
    packet.cl = 0;
356
    packet.network = 0;
357
    packet.packetSize = packetSize;
358
    packet.msgType = msgType;
359
    packet.coType = coType;
360
    packet.address = address;
361
 
362
    synful_packet_queue.Enqueue(packet, time);
363
    synful_total_pck_queud++;
364
}
365
 
366
void synful_UniformInject(int writes, int reads, int ccrs, int dcrs) {
367
    int source, destination;
368
    UniformDistribution uni_dist(0, g_resolution/2 -1);
369
 
370
    int delta = 0;
371
 
372
 
373
 
374
    for(int i = 0; i < writes; i++) {
375
        delta = uni_dist.Generate(DEFAULT_ENG) * 2;
376
        source = g_writeSpat[g_hierClass][synful_state].Generate(DEFAULT_ENG);
377
        source = source * 2;
378
 
379
        destination = g_writeDest[g_hierClass][synful_state][source].Generate(DEFAULT_ENG);
380
        destination = destination * 2 + 1;
381
 
382
        synful_QueuePacket(source, destination, REQUEST, WRITE, CONTROL_SIZE,
383
                synful_cycle + delta, -1);
384
    }
385
 
386
    for(int i = 0; i < reads; i++) {
387
        delta = uni_dist.Generate(DEFAULT_ENG) * 2;
388
        source = g_readSpat[g_hierClass][synful_state].Generate(DEFAULT_ENG);
389
        source = source * 2;
390
 
391
        destination = g_readDest[g_hierClass][synful_state][source].Generate(DEFAULT_ENG);
392
        destination = destination * 2 + 1;
393
 
394
        synful_QueuePacket(source, destination, REQUEST, READ, CONTROL_SIZE,
395
                synful_cycle + delta, -1);
396
    }
397
 
398
    for(int i = 0; i < ccrs; i++) {
399
        delta = uni_dist.Generate(DEFAULT_ENG) * 2;
400
        source = g_ccrSpat[g_hierClass][synful_state].Generate(DEFAULT_ENG);
401
        source = source * 2;
402
 
403
        destination = g_ccrDest[g_hierClass][synful_state][source].Generate(DEFAULT_ENG);
404
        destination = destination * 2 + 1;
405
 
406
        synful_QueuePacket(source, destination, REQUEST, PUTC, CONTROL_SIZE,
407
                synful_cycle + delta, -1);
408
    }
409
 
410
    for(int i = 0; i < dcrs; i++) {
411
        delta = uni_dist.Generate(DEFAULT_ENG) * 2;
412
        source = g_dcrSpat[g_hierClass][synful_state].Generate(DEFAULT_ENG);
413
        source = source * 2;
414
 
415
        destination = g_dcrDest[g_hierClass][synful_state][source].Generate(DEFAULT_ENG);
416
        destination = destination * 2 + 1;
417
 
418
        synful_QueuePacket(source, destination, REQUEST, PUTD, DATA_SIZE,
419
                synful_cycle + delta, -1);
420
    }
421
}
422
 
423
//Volumes
424
void synful_InitiateMessages() {
425
    int writes = g_writes[g_hierClass][synful_state].Generate(INIT_MSG_ENG);
426
    int reads = g_reads[g_hierClass][synful_state].Generate(INIT_MSG_ENG);
427
    int ccrs = g_ccrs[g_hierClass][synful_state].Generate(INIT_MSG_ENG);
428
    int dcrs = g_dcrs[g_hierClass][synful_state].Generate(INIT_MSG_ENG);
429
 
430
    //cout << "synfull: writes " << writes << " reads " << reads << " ccrs " << ccrs << " dcrs " << dcrs  << endl;
431
    synful_UniformInject(writes, reads, ccrs, dcrs);
432
}
433
 
434
void synful_Inject() {
435
    list<InjectReqMsg> packets = synful_packet_queue.DeQueue(synful_cycle);
436
    list<InjectReqMsg>::iterator it;
437
 
438
    for(it = packets.begin(); it != packets.end(); ++it) {
439
        synful_sendPacket(*it);
440
    }
441
 
442
    synful_packet_queue.CleanUp(synful_cycle);
443
}
444
 
445
void synful_react(EjectResMsg ePacket) {
446
    map<int, InjectReqMsg>::iterator it = synful_inTransitPackets.find(ePacket.id);
447
    if(it == synful_inTransitPackets.end()) {
448
        cerr << "Error: couldn't find in transit packet " << ePacket.id << endl;
449
        exit(-1);
450
    }
451
 
452
    InjectReqMsg request = it->second;
453
    InjectReqMsg response;
454
    synful_inTransitPackets.erase(it);
455
 
456
    //cout << "synfull received packet id: " << request.id << " " << cycle  << endl;
457
 
458
 
459
    map<int, transaction_t>::iterator trans = synful_inTransitTransactions.find(request.address);
460
 
461
    if(request.msgType == REQUEST &&
462
            (request.coType == WRITE || request.coType == READ)) {
463
        //Handle Read/Write Requests
464
        if((int) request.address == request.id) {
465
            //This is an initiating request. Should we forward it or go to
466
            //memory?
467
            bool isForwarded = g_toForward[g_hierClass][request.dest][request.coType].Generate(REACT_ENG) == 0;
468
 
469
            if(isForwarded) {
470
                int destination = g_forwardDest[g_hierClass][synful_state][request.dest].Generate(REACT_ENG);
471
                destination = destination*2;
472
                if(destination % 2 != 0) {
473
                    cerr << "Error: Invalid destination for forwarded request." << endl;
474
                    exit(-1);
475
                }
476
 
477
                synful_QueuePacket(request.dest, destination, REQUEST, request.coType,
478
                        CONTROL_SIZE, synful_cycle + 1, request.address);
479
 
480
                if(request.coType == WRITE) {
481
                    //How many invalidates to send
482
                    int numInv = g_numInv[g_hierClass][synful_state][request.dest].Generate(REACT_ENG);
483
                    int s = synful_state;
484
 
485
                    if(numInv <= 0) {
486
                        return;
487
                    }
488
 
489
                    //Ensure invalidate destinations are unique (i.e. no two
490
                    //invalidate messages to the same destination)
491
                    set<int> destinations;
492
                    destinations.insert(destination); //Request already forwarded here
493
                    while(destinations.size() != (unsigned int) numInv) {
494
                        int dest = g_invDest[g_hierClass][s][request.dest].Generate(REACT_ENG);
495
                        dest = dest*2;
496
                        destinations.insert(dest);
497
                    }
498
 
499
                    for(set<int>::iterator it = destinations.begin();
500
                            it != destinations.end(); ++it) {
501
                        synful_QueuePacket(request.dest, *it, REQUEST, INV,
502
                                CONTROL_SIZE, synful_cycle + 1, request.address);
503
                        trans->second.invs_sent++;
504
                    }
505
                }
506
 
507
            } else {
508
                //Access memory, queue up a data response for the future
509
                    //cout << "synfull mem access  id: " << request.id << " src:"<< request.source 
510
                    //    << " dst:" << request.dest << " addr:" << request.address 
511
                    //    << " " << cycle  << endl;
512
                synful_QueuePacket(request.dest, request.source, RESPONSE, DATA,
513
                        DATA_SIZE, synful_cycle + 80, request.address);
514
            }
515
 
516
            return;
517
        } else {
518
            //This is not an initiating request, so it's a forwarded request
519
            //if(request.id==52)
520
            //{
521
            //    cout << "synfull packet debug  id: " << request.id << " src:"<< request.dest 
522
            //        << " dst:" << trans->second.source << 
523
            //           " addr:" << request.address << " " << cycle  << endl;
524
            //}
525
 
526
            //Respond with Data
527
            synful_QueuePacket(request.dest,
528
                    trans->second.source, RESPONSE,
529
                    DATA, DATA_SIZE, synful_cycle + 1, request.address);
530
        }
531
    }
532
    else if(request.msgType == REQUEST &&
533
            (request.coType == PUTC || request.coType == PUTD)) {
534
        //Respond with WB_ACK
535
        synful_QueuePacket(request.dest, request.source, RESPONSE, WB_ACK,
536
                CONTROL_SIZE, synful_cycle + 1, request.address);
537
 
538
    }
539
    else if(request.msgType == REQUEST && request.coType == INV) {
540
        //Respond with Ack
541
        synful_QueuePacket(request.dest, trans->second.source,
542
                RESPONSE, ACK, CONTROL_SIZE, synful_cycle + 1, request.address);
543
    } else if(request.msgType == RESPONSE && request.coType == DATA) {
544
        trans->second.data_received = true;
545
        //Send unblock
546
        synful_QueuePacket(synful_inTransitTransactions[request.address].source,
547
                synful_inTransitTransactions[request.address].dest, RESPONSE, UNBLOCK,
548
                CONTROL_SIZE, synful_cycle + 1, request.address);
549
    } else if(request.msgType == RESPONSE && request.coType == ACK) {
550
        trans->second.acks_received++;
551
    } else if(request.msgType == RESPONSE && request.coType == UNBLOCK) {
552
                trans->second.unblock_received = true;
553
        }
554
 
555
    if(trans->second.Completed()) {
556
        synful_inTransitTransactions.erase(trans);
557
    }
558
}
559
 
560
 
561
 
562
 
563
 
564
 
565
 
566
 
567
 
568
void synful_reset_ss() {
569
    for (std::map<int,int>::iterator it=synful_steadyState[g_hierClass].begin();
570
            it!=synful_steadyState[g_hierClass].end(); ++it) {
571
        it->second = 0;
572
    }
573
   synful_state = 1;
574
}
575
 
576
 
577
 
578
 
579
 
580
void synful_model_init(char * fname, bool ss_exit, int seed,unsigned int max_clk, unsigned int max_pck, int * mapping){
581
    cout << "Initiating synful with: " << fname << "random seed:" << seed << endl;
582
        synful_ssExit = ss_exit;
583
 
584
 
585
        ifstream modelFile(fname);
586
        if(!modelFile.good()) {
587
                cerr << "Could not open file " << fname << endl;
588
                exit(-1);
589
        }
590
 
591
 
592
        //Parses the file and stores all information in global variables
593
        ReadModel(modelFile);
594
 
595
        //Close the file stream
596
        modelFile.close();
597
 
598
        synful_next_interval = 0;
599
    synful_next_hinterval = 0;
600
        //Calculate an acceptable MSE for the Markovian Steady-State
601
    double sensitivity = 1.04;
602
        vector<double> predict;
603
    for (unsigned int i = 0; i < g_hierSState.size(); i++) {
604
        predict.push_back(((double) g_hierSState[i] * sensitivity));
605
    }
606
    synful_acceptable_hmse = synful_calculate_mse(predict, g_hierSState);
607
 
608
    synful_max_pck =max_pck;
609
    synful_max_clk =max_clk;
610
    for (int i=0;i< RND_ENG_NUM; i++){
611
        mt_rng[i].seed(seed+i);
612
    }
613
 
614
    pronoc_mapping=mapping;
615
 
616
}
617
 
618
 
619
void synful_run_one_cycle (){
620
 
621
           if(synful_cycle >= synful_next_hinterval) {
622
                synful_next_hinterval += g_timeSpan;
623
 
624
                synful_hSteadyState[g_hierClass]++;
625
 
626
                if(synful_cycle != 0) {
627
                    synful_lastHState = g_hierClass;
628
                    g_hierClass = g_hierState[g_hierClass].Generate(hierClass_ENG) + 1;
629
                    synful_reset_ss();
630
                }
631
 
632
                if(synful_InHSteadyState(synful_numCycles) && synful_ssExit) {
633
 
634
 
635
                    //end simulation
636
                    synful_steady_exit_activated=1;
637
                }
638
 
639
                cout << "Current hierarchical state: " << g_hierClass << endl;
640
            }
641
 
642
            if(synful_cycle >= synful_next_interval) {
643
                synful_next_interval += g_resolution;
644
 
645
                //Track state history for markovian steady state
646
                synful_steadyState[g_hierClass][synful_state]++;
647
 
648
                if(synful_cycle != 0) {
649
                    //Update state
650
                    synful_lastState = synful_state;
651
                    synful_state = g_states1[g_hierClass][synful_state].Generate(hierClass_ENG) + 1;
652
                }
653
 
654
                //Queue up initiating messages for injection
655
                synful_InitiateMessages();
656
            }
657
 
658
            //Inject all of this cycles' messages into the network injection queue
659
            synful_Inject();
660
 
661
 
662
            if (synful_allPacketsEjected)
663
            {
664
                cout << "all pck injected" << endl;
665
                synful_cycle = synful_numCycles;
666
            }
667
 
668
}
669
 
670
 
671
void synful_Eject (pronoc_pck_t * packet){
672
 
673
        EjectResMsg res;
674
 
675
        res.id = packet->id;
676
        res.source = packet->source;
677
        res.dest = packet->dest;
678
        res.packetSize = packet->packetSize;
679
        res.network = 0;
680
        res.cl =0;
681
        //res->miss_pred;
682
        //res->remainingRequests;
683
 
684
 
685
 
686
        //bool hasRequests = true; //Whether there are more requests from the network
687
        if(res.id >= 0) {
688
    //Add responses to list
689
        if(res.id > -1) {
690
             synful_cntPackets++;
691
             synful_react(res);
692
        }
693
     }
694
    //Check if there are more messages from the network
695
   // hasRequests = res.remainingRequests;
696
}
697
 
698
 
699
 
700
 
701
 

powered by: WebSVN 2.1.0

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