To create a new CodeModule, there are only two things you (the developer) must do.
touch CodeModule/HexRotate.cxx touch CodeModules/HexRotate.hxxAt this point you will want to fill in their content, you can copy and paste the following as a template:
HexRotate.hxx:
///////////////////////////////////////////////////////
// //
// Copyright (C) 2006 by Intel Corporation and CMU //
// //
///////////////////////////////////////////////////////
#ifndef __HEXROTATE_H
#define __HEXROTATE_H
#include "CodeModule.hxx"
#include "CatomWorld.hxx"
CODE_MODULE_PROTOTYPE( HexRotate, HexRotate );
using namespace std;
extern CatomWorld *worldPtr;
class HexRotate : public CodeModule {
int mode, old_mode;
int wait;
public:
HexRotate(catomID _hostCatom) :
CodeModule(_hostCatom),mode(0) {}
virtual void newTick();
virtual void endTick();
virtual void oracle();
};
#endif
HexRotate.cxx: /////////////////////////////////////////////////////// // // // Copyright (C) 2006 by Intel Corporation and CMU // // // /////////////////////////////////////////////////////// #includeThe only non-obvious part of this should be the#include #include #include "HexRotate.hxx" #include "CatomWorld.hxx" CODE_MODULE_DECLARATION( HexRotate, HexRotate ); using namespace std; void HexRotate::newTick() { Catom *thisCatom = &(worldPtr->catomHash[hostCatom]->C); // CODE HERE } void HexRotate::endTick() { Catom *thisCatom = &(worldPtr->catomHash[hostCatom]->C); // CODE HERE } void HexRotate::oracle() { cout << "HexRotate Oracle: running concurrently with simulationStart\n"; // CODE HERE oracleYield(); cout << "HexRotate Oracle: running with other oracles only\n"; // CODE HERE oracleYield(); while (1) { cout << "HexRotate Oracle: running concurrently with newTick, endTick\n"; // CODE HERE oracleYield(); cout << "HexRotate Oracle: running with other oracles only\n"; // CODE HERE oracleYield(); } }
CODE_MODULE_PROTOTYPE( HexRotate, HexRotate ); and CODE_MODULE_DECLARATION( HexRotate, HexRotate );parts. These are MACROs that add your Code as a runtime loadable module in the Simulator. In both cases the first argument is the class name you defined, and the second is the string you would like to be able to identify the module as in the Simulator. the presence of these lines allows you to trigger the loading of the module by name in the experiment file by writing MODULES=HexRotate. You can add more than one simultaneous module by making it a comma separated list, such as:
MODULES=HexRotate,Flicker,Heirarchy
emacs CodeModules/Makefile [add HexRotate.cxx to the COMOSRCS= list]