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