Skip to main content

constructor

StandardMem(SST::ComponentId_t id, Params& params, TimeConverter* time, HandlerBase* handler);

This constructor is called when a (Sub)Component loads a StandardMem interface.

Requirements

Memory interface  
No specific requirements beyond constructing the object.

Endpoint  
Do not call this function directly. The functions for loading SubComponents invoke this constructor.

Parameters

  • id (ComponentId_t) A unique ID generated by SST for each SubComponent
  • params (Params&) The parameter set passed into the StandardMem SubComponent by the simulation configuration file if user-defined or by the parent (Sub)Component if anonymous
  • time (TimeConverter*) A time base to use for the SubComponent's links if needed
  • handler (HandlerBase*) A function callback for returning responses
  • returns (StandardMem) The newly constructed StandardMem SubComponent

Example

Example 1: Implementing a StandardMem constructor

Excerpt from sst-elements/src/sst/elements/memHierarchy/standardInterface.h
#include <sst/core/interfaces/stdMem.h>

class StandardInterface : public SST::Interfaces::StandardMem {
public:
// Tell SST that this class is a SubComponent API
SST_ELI_REGISTER_SUBCOMPONENT(StandardInterface, "memHierarchy", "standardInterface", SST_ELI_ELEMENT_VERSION(1,0,0), "Interface to memory hierarchy between endpoint and cache. COnverts StandardMem requests into MemEventBases.", SST::Interfaces::StandardMem)

/* Rest of ELI macros */

StandardInterface(ComponentId_t cid, Params &params, TimeConverter* time, HandlerBase* handler = NULL);

~StandardInterface();

/* Rest of class */
};
Excerpt from sst-elements/src/sst/elements/memHierarchy/standardInterface.cc
#include <sst_config.h>
#include "standardInterface.h"

StandardInterface::StandardInterface(ComponentId_t cid, Params &params, TimeConverter* time, HandlerBase* handler) :
StandardMem(id, params, time, handler)
{
setDefaultTimeBase(time); // Links are required to have a timebase

/** Rest of constructor implementation **/
}

Example 2: Loading a StandardMem interface

Excerpt from sst-elements/src/sst/elements/memHierarchy/testcpu/standardCPU.cc
standardCPU::standardCPU(ComponentId_t id, Params& params) : Component(id), rng(id, 13)
{
/* Other standardCPU constructor code */

// Load interface subcomponent
// clockTC is standardCPU's clock timeconverter
memory = loadUserSubComponent<StandardMem>("memory", ComponentInfo::SHARE_NONE, clockTC,
new StandardMem::Handler<standardCPU>(this, &standardCPU::handleEvent));

if (!memory)
{
out.fatal(CALL_INFO, -1, "Unable to load StandardMem subcomponent. Check that 'memory' slot is filled in input.\n");
}

/* Some more standardCPU constructor code */
}
#include <sst/core/interfaces/stdMem.h>