Go to the documentation of this file.
39 #ifndef TTA_OSAL_LANGUAGE_DEFINITIONS_HH
40 #define TTA_OSAL_LANGUAGE_DEFINITIONS_HH
44 #include "tce_config.h"
75 #define OPERATION_COMMON(OPNAME) \
77 OPNAME##_Behavior(const Operation& parent) : OperationBehavior(parent) {}; \
79 mutable OperationPool opPool_;
90 #define OPERATION(OPNAME) \
91 class OPNAME##_Behavior : public OperationBehavior { \
93 typedef NullOperationState StateType; \
95 StateType* fetchState(const OperationContext&) const { \
96 return NullOperationState::instance(); \
98 OPERATION_COMMON(OPNAME) \
131 #define END_OPERATION(OPNAME) \
134 OperationBehavior* createOpBehavior_##OPNAME(const Operation& parent) {\
135 return new OPNAME##_Behavior(parent);\
137 void deleteOpBehavior_##OPNAME(OperationBehavior* target) {\
162 #define OPERATION_WITH_STATE(OPNAME, STATE_NAME) \
163 class OPNAME##_Behavior : public OperationBehavior { \
165 typedef STATE_NAME##_State StateType;\
167 void createState(OperationContext& context) const {\
168 if (!stateExists(context)) {\
169 context.registerState(new STATE_NAME##_State(context));\
173 void deleteState(OperationContext& context) const {\
174 if (!stateExists(context)) {\
177 delete &context.state(#STATE_NAME);\
178 context.unregisterState(#STATE_NAME);\
181 const char* stateName() const {\
185 StateType* fetchState(const OperationContext& oc) const { \
186 return dynamic_cast<StateType*>(&oc.state(#STATE_NAME)); \
188 bool stateExists(OperationContext& context) const {\
190 context.state(#STATE_NAME);\
196 OPERATION_COMMON(OPNAME) \
199 #define END_OPERATION_WITH_STATE(OPNAME) END_OPERATION(OPNAME)
214 #define DEFINE_STATE(STATE_NAME) \
215 class STATE_NAME##_State : public OperationState { \
217 const char* name() { return #STATE_NAME; };
219 #define END_DEFINE_STATE };
229 #define INIT_STATE(STATE_NAME) \
230 public: STATE_NAME##_State(OperationContext& context) { \
233 #define END_INIT_STATE }
242 #define FINALIZE_STATE(STATE_NAME) \
243 public: ~STATE_NAME##_State() {
245 #define END_FINALIZE_STATE }
262 bool simulateTrigger( \
264 OperationContext& context) const { \
271 #define STATE (*fetchState(context))
277 #define END_TRIGGER return true; }
287 #define ADVANCE_CLOCK \
288 void advanceClock(OperationContext& context) { \
294 #define END_ADVANCE_CLOCK }
312 #define INT(OPERAND) (io[(OPERAND) - 1]->intValue())
313 #define UINT(OPERAND) (io[(OPERAND) - 1]->unsignedValue())
314 #define LONG(OPERAND) (io[(OPERAND) - 1]->sLongWordValue())
315 #define ULONG(OPERAND) (io[(OPERAND) - 1]->uLongWordValue())
316 #define FLT(OPERAND) (io[(OPERAND) - 1]->floatWordValue())
317 #define DBL(OPERAND) (io[(OPERAND) - 1]->doubleWordValue())
318 #define HFLT(OPERAND) (io[(OPERAND) -1]->halfFloatWordValue())
325 #define SUBWORD1(OPERAND, ELEMENT) \
326 (io[(OPERAND) - 1]->bitElement(ELEMENT))
327 #define SUBWORD8(OPERAND, ELEMENT) \
328 (io[(OPERAND) - 1]->byteElement(ELEMENT))
329 #define SUBWORD16(OPERAND, ELEMENT) \
330 (io[(OPERAND) - 1]->halfWordElement(ELEMENT))
331 #define SUBWORD32(OPERAND, ELEMENT) \
332 (io[(OPERAND) - 1]->wordElement(ELEMENT))
333 #define SET_SUBWORD1(OPERAND, ELEMENT, VALUE) \
334 (io[(OPERAND) - 1]->setBitElement(ELEMENT, VALUE))
335 #define SET_SUBWORD8(OPERAND, ELEMENT, VALUE) \
336 (io[(OPERAND) - 1]->setByteElement(ELEMENT, VALUE))
337 #define SET_SUBWORD16(OPERAND, ELEMENT, VALUE) \
338 (io[(OPERAND) - 1]->setHalfWordElement(ELEMENT, VALUE))
339 #define SET_SUBWORD32(OPERAND, ELEMENT, VALUE) \
340 (io[(OPERAND) - 1]->setWordElement(ELEMENT, VALUE))
342 #define SUBFLOAT16(OPERAND, ELEMENT) \
343 (io[(OPERAND) - 1]->halfFloatElement(ELEMENT))
344 #define SUBFLOAT32(OPERAND, ELEMENT) \
345 (io[(OPERAND) - 1]->floatElement(ELEMENT))
346 #define SUBFLOAT64(OPERAND, ELEMENT) \
347 (io[(OPERAND) - 1]->doubleFloatElement(ELEMENT))
349 #define SET_SUBFLOAT16(OPERAND, ELEMENT, VALUE) \
350 (io[(OPERAND) - 1]->setHalfFloatElement(ELEMENT, VALUE))
351 #define SET_SUBFLOAT32(OPERAND, ELEMENT, VALUE) \
352 (io[(OPERAND) - 1]->setFloatElement(ELEMENT, VALUE))
353 #define SET_SUBFLOAT64(OPERAND, ELEMENT, VALUE) \
354 (io[(OPERAND) - 1]->setDoubleWordElement(ELEMENT, VALUE))
361 #define IO(OPERAND) (*io[(OPERAND) - 1])
366 #define BWIDTH(OPERAND) (((io[(OPERAND) - 1])->width()))
371 #define PROGRAM_COUNTER (context.programCounter())
377 #define SET_PROGRAM_COUNTER(PCVAL) \
378 context.programCounter() = (PCVAL); \
379 context.setUpdateProgramCounter(true)
384 #define SAVE_RETURN_ADDRESS context.setSaveReturnAddress(true)
389 #define RETURN_ADDRESS (context.returnAddress())
394 #define CONTEXT_ID (context.contextId())
403 #define MAU_SIZE (context.memory().MAUSize())
408 #define MEMORY context.memory()
426 #define SIGN_EXTEND(VALUE, WIDTH) \
427 ((SLongWord)((SLongWord(VALUE) << (64-(WIDTH))) >> (64-(WIDTH))))
446 #define ZERO_EXTEND(VALUE, WIDTH) \
447 ((ULongWord(VALUE) << (64-(WIDTH))) >> (64-(WIDTH)))
456 #define OUTPUT_STREAM OperationGlobals::outputStream()
462 #define OSAL_WORD_WIDTH sizeof(ULongWord) * BYTE_BITWIDTH
470 #define RUNTIME_ERROR(MESSAGE) OperationGlobals::runtimeError(\
471 MESSAGE, __FILE__, __LINE__, parent_);
476 #define EXEC_OPERATION(OPNAME, ...) \
477 const Operation& __used_in_macro_temp__ = opPool_.operation(#OPNAME); \
478 executeOperation(__used_in_macro_temp__.behavior(), context, __VA_ARGS__);
479 #define OP(OPNAME, ...) \
480 const Operation& __used_in_macro_temp__ = opPool_.operation(#OPNAME); \
481 executeOperation(__used_in_macro_temp__.behavior(), context, __VA_ARGS__);
489 #define CYCLE_COUNT (context.cycleCount())
494 #define FU_NAME (context.functionUnitName())
499 #define BRANCH_DELAY_CYCLES (context.branchDelayCycles())
505 #define INPUT_VALIDATION \
506 virtual bool areValid( \
507 const OperationBehavior::InputOperandVector& inputs, \
508 const OperationContext& context) const { \
511 std::vector<const SimValue*> io; \
512 for (size_t i = 0; i < inputs.size(); i++) { \
513 const SimValue* tmp = &inputs.at(i); \
520 #define END_INPUT_VALIDATION \
527 #define DECLARE_VALID \