gem5/src/mem/ruby/network/booksim2/routefunc.cc
void tree4_anca( const BSRouter *r, const Flit *f,
		 int in_channel, OutputSet* outputs, bool inject)
{
  int vcBegin = 0, vcEnd = gNumVCs-1;
  if ( f->type == Flit::READ_REQUEST ) {
    vcBegin = gReadReqBeginVC;
    vcEnd = gReadReqEndVC;
  } else if ( f->type == Flit::WRITE_REQUEST ) {
    vcBegin = gWriteReqBeginVC;
    vcEnd = gWriteReqEndVC;
  } else if ( f->type ==  Flit::READ_REPLY ) {
    vcBegin = gReadReplyBeginVC;
    vcEnd = gReadReplyEndVC;
  } else if ( f->type ==  Flit::WRITE_REPLY ) {
    vcBegin = gWriteReplyBeginVC;
    vcEnd = gWriteReplyEndVC;
  }
  assert(((f->vc >= vcBegin) && (f->vc <= vcEnd)) || (inject && (f->vc < 0)));

  int range = 1;

  int out_port;

  if(inject) {

    out_port = -1;

  } else {

    int dest = f->dest;

    const int NPOS = 16;

    int rH = r->GetID( ) / NPOS;
    int rP = r->GetID( ) % NPOS;

    if ( rH == 0 ) {
      dest /= 16;
      out_port = 2 * dest + RandomInt(1);
    } else if ( rH == 1 ) {
      dest /= 4;
      if ( dest / 4 == rP / 2 )
	out_port = dest % 4;
      else {
	out_port = gK;
	range = gK;
      }
    } else {
      if ( dest/4 == rP )
	out_port = dest % 4;
      else {
	out_port = gK;
	range = 2;
      }
    }

    //  cout << "BSRouter("<<rH<<","<<rP<<"): id= " << f->id << " dest= " << f->dest << " out_port = "
    //       << out_port << endl;

  }

  outputs->Clear( );

  for (int i = 0; i < range; ++i)
    outputs->AddRange( out_port + i, vcBegin, vcEnd );
}
// ============================================================
//  Tree4: Nearest Common Ancestor w/ Adaptive Routing Up
// ===
Nearest Common Ancestor w/ Adaptive Routing Up
Nearest Common Ancestor w / Adaptive Routing Up
void tree4_anca( const BSRouter *r, const Flit *f,
		 int in_channel, OutputSet* outputs, bool inject)
{
  int vcBegin = 0, vcEnd = gNumVCs-1;
  if ( f->type == Flit::READ_REQUEST ) {
    vcBegin = gReadReqBeginVC;
    vcEnd = gReadReqEndVC;
  } else if ( f->type == Flit::WRITE_REQUEST ) {
    vcBegin = gWriteReqBeginVC;
    vcEnd = gWriteReqEndVC;
  } else if ( f->type ==  Flit::READ_REPLY ) {
    vcBegin = gReadReplyBeginVC;
    vcEnd = gReadReplyEndVC;
  } else if ( f->type ==  Flit::WRITE_REPLY ) {
    vcBegin = gWriteReplyBeginVC;
    vcEnd = gWriteReplyEndVC;
  }
  assert(((f->vc >= vcBegin) && (f->vc <= vcEnd)) || (inject && (f->vc < 0)));
  int range = 1;
  int out_port;
  if(inject) {
    out_port = -1;
  } else {
    int dest = f->dest;
    const int NPOS = 16;
    int rH = r->GetID( ) / NPOS;
    int rP = r->GetID( ) % NPOS;
    if ( rH == 0 ) {
      dest /= 16;
      out_port = 2 * dest + RandomInt(1);
    } else if ( rH == 1 ) {
      dest /= 4;
      if ( dest / 4 == rP / 2 )
	out_port = dest % 4;
      else {
	out_port = gK;
	range = gK;
      }
    } else {
      if ( dest/4 == rP )
	out_port = dest % 4;
      else {
	out_port = gK;
	range = 2;
      }
    }
  }
  outputs->Clear( );
  for (int i = 0; i < range; ++i)
    outputs->AddRange( out_port + i, vcBegin, vcEnd );
}
void tree4_anca ( const BSRouter * r , const Flit * f , int in_channel , OutputSet * outputs , bool inject ) { int vcBegin = 0 , vcEnd = gNumVCs - 1 ; if ( f -> type == Flit :: READ_REQUEST ) { vcBegin = gReadReqBeginVC ; vcEnd = gReadReqEndVC ; } else if ( f -> type == Flit :: WRITE_REQUEST ) { vcBegin = gWriteReqBeginVC ; vcEnd = gWriteReqEndVC ; } else if ( f -> type == Flit :: READ_REPLY ) { vcBegin = gReadReplyBeginVC ; vcEnd = gReadReplyEndVC ; } else if ( f -> type == Flit :: WRITE_REPLY ) { vcBegin = gWriteReplyBeginVC ; vcEnd = gWriteReplyEndVC ; } assert ( ( ( f -> vc >= vcBegin ) && ( f -> vc <= vcEnd ) ) || ( inject && ( f -> vc < 0 ) ) ) ; int range = 1 ; int out_port ; if ( inject ) { out_port = -1 ; } else { int dest = f -> dest ; const int NPOS = 16 ; int rH = r -> GetID ( ) / NPOS ; int rP = r -> GetID ( ) % NPOS ; if ( rH == 0 ) { dest /= 16 ; out_port = 2 * dest + RandomInt ( 1 ) ; } else if ( rH == 1 ) { dest /= 4 ; if ( dest / 4 == rP / 2 ) out_port = dest % 4 ; else { out_port = gK ; range = gK ; } } else { if ( dest / 4 == rP ) out_port = dest % 4 ; else { out_port = gK ; range = 2 ; } } } outputs -> Clear ( ) ; for ( int i = 0 ; i < range ; ++ i ) outputs -> AddRange ( out_port + i , vcBegin , vcEnd ) ; }
Tree4: Nearest Common Ancestor w/ Adaptive Routing Up
Tree4 : Nearest Common Ancestor w / Adaptive Routing Up
//  cout << "BSRouter("<<rH<<","<<rP<<"): id= " << f->id << " dest= " << f->dest << " out_port = " //       << out_port << endl;