highLevelPacket.cc

Go to the documentation of this file.
00001 /*
00002  * =====================================================================================
00003  *
00004  *       Filename:  HighLevelPacket.cc
00005  *
00006  *    Description:  
00007  *
00008  *        Version:  1.0
00009  *        Created:  02/09/2010 08:22:03 PM
00010  *       Revision:  none
00011  *       Compiler:  gcc
00012  *
00013  *         Author:  Mitchelle Rasquinha (), mitchelle.rasquinha@gatech.edu
00014  *        Company:  Georgia Institute of Technology
00015  *
00016  * =====================================================================================
00017  */
00018 
00019 #ifndef  _highlevelpacket_cc_INC
00020 #define  _highlevelpacket_cc_INC
00021 
00022 #include        "highLevelPacket.h"
00023 
00024 /*
00025  *--------------------------------------------------------------------------------------
00026  *       Class:  HighLevelPacket
00027  *      Method:  HighLevelPacket
00028  * Description:  constructor
00029  *--------------------------------------------------------------------------------------
00030  */
00031 HighLevelPacket::HighLevelPacket ()
00032 {
00033     avg_network_latency = 0;
00034     hop_count = 0;
00035     source = -1;
00036     destination = -1;
00037     pkt_cnt=0;
00038     reqs_left=-1;
00039     startIndex=0;
00040     vn = VN0;
00041     msg_class = INVALID_PKT;
00042     transaction_id = 0;
00043     virtual_channel = 0;
00044     data_payload_length = 0;
00045     sent_time = (ullint)Simulator::Now();
00046     recv_time = 0;
00047     req_start_time = 0;
00048     waiting_in_ni = 0;
00049     stat_memory_serviced_time = 0;
00050 }  /* -----  end of method HighLevelPacket::HighLevelPacket  (constructor)  ----- */
00051 
00052 HighLevelPacket::~HighLevelPacket()
00053 {
00054     data.clear();
00055 }
00056 
00057 string HighLevelPacket::toString() const
00058 {
00059     stringstream str;
00060     str << " Creation time: " << sent_time 
00061         << " Source: " << source 
00062         << " Dest: " << destination 
00063         << " transaction_id: " << transaction_id
00064         << " VC: " << virtual_channel
00065         << " msg_class: " << msg_class
00066         << " hop_count: " << hop_count
00067         << " avg_network_latency: " << avg_network_latency
00068         << " data_size: " << data.size()
00069         << " data_payload_length (bits): " << data_payload_length
00070         << " addr: " << hex << addr << dec
00071         << "\t";
00072     return str.str();
00073 }  /* -----  end of method HighLevelPacket::toString::HighLevelPacket::toString  (constructor)  ----- */
00074 
00075 simTime HighLevelPacket::get_transit_time()
00076 {
00077     return recv_time - sent_time;
00078 }
00079 
00080 bool HighLevelPacket::operator==( const HighLevelPacket* p )
00081 {
00082     if( transaction_id == p->transaction_id &&
00083         source == p->source)
00084         return true;
00085     else
00086         return false;
00087 }
00088 
00089 /* This function instantiates a low level packet. One needs to explicitly
00090  * destroy it if used */
00091 void
00092 HighLevelPacket::to_low_level_packet(LowLevelPacket* pkt)
00093 {
00094     pkt->source = source;
00095     pkt->destination = destination;
00096     pkt->transaction_id = transaction_id;
00097     pkt->sent_time = sent_time;
00098     pkt->msg_class = msg_class;
00099     pkt->pkt_cnt = pkt_cnt;
00100     pkt->addr = addr;
00101     pkt->hop_count = hop_count;
00102     pkt->avg_network_latency = avg_network_latency;
00103     pkt->stat_memory_serviced_time = stat_memory_serviced_time;
00104     pkt->req_start_time = req_start_time;
00105     HeadFlit *hf = new HeadFlit();
00106     if( msg_class == REQUEST_PKT)
00107     {
00108         pkt->length = 2;
00109     }
00110     else if( msg_class == ONE_FLIT_REQ || msg_class == PRIORITY_REQ)
00111     {
00112         pkt->length = 1;
00113         hf->is_single_flit_pkt = true;
00114     }
00115     else
00116     {
00117         pkt->length = (uint)(((this->data_payload_length+0.0)/max_phy_link_bits) + 2); // data_payload_length is the number of bits of data;
00118         hf->is_single_flit_pkt = false;
00119     }
00120     pkt->virtual_channel = virtual_channel;
00121 
00122     hf->control_bits.resize(CONTROL_VECTOR_SIZE);
00123     pkt->control_bits.resize(CONTROL_VECTOR_SIZE);
00124 
00125     /*  Create the mask based on message class and vc and virtual network */
00126     uint vc_mask = virtual_channel & 0x0f;
00127     uint vn_mask = (vn & 0x0f) << 4;
00128     uint mc_mask = (msg_class & 0x0f) << 8;
00129     uint mask = vc_mask | vn_mask | mc_mask;
00130     for ( uint i=0 ; i< pkt->control_bits.size() ;i++ )
00131     {
00132         pkt->control_bits[i] = ( mask >> i ) & 0x01;
00133         hf->control_bits[i] = ( mask >> i ) & 0x01;
00134     }
00135 
00136     /* 
00137     if( msg_class == PRIORITY_REQ || msg_class == ONE_FLIT_REQ || msg_class == REQUEST_PKT)
00138         for( uint i=0; i<this->data.size(); i++)
00139         {
00140             hf->payload.push_back(this->data[i]);
00141         }
00142      * */
00143 
00144     hf->packet_originated_time = pkt->sent_time;
00145     hf->addr = addr;
00146     hf->src_address = source;
00147     hf->dst_address = destination;
00148     hf->transaction_id = transaction_id;
00149     hf->pkt_cnt = pkt->pkt_cnt;
00150     hf->length = pkt->length;
00151     hf->vc = virtual_channel;
00152     hf->msg_class = msg_class;
00153     hf->populate_head_flit();
00154     hf->avg_network_latency = avg_network_latency;
00155     hf->hop_count = hop_count;
00156     hf->stat_memory_serviced_time = stat_memory_serviced_time;
00157     hf->req_start_time = req_start_time;
00158     hf->waiting_in_ni = waiting_in_ni; 
00159     pkt->flits.push_back(hf);
00160 
00161     if( msg_class == RESPONSE_PKT || msg_class == WRITE_REQ)
00162     {
00163         vector< bool> temp;
00164         uint no_of_body_flits = ceil(this->data_payload_length/max_phy_link_bits);
00165         for ( uint i=0 ; i<no_of_body_flits ; i++ )
00166         {
00167             BodyFlit* bf = new BodyFlit();
00168             /* 
00169                for ( uint j=0 ; j<max_phy_link_bits && (i*max_phy_link_bits + j)< data.size() ; j++ )
00170                bf->bf_data.push_back(this->data[i*max_phy_link_bits + j]);
00171                */
00172 
00173             bf->populate_body_flit();
00174             pkt->flits.push_back(bf);
00175             temp.clear();
00176         }
00177     }
00178 
00179     if( msg_class == REQUEST_PKT || msg_class == RESPONSE_PKT || msg_class == WRITE_REQ)
00180     {
00181         TailFlit* tf = new TailFlit();
00182         tf->packet_originated_time = pkt->sent_time;
00183         tf->populate_tail_flit();
00184         pkt->flits.push_back(tf);
00185     }
00186 
00187     /* Compute the number of head flits required based on source addr dest
00188      * addr, transaction id and control bits and phit size */
00189 
00190     return ;
00191 }
00192 
00193 void
00194 HighLevelPacket::from_low_level_packet ( LowLevelPacket* llp )
00195 {
00196     source = llp->source;
00197     destination = llp->destination;
00198     transaction_id = llp->transaction_id;
00199     pkt_cnt = llp->pkt_cnt ;
00200     data_payload_length = llp->length;
00201     sent_time = llp->sent_time;
00202     virtual_channel = llp->virtual_channel;
00203     msg_class = llp->msg_class;
00204     addr = llp->addr;
00205     avg_network_latency = llp->avg_network_latency;
00206     hop_count = llp->hop_count;
00207     stat_memory_serviced_time = llp->stat_memory_serviced_time;
00208     req_start_time = llp->req_start_time;
00209     waiting_in_ni = llp->waiting_in_ni;
00210 
00211     for( uint i=0; i<llp->payload.size(); i++)
00212         data.push_back( llp->payload[i]);
00213 
00214     uint mask = 0;
00215     for (uint i=0; i<llp->control_bits.size(); i++)
00216         mask = (mask <<i)|(llp->control_bits[i] & 0x01);
00217 
00218     /*  Need to check this mask propagation: The VC aint right */
00219     //virtual_channel = (mask & 0x00c0)>>6;
00220     switch ((mask & 0x00f0) >> 4)
00221     {
00222         case 0:
00223             vn = VN0;
00224             break;
00225         case 1:
00226             vn = VN1;
00227             break;
00228         default:
00229             vn = VN2;
00230             break;
00231     }
00232 
00233     llp->flits.clear();
00234     llp->control_bits.clear();
00235     llp->payload.clear();
00236     return ;
00237 }               /* -----  end of function HighLevelPacket::from_low_level_packet  ----- */
00238 
00239 #endif   /* ----- #ifndef _highlevelpacket_cc_INC  ----- */
00240 

Generated on Tue Oct 19 17:22:00 2010 for IRIS by  doxygen 1.5.8