00001
00002 #ifndef __BUTTERFLY__HH__
00003 #define __BUTTERFLY__HH__
00004
00005 #include "interconnect.hh"
00006
00007
00025 class Butterfly : public Interconnect
00026 {
00027 private:
00028 int switchDelay;
00029 int radix;
00030 int butterflyCpuCount;
00031 int butterflyCacheBanks;
00032 int terminalNodes;
00033 int stages;
00034 int switches;
00035 int butterflyHeight;
00036 int hopCount;
00037 int chanBetweenStages;
00038
00039 std::map<int, int> cpuIDtoNode;
00040 std::map<int, int> l2IDtoNode;
00041
00042 std::list<InterconnectRequest*> requestQueue;
00043 std::list<InterconnectDelivery*> deliverQueue;
00044
00045 std::vector<bool> butterflyStatus;
00046 std::vector<int> channelUsage;
00047
00048 std::vector<int> blockedInterfaces;
00049
00050 public:
00051
00075 Butterfly(const std::string &_name,
00076 int _width,
00077 int _clock,
00078 int _transDelay,
00079 int _arbDelay,
00080 int _cpu_count,
00081 HierParams *_hier,
00082 int _switchDelay,
00083 int _radix,
00084 int _banks);
00085
00089 ~Butterfly(){
00090
00091 }
00092
00102 void request(Tick time, int fromID);
00103
00114 void send(MemReqPtr& req, Tick time, int fromID);
00115
00129 void arbitrate(Tick cycle);
00130
00146 void deliver(MemReqPtr& req, Tick cycle, int toID, int fromID);
00147
00155 void setBlocked(int fromInterface);
00156
00164 void clearBlocked(int fromInterface);
00165
00174 int getChannelCount();
00175
00185 std::vector<int> getChannelSample();
00186
00195 void writeChannelDecriptor(std::ofstream &stream);
00196
00197 private:
00198
00199 void scheduleArbitrationEvent(Tick candidateTime);
00200
00201 bool setChannelsOccupied(int fromInterfaceID, int toInterfaceID);
00202
00203 int getDestinationId(int fromID);
00204
00205 void printChannelStatus();
00206 };
00207
00208 #endif //__BUTTERFLY__HH__
00209