crossbar.hh

00001 
00002 #ifndef __CROSSBAR_HH__
00003 #define __CROSSBAR_HH__
00004 
00005 #include <iostream>
00006 #include <vector>
00007 #include <queue>
00008 
00009 #include "interconnect.hh"
00010 
00011 #define DEBUG_CROSSBAR
00012 
00032 class Crossbar : public Interconnect
00033 {
00034     
00035     private:
00036         
00037         bool isFirstRequest;
00038         Tick nextBusFreeTime;
00039         
00040         std::vector<std::list<InterconnectRequest*>* > requestQueues;
00041         std::list<InterconnectDelivery*> deliverQueue;
00042         
00043         void insertIntoList(std::list<InterconnectRequest* >* inList,
00044                             Tick reqTime,
00045                             int fromID);
00046         
00047         bool moreRequestsAvailable();
00048         
00049         int getDestinationId(int fromID);
00050         
00051         void scheduleArbitrationEvent(Tick reqTime);
00052         
00053         std::vector<int> blockedInterfaces;
00054         
00055         bool doProfiling;
00056         std::vector<int> channelUseCycles;
00057         
00058 #ifdef DEBUG_CROSSBAR
00059         void printRequests();
00060 #endif //DEBUG_CROSSBAR
00061         
00062     public:
00063         
00082         Crossbar(const std::string &_name,
00083                  int _width, 
00084                  int _clock,
00085                  int _transDelay,
00086                  int _arbDelay,
00087                  int _cpu_count,
00088                  HierParams *_hier)
00089             : Interconnect(_name,
00090                            _width, 
00091                            _clock, 
00092                            _transDelay, 
00093                            _arbDelay,
00094                            _cpu_count,
00095                            _hier){
00096             
00097             isFirstRequest = true;
00098             nextBusFreeTime = 0;
00099             doProfiling = false;
00100         }
00101         
00106         ~Crossbar(){
00107             for(int i=0;i<requestQueues.size();i++){
00108                 delete requestQueues[i];
00109             }
00110         }
00111         
00120         void request(Tick time, int fromID);
00121 
00132         void send(MemReqPtr& req, Tick time, int fromID);
00133         
00143         void arbitrate(Tick cycle);
00144         
00160         void deliver(MemReqPtr& req, Tick cycle, int toID, int fromID);
00161         
00169         void setBlocked(int fromInterface);
00170         
00171         
00179         void clearBlocked(int fromInterface);
00180         
00191         int getChannelCount(){
00192             //one channel for all interfaces and one coherence bus
00193             channelUseCycles.resize(allInterfaces.size()+1,0);
00194             return allInterfaces.size() + 1;
00195         }
00196         
00206         std::vector<int> getChannelSample();
00207         
00216         void writeChannelDecriptor(std::ofstream &stream);
00217 };
00218 
00219 #endif // __CROSSBAR_HH__

Generated on Tue Jun 5 12:55:20 2007 for M5InterconnectExtensions by  doxygen 1.4.7