Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Chipper.cpp #1

Merged
merged 1 commit into from
Jan 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 112 additions & 7 deletions src/routers/chipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,122 @@ void Chipper::Display( ostream & os ) const
os << "Nothing to display" << endl; // Ameya: Just for sake of avoiding pure virual func
}

void Chipper::ReadInputs()
void Chipper::ReadInputs() // HH : Performs the function of reading flits from channel into input buffer
{
cout << "Nothing to display" << endl; // Ameya: Just for sake of avoiding pure virual func
// HH : Receiving flits from channel into input buffer, no credits received, as in event_router
}

void Chipper::WriteOutputs()
// HH Definition of _ReceiveFlits: inserts flit into buffer from channel corresponding to current sim time
int Chipper::_IncomingFlits( )
{
cout << "Nothing to display" << endl; // Ameya: Just for sake of avoiding pure virual func
Flit *f;
map< int,Flit* > buffer_timed;
receive_time = GetSimTime();
for ( int input = 0; input < _inputs; ++input ) {
f = _input_channels[input]->Receive();
if ( f ) {
_input_buffer[input].insert( pair(receive_time,f) );
}
}
}

void Chipper::_InternalStep()
void Chipper::WriteOutputs() // HH : Performs the function of sending flits from output buffer into channel
{
cout << "Nothing to display" << endl; // Ameya: Just for sake of avoiding pure virual func
}
_SendFlits( ); //HH : Sending flits from output buffer into input channel, no credits sent, as in event_router
}

// HH Definition of _Sendflits in Chipper class same as that in class event_router
void Chipper::_SendFlits( int pair_time)
{
map<int,Flit*> buffer_timed;
Flit *f;
for ( int output = 0; output < _outputs; ++output ) {
//if ( !_output_buffer[output].empty( ) ) {
//Flit *f = _output_buffer[output].front( );
//_output_buffer[output].pop( );
//_output_channels[output]->Send( f );
buffer_timed = _output_buffer.back;
f = buffer_timed.find( pair_time);
if(f){
_output_channels[output]->Send( f );
}
}
}

void Chipper::_InternalStep( )
{
// Receive incoming flits
int pair_time = _IncomingFlits( );
//HH : Need to make the time the flits are received global in order to know when the input flits were
// were paired into the map
//Have to pass this onto subsequent functions to find the correct flit from each buffer
// I am thinking pair_time should be updated at each stage with GetSimTime and then passed onto next stage
// Eject flits which have reached their desitnation
_EjectFlits();

_Buffer_to_stage1();

_stage1_to_stage2();



}

// Added by HH
void _EjectFlits(){
Flit *f;

for ( int input = 0; input < _inputs; ++input ) {
// f = _input_buffer[input].pop;

if ( f->dest == GetID() ) {
;
}
else if {

}
else
}
}

void Chipper::_Buffer_to_stage1()
{
map<int, Flit *> intermediate_1;
int input = 0;
for ( int input = 0; input < _inputs; ++input ){
intermediate = _input_buffer[input];
for( map<int, Flit*>::iterator it = intermediate_1.begin() ; it = intermediate_1.end() ; ++it ){ //Nandan: Adding the delay associated with the pipe
if(pair_time == it->first){
it->first = it->first + delay_pipe_1;
}
}
stage_1[input] = _input_buffer[input];
}
}

void Chipper::_stage1_to_stage2()
{
msp<int, Flit *> intermediate_2;
int input = 0;
for ( int input = 0; input < _inputs; ++input ){ // Nandan: Adding the delay associated with the pipe
intermediate = _stage_1[input];
for( map<int, Flit*>::iterator it = intermediate_2.begin() ; it = intermediate_2.end() ; ++it ){
if(pair_time == it->first){
it->first = it->first + delay_pipe_2;
}
}
stage_2[input] = _stage_1[input];
}
}
// Added by HH : scheme for determining Golden_packet as in chipper paper(not exactly)
// Returning the packet id that is to be made golden by just dividing time_elapsed by L instead of
// keeping track of all the packets in the network. (I don't know if a maximum number of packets is available)
// Instead of iterating over all possible packet ids called "transaction ids" from all nodes, just iterate over
// packet ids which uniquely identifies each packet
int Chipper::Golden_Packet(int L) // Parameter L is obtained from before from another function
{
int time_elapsed = GetSimTime();
int epoch_no = time_elapsed/L; // L is the golden epoch, needs to be defined as the upper
//bound of the maximum time taken by a golden packet to reach its destination
return epoch_no;
}