00001 00002 #ifndef __INTERCONNECT_PROFILE_HH__ 00003 #define __INTERCONNECT_PROFILE_HH__ 00004 00005 #include "sim/sim_object.hh" 00006 #include "sim/eventq.hh" 00007 #include "interconnect.hh" 00008 00010 #define RESOLUTION 1000000 00011 00012 class Interconnect; 00013 class InterconnectProfileEvent; 00014 00016 typedef enum {SEND, CHANNEL} INTERCONNECT_PROFILE_TYPE; 00017 00034 class InterconnectProfile : public SimObject 00035 { 00036 private: 00037 Interconnect* interconnect; 00038 bool traceSends; 00039 bool traceChannelUtil; 00040 Tick startTick; 00041 00042 InterconnectProfileEvent* sendEvent; 00043 InterconnectProfileEvent* channelEvent; 00044 00045 std::string sendFileName; 00046 std::string channelFileName; 00047 std::string channelExplFileName; 00048 00049 public: 00061 InterconnectProfile(const std::string &_name, 00062 bool _traceSends, 00063 bool _traceChannelUtil, 00064 Tick _startTick, 00065 Interconnect* _interconnect); 00066 00070 void initSendFile(); 00071 00077 void writeSendEntry(); 00078 00087 bool initChannelFile(); 00088 00093 void writeChannelEntry(); 00094 }; 00095 00103 class InterconnectProfileEvent : public Event 00104 { 00105 00106 public: 00107 00108 InterconnectProfile* profiler; 00109 INTERCONNECT_PROFILE_TYPE traceType; 00110 00117 InterconnectProfileEvent(InterconnectProfile* _profiler, 00118 INTERCONNECT_PROFILE_TYPE _type) 00119 : Event(&mainEventQueue) 00120 { 00121 profiler = _profiler; 00122 traceType = _type; 00123 } 00124 00130 void process(){ 00131 00132 switch(traceType){ 00133 case SEND: 00134 profiler->writeSendEntry(); 00135 break; 00136 case CHANNEL: 00137 profiler->writeChannelEntry(); 00138 break; 00139 default: 00140 fatal("Unimplemented interconnect trace type"); 00141 } 00142 00143 this->schedule(curTick + RESOLUTION); 00144 } 00145 00149 virtual const char *description(){ 00150 return "InterconnectProfileEvent"; 00151 } 00152 }; 00153 00154 #endif //__INTERCONNECT_PROFILE_HH__