00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _EVENT_CHANNEL_H
00014 #define _EVENT_CHANNEL_H
00015
00016 #include <deque>
00017
00018 #include <sst/core/component.h>
00019 #include <sst/core/event.h>
00020 #include <sst/core/link.h>
00021 #include <sst/core/log.h>
00022
00023 #ifndef EVENTCHANNEL_DBG
00024 #define EVENTCHANNEL_DBG 0
00025 #endif
00026
00027 using namespace SST;
00028
00029 template < typename eventT >
00030 class ChannelEvent : public Event {
00031 public:
00032 typedef enum { CREDIT, EVENT } type_t;
00033 type_t type;
00034 uint32_t credit;
00035 eventT* event;
00036 int virtChan;
00037 };
00038
00039 template < typename eventT >
00040 class EventChannel
00041 {
00042 typedef ChannelEvent<eventT> event_t;
00043
00044 public:
00045
00046 virtual ~EventChannel() {;}
00047 EventChannel( Component&, Component::Params_t,
00048 std::string name, int numVC = 1 );
00049
00050 virtual bool ready( int credits, int vc = 0 );
00051 virtual bool send( eventT*, int credits, int vc = 0 );
00052 virtual bool recv( eventT**, int vc = 0);
00053
00054 private:
00055
00056 EventChannel( const EventChannel< eventT >& );
00057 void handler( Event* );
00058 bool clock( Cycle_t );
00059
00060 private:
00061 class VirtChan {
00062 typedef std::deque< ChannelEvent< eventT >* > que_t;
00063 public:
00064 VirtChan( int vc, Link& link, std::string& name, bool dbgFlag,
00065 int startCredit = 1, int threshold = 0 );
00066 bool clock( Cycle_t );
00067 void handler( event_t* );
00068 bool ready( int credits );
00069 bool send( eventT*, int credits );
00070 bool recv( eventT** );
00071
00072 private:
00073 int m_vc;
00074 Link& m_link;
00075 uint32_t m_creditAvail;
00076 uint32_t m_creditFreed;
00077 uint32_t m_creditThreshold;
00078 que_t m_inQ;
00079 que_t m_outQ;
00080 std::string& m_name;
00081
00082 Log< EVENTCHANNEL_DBG >& m_dbg;
00083 };
00084
00085 private:
00086
00087 Component& m_component;
00088 std::vector< VirtChan* > m_vcV;
00089
00090 Log<>& m_log;
00091 Log< EVENTCHANNEL_DBG >& m_dbg;
00092 };
00093
00094 #define EVENTCHANNEL( retType ) \
00095 template < typename eventT >\
00096 retType EventChannel< eventT >\
00097
00098 #include <sst/elements/include/eventChannel2.h>
00099
00100 #endif