• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/xbar/xbar.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
00011 
00012 
00013 #ifndef _XBAR_H
00014 #define _XBAR_H
00015 
00016 #include <sst/core/event.h>
00017 #include <sst/core/component.h>
00018 #include <sst/core/link.h>
00019 
00020 using namespace SST;
00021 
00022 #if DBG_XBAR
00023 #define _XBAR_DBG( fmt, args...)\
00024          printf( "%d:Xbar::%s():%d: "fmt, _debug_rank,__FUNCTION__,__LINE__, ## args )
00025 #else
00026 #define _XBAR_DBG( fmt, args...)
00027 #endif
00028 
00029 class Xbar : public Component {
00030 
00031     public:
00032         Xbar( ComponentId_t id, Params_t& params ) :
00033             Component( id ), 
00034             params( params ),
00035             frequency( "2.2GHz" )
00036         { 
00037             _XBAR_DBG("new id=%lu\n",id);
00038 
00039             if ( params.find("clock") != params.end() ) {
00040                 frequency = params["clock"];
00041             }
00042 
00043             cpu = configureLink( "port0" );
00044 
00045             nic = configureLink( "port1", new Event::Handler<Xbar>(this,&Xbar::processEvent) );
00046             selfPush = configureSelfLink("selfPush",new Event::Handler<Xbar>(this,&Xbar::selfEvent));
00047             selfPull = configureSelfLink("selfPull");
00048             
00049             TimeConverter* tc = registerClock( frequency, new Clock::Handler<Xbar>(this, &Xbar::clock) );
00050             cpu->setDefaultTimeBase(tc);
00051             nic->setDefaultTimeBase(tc);
00052             selfPush->setDefaultTimeBase(tc);
00053             selfPull->setDefaultTimeBase(tc);
00054 
00055             _XBAR_DBG("Done registering clock\n",id);
00056         }
00057 
00058     private:
00059 
00060         Xbar() : Component(-1) {} // for serialization only
00061         Xbar( const Xbar& c );
00062         bool clock( Cycle_t );
00063         void processEvent( Event*  );
00064         void selfEvent( Event*);
00065         
00066         Params_t    params;
00067         Link*       cpu;
00068         Link*       nic;
00069         Link*       selfPush;
00070         Link*       selfPull;
00071         std::string frequency;
00072 
00073         friend class boost::serialization::access;
00074         template<class Archive>
00075         void serialize(Archive & ar, const unsigned int version )
00076         {
00077             ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Component);
00078             printf("xbaf::serialize()\n");
00079             _AR_DBG(Xbar,"start\n");
00080             printf("  base serializing: Component\n");
00081             printf("  serializing: cpu\n");
00082             ar & BOOST_SERIALIZATION_NVP( cpu );
00083             printf("  serializing: nic\n");
00084             ar & BOOST_SERIALIZATION_NVP( nic );
00085             _AR_DBG(Xbar,"done\n");
00086         }
00087 };
00088 
00089 #endif

Generated on Fri Oct 22 2010 11:02:28 for SST by  doxygen 1.7.1