genericLink.cc

Go to the documentation of this file.
00001 
00020 #ifndef  _genericlink_cc_INC
00021 #define  _genericlink_cc_INC
00022 
00023 #include        "genericLink.h"
00024 
00025 void
00026 GenericLink::setup()
00027 {
00028     name = "link";
00029     address = myId();
00030     node_ip = 0;
00031     flits_passed= 0;
00032     credits_passed=0;
00033 }
00034 
00035 void
00036 GenericLink::process_event ( IrisEvent* e )
00037 {
00038     switch(e->type)
00039     {
00040         case LINK_ARRIVAL_EVENT:
00041             handle_link_arrival_event(e);
00042             break;
00043         default:
00044             cout << " Unk event type at link " << endl;
00045             break;
00046     }
00047 
00048     return ;
00049 }               /* -----  end of function GenericLink::process_event  ----- */
00050 
00051 void
00052 GenericLink::handle_link_arrival_event( IrisEvent* e)
00053 {
00054     LinkArrivalData* data = static_cast<LinkArrivalData*>(e->event_data.at(0));
00055 
00056 #ifdef _DEBUG
00057     _DBG("handle_link_arrival_event vc: %d src_id: %d dest: %d, data type: %d", data->vc, e->src_id, e->dst_id, data->type);
00058 #endif
00059 
00060     if(e->src_id == input_connection->address)
00061     {
00062         /* Update stats */
00063         flits_passed++;
00064 
00065         EventId uid = Simulator::Schedule( Simulator::Now()+ 0.75, &NetworkComponent::process_event, output_connection, e);
00066 //        cout << " inseid link: " << uid.time << " " << uid.uid << " " << uid.nextUID;
00067     }
00068     else
00069     {
00070         /* Update stats */
00071         credits_passed++;
00072         Simulator::Schedule( Simulator::Now()+ 0.75, &NetworkComponent::process_event, input_connection, e);
00073     }
00074 }
00075 
00076 string
00077 GenericLink::toString () const
00078 {
00079     stringstream str;
00080     str << "GenericLink: "
00081         << "\taddress: " << address;
00082     if(input_connection)
00083         str << "\tinput_connection: " << static_cast<NetworkComponent*>(input_connection)->address;
00084     if(output_connection)
00085         str << "\toutput_connection: " << static_cast<NetworkComponent*>(output_connection)->address;
00086     
00087     return str.str();
00088 }               /* -----  end of function GenericLink::toString  ----- */
00089 
00090 string
00091 GenericLink::print_stats() const
00092 {
00093     stringstream str;
00094     str << endl << toString()
00095         << "\n link[" << address << "] No flits passed: " << flits_passed
00096         << "\n link[" << address << "] No credits passed: " << credits_passed
00097         << ". " << endl;
00098     if( flits_passed != credits_passed)
00099         str << " ERROR in link stat.. should be equal for Flit level Flow Control " << endl;
00100 
00101     return str.str();
00102 }
00103 
00104 ullint
00105 GenericLink::get_flits_utilization()
00106 {
00107     return flits_passed;
00108 }
00109 
00110 ullint
00111 GenericLink::get_credits_utilization()
00112 {
00113     return credits_passed;
00114 }
00115 
00116 
00117 #endif   /* ----- #ifndef _genericlink_cc_INC  ----- */

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