void TrafficManager::_Step( ) { Flit *f; Credit *cred; // Inject traffic if ( _voqing ) { _VOQInject( ); } else { _ClassInject( ); } // Advance network _net->ReadInputs( ); _partial_internal_cycles += _internal_speedup; while ( _partial_internal_cycles >= 1.0 ) { _net->InternalStep( ); _partial_internal_cycles -= 1.0; } _net->WriteOutputs( ); ++_time; // Eject traffic and send credits Flit *last_valid_flit; //= new Flit; for ( int output = 0; output < _dests; ++output ) { f = _net->ReadFlit( output ); if ( f ) { if (1 || f->tail) { write_out_buf(output, f); // it should have space! if ( f->watch ) { cout << "Sent flit " << f->id << " to output buffer " << output << endl; cout << " Not sending the credit yet! " <<endl; } } else { if ( f->watch ) { cout << "ejected flit " << f->id << " at output " << output << endl; cout << "sending credit for " << f->vc << endl; } if ( _reorder ) { if ( f->watch ) { cout << "adding flit " << f->id << " to reorder buffer" << endl; cout << "flit's SN is " << f->sn << " buffer's SN is " << _rob_sqn[f->src][f->dest] << endl; } if ( f->sn > _rob_sqn_max[f->src][f->dest] ) { _rob_sqn_max[f->src][f->dest] = f->sn; } if ( f->head ) { _rob_size->AddSample( f->sn - _rob_sqn[f->src][f->dest] ); } f->rob_time = _time; _rob[f->src][output].push( f ); } else { _RetireFlit( f, output ); if ( !_empty_network ) { _accepted_packets[output]->AddSample( 1 ); } } } } transfer2boundary_buf( output ); if (!credit_return_queue[output].empty()) { last_valid_flit = credit_return_queue[output].front(); credit_return_queue[output].pop(); } else { last_valid_flit=NULL; } if (last_valid_flit) { cred = new Credit( 1 ); cred->vc[0] =last_valid_flit->vc; cred->vc_cnt = 1; cred->head = last_valid_flit->head; cred->tail =last_valid_flit->tail; _net->WriteCredit( cred, output ); if (last_valid_flit->watch) { cout <<"WE WROTE A CREDIT for flit "<<last_valid_flit->id<<"To output "<<output<< endl; } _RetireFlit(last_valid_flit, output ); if ( !_empty_network ) { _accepted_packets[output]->AddSample( 1 ); } } else { _net->WriteCredit( 0, output ); if ( !_reorder && !_empty_network) { _accepted_packets[output]->AddSample( 0 ); } } if ( _reorder ) { f = _ReadROB( output ); if ( f ) { if ( f->watch ) { cout << "flit " << f->id << " removed from ROB at output " << output << endl; } _RetireFlit( f, output ); if ( !_empty_network ) { _accepted_packets[output]->AddSample( 1 ); } } else { if ( !_empty_network ) { _accepted_packets[output]->AddSample( 0 ); } } } } }
void TrafficManager::_Step() { Flit *f; Credit *cred; // Inject traffic if (_voqing) { _VOQInject(); } else { _ClassInject(); } // Advance network _net->ReadInputs(); _partial_internal_cycles += _internal_speedup; while (_partial_internal_cycles >= 1.0) { _net->InternalStep(); _partial_internal_cycles -= 1.0; } _net->WriteOutputs(); ++_time; // Eject traffic and send credits for (int output = 0; output < _dests; ++output) { f = _net->ReadFlit(output); if (f) { if (f->watch) { cout << "ejected flit " << f->id << " at output " << output << endl; cout << "sending credit for " << f->vc << endl; } cred = new Credit(1); cred->vc[0] = f->vc; cred->vc_cnt = 1; cred->head = f->head; cred->tail = f->tail; _net->WriteCredit(cred, output); if (f->head && (f->dest != output)) { cout << "At output " << output << endl; cout << *f; Error("Flit arrived at incorrect output"); } if (_reorder) { if (f->watch) { cout << "adding flit " << f->id << " to reorder buffer" << endl; cout << "flit's SN is " << f->sn << " buffer's SN is " << _rob_sqn[f->src][f->dest] << endl; } if (f->sn > _rob_sqn_max[f->src][f->dest]) { _rob_sqn_max[f->src][f->dest] = f->sn; } if (f->head) { _rob_size->AddSample(f->sn - _rob_sqn[f->src][f->dest]); } f->rob_time = _time; _rob[f->src][output].push(f); } else { _RetireFlit(f, output); if (!_empty_network) { _accepted_packets[output]->AddSample(1); } } } else { _net->WriteCredit(0, output); if (!_reorder && !_empty_network) { _accepted_packets[output]->AddSample(0); } } if (_reorder) { f = _ReadROB(output); if (f) { if (f->watch) { cout << "flit " << f->id << " removed from ROB at output " << output << endl; } _RetireFlit(f, output); if (!_empty_network) { _accepted_packets[output]->AddSample(1); } } else { if (!_empty_network) { _accepted_packets[output]->AddSample(0); } } } } }