33#ifndef TTA_POMGEN_MACROS
34#define TTA_POMGEN_MACROS
71# define PRINTOUT(STUFF) Application::logStream() << STUFF
73# define PRINTOUT(STUFF)
105 abortWithError(std::string(
"No register file ") + name +
" found.");
109 return *nav.
item(name);
123#define REG(RFNAME, REGNUM) \
124 new TerminalRegister(\
125 *findRegisterFile(machine__, #RFNAME).port(0), \
127 PRINTOUT(#RFNAME "" #REGNUM)
133#define IREG(REGNUM) \
149 machine).universalFunctionUnit();
153 return *nav.
item(name);
163 std::string fuName, std::string pName, std::string opName) {
199 std::string portName) {
203 universalFunctionUnit().operation(fuName)->port(
216#define PORT(FUNAME, PORTNAME) \
217 new TerminalFUPort( \
218 dynamic_cast<BaseFUPort&>( \
219 findFUPort(machine__, #FUNAME, #PORTNAME)));\
220 PRINTOUT(#FUNAME "." #PORTNAME)
229#define OPORT(FUNAME, PORTNAME, OPERATION) \
230 createTerminalFUPort( \
231 machine__, #FUNAME, #PORTNAME, #OPERATION);\
232 PRINTOUT(#FUNAME "." #OPERATION "." #PORTNAME)
241#define OPERAND(OPERATION, OPERAND_INDEX) \
242 OPORT(OPERATION, OPERAND_INDEX, OPERATION)
274 return *nav.
item(busName);
286#define IMM(WIDTH, VALUE) \
287 new TerminalImmediate(tempSimValue(WIDTH, VALUE)); \
297#define CONTROL_OPERAND(OPERATION, OPNUM) \
298 new TerminalFUPort( \
299 *machine__.controlUnit()->operation(#OPERATION), \
301 PRINTOUT(#OPERATION "." #OPNUM)
318 for (
int i = 0; i < navigator.
count(); ++i) {
328 abortWithError(
"Can't find boolean register file from machine!.");
352 if (regGuard == NULL) {
372 new TerminalRegister(\
373 *findBooleanRegisterFile(machine__).port(0), 0);\
380 findBooleanGuard(machine__, false);\
381 PRINTOUT("boolguard")
386#define INVBOOLGUARD() \
387 findBooleanGuard(machine__, true);\
388 PRINTOUT("invboolguard")
395 dynamic_cast<BaseFUPort&>( \
396 *machine__.controlUnit()->returnAddressPort()));\
405#define IMM32(VALUE) \
413#define INSTRUCTION(ADD_MOVES) \
415 Instruction* tempInstruction__ = new Instruction(); \
416 int moveCounter__ = 1; \
417 PRINTOUT("\t" << currentIP__ << ": ");\
420 proc->add(tempInstruction__); \
421} currentIP__ += incrementOfIP__
430#define MOVE_TEMPLATE(SRC, DST, CONSTRUCT_MOVE) \
432 Terminal* src__ = SRC;\
434 Terminal* dst__ = DST;\
436 Bus* bus__ = &findBus(\
437 machine__, std::string("bus") + Conversion::toString(moveCounter__));\
438 std::shared_ptr<Move> tempMove = nullptr; \
440 tempInstruction__->addMove(tempMove);\
446#define BASIC_MOVE_CONSTRUCTION tempMove = std::make_shared<Move>(src__, dst__, *bus__)
458#define MOVE(SRC, DST) MOVE_TEMPLATE(SRC, DST, BASIC_MOVE_CONSTRUCTION);
465#define NOP PRINTOUT("nop "); moveCounter__++;
475#define LABEL(LABEL_NAME) iaddress_##LABEL_NAME
485#define SET_LABEL(LABEL_NAME) \
486 PRINTOUT(#LABEL_NAME ":\n");\
487 unsigned int LABEL(LABEL_NAME) = currentIP__; \
488 LABEL(LABEL_NAME) = currentIP__;
495#define SET_IP(VALUE) currentIP__ = VALUE
503#define SET_IP_INCREMENT(COUNT) incrementOfIP__ = COUNT
520#define GUARDED_MOVE_CONSTRUCTION(ADFGUARD) \
521 TTAMachine::Guard &adfGuard__ = ADFGUARD; \
522 MoveGuard* guard__ = new MoveGuard(adfGuard__); \
523 tempMove = std::make_shared<Move>(src__, dst__, *bus__, guard__);
539#define GMOVE(SRC, DST, GUARD) \
540 MOVE_TEMPLATE(SRC, DST, GUARDED_MOVE_CONSTRUCTION(GUARD));
563#define CREATE_PROGRAM(PROGRAM, MACHINE) \
565 Application::initialize(); \
566 OperationPool operationPool; \
567 unsigned int currentIP__ = 0; \
569 unsigned int incrementOfIP__ = 1; \
570 incrementOfIP__ = 1; \
571 Procedure* proc = NULL;\
572 const AddressSpace& programSpace__ = \
573 *MACHINE.controlUnit()->addressSpace();\
574 Program PROGRAM(programSpace__);\
575 Program& program__ = PROGRAM; \
576 const Machine& machine__ = MACHINE;\
577 PRINTOUT("\n# program '" #PROGRAM "':\n")
584#define CREATE_PROCEDURE(PROCNAME) \
585 SET_LABEL(PROCNAME); \
586 Procedure* PROCNAME = \
587 new Procedure("proc_"#PROCNAME, programSpace__, LABEL(PROCNAME));\
588 program__.addProcedure(PROCNAME);\
598 int foooooO__ = 1; foooooO__++;\
599 PRINTOUT("\n# program ends\n")
#define abortWithError(message)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
TTAMachine::RegisterFile & findRegisterFile(const TTAMachine::Machine &machine, std::string name)
TTAMachine::Port & findFUPort(const TTAMachine::Machine &machine, std::string fuName, std::string portName)
TTAMachine::Bus & findBus(const TTAMachine::Machine &machine, std::string busName)
SimValue & tempSimValue(unsigned int bitWidth, SIntWord intValue)
TTAMachine::Guard & findBooleanGuard(const TTAMachine::Machine &machine, bool isInverted)
TTAProgram::TerminalFUPort * createTerminalFUPort(const TTAMachine::Machine &machine, std::string fuName, std::string pName, std::string opName)
TTAMachine::FunctionUnit & findFunctionUnit(const TTAMachine::Machine &machine, std::string name)
TTAMachine::RegisterFile & findBooleanRegisterFile(const TTAMachine::Machine &machine)
static int toInt(const T &source)
virtual int numberOfRegisters() const
virtual int width() const
Guard * guard(int index) const
virtual HWOperation * operation(const std::string &name) const
virtual FUPort * operationPort(const std::string &name) const
virtual bool hasOperation(const std::string &name) const
virtual BaseFUPort * port(const std::string &name) const
virtual bool isInverted() const
int io(const FUPort &port) const
ComponentType * item(int index) const
virtual RegisterFileNavigator registerFileNavigator() const
virtual FunctionUnitNavigator functionUnitNavigator() const
virtual BusNavigator busNavigator() const
const RegisterFile * registerFile() const