OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Private Member Functions | List of all members
ADFSerializer Class Reference

#include <ADFSerializer.hh>

Inheritance diagram for ADFSerializer:
Inheritance graph
Collaboration diagram for ADFSerializer:
Collaboration graph

Public Member Functions

 ADFSerializer ()
 
virtual ~ADFSerializer ()
 
void writeState (const ObjectState *machineState)
 
ObjectStatereadState ()
 
void writeMachine (const TTAMachine::Machine &machine)
 
TTAMachine::MachinereadMachine ()
 
- Public Member Functions inherited from XMLSerializer
 XMLSerializer ()
 
virtual ~XMLSerializer ()
 
void setSourceFile (const std::string &fileName)
 
void setSourceString (const std::string &source)
 
void setDestinationFile (const std::string &fileName)
 
void setDestinationString (std::string &destination)
 
void setSchemaFile (const std::string &fileName)
 
void setUseSchema (bool useSchema)
 
void setXMLNamespace (std::string nsUri)
 
- Public Member Functions inherited from TCETools::Serializer
virtual ~Serializer ()
 

Protected Member Functions

 ADFSerializer (const ADFSerializer &)
 Copying forbidden.
 
ADFSerializeroperator= (const ADFSerializer &)
 Assingment forbidden.
 
- Protected Member Functions inherited from XMLSerializer
std::string sourceFile () const
 

Static Private Member Functions

static ObjectStateconvertToMDFFormat (const ObjectState *machineState)
 
static ObjectStatebusToMDF (const ObjectState *busState)
 
static ObjectStatesocketToMDF (const ObjectState *socketState)
 
static ObjectStatebridgeToMDF (const ObjectState *bridgeState)
 
static ObjectStatefunctionUnitToMDF (const ObjectState *fuState)
 
static ObjectStateregisterFileToMDF (const ObjectState *rfState)
 
static ObjectStateimmediateUnitToMDF (const ObjectState *iuState, const ObjectState *machineState)
 
static ObjectStateaddressSpaceToMDF (const ObjectState *asState)
 
static ObjectStatecontrolUnitToMDF (const ObjectState *cuState)
 
static ObjectStateimmediateSlotToMDF (const ObjectState *isState)
 
static ObjectStateconvertToMachineFormat (const ObjectState *mdfState)
 
static ObjectStatebusToMachine (const ObjectState *busState)
 
static ObjectStatesocketToMachine (const ObjectState *socketState)
 
static ObjectStatebridgeToMachine (const ObjectState *bridgeState)
 
static ObjectStatefunctionUnitToMachine (const ObjectState *fuState, const int orderNumber)
 
static ObjectStateregisterFileToMachine (const ObjectState *rfState)
 
static ObjectStateaddressSpaceToMachine (const ObjectState *asState)
 
static ObjectStatecontrolUnitToMachine (const ObjectState *cuState)
 
static ObjectStateimmediateUnitToMachine (const ObjectState *iuState, ObjectState *machineState)
 
static ObjectStateimmediateSlotToMachine (const ObjectState *isState)
 
static ObjectStatemachineSRPort (const ObjectState *mdfSRPortState)
 
static ObjectStatemdfSRPort (const ObjectState *machineSRPortState)
 
static void setIUExtensionMode (const ObjectState *mdfIUState, ObjectState *momIUState)
 
static ObjectStatemachineRFPort (const ObjectState *mdfPortState)
 
static ObjectStatemdfPort (const ObjectState *machinePortState)
 
static ObjectStatemachineFUPort (const ObjectState *mdfFUPortState)
 
static ObjectStatemdfFUPort (const ObjectState *machineFUPortState)
 
static ObjectStatemachineOperation (const ObjectState *mdfOperationState)
 
static ObjectStatemdfOperation (const ObjectState *machineOperationState)
 
static ObjectStatemachinePipeline (const ObjectState *mdfPipelineState)
 
static ObjectStatemdfPipeline (const ObjectState *machinePipelineState)
 
static void instructionTemplateToMDF (const ObjectState *momITState, ObjectState *mdfIUState)
 
static void instructionTemplateToMachine (const ObjectState *mdfITState, ObjectState *momMachineState, const std::string &iuName=std::string(""))
 
static ObjectStatemomTemplateSlot (const ObjectState *momITState, const std::string &busName)
 
static bool hasEmptyInstructionTemplate (const ObjectState *momMachineState)
 

Detailed Description

This class is used to generate a machine object model from MDF file and to generate MDF file from a machine object model.

By default ADFSerializer validates the files it reads with ADF Schema.

Definition at line 49 of file ADFSerializer.hh.

Constructor & Destructor Documentation

◆ ADFSerializer() [1/2]

ADFSerializer::ADFSerializer ( )

Constructor.

Definition at line 203 of file ADFSerializer.cc.

203 : XMLSerializer() {
205 setUseSchema(true);
206}
const string ADF_SCHEMA_FILE
static std::string schemaDirPath(const std::string &prog)
void setUseSchema(bool useSchema)
void setSchemaFile(const std::string &fileName)

References ADF_SCHEMA_FILE, Environment::schemaDirPath(), XMLSerializer::setSchemaFile(), and XMLSerializer::setUseSchema().

Here is the call graph for this function:

◆ ~ADFSerializer()

ADFSerializer::~ADFSerializer ( )
virtual

Destructor.

Definition at line 212 of file ADFSerializer.cc.

212 {
213}

◆ ADFSerializer() [2/2]

ADFSerializer::ADFSerializer ( const ADFSerializer )
protected

Copying forbidden.

Member Function Documentation

◆ addressSpaceToMachine()

ObjectState * ADFSerializer::addressSpaceToMachine ( const ObjectState asState)
staticprivate

Creates a new ObjectState tree which can be read by AddressSpace::loadState.

The ObjectState tree is created according to the given ObjectState tree which matches with the syntax of address space declaration in MDF file.

Parameters
asStateThe ObjectState tree which matches with the syntax of address space declaration in MDF file.
Returns
The newly created ObjectState tree.

Definition at line 1391 of file ADFSerializer.cc.

1391 {
1392
1394
1395 // set name
1396 as->setAttribute(
1398
1399 // set width
1400 ObjectState* width = asState->childByName(AS_WIDTH);
1402
1403 // set min address
1404 ObjectState* minAddress = asState->childByName(AS_MIN_ADDRESS);
1405 as->setAttribute(
1407
1408 // set max address
1409 ObjectState* maxAddress = asState->childByName(AS_MAX_ADDRESS);
1410 as->setAttribute(
1412
1413 if (asState->hasChild(AS_SHARED_MEMORY)) {
1414 ObjectState* shared = asState->childByName(AS_SHARED_MEMORY);
1415 as->setAttribute(
1417 }
1418
1419 // the numerical ids
1420 for (int i = 0; i < asState->childCount(); i++) {
1421 ObjectState* child = asState->child(i);
1422 if (child->name() == AS_NUMERICAL_ID) {
1423 ObjectState* idObj =
1425 idObj->setValue(child->intValue());
1426 as->addChild(idObj);
1427 }
1428 }
1429
1430 return as;
1431}
const string AS_MAX_ADDRESS
const string AS_NAME
const string AS_WIDTH
const string AS_MIN_ADDRESS
const string AS_NUMERICAL_ID
const string AS_SHARED_MEMORY
ObjectState * childByName(const std::string &name) const
void setAttribute(const std::string &name, const std::string &value)
void setValue(const std::string &value)
bool boolValue() const
bool hasChild(const std::string &name) const
ObjectState * child(int index) const
void addChild(ObjectState *child)
int intValue() const
std::string stringAttribute(const std::string &name) const
std::string stringValue() const
std::string name() const
int childCount() const
static const std::string OSKEY_NUMERICAL_ID
static const std::string OSNAME_ADDRESS_SPACE
ObjectState name for AddressSpace.
static const std::string OSKEY_SHARED_MEMORY
static const std::string OSKEY_MAX_ADDRESS
ObjectState attribute key for maximum address.
static const std::string OSKEY_MIN_ADDRESS
ObjectState attribute key for minimum address.
static const std::string OSKEY_WIDTH
ObjectState attribute key for the bit width.
static const std::string OSKEY_NAME
ObjectState attribute key for the name of the component.

References ObjectState::addChild(), AS_MAX_ADDRESS, AS_MIN_ADDRESS, AS_NAME, AS_NUMERICAL_ID, AS_SHARED_MEMORY, AS_WIDTH, ObjectState::boolValue(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), ObjectState::hasChild(), ObjectState::intValue(), ObjectState::name(), TTAMachine::AddressSpace::OSKEY_MAX_ADDRESS, TTAMachine::AddressSpace::OSKEY_MIN_ADDRESS, TTAMachine::Component::OSKEY_NAME, TTAMachine::AddressSpace::OSKEY_NUMERICAL_ID, TTAMachine::AddressSpace::OSKEY_SHARED_MEMORY, TTAMachine::AddressSpace::OSKEY_WIDTH, TTAMachine::AddressSpace::OSNAME_ADDRESS_SPACE, ObjectState::setAttribute(), ObjectState::setValue(), ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ addressSpaceToMDF()

ObjectState * ADFSerializer::addressSpaceToMDF ( const ObjectState asState)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by AddressSpace::saveState.

Parameters
asStateRoot node of the ObjectState tree created by AddressSpace::saveState.
Returns
The newly created ObjectState tree.

Definition at line 852 of file ADFSerializer.cc.

852 {
853
855 as->setAttribute(
856 AS_NAME, asState->stringAttribute(AddressSpace::OSKEY_NAME));
857
858 // add width element
859 ObjectState* width = new ObjectState(AS_WIDTH);
860 as->addChild(width);
862
863 // add min-address element
864 ObjectState* minAddress = new ObjectState(AS_MIN_ADDRESS);
865 as->addChild(minAddress);
866 minAddress->setValue(
868
869 // add max-address element
870 ObjectState* maxAddress = new ObjectState(AS_MAX_ADDRESS);
871 as->addChild(maxAddress);
872 maxAddress->setValue(
874
877 as->addChild(shared);
878 shared->setValue(
880 }
881 // the numerical ids
882 for (int i = 0; i < asState->childCount(); i++) {
883 ObjectState* child = asState->child(i);
884 if (child->name() == AddressSpace::OSKEY_NUMERICAL_ID) {
885 ObjectState* idObj = new ObjectState(AS_NUMERICAL_ID, as);
886 idObj->setValue(child->intValue());
887 }
888 }
889 return as;
890}
const string ADDRESS_SPACE
bool hasAttribute(const std::string &name) const
bool boolAttribute(const std::string &name) const

References ObjectState::addChild(), ADDRESS_SPACE, AS_MAX_ADDRESS, AS_MIN_ADDRESS, AS_NAME, AS_NUMERICAL_ID, AS_SHARED_MEMORY, AS_WIDTH, ObjectState::boolAttribute(), ObjectState::child(), ObjectState::childCount(), ObjectState::hasAttribute(), ObjectState::intValue(), ObjectState::name(), TTAMachine::AddressSpace::OSKEY_MAX_ADDRESS, TTAMachine::AddressSpace::OSKEY_MIN_ADDRESS, TTAMachine::AddressSpace::OSKEY_NUMERICAL_ID, TTAMachine::AddressSpace::OSKEY_SHARED_MEMORY, TTAMachine::AddressSpace::OSKEY_WIDTH, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ bridgeToMachine()

ObjectState * ADFSerializer::bridgeToMachine ( const ObjectState bridgeState)
staticprivate

Creates a new ObjectState tree which can be read by Bridge::loadState.

The ObjectState tree is created according to the given ObjectState tree which matches with the syntax of bridge declaration in MDF file.

Parameters
bridgeStateThe ObjectState tree which matches with the syntax of bridge declaration in MDF file.
Returns
The newly created ObjectState tree.

Definition at line 1232 of file ADFSerializer.cc.

1232 {
1233
1235 bridge->setAttribute(
1237 ObjectState* readsFrom = bridgeState->childByName(BRIDGE_READS_FROM);
1238 bridge->setAttribute(Bridge::OSKEY_SOURCE_BUS, readsFrom->stringValue());
1239 ObjectState* writesTo = bridgeState->childByName(BRIDGE_WRITES_TO);
1240 bridge->setAttribute(
1242 return bridge;
1243}
const string BRIDGE_WRITES_TO
const string BRIDGE_READS_FROM
const string BRIDGE_NAME
static const std::string OSNAME_BRIDGE
ObjectState name for bridge.
Definition Bridge.hh:70
static const std::string OSKEY_DESTINATION_BUS
ObjectState attribute key for destination bus name.
Definition Bridge.hh:74
static const std::string OSKEY_SOURCE_BUS
ObjectState attribute key for source bus name.
Definition Bridge.hh:72

References BRIDGE_NAME, BRIDGE_READS_FROM, BRIDGE_WRITES_TO, ObjectState::childByName(), TTAMachine::Bridge::OSKEY_DESTINATION_BUS, TTAMachine::Component::OSKEY_NAME, TTAMachine::Bridge::OSKEY_SOURCE_BUS, TTAMachine::Bridge::OSNAME_BRIDGE, ObjectState::setAttribute(), ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ bridgeToMDF()

ObjectState * ADFSerializer::bridgeToMDF ( const ObjectState bridgeState)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by Bridge::saveState.

Parameters
bridgeStateRoot node of the ObjectState tree created by Bridge::saveState.
Returns
The newly created ObjectState tree.

Definition at line 597 of file ADFSerializer.cc.

597 {
598
599 ObjectState* bridge = new ObjectState(BRIDGE);
600 bridge->setAttribute(
601 BRIDGE_NAME, bridgeState->stringAttribute(Bridge::OSKEY_NAME));
602
603 ObjectState* readsFrom = new ObjectState(BRIDGE_READS_FROM);
604 bridge->addChild(readsFrom);
605 readsFrom->setValue(
607
609 bridge->addChild(writesTo);
610 writesTo->setValue(
612
613 return bridge;
614}
const string BRIDGE

References ObjectState::addChild(), BRIDGE, BRIDGE_NAME, BRIDGE_READS_FROM, BRIDGE_WRITES_TO, TTAMachine::Bridge::OSKEY_DESTINATION_BUS, TTAMachine::Bridge::OSKEY_SOURCE_BUS, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ busToMachine()

ObjectState * ADFSerializer::busToMachine ( const ObjectState busState)
staticprivate

Creates a new ObjectState tree which can be read by Bus::loadState and which corresponds with the given ObjectState tree declaring a bus by MDF syntax.

Parameters
busStateThe ObjectState tree declaring a bus by MDF syntax.
Returns
The newly created ObjectState tree.

Definition at line 1064 of file ADFSerializer.cc.

1064 {
1065
1067
1068 // set name
1069 bus->setAttribute(
1071
1072 // set width
1073 ObjectState* width = busState->childByName(BUS_WIDTH);
1075
1076 // set immediate width and extension
1077 ObjectState* shortImm = busState->childByName(SHORT_IMMEDIATE);
1078 ObjectState* shortImmWidth = shortImm->childByName(SHORT_IMM_WIDTH);
1079 bus->setAttribute(Bus::OSKEY_IMMWIDTH, shortImmWidth->stringValue());
1080 ObjectState* shortImmExt = shortImm->childByName(SHORT_IMM_EXTENSION);
1081 string extension = shortImmExt->stringValue();
1082 if (extension == SIGN_EXTENSION) {
1084 } else if (extension == ZERO_EXTENSION) {
1086 } else {
1087 string procName = "ADFSerializer::busToMachine";
1088 string errorMsg = "Unknown extension value in ObjectState.";
1089 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
1091 }
1092
1093 // add segments and guards
1094 for (int i = 0; i < busState->childCount(); i++) {
1095 ObjectState* child = busState->child(i);
1096 if (child->name() == SEGMENT) {
1098 bus->addChild(segment);
1099 segment->setAttribute(
1101 ObjectState* writesTo = child->childByName(SEGMENT_WRITES_TO);
1102 string destination = writesTo->stringValue();
1103 if (destination != "") {
1104 segment->setAttribute(
1106 }
1107 } else if (child->name() == GUARD) {
1108 ObjectState* guardType = child->child(0);
1109 if (guardType->name() == ALWAYS_TRUE_GUARD) {
1110 ObjectState* ucGuard = new ObjectState(
1112 bus->addChild(ucGuard);
1113 ucGuard->setAttribute(Guard::OSKEY_INVERTED, false);
1114 } else if (guardType->name() == ALWAYS_FALSE_GUARD) {
1115 ObjectState* ucGuard = new ObjectState(
1117 bus->addChild(ucGuard);
1118 ucGuard->setAttribute(Guard::OSKEY_INVERTED, true);
1119 } else if (guardType->name() == SIMPLE_EXPR ||
1120 guardType->name() == INVERTED_EXPR) {
1121 ObjectState* boolOrUnit = guardType->child(0);
1122 string objectStateName;
1123 string unitNameElem;
1124 string unitNameAttrib;
1125 string targetNameElem;
1126 string targetNameAttrib;
1127 if (boolOrUnit->name() == GUARD_BOOL) {
1128 objectStateName = RegisterGuard::OSNAME_REGISTER_GUARD;
1129 unitNameElem = GUARD_REGFILE_NAME;
1130 unitNameAttrib = RegisterGuard::OSKEY_REGFILE;
1131 targetNameElem = GUARD_REGFILE_INDEX;
1132 targetNameAttrib = RegisterGuard::OSKEY_INDEX;
1133 } else if (boolOrUnit->name() == GUARD_UNIT) {
1134 objectStateName = PortGuard::OSNAME_PORT_GUARD;
1135 unitNameElem = GUARD_UNIT_NAME;
1136 unitNameAttrib = PortGuard::OSKEY_FU;
1137 targetNameElem = GUARD_UNIT_PORT;
1138 targetNameAttrib = PortGuard::OSKEY_PORT;
1139 } else {
1140 string procName = "ADFSerializer::busToMachine";
1141 string errorMsg = "Unknown ObjectState name.";
1143 __FILE__, __LINE__, procName, errorMsg);
1145 }
1146
1147 ObjectState* guard = new ObjectState(objectStateName);
1148 bus->addChild(guard);
1149 if (guardType->name() == SIMPLE_EXPR) {
1150 guard->setAttribute(Guard::OSKEY_INVERTED, false);
1151 } else {
1152 guard->setAttribute(Guard::OSKEY_INVERTED, true);
1153 }
1154 ObjectState* unit = boolOrUnit->childByName(unitNameElem);
1155 guard->setAttribute(unitNameAttrib, unit->stringValue());
1156 ObjectState* target = boolOrUnit->childByName(
1157 targetNameElem);
1158 guard->setAttribute(targetNameAttrib, target->stringValue());
1159 }
1160 }
1161 }
1162
1163 return bus;
1164}
const string GUARD_UNIT_PORT
const string SIGN_EXTENSION
const string BUS_WIDTH
const string GUARD
const string GUARD_REGFILE_NAME
const string GUARD_BOOL
const string ALWAYS_FALSE_GUARD
const string SHORT_IMM_EXTENSION
const string SHORT_IMM_WIDTH
const string SEGMENT
const string ALWAYS_TRUE_GUARD
const string GUARD_REGFILE_INDEX
const string INVERTED_EXPR
const string GUARD_UNIT_NAME
const string SHORT_IMMEDIATE
const string SEGMENT_NAME
const string GUARD_UNIT
const string SEGMENT_WRITES_TO
const string SIMPLE_EXPR
const string ZERO_EXTENSION
const string BUS_NAME
static void abortProgram() __attribute__((noreturn))
static void writeToErrorLog(const std::string fileName, const int lineNumber, const std::string functionName, const std::string message, const int neededVerbosity=0)
static const std::string OSKEY_EXTENSION
ObjectState attribute key for extension mode.
Definition Bus.hh:122
static const std::string OSKEY_WIDTH
ObjectState attribute key for bus width.
Definition Bus.hh:118
static const std::string OSNAME_BUS
ObjectState name for Bus ObjectState.
Definition Bus.hh:116
static const std::string OSVALUE_ZERO
ObjectState attribute key for zero extension.
Definition Bus.hh:126
static const std::string OSVALUE_SIGN
ObjectState attribute value for sign extension.
Definition Bus.hh:124
static const std::string OSKEY_IMMWIDTH
ObjectState attribute key for immediate width.
Definition Bus.hh:120
static const std::string OSKEY_INVERTED
ObjectState attribute key for inverted feature.
Definition Guard.hh:77
static const std::string OSKEY_PORT
ObjectState attribute key for port name.
Definition Guard.hh:121
static const std::string OSKEY_FU
ObjectState attribute key for function unit name.
Definition Guard.hh:119
static const std::string OSNAME_PORT_GUARD
ObjectState name for PortGuard ObjectState.
Definition Guard.hh:117
static const std::string OSNAME_REGISTER_GUARD
ObjectState name for RegisterGuard.
Definition Guard.hh:159
static const std::string OSKEY_INDEX
ObjectState attribute key for register index.
Definition Guard.hh:163
static const std::string OSKEY_REGFILE
ObjectState attribute key for register file name.
Definition Guard.hh:161
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination segment name.
Definition Segment.hh:91
static const std::string OSNAME_SEGMENT
ObjectState name for Segment.
Definition Segment.hh:87
static const std::string OSKEY_NAME
ObjectState attribute key for segment name.
Definition Segment.hh:89
static const std::string OSNAME_UNCONDITIONAL_GUARD
ObjectState name for UnconditionalGuard.
Definition Guard.hh:195

References Application::abortProgram(), ObjectState::addChild(), ALWAYS_FALSE_GUARD, ALWAYS_TRUE_GUARD, BUS_NAME, BUS_WIDTH, ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), GUARD, GUARD_BOOL, GUARD_REGFILE_INDEX, GUARD_REGFILE_NAME, GUARD_UNIT, GUARD_UNIT_NAME, GUARD_UNIT_PORT, INVERTED_EXPR, ObjectState::name(), TTAMachine::Segment::OSKEY_DESTINATION, TTAMachine::Bus::OSKEY_EXTENSION, TTAMachine::PortGuard::OSKEY_FU, TTAMachine::Bus::OSKEY_IMMWIDTH, TTAMachine::RegisterGuard::OSKEY_INDEX, TTAMachine::Guard::OSKEY_INVERTED, TTAMachine::Component::OSKEY_NAME, TTAMachine::Segment::OSKEY_NAME, TTAMachine::PortGuard::OSKEY_PORT, TTAMachine::RegisterGuard::OSKEY_REGFILE, TTAMachine::Bus::OSKEY_WIDTH, TTAMachine::Bus::OSNAME_BUS, TTAMachine::PortGuard::OSNAME_PORT_GUARD, TTAMachine::RegisterGuard::OSNAME_REGISTER_GUARD, TTAMachine::Segment::OSNAME_SEGMENT, TTAMachine::UnconditionalGuard::OSNAME_UNCONDITIONAL_GUARD, TTAMachine::Bus::OSVALUE_SIGN, TTAMachine::Bus::OSVALUE_ZERO, SEGMENT, SEGMENT_NAME, SEGMENT_WRITES_TO, ObjectState::setAttribute(), SHORT_IMM_EXTENSION, SHORT_IMM_WIDTH, SHORT_IMMEDIATE, SIGN_EXTENSION, SIMPLE_EXPR, ObjectState::stringAttribute(), ObjectState::stringValue(), Application::writeToErrorLog(), and ZERO_EXTENSION.

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ busToMDF()

ObjectState * ADFSerializer::busToMDF ( const ObjectState busState)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by Bus::saveState.

Parameters
busStateRoot node of the ObjectState tree created by Bus::saveState.
Returns
The newly created ObjectState tree.

Definition at line 419 of file ADFSerializer.cc.

419 {
420
421 ObjectState* root = new ObjectState(BUS);
422 root->setAttribute(BUS_NAME, busState->stringAttribute(Bus::OSKEY_NAME));
423
424 // add width element
425 ObjectState* widthChild = new ObjectState(BUS_WIDTH);
426 widthChild->setValue(busState->stringAttribute(Bus::OSKEY_WIDTH));
427 root->addChild(widthChild);
428
429 // add guards
430 for (int i = 0; i < busState->childCount(); i++) {
431 ObjectState* child = busState->child(i);
432
433 if (child->name() == PortGuard::OSNAME_PORT_GUARD ||
435 string guardType;
436 string guardUnit;
437 string guardTarget;
438 string unitNameAttrib;
439 string targetNameAttrib;
440 if (child->name() == PortGuard::OSNAME_PORT_GUARD) {
441 guardType = GUARD_UNIT;
442 guardUnit = GUARD_UNIT_NAME;
443 guardTarget = GUARD_UNIT_PORT;
444 unitNameAttrib = PortGuard::OSKEY_FU;
445 targetNameAttrib = PortGuard::OSKEY_PORT;
446 } else if (child->name() ==
448 guardType = GUARD_BOOL;
449 guardUnit = GUARD_REGFILE_NAME;
450 guardTarget = GUARD_REGFILE_INDEX;
451 unitNameAttrib = RegisterGuard::OSKEY_REGFILE;
452 targetNameAttrib = RegisterGuard::OSKEY_INDEX;
453 }
454
455 ObjectState* guardChild = new ObjectState(GUARD);
456 root->addChild(guardChild);
457 ObjectState* conditionalChild;
459 conditionalChild = new ObjectState(INVERTED_EXPR);
460 } else {
461 conditionalChild = new ObjectState(SIMPLE_EXPR);
462 }
463 guardChild->addChild(conditionalChild);
464 ObjectState* typeChild = new ObjectState(guardType);
465 conditionalChild->addChild(typeChild);
466 ObjectState* unitChild = new ObjectState(guardUnit);
467 typeChild->addChild(unitChild);
468 unitChild->setValue(child->stringAttribute(unitNameAttrib));
469 ObjectState* targetChild = new ObjectState(guardTarget);
470 typeChild->addChild(targetChild);
471 targetChild->setValue(child->stringAttribute(targetNameAttrib));
472
473 } else if (child->name() ==
475
476 // unconditional guards
477 ObjectState* guardChild = new ObjectState(GUARD);
478 root->addChild(guardChild);
480 guardChild->addChild(new ObjectState(ALWAYS_FALSE_GUARD));
481 } else {
482 guardChild->addChild(new ObjectState(ALWAYS_TRUE_GUARD));
483 }
484 }
485 }
486
487 // add segments
488 for (int i = 0; i < busState->childCount(); i++) {
489 ObjectState* child = busState->child(i);
490
491 if (child->name() == Segment::OSNAME_SEGMENT) {
492 ObjectState* segment = new ObjectState(SEGMENT);
493 root->addChild(segment);
494 segment->setAttribute(
497 segment->addChild(writesTo);
499 writesTo->setValue(
501 }
502 }
503 }
504
505 // add short immediate element
506 ObjectState* sImmChild = new ObjectState(SHORT_IMMEDIATE);
507 root->addChild(sImmChild);
508 ObjectState* extensionChild = new ObjectState(SHORT_IMM_EXTENSION);
509 string extension = busState->stringAttribute(Bus::OSKEY_EXTENSION);
510 if (extension == Bus::OSVALUE_SIGN) {
511 extensionChild->setValue(SIGN_EXTENSION);
512 } else if (extension == Bus::OSVALUE_ZERO) {
513 extensionChild->setValue(ZERO_EXTENSION);
514 } else {
515 string procName = "MDFSerialiser::busToMDF";
516 string errorMsg = "Unknown extension attribute value in ObjectState "
517 "instance.";
518 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
520 }
521
522 sImmChild->addChild(extensionChild);
523 ObjectState* sImmWidthChild = new ObjectState(SHORT_IMM_WIDTH);
524 sImmChild->addChild(sImmWidthChild);
525 sImmWidthChild->setValue(busState->stringAttribute(Bus::OSKEY_IMMWIDTH));
526
527 return root;
528}
const string BUS
int intAttribute(const std::string &name) const

References Application::abortProgram(), ObjectState::addChild(), ALWAYS_FALSE_GUARD, ALWAYS_TRUE_GUARD, ObjectState::boolAttribute(), BUS, BUS_NAME, BUS_WIDTH, ObjectState::child(), ObjectState::childCount(), GUARD, GUARD_BOOL, GUARD_REGFILE_INDEX, GUARD_REGFILE_NAME, GUARD_UNIT, GUARD_UNIT_NAME, GUARD_UNIT_PORT, ObjectState::hasAttribute(), ObjectState::intAttribute(), INVERTED_EXPR, ObjectState::name(), TTAMachine::Segment::OSKEY_DESTINATION, TTAMachine::Bus::OSKEY_EXTENSION, TTAMachine::PortGuard::OSKEY_FU, TTAMachine::Bus::OSKEY_IMMWIDTH, TTAMachine::RegisterGuard::OSKEY_INDEX, TTAMachine::Guard::OSKEY_INVERTED, TTAMachine::Segment::OSKEY_NAME, TTAMachine::PortGuard::OSKEY_PORT, TTAMachine::RegisterGuard::OSKEY_REGFILE, TTAMachine::Bus::OSKEY_WIDTH, TTAMachine::PortGuard::OSNAME_PORT_GUARD, TTAMachine::RegisterGuard::OSNAME_REGISTER_GUARD, TTAMachine::Segment::OSNAME_SEGMENT, TTAMachine::UnconditionalGuard::OSNAME_UNCONDITIONAL_GUARD, TTAMachine::Bus::OSVALUE_SIGN, TTAMachine::Bus::OSVALUE_ZERO, SEGMENT, SEGMENT_NAME, SEGMENT_WRITES_TO, ObjectState::setAttribute(), ObjectState::setValue(), SHORT_IMM_EXTENSION, SHORT_IMM_WIDTH, SHORT_IMMEDIATE, SIGN_EXTENSION, SIMPLE_EXPR, ObjectState::stringAttribute(), Application::writeToErrorLog(), and ZERO_EXTENSION.

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ controlUnitToMachine()

ObjectState * ADFSerializer::controlUnitToMachine ( const ObjectState cuState)
staticprivate

Creates a new ObjectState tree which can be read by ControlUnit::loadState.

The ObjectState tree is created according to the given ObjectState tree which matches with the syntax of control unit declaration in MDF file.

Parameters
cuStateThe ObjectState tree which matches with the syntax of control unit declaration in MDF file.
Returns
The newly created ObjectState tree.

Definition at line 1446 of file ADFSerializer.cc.

1446 {
1447
1449
1450 // set name
1451 cu->setAttribute(
1453
1454 // set address space
1456 string asName = as->stringValue();
1457 if (asName != "") {
1459 }
1460
1461 // set delay slots
1462 ObjectState* delaySlots = cuState->childByName(CU_DELAY_SLOTS);
1463 cu->setAttribute(
1465
1466 // set the guard latency
1467 ObjectState* gLatency = cuState->childByName(CU_GUARD_LATENCY);
1468 cu->setAttribute(
1470
1471 // set ports
1472 for (int i = 0; i < cuState->childCount(); i++) {
1473 ObjectState* child = cuState->child(i);
1474 if (child->name() == PORT) {
1475 cu->addChild(machineFUPort(child));
1476 } else if (child->name() == CU_SPECIAL_PORT) {
1477 cu->addChild(machineSRPort(child));
1478 }
1479 }
1480
1481 // set return address port binding
1482 ObjectState* raElem = cuState->childByName(CU_RETURN_ADDRESS);
1483 string raPortName = raElem->stringValue();
1484 if (raPortName != "") {
1486 }
1487
1488 // set operations
1489 for (int i = 0; i < cuState->childCount(); i++) {
1490 ObjectState* child = cuState->child(i);
1491 if (child->name() == CU_CTRL_OPERATION) {
1492 cu->addChild(machineOperation(child));
1493 }
1494 }
1495
1496 return cu;
1497}
const string CU_ADDRESS_SPACE
const string CU_SPECIAL_PORT
const string CU_GUARD_LATENCY
const string CU_DELAY_SLOTS
const string CU_RETURN_ADDRESS
const string CU_NAME
const string CU_CTRL_OPERATION
#define PORT(FUNAME, PORTNAME)
static ObjectState * machineOperation(const ObjectState *mdfOperationState)
static ObjectState * machineSRPort(const ObjectState *mdfSRPortState)
static ObjectState * machineFUPort(const ObjectState *mdfFUPortState)
static const std::string OSNAME_CONTROL_UNIT
ObjectState name for ControlUnit.
static const std::string OSKEY_DELAY_SLOTS
ObjectState attribute key for the number of delay slots.
static const std::string OSKEY_GUARD_LATENCY
ObjectState attribute key for the global guard latency.
static const std::string OSKEY_RA_PORT
ObjectState attribute key for the name of the return address port.
static const std::string OSKEY_AS
ObjectState attribute key for name of the address space.

References ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), CU_ADDRESS_SPACE, CU_CTRL_OPERATION, CU_DELAY_SLOTS, CU_GUARD_LATENCY, CU_NAME, CU_RETURN_ADDRESS, CU_SPECIAL_PORT, machineFUPort(), machineOperation(), machineSRPort(), ObjectState::name(), TTAMachine::FunctionUnit::OSKEY_AS, TTAMachine::ControlUnit::OSKEY_DELAY_SLOTS, TTAMachine::ControlUnit::OSKEY_GUARD_LATENCY, TTAMachine::Component::OSKEY_NAME, TTAMachine::ControlUnit::OSKEY_RA_PORT, TTAMachine::ControlUnit::OSNAME_CONTROL_UNIT, PORT, ObjectState::setAttribute(), ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ controlUnitToMDF()

ObjectState * ADFSerializer::controlUnitToMDF ( const ObjectState cuState)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by ControlUnit::saveState.

Parameters
cuStateRoot node of the ObjectState tree created by ControlUnit::saveState.
Returns
The newly created ObjectState tree.

Definition at line 905 of file ADFSerializer.cc.

905 {
906
908 cUnit->setAttribute(
909 CU_NAME, cuState->stringAttribute(ControlUnit::OSKEY_NAME));
910
911 // add operand ports
912 for (int i = 0; i < cuState->childCount(); i++) {
913 ObjectState* child = cuState->child(i);
914 if (child->name() == FUPort::OSNAME_FUPORT) {
915 cUnit->addChild(mdfFUPort(child));
916 }
917 }
918
919 // add special ports
920 for (int i = 0; i < cuState->childCount(); i++) {
921 ObjectState* child = cuState->child(i);
923 cUnit->addChild(mdfSRPort(child));
924 }
925 }
926
927 // add return-address element
928 ObjectState* raElement = new ObjectState(CU_RETURN_ADDRESS);
929 cUnit->addChild(raElement);
931 raElement->setValue(
933 }
934
935 // add operations
936 for (int i = 0; i < cuState->childCount(); i++) {
937 ObjectState* child = cuState->child(i);
938 if (child->name() == HWOperation::OSNAME_OPERATION) {
939 ObjectState* ctrlOperation = mdfOperation(child);
940 ctrlOperation->setName(CU_CTRL_OPERATION);
941 cUnit->addChild(ctrlOperation);
942 }
943 }
944
945 // add address space element
947 cUnit->addChild(as);
948 if (cuState->hasAttribute(FunctionUnit::OSKEY_AS)) {
950 }
951
952 // add delay-slots element
954 cUnit->addChild(dSlots);
955 dSlots->setValue(
957
958 // add guard latency element
960 cUnit->addChild(gLatency);
961 gLatency->setValue(
963
964 return cUnit;
965}
const string CONTROL_UNIT
static ObjectState * mdfSRPort(const ObjectState *machineSRPortState)
static ObjectState * mdfOperation(const ObjectState *machineOperationState)
static ObjectState * mdfFUPort(const ObjectState *machineFUPortState)
void setName(const std::string &name)
static const std::string OSNAME_FUPORT
ObjectState name for FUPort.
Definition FUPort.hh:71
static const std::string OSNAME_OPERATION
ObjectState name for HWOperation.
static const std::string OSNAME_SPECIAL_REG_PORT
ObjectState name for special register port.

References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), CONTROL_UNIT, CU_ADDRESS_SPACE, CU_CTRL_OPERATION, CU_DELAY_SLOTS, CU_GUARD_LATENCY, CU_NAME, CU_RETURN_ADDRESS, ObjectState::hasAttribute(), mdfFUPort(), mdfOperation(), mdfSRPort(), ObjectState::name(), TTAMachine::FunctionUnit::OSKEY_AS, TTAMachine::ControlUnit::OSKEY_DELAY_SLOTS, TTAMachine::ControlUnit::OSKEY_GUARD_LATENCY, TTAMachine::ControlUnit::OSKEY_RA_PORT, TTAMachine::FUPort::OSNAME_FUPORT, TTAMachine::HWOperation::OSNAME_OPERATION, TTAMachine::SpecialRegisterPort::OSNAME_SPECIAL_REG_PORT, ObjectState::setAttribute(), ObjectState::setName(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ convertToMachineFormat()

ObjectState * ADFSerializer::convertToMachineFormat ( const ObjectState mdfState)
staticprivate

Creates a new ObjectState tree which can be read by Machine::loadState and which corresponds with the given ObjectState tree.

Parameters
mdfStateAn ObjectState tree whose structure matches with MDF file structure.
Returns
The newly created ObjectState tree.
Exceptions
SerializerExceptionIf an error occurs while converting.

Definition at line 995 of file ADFSerializer.cc.

995 {
997
998 // Will count the number of function units and give sequential number
999 // to each of them.
1000 int orderNumber = 0;
1001
1002 try {
1003 for (int i = 0; i < mdfState->childCount(); i++) {
1004 ObjectState* child = mdfState->child(i);
1005 if (child->name() == TRIGGER_INVALIDATES_OLD_RESULTS) {
1006 machine->setAttribute(
1008 } else if (child->name() == ALWAYS_WRITE_BACK_RESULTS) {
1009 machine->setAttribute(
1011 } else if (child->name() == LITTLE_ENDIAN_MACHINE) {
1012 machine->setAttribute(LITTLE_ENDIAN_MACHINE, true);
1013 } else if (child->name() == BITNESS64) {
1014 machine->setAttribute(BITNESS64, true);
1015 } else if (child->name() == FUNCTION_UNITS_ORDERED) {
1016 machine->setAttribute(
1018 } else if (child->name() == BUS) {
1019 machine->addChild(busToMachine(child));
1020 } else if (child->name() == SOCKET) {
1021 machine->addChild(socketToMachine(child));
1022 } else if (child->name() == BRIDGE) {
1023 machine->addChild(bridgeToMachine(child));
1024 } else if (child->name() == FUNCTION_UNIT) {
1025 orderNumber++;
1026 machine->addChild(functionUnitToMachine(child, orderNumber));
1027 } else if (child->name() == REGISTER_FILE) {
1028 machine->addChild(registerFileToMachine(child));
1029 } else if (child->name() == ADDRESS_SPACE) {
1030 machine->addChild(addressSpaceToMachine(child));
1031 } else if (child->name() == CONTROL_UNIT) {
1032 machine->addChild(controlUnitToMachine(child));
1033 } else if (child->name() == IMMEDIATE_UNIT) {
1034 machine->addChild(immediateUnitToMachine(child, machine));
1035 } else if (child->name() == IMMEDIATE_SLOT) {
1036 machine->addChild(immediateSlotToMachine(child));
1037 } else if (child->name() == IU_TEMPLATE) {
1038 // the instruction template must not belong to any IU in case
1039 // one defines a template with implicit slots
1041 } else if (
1043 ObjectState* newChild = new ObjectState(*child);
1044 machine->addChild(newChild);
1045 }
1046 }
1047 } catch (const SerializerException&) {
1048 delete machine;
1049 throw;
1050 }
1051
1052 return machine;
1053}
const string FUNCTION_UNITS_ORDERED
const string ALWAYS_WRITE_BACK_RESULTS
const string BITNESS64
const string FUNCTION_UNIT
const string IU_TEMPLATE
const string REGISTER_FILE
const string IMMEDIATE_UNIT
const string LITTLE_ENDIAN_MACHINE
const string TRIGGER_INVALIDATES_OLD_RESULTS
const string SOCKET
const string IMMEDIATE_SLOT
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static ObjectState * immediateUnitToMachine(const ObjectState *iuState, ObjectState *machineState)
static ObjectState * controlUnitToMachine(const ObjectState *cuState)
static ObjectState * functionUnitToMachine(const ObjectState *fuState, const int orderNumber)
static ObjectState * busToMachine(const ObjectState *busState)
static ObjectState * socketToMachine(const ObjectState *socketState)
static ObjectState * addressSpaceToMachine(const ObjectState *asState)
static ObjectState * registerFileToMachine(const ObjectState *rfState)
static void instructionTemplateToMachine(const ObjectState *mdfITState, ObjectState *momMachineState, const std::string &iuName=std::string(""))
static ObjectState * bridgeToMachine(const ObjectState *bridgeState)
static ObjectState * immediateSlotToMachine(const ObjectState *isState)
static const std::string OSKEY_ALWAYS_WRITE_BACK_RESULTS
ObjectState attribute key for always-write-back-results.
Definition Machine.hh:251
static const std::string OSKEY_TRIGGER_INVALIDATES_OLD_RESULTS
ObjectState attribute key for trigger-invalidates-old-results.
Definition Machine.hh:253
static const std::string OSKEY_FUNCTION_UNITS_ORDERED
ObjectState attribute key for function units ordered in order of their sequential presence in ADF.
Definition Machine.hh:256
static const std::string OSNAME_MACHINE
ObjectState name for Machine.
Definition Machine.hh:249

References ADDRESS_SPACE, addressSpaceToMachine(), ALWAYS_WRITE_BACK_RESULTS, BITNESS64, BRIDGE, bridgeToMachine(), BUS, busToMachine(), ObjectState::child(), ObjectState::childCount(), CONTROL_UNIT, controlUnitToMachine(), FUNCTION_UNIT, FUNCTION_UNITS_ORDERED, functionUnitToMachine(), IMMEDIATE_SLOT, IMMEDIATE_UNIT, immediateSlotToMachine(), immediateUnitToMachine(), instructionTemplateToMachine(), IU_TEMPLATE, LITTLE_ENDIAN_MACHINE, machine, ObjectState::name(), TTAMachine::Machine::OSKEY_ALWAYS_WRITE_BACK_RESULTS, TTAMachine::Machine::OSKEY_FUNCTION_UNITS_ORDERED, TTAMachine::Machine::OSKEY_TRIGGER_INVALIDATES_OLD_RESULTS, TTAMachine::OperationTriggeredFormat::OSNAME_FORMAT, TTAMachine::Machine::OSNAME_MACHINE, REGISTER_FILE, registerFileToMachine(), SOCKET, socketToMachine(), and TRIGGER_INVALIDATES_OLD_RESULTS.

Referenced by readState().

Here is the call graph for this function:

◆ convertToMDFFormat()

ObjectState * ADFSerializer::convertToMDFFormat ( const ObjectState machineState)
staticprivate

Converts the given ObjectState tree created by Machine to correspond with MDF format.

Parameters
machineStateRoot of the ObjectState tree.
Returns
The newly created ObjectState tree which matches with MDF format.

Definition at line 292 of file ADFSerializer.cc.

292 {
293
294 ObjectState* root = new ObjectState(MDF);
296
297 // Test for global attributes.
298 if (machineState->hasAttribute(
300 machineState->boolAttribute(
303 }
307 }
311 }
312 if (machineState->hasAttribute(LITTLE_ENDIAN_MACHINE) &&
313 machineState->boolAttribute(LITTLE_ENDIAN_MACHINE)) {
315 }
316
317 if (machineState->hasAttribute(BITNESS64) &&
318 machineState->boolAttribute(BITNESS64)) {
319 root->addChild(new ObjectState(BITNESS64));
320 }
321
322 // add buses
323 for (int i = 0; i < machineState->childCount(); i++) {
324 ObjectState* child = machineState->child(i);
325 if (child->name() == Bus::OSNAME_BUS) {
326 root->addChild(busToMDF(child));
327 }
328 }
329
330 // add sockets
331 for (int i = 0; i < machineState->childCount(); i++) {
332 ObjectState* child = machineState->child(i);
333 if (child->name() == Socket::OSNAME_SOCKET) {
334 root->addChild(socketToMDF(child));
335 }
336 }
337
338 // add bridges
339 for (int i = 0; i < machineState->childCount(); i++) {
340 ObjectState* child = machineState->child(i);
341 if (child->name() == Bridge::OSNAME_BRIDGE) {
342 root->addChild(bridgeToMDF(child));
343 }
344 }
345
346 // add function units
347 for (int i = 0; i < machineState->childCount(); i++) {
348 ObjectState* child = machineState->child(i);
349 if (child->name() == FunctionUnit::OSNAME_FU) {
350 root->addChild(functionUnitToMDF(child));
351 }
352 }
353
354 // add register files
355 for (int i = 0; i < machineState->childCount(); i++) {
356 ObjectState* child = machineState->child(i);
358 root->addChild(registerFileToMDF(child));
359 }
360 }
361
362 // add address spaces
363 for (int i = 0; i < machineState->childCount(); i++) {
364 ObjectState* child = machineState->child(i);
366 root->addChild(addressSpaceToMDF(child));
367 }
368 }
369
370 // add control unit
371 for (int i = 0; i < machineState->childCount(); i++) {
372 ObjectState* child = machineState->child(i);
373 if (child->name() == ControlUnit::OSNAME_CONTROL_UNIT) {
374 root->addChild(controlUnitToMDF(child));
375 }
376 }
377
378 // add immediate units
379 for (int i = 0; i < machineState->childCount(); i++) {
380 ObjectState* child = machineState->child(i);
382 root->addChild(immediateUnitToMDF(child, machineState));
383 }
384 }
385
386 // add immediate slots
387 for (int i = 0; i < machineState->childCount(); i++) {
388 ObjectState* child = machineState->child(i);
390 root->addChild(immediateSlotToMDF(child));
391 }
392 }
393
394 // Add operation triggered formats
395 for (int i = 0; i < machineState->childCount(); i++) {
396 ObjectState* child = machineState->child(i);
398 ObjectState* newChild = new ObjectState(*child);
399 root->addChild(newChild);
400 }
401 }
402
403 return root;
404}
const string MDF
const string MDF_VERSION
const string MDF_VERSION_NUMBER
static ObjectState * addressSpaceToMDF(const ObjectState *asState)
static ObjectState * controlUnitToMDF(const ObjectState *cuState)
static ObjectState * functionUnitToMDF(const ObjectState *fuState)
static ObjectState * immediateSlotToMDF(const ObjectState *isState)
static ObjectState * socketToMDF(const ObjectState *socketState)
static ObjectState * immediateUnitToMDF(const ObjectState *iuState, const ObjectState *machineState)
static ObjectState * bridgeToMDF(const ObjectState *bridgeState)
static ObjectState * busToMDF(const ObjectState *busState)
static ObjectState * registerFileToMDF(const ObjectState *rfState)
static const std::string OSNAME_FU
ObjectState name for function unit.
static const std::string OSNAME_IMMEDIATE_SLOT
ObjectState name for ImmediateSlot.
static const std::string OSNAME_IMMEDIATE_UNIT
ObjectState name for ImmediateUnit.
static const std::string OSNAME_REGISTER_FILE
ObjectState name for RegisterFile.
static const std::string OSNAME_SOCKET
ObjectState name for socket.
Definition Socket.hh:100

References ObjectState::addChild(), addressSpaceToMDF(), ALWAYS_WRITE_BACK_RESULTS, BITNESS64, ObjectState::boolAttribute(), bridgeToMDF(), busToMDF(), ObjectState::child(), ObjectState::childCount(), controlUnitToMDF(), FUNCTION_UNITS_ORDERED, functionUnitToMDF(), ObjectState::hasAttribute(), immediateSlotToMDF(), immediateUnitToMDF(), LITTLE_ENDIAN_MACHINE, MDF, MDF_VERSION, MDF_VERSION_NUMBER, ObjectState::name(), TTAMachine::Machine::OSKEY_ALWAYS_WRITE_BACK_RESULTS, TTAMachine::Machine::OSKEY_FUNCTION_UNITS_ORDERED, TTAMachine::Machine::OSKEY_TRIGGER_INVALIDATES_OLD_RESULTS, TTAMachine::AddressSpace::OSNAME_ADDRESS_SPACE, TTAMachine::Bridge::OSNAME_BRIDGE, TTAMachine::Bus::OSNAME_BUS, TTAMachine::ControlUnit::OSNAME_CONTROL_UNIT, TTAMachine::OperationTriggeredFormat::OSNAME_FORMAT, TTAMachine::FunctionUnit::OSNAME_FU, TTAMachine::ImmediateSlot::OSNAME_IMMEDIATE_SLOT, TTAMachine::ImmediateUnit::OSNAME_IMMEDIATE_UNIT, TTAMachine::RegisterFile::OSNAME_REGISTER_FILE, TTAMachine::Socket::OSNAME_SOCKET, registerFileToMDF(), ObjectState::setAttribute(), socketToMDF(), and TRIGGER_INVALIDATES_OLD_RESULTS.

Referenced by writeState().

Here is the call graph for this function:

◆ functionUnitToMachine()

ObjectState * ADFSerializer::functionUnitToMachine ( const ObjectState fuState,
const int  orderNumber 
)
staticprivate

Creates a new ObjectState tree which can be read by FunctionUnit::loadState.

The ObjectState tree is created according to the given ObjectState tree which matches with the syntax of function unit declaration in MDF file.

Parameters
fuStateThe ObjectState tree which matches with the syntax of function unit declaration in MDF file.
orderNumberThe number indicating sequential position of the FU in the ADF.
Returns
The newly created ObjectState tree.

Definition at line 1260 of file ADFSerializer.cc.

1262 {
1263
1265
1266 // set name
1267 fu->setAttribute(
1269 // each FU has own value of ordering
1271 // set address space
1273 string asName = as->stringValue();
1274 if (asName != "") {
1276 }
1277
1278 // set ports and operations
1279 for (int i = 0; i < fuState->childCount(); i++) {
1280 ObjectState* child = fuState->child(i);
1281 if (child->name() == PORT) {
1282 fu->addChild(machineFUPort(child));
1283 } else if (child->name() == FU_OPERATION) {
1284 fu->addChild(machineOperation(child));
1285 }
1286 }
1287
1288 return fu;
1289}
const string FU_ADDRESS_SPACE
const string FU_OPERATION
#define FU_NAME
Definition OSAL.hh:494
static const std::string OSKEY_ORDER_NUMBER
ObjectState attribute key for FU order number name.

References ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), FU_ADDRESS_SPACE, FU_NAME, FU_OPERATION, machineFUPort(), machineOperation(), ObjectState::name(), TTAMachine::FunctionUnit::OSKEY_AS, TTAMachine::Component::OSKEY_NAME, TTAMachine::FunctionUnit::OSKEY_ORDER_NUMBER, TTAMachine::FunctionUnit::OSNAME_FU, PORT, ObjectState::setAttribute(), ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ functionUnitToMDF()

ObjectState * ADFSerializer::functionUnitToMDF ( const ObjectState fuState)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by FunctionUnit::saveState.

Parameters
fuStateRoot node of the ObjectState tree created by FunctionUnit::saveState.
Returns
The newly created ObjectState tree.

Definition at line 629 of file ADFSerializer.cc.

629 {
630
632 fu->setAttribute(
633 FU_NAME, fuState->stringAttribute(FunctionUnit::OSKEY_NAME));
634
635 // add ports and operations
636 for (int i = 0; i < fuState->childCount(); i++) {
637 ObjectState* child = fuState->child(i);
638 if (child->name() == FUPort::OSNAME_FUPORT) {
639 fu->addChild(mdfFUPort(child));
640 } else if (child->name() == HWOperation::OSNAME_OPERATION) {
641 fu->addChild(mdfOperation(child));
642 }
643 }
644
645 // add address space
646 ObjectState* addressSpace = new ObjectState(FU_ADDRESS_SPACE);
647 fu->addChild(addressSpace);
648
649 // set address space name if it exists
650 if (fuState->hasAttribute(FunctionUnit::OSKEY_AS)) {
651 addressSpace->setValue(
653 }
654
655 return fu;
656}

References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), FU_ADDRESS_SPACE, FU_NAME, FUNCTION_UNIT, ObjectState::hasAttribute(), mdfFUPort(), mdfOperation(), ObjectState::name(), TTAMachine::FunctionUnit::OSKEY_AS, TTAMachine::FUPort::OSNAME_FUPORT, TTAMachine::HWOperation::OSNAME_OPERATION, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ hasEmptyInstructionTemplate()

bool ADFSerializer::hasEmptyInstructionTemplate ( const ObjectState momMachineState)
staticprivate

Checks whether the machine represented by the given ObjectState tree contains an empty instruction template.

Parameters
momMachineStateThe ObjectState tree.
Returns
True if it contains an empty instruction template, otherwise false.

Definition at line 2332 of file ADFSerializer.cc.

2333 {
2334
2335 for (int i = 0; i < momMachineState->childCount(); i++) {
2336 ObjectState* child = momMachineState->child(i);
2337 if (child->name() ==
2339 child->childCount() == 0) {
2340 return true;
2341 }
2342 }
2343
2344 return false;
2345}
static const std::string OSNAME_INSTRUCTION_TEMPLATE
ObjectState name for instruction template.

References ObjectState::child(), ObjectState::childCount(), ObjectState::name(), and TTAMachine::InstructionTemplate::OSNAME_INSTRUCTION_TEMPLATE.

Referenced by immediateUnitToMachine().

Here is the call graph for this function:

◆ immediateSlotToMachine()

ObjectState * ADFSerializer::immediateSlotToMachine ( const ObjectState isState)
staticprivate

Creates an ObjectState instance that can be loaded by ImmediateSlot instance.

Parameters
isStateAn ObjectState instance that represents an immediate-slot element of ADF file.
Returns
The newly created ObjectState instance.

Definition at line 1636 of file ADFSerializer.cc.

1636 {
1637 ObjectState* immediateSlot = new ObjectState(
1639 immediateSlot->setAttribute(
1640 ImmediateSlot::OSKEY_NAME,
1642 return immediateSlot;
1643}
const string IMMEDIATE_SLOT_NAME

References IMMEDIATE_SLOT_NAME, TTAMachine::ImmediateSlot::OSNAME_IMMEDIATE_SLOT, ObjectState::setAttribute(), and ObjectState::stringAttribute().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ immediateSlotToMDF()

ObjectState * ADFSerializer::immediateSlotToMDF ( const ObjectState isState)
staticprivate

Creates a new ObjectState instance that matches with the syntax of immediate-slot element in ADF file.

Parameters
isStateObjectState instance representing ImmediateSlot instance.
Returns
The newly created ObjectState instance.

Definition at line 976 of file ADFSerializer.cc.

976 {
977 ObjectState* immediateSlot = new ObjectState(IMMEDIATE_SLOT);
978 immediateSlot->setAttribute(
980 isState->stringAttribute(ImmediateSlot::OSKEY_NAME));
981 return immediateSlot;
982}

References IMMEDIATE_SLOT, IMMEDIATE_SLOT_NAME, ObjectState::setAttribute(), and ObjectState::stringAttribute().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ immediateUnitToMachine()

ObjectState * ADFSerializer::immediateUnitToMachine ( const ObjectState iuState,
ObjectState machineState 
)
staticprivate

Creates a new ObjectState tree which can be read by ImmediateUnit::loadState.

The ObjectState tree is created according to the given ObjectState tree which matches with the syntax of immediate unit declaration in MDF file. Adds also instruction template ObjectStates to the given ObjectState tree which contains the whole machine.

Parameters
iuStateThe ObjectState tree which matches with the syntax of immediate unit declaration in MDF file.
machineStateThe ObjectState tree containing tree instruction templates as child objects.
Returns
The newly created ObjectState tree.
Exceptions
SerializerExceptionIf an error occurs while processing.

Definition at line 1517 of file ADFSerializer.cc.

1518 {
1520
1521 // set name
1522 iu->setAttribute(
1524
1525 // set type
1526 ObjectState* typeChild = iuState->childByName(IU_TYPE);
1527 string type = typeChild->stringValue();
1528 if (type == IU_TYPE_NORMAL) {
1529 iu->setAttribute(
1530 ImmediateUnit::OSKEY_TYPE, ImmediateUnit::OSVALUE_NORMAL);
1531 } else if (type == IU_TYPE_RESERVED) {
1532 iu->setAttribute(
1533 ImmediateUnit::OSKEY_TYPE, ImmediateUnit::OSVALUE_RESERVED);
1534 } else if (type == IU_TYPE_VOLATILE) {
1535 iu->setAttribute(
1536 ImmediateUnit::OSKEY_TYPE, ImmediateUnit::OSVALUE_VOLATILE);
1537 } else {
1538 string procName = "ADFSerializer::registerFileToMachine";
1539 string errorMsg = "Unknown register file type in ObjectState "
1540 "instance.";
1541 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
1543 }
1544
1545 // set size
1546 ObjectState* size = iuState->childByName(IU_SIZE);
1548
1549 // set width
1550 ObjectState* width = iuState->childByName(IU_WIDTH);
1552
1553 // set max reads
1554 ObjectState* maxReads = iuState->childByName(IU_MAX_READS);
1555 iu->setAttribute(
1556 ImmediateUnit::OSKEY_MAX_READS, maxReads->stringValue());
1557
1558 // set max writes
1559 ObjectState* maxWrites = iuState->childByName(IU_MAX_WRITES);
1560 iu->setAttribute(
1561 ImmediateUnit::OSKEY_MAX_WRITES, maxWrites->stringValue());
1562
1563 // set guard latency
1564 if (iuState->hasChild(IU_GUARD_LATENCY)) {
1565 ObjectState* guardLatencyChild =
1566 iuState->childByName(IU_GUARD_LATENCY);
1567 iu->setAttribute(
1568 ImmediateUnit::OSKEY_GUARD_LATENCY,
1569 guardLatencyChild->stringValue());
1570 } else {
1571 iu->setAttribute(ImmediateUnit::OSKEY_GUARD_LATENCY, 0);
1572 }
1573
1574 // set read latency
1575 if (iuState->hasChild(IU_LATENCY)) {
1576 ObjectState* readLatencyChild = iuState->childByName(IU_LATENCY);
1577 iu->setAttribute(
1578 ImmediateUnit::OSKEY_LATENCY, readLatencyChild->stringValue());
1579 } else {
1581 }
1582
1583 setIUExtensionMode(iuState, iu);
1584
1585 // set ports and instruction templates
1586 for (int i = 0; i < iuState->childCount(); i++) {
1587 ObjectState* child = iuState->child(i);
1588 if (child->name() == PORT) {
1589 iu->addChild(machineRFPort(child));
1590 } else if (child->name() == IU_TEMPLATE) {
1591 try {
1593 child, machineState, iuState->stringAttribute(IU_NAME));
1594 } catch (const SerializerException&) {
1595 delete iu;
1596 throw;
1597 }
1598 }
1599 }
1600
1601 // if machine has an empty instruction template, it must be found in the
1602 // immediate unit declaration
1603 if (hasEmptyInstructionTemplate(machineState)) {
1604 bool emptyFound = false;
1605 for (int i = 0; i < iuState->childCount(); i++) {
1606 ObjectState* child = iuState->child(i);
1607 if (child->name() == IU_TEMPLATE && child->childCount() == 0) {
1608 emptyFound = true;
1609 break;
1610 }
1611 }
1612 if (!emptyFound) {
1613 delete iu;
1615 format errorMsg = textGen.text(
1617 errorMsg % iuState->stringAttribute(IU_NAME);
1618 string procName = "ADFSerializer::immediateUnitToMachine";
1619 throw SerializerException(
1620 __FILE__, __LINE__, procName, errorMsg.str());
1621 }
1622 }
1623
1624 return iu;
1625}
const string IU_SIZE
const string IU_TYPE_RESERVED
const string IU_WIDTH
const string IU_GUARD_LATENCY
const string IU_MAX_WRITES
const string IU_TYPE
const string IU_TYPE_NORMAL
const string IU_MAX_READS
const string IU_TYPE_VOLATILE
const string IU_LATENCY
const string IU_NAME
static bool hasEmptyInstructionTemplate(const ObjectState *momMachineState)
static ObjectState * machineRFPort(const ObjectState *mdfPortState)
static void setIUExtensionMode(const ObjectState *mdfIUState, ObjectState *momIUState)
static const std::string OSKEY_SIZE
ObjectState attribute key for the number of registers.
static const std::string OSKEY_WIDTH
ObjectState attribute key for bit width of the registers.
static const std::string OSKEY_LATENCY
ObjectState attribute key for latency.
virtual boost::format text(int textId)

References Application::abortProgram(), ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), ObjectState::hasChild(), hasEmptyInstructionTemplate(), instructionTemplateToMachine(), IU_GUARD_LATENCY, IU_LATENCY, IU_MAX_READS, IU_MAX_WRITES, IU_NAME, IU_SIZE, IU_TEMPLATE, IU_TYPE, IU_TYPE_NORMAL, IU_TYPE_RESERVED, IU_TYPE_VOLATILE, IU_WIDTH, machineRFPort(), ObjectState::name(), TTAMachine::ImmediateUnit::OSKEY_LATENCY, TTAMachine::Component::OSKEY_NAME, TTAMachine::BaseRegisterFile::OSKEY_SIZE, TTAMachine::BaseRegisterFile::OSKEY_WIDTH, TTAMachine::ImmediateUnit::OSNAME_IMMEDIATE_UNIT, PORT, ObjectState::setAttribute(), setIUExtensionMode(), ObjectState::stringAttribute(), ObjectState::stringValue(), Texts::TextGenerator::text(), ADFSerializerTextGenerator::TXT_EMPTY_IT_NOT_DECLARED, and Application::writeToErrorLog().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ immediateUnitToMDF()

ObjectState * ADFSerializer::immediateUnitToMDF ( const ObjectState iuState,
const ObjectState machineState 
)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by ImmediateUnit::saveState. The whole ObjectState tree created by Machine::saveState must be given too because instruction templates are needed too to create the new ObjectState tree.

Parameters
iuStateRoot node of the ObjectState tree created by ImmediateUnit::saveState.
machineStateThe ObjectState tree created by Machine::saveState.
Returns
The newly created ObjectState tree.

Definition at line 751 of file ADFSerializer.cc.

752 {
753
755 string iuName = iuState->stringAttribute(ImmediateUnit::OSKEY_NAME);
756 iUnit->setAttribute(IU_NAME, iuName);
757
758 // type
759 ObjectState* type = new ObjectState(IU_TYPE);
760 iUnit->addChild(type);
761 string typeValue = iuState->stringAttribute(RegisterFile::OSKEY_TYPE);
762 if (typeValue == ImmediateUnit::OSVALUE_NORMAL) {
764 } else if (typeValue == ImmediateUnit::OSVALUE_RESERVED) {
766 } else if (typeValue == ImmediateUnit::OSVALUE_VOLATILE) {
768 } else {
769 string procName = "ADFSerializer::immediateUnitToMDF";
770 string errorMsg = "Unknown immediate unit type in ObjectState "
771 "instance.";
772 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
774 }
775
776 // add size element
777 ObjectState* size = new ObjectState(IU_SIZE);
778 iUnit->addChild(size);
779 size->setValue(iuState->stringAttribute(ImmediateUnit::OSKEY_SIZE));
780
781 // add width element
782 ObjectState* width = new ObjectState(IU_WIDTH);
783 iUnit->addChild(width);
784 width->setValue(iuState->stringAttribute(ImmediateUnit::OSKEY_WIDTH));
785
786 // add max reads
787 ObjectState* maxReads = new ObjectState(RF_MAX_READS);
788 iUnit->addChild(maxReads);
789 maxReads->setValue(
791
792 // add max writes
793 ObjectState* maxWrites = new ObjectState(IU_MAX_WRITES);
794 iUnit->addChild(maxWrites);
795 maxWrites->setValue(
797
798 // add guard latency
799 if (iuState->intAttribute(ImmediateUnit::OSKEY_GUARD_LATENCY) > 0) {
800 ObjectState* guardLatency = new ObjectState(IU_GUARD_LATENCY);
801 iUnit->addChild(guardLatency);
802 guardLatency->setValue(
803 iuState->stringAttribute(ImmediateUnit::OSKEY_GUARD_LATENCY));
804 }
805
806 // add read latency element
807 ObjectState* readLatency = new ObjectState(IU_LATENCY);
808 iUnit->addChild(readLatency);
809 readLatency->setValue(
811
812 // add extension element
813 ObjectState* extension = new ObjectState(IU_EXTENSION);
814 iUnit->addChild(extension);
815 extension->setValue(
817
818 // add ports
819 for (int i = 0; i < iuState->childCount(); i++) {
820 ObjectState* child = iuState->child(i);
821 if (child->name() == RFPort::OSNAME_RFPORT) {
822 iUnit->addChild(mdfPort(child));
823 }
824 }
825
826 // add instruction templates
827 for (int iTempIndex = 0; iTempIndex < machineState->childCount();
828 iTempIndex++) {
829 ObjectState* iTemp = machineState->child(iTempIndex);
830 if (iTemp->name() ==
832 instructionTemplateToMDF(iTemp, iUnit);
833 }
834 }
835
836 return iUnit;
837}
const string IU_EXTENSION
const string RF_MAX_READS
static ObjectState * mdfPort(const ObjectState *machinePortState)
static void instructionTemplateToMDF(const ObjectState *momITState, ObjectState *mdfIUState)
static const std::string OSKEY_EXTENSION
ObjectState attribute key for the extension mode.
static const std::string OSNAME_RFPORT
ObjectState name for register file port.
Definition RFPort.hh:58
static const std::string OSKEY_MAX_WRITES
ObjectState attribute key for maximum simultaneous writers.
static const std::string OSKEY_MAX_READS
ObjectState attribute key for maximum simultaneous readers.
static const std::string OSKEY_TYPE
ObjectState attribute key for register file type.

References Application::abortProgram(), ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), IMMEDIATE_UNIT, instructionTemplateToMDF(), ObjectState::intAttribute(), IU_EXTENSION, IU_GUARD_LATENCY, IU_LATENCY, IU_MAX_WRITES, IU_NAME, IU_SIZE, IU_TYPE, IU_TYPE_NORMAL, IU_TYPE_RESERVED, IU_TYPE_VOLATILE, IU_WIDTH, mdfPort(), ObjectState::name(), TTAMachine::ImmediateUnit::OSKEY_EXTENSION, TTAMachine::ImmediateUnit::OSKEY_LATENCY, TTAMachine::RegisterFile::OSKEY_MAX_READS, TTAMachine::RegisterFile::OSKEY_MAX_WRITES, TTAMachine::RegisterFile::OSKEY_TYPE, TTAMachine::InstructionTemplate::OSNAME_INSTRUCTION_TEMPLATE, TTAMachine::RFPort::OSNAME_RFPORT, RF_MAX_READS, ObjectState::setAttribute(), ObjectState::setValue(), ObjectState::stringAttribute(), and Application::writeToErrorLog().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ instructionTemplateToMachine()

void ADFSerializer::instructionTemplateToMachine ( const ObjectState mdfITState,
ObjectState momMachineState,
const std::string &  iuName = std::string("") 
)
staticprivate

Adds/modifies instruction templates to the given ObjectState instance representing machine in machine object model format.

Instruction templates are read from the given ObjectState instance representing a template element inside immediate unit declaration of mdf.

Parameters
mdfITStateObjectState instance representing a template element.
momMachineStateObjectState instance representing a machine in machine object model format.
iuNameName of the immediate unit which contains the template element.
Exceptions
SerializerExceptionIf an error is occurred while processing.

Definition at line 2215 of file ADFSerializer.cc.

2217 {
2218 const string procName = "ADFSerializer::instructionTemplateToMachine";
2219
2220 string templateName = mdfITState->stringAttribute(IU_TEMPLATE_NAME);
2221 ObjectState* iTemp = NULL;
2222 bool iTempFound = false;
2223
2224 for (int iTempIndex = 0; iTempIndex < momMachineState->childCount();
2225 iTempIndex++) {
2226 iTemp = momMachineState->child(iTempIndex);
2227 if (iTemp->name() ==
2230 templateName) {
2231 iTempFound = true;
2232 break;
2233 }
2234 }
2235
2236 if (!iTempFound) {
2237 iTemp = new ObjectState(
2239 momMachineState->addChild(iTemp);
2240 iTemp->setAttribute(Component::OSKEY_NAME, templateName);
2241 }
2242
2244
2245 if ((mdfITState->childCount() == 0 && iTempFound &&
2246 iTemp->childCount() > 0) ||
2247 (mdfITState->childCount() > 0 && iTempFound &&
2248 iTemp->childCount() == 0)) {
2249 format errorMsg = textGen.text(
2251 errorMsg % templateName;
2252 throw SerializerException(
2253 __FILE__, __LINE__, procName, errorMsg.str());
2254 }
2255
2256 for (int slotIndex = 0; slotIndex < mdfITState->childCount();
2257 slotIndex++) {
2258 ObjectState* slot = mdfITState->child(slotIndex);
2259 string slotName =
2261 string width =
2263
2264 ObjectState* iTempSlot = momTemplateSlot(iTemp, slotName);
2265 if (iTempSlot == NULL) {
2267 iTempSlot->setAttribute(TemplateSlot::OSKEY_SLOT, slotName);
2268 iTempSlot->setAttribute(TemplateSlot::OSKEY_WIDTH, width);
2270 iTemp->addChild(iTempSlot);
2271 } else {
2272 format errorMsg;
2274 iuName) {
2275 errorMsg = textGen.text(
2277 errorMsg % slotName % iuName % templateName;
2278 } else {
2279 errorMsg = textGen.text(
2281 TXT_MULTIPLE_DESTINATIONS_IN_TEMPLATE_SLOT);
2282 errorMsg % slotName % templateName % iuName %
2283 iTempSlot->stringAttribute(
2285 }
2286 throw SerializerException(
2287 __FILE__, __LINE__, procName, errorMsg.str());
2288 }
2289 }
2290}
const string IU_TEMPLATE_NAME
const string IU_TEMPLATE_SLOT_NAME
const string IU_TEMPLATE_SLOT_WIDTH
static ObjectState * momTemplateSlot(const ObjectState *momITState, const std::string &busName)
static const std::string OSNAME_TEMPLATE_SLOT
ObjectState name for template slot.
static const std::string OSKEY_SLOT
ObjectState attribute key for slot name.
static const std::string OSKEY_DESTINATION
ObjectState attribute key for destination.
static const std::string OSKEY_WIDTH
ObjectState attribute key for bit width.

References ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), IU_TEMPLATE_NAME, IU_TEMPLATE_SLOT_NAME, IU_TEMPLATE_SLOT_WIDTH, momTemplateSlot(), ObjectState::name(), TTAMachine::TemplateSlot::OSKEY_DESTINATION, TTAMachine::Component::OSKEY_NAME, TTAMachine::TemplateSlot::OSKEY_SLOT, TTAMachine::TemplateSlot::OSKEY_WIDTH, TTAMachine::InstructionTemplate::OSNAME_INSTRUCTION_TEMPLATE, TTAMachine::TemplateSlot::OSNAME_TEMPLATE_SLOT, ObjectState::setAttribute(), ObjectState::stringAttribute(), ObjectState::stringValue(), Texts::TextGenerator::text(), ADFSerializerTextGenerator::TXT_IT_EMPTY_AND_NON_EMPTY, and ADFSerializerTextGenerator::TXT_SAME_TEMPLATE_SLOT.

Referenced by convertToMachineFormat(), and immediateUnitToMachine().

Here is the call graph for this function:

◆ instructionTemplateToMDF()

void ADFSerializer::instructionTemplateToMDF ( const ObjectState momITState,
ObjectState mdfIUState 
)
staticprivate

Includes the given instruction template information to ObjectState tree representing immediate unit in mdf format.

Parameters
momITStateObjectState instance representing an instruction template in machine object model format.
mdfIUStateObjectState instance representing an immediate unit in mdf format.

Definition at line 2149 of file ADFSerializer.cc.

2151 {
2152
2153 string iuName = mdfIUState->stringAttribute(IU_NAME);
2154 string iTempName = momITState->stringAttribute(Component::OSKEY_NAME);
2155 for (int slotIndex = 0; slotIndex < momITState->childCount();
2156 slotIndex++) {
2157 ObjectState* slot = momITState->child(slotIndex);
2159 iuName) {
2160 ObjectState* correctTemplate = NULL;
2161
2162 for (int iuChildIndex = 0;
2163 iuChildIndex < mdfIUState->childCount(); iuChildIndex++) {
2164 ObjectState* iuChild = mdfIUState->child(iuChildIndex);
2165 if (iuChild->name() == IU_TEMPLATE &&
2166 iuChild->stringAttribute(IU_TEMPLATE_NAME) == iTempName) {
2167 correctTemplate = iuChild;
2168 }
2169 }
2170
2171 if (correctTemplate == NULL) {
2172 correctTemplate = new ObjectState(IU_TEMPLATE);
2173 mdfIUState->addChild(correctTemplate);
2174 correctTemplate->setAttribute(IU_TEMPLATE_NAME, iTempName);
2175 }
2176
2177 ObjectState* slotElem = new ObjectState(IU_TEMPLATE_SLOT);
2178 correctTemplate->addChild(slotElem);
2180 slotElem->addChild(nameElem);
2181 nameElem->setValue(
2184 slotElem->addChild(widthElem);
2185 widthElem->setValue(
2187 }
2188 }
2189
2190
2191 if (momITState->childCount() == 0) {
2192 ObjectState* emptyTemplate = new ObjectState(IU_TEMPLATE);
2193 mdfIUState->addChild(emptyTemplate);
2194 emptyTemplate->setAttribute(IU_TEMPLATE_NAME, iTempName);
2195 }
2196}
const string IU_TEMPLATE_SLOT

References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), IU_NAME, IU_TEMPLATE, IU_TEMPLATE_NAME, IU_TEMPLATE_SLOT, IU_TEMPLATE_SLOT_NAME, IU_TEMPLATE_SLOT_WIDTH, ObjectState::name(), TTAMachine::TemplateSlot::OSKEY_DESTINATION, TTAMachine::Component::OSKEY_NAME, TTAMachine::TemplateSlot::OSKEY_SLOT, TTAMachine::TemplateSlot::OSKEY_WIDTH, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by immediateUnitToMDF().

Here is the call graph for this function:

◆ machineFUPort()

ObjectState * ADFSerializer::machineFUPort ( const ObjectState mdfFUPortState)
staticprivate

Creates an ObjectState instance that represent a function unit port in machine object model format.

The ObjectState instance is created according to the given ObjectState instance that represents a function unit port in mdf format. The given instance must have an attribute called 'name' and up to two 'connects-to' children. It has also 'width' child and may also have 'triggers' and 'setsOpcode' children.

Parameters
mdfFUPortStateObjectState instance representing a function port in mdf format.
Returns
The newly created ObjectState instance representing a function unit port in machine object model format.

Definition at line 1863 of file ADFSerializer.cc.

1863 {
1864
1866 fuPort->setAttribute(Port::OSKEY_NAME, mdfFUPortState->stringAttribute(
1867 PORT_NAME));
1868
1869 // set socket connections
1870 for (int i = 0; i < mdfFUPortState->childCount(); i++) {
1871 ObjectState* portChild = mdfFUPortState->child(i);
1872 if (portChild->name() == PORT_CONNECTS_TO) {
1873 if (!fuPort->hasAttribute(Port::OSKEY_FIRST_SOCKET)) {
1874 fuPort->setAttribute(
1876 } else {
1877 fuPort->setAttribute(
1879 }
1880 }
1881 }
1882
1883 // set other attributes
1884 ObjectState* width = mdfFUPortState->childByName(FU_PORT_WIDTH);
1885 fuPort->setAttribute(FUPort::OSKEY_WIDTH, width->stringValue());
1886 fuPort->setAttribute(
1887 FUPort::OSKEY_TRIGGERING, mdfFUPortState->hasChild(
1889 fuPort->setAttribute(
1890 FUPort::OSKEY_OPCODE_SETTING, mdfFUPortState->hasChild(
1892 fuPort->setAttribute(
1893 FUPort::OSKEY_NO_REGISTER, mdfFUPortState->hasChild(
1895
1896 return fuPort;
1897}
const string FU_PORT_WIDTH
const string FU_PORT_NO_REGISTER
const string PORT_NAME
const string FU_PORT_SETS_OPCODE
const string PORT_CONNECTS_TO
const string FU_PORT_TRIGGERS
static const std::string OSKEY_OPCODE_SETTING
ObjectState attribute key for operand code setting feature.
Definition FUPort.hh:75
static const std::string OSKEY_NO_REGISTER
ObjectState attribute key for noRegister setting feature.
Definition FUPort.hh:77
static const std::string OSKEY_TRIGGERING
ObjectState attribute key for triggering feature.
Definition FUPort.hh:73
static const std::string OSKEY_FIRST_SOCKET
ObjectState attribute key for the name of the connected socket.
Definition Port.hh:84
static const std::string OSKEY_SECOND_SOCKET
ObjectState attribute key for the name of the other connected socket.
Definition Port.hh:86
static const std::string OSKEY_NAME
ObjectState attribute key for the name of the port.
Definition Port.hh:82

References ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), FU_PORT_NO_REGISTER, FU_PORT_SETS_OPCODE, FU_PORT_TRIGGERS, FU_PORT_WIDTH, ObjectState::hasAttribute(), ObjectState::hasChild(), ObjectState::name(), TTAMachine::Port::OSKEY_FIRST_SOCKET, TTAMachine::Port::OSKEY_NAME, TTAMachine::FUPort::OSKEY_NO_REGISTER, TTAMachine::FUPort::OSKEY_OPCODE_SETTING, TTAMachine::Port::OSKEY_SECOND_SOCKET, TTAMachine::FUPort::OSKEY_TRIGGERING, TTAMachine::FUPort::OSNAME_FUPORT, PORT_CONNECTS_TO, PORT_NAME, ObjectState::setAttribute(), ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by controlUnitToMachine(), and functionUnitToMachine().

Here is the call graph for this function:

◆ machineOperation()

ObjectState * ADFSerializer::machineOperation ( const ObjectState mdfOperationState)
staticprivate

Creates an ObjectState instance that represents an operation in machine object model format.

The ObjectState instance is created according to the given ObjectState instance that represents an operation in mdf format.

Parameters
mdfOperationStateObjectState instance representing an operation in mdf format.
Returns
The newly created ObjectState instance representing an operation in machine object model format.

Definition at line 1949 of file ADFSerializer.cc.

1949 {
1950
1955 mdfOperationState->childByName(FU_OP_NAME)->stringValue());
1956
1957 // set operand bindings
1958 for (int i = 0; i < mdfOperationState->childCount(); i++) {
1959 ObjectState* child = mdfOperationState->child(i);
1960 if (child->name() == FU_OP_BIND) {
1961 ObjectState* binding = new ObjectState(
1963 machineOperation->addChild(binding);
1964 binding->setAttribute(
1967 binding->setAttribute(
1969 }
1970 }
1971
1972 // set pipeline
1973 ObjectState* mdfPipeline = mdfOperationState->childByName(
1976
1977 return machineOperation;
1978}
const string FU_OP_NAME
const string FU_OP_BIND
const string FU_OP_BIND_NAME
const string FU_OP_PIPELINE
static ObjectState * machinePipeline(const ObjectState *mdfPipelineState)
static ObjectState * mdfPipeline(const ObjectState *machinePipelineState)
static const std::string OSKEY_NAME
ObjectState attribute key for name of the operation.
static const std::string OSKEY_PORT
ObjectState attribute key for port name.
static const std::string OSKEY_OPERAND
ObjectState attribute key for operand index.
static const std::string OSNAME_OPERAND_BINDING
ObjectState name for an operand binding.

References ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), FU_OP_BIND, FU_OP_BIND_NAME, FU_OP_NAME, FU_OP_PIPELINE, machineOperation(), machinePipeline(), mdfPipeline(), ObjectState::name(), TTAMachine::HWOperation::OSKEY_NAME, TTAMachine::HWOperation::OSKEY_OPERAND, TTAMachine::HWOperation::OSKEY_PORT, TTAMachine::HWOperation::OSNAME_OPERAND_BINDING, TTAMachine::HWOperation::OSNAME_OPERATION, ObjectState::setAttribute(), ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by controlUnitToMachine(), functionUnitToMachine(), and machineOperation().

Here is the call graph for this function:

◆ machinePipeline()

ObjectState * ADFSerializer::machinePipeline ( const ObjectState mdfPipelineState)
staticprivate

Creates an ObjectState instance that represents a pipeline in machine object model format.

The ObjectState instance is created according to the given ObjectState instance that represents a pipeline in mdf format.

Parameters
mdfPipelineStateObjectState instance representing a pipeline in mdf format.
Returns
The newly created ObjectState instance representing a pipeline in machine object model format.

Definition at line 2035 of file ADFSerializer.cc.

2035 {
2036
2039
2040 for (int i = 0; i < mdfPipelineState->childCount(); i++) {
2041 ObjectState* mdfResource = mdfPipelineState->child(i);
2042 ObjectState* machineResource = NULL;
2043 if (mdfResource->name() == FU_OP_PL_RESOURCE) {
2044 machineResource = new ObjectState(
2046 machineResource->setAttribute(
2048 mdfResource->stringAttribute(FU_OP_PL_RES_NAME));
2049 } else if (mdfResource->name() == FU_OP_PL_READS) {
2050 machineResource = new ObjectState(
2052 machineResource->setAttribute(
2054 mdfResource->stringAttribute(FU_OP_PL_READS_NAME));
2055 } else if (mdfResource->name() == FU_OP_PL_WRITES) {
2056 machineResource = new ObjectState(
2058 machineResource->setAttribute(
2061 } else {
2062 const string procName = "ADFSerializer::machinePipeline";
2063 const string errorMsg = "Given pipeline model is invalid.";
2065 __FILE__, __LINE__, procName, errorMsg);
2067 }
2068
2069 machinePipeline->addChild(machineResource);
2070 machineResource->setAttribute(
2073 stringValue());
2074 machineResource->setAttribute(
2077 }
2078
2079 return machinePipeline;
2080}
const string FU_OP_PL_RESOURCE
const string FU_OP_PL_RES_START_CYCLE
const string FU_OP_PL_RES_CYCLES
const string FU_OP_PL_WRITES
const string FU_OP_PL_READS
const string FU_OP_PL_READS_NAME
const string FU_OP_PL_WRITES_NAME
const string FU_OP_PL_RES_NAME
static const std::string OSKEY_RESOURCE_NAME
ObjectState attribute key for name of resource.
static const std::string OSNAME_OPERAND_WRITE
ObjectState name for operand write.
static const std::string OSKEY_START_CYCLE
ObjectState attribute key for start cycle of a resource usage.
static const std::string OSKEY_OPERAND
ObjectState attribute key for operand number.
static const std::string OSNAME_OPERAND_READ
ObjectState name for operand read.
static const std::string OSNAME_PIPELINE
ObjectState name for ExecutionPipeline.
static const std::string OSNAME_RESOURCE_USAGE
ObjectState name for pipeline resource usage.
static const std::string OSKEY_CYCLES
ObjectState attribute key for duration of a resource usage.

References Application::abortProgram(), ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), FU_OP_PL_READS, FU_OP_PL_READS_NAME, FU_OP_PL_RES_CYCLES, FU_OP_PL_RES_NAME, FU_OP_PL_RES_START_CYCLE, FU_OP_PL_RESOURCE, FU_OP_PL_WRITES, FU_OP_PL_WRITES_NAME, machinePipeline(), ObjectState::name(), TTAMachine::ExecutionPipeline::OSKEY_CYCLES, TTAMachine::ExecutionPipeline::OSKEY_OPERAND, TTAMachine::ExecutionPipeline::OSKEY_RESOURCE_NAME, TTAMachine::ExecutionPipeline::OSKEY_START_CYCLE, TTAMachine::ExecutionPipeline::OSNAME_OPERAND_READ, TTAMachine::ExecutionPipeline::OSNAME_OPERAND_WRITE, TTAMachine::ExecutionPipeline::OSNAME_PIPELINE, TTAMachine::ExecutionPipeline::OSNAME_RESOURCE_USAGE, ObjectState::setAttribute(), ObjectState::stringAttribute(), ObjectState::stringValue(), and Application::writeToErrorLog().

Referenced by machineOperation(), and machinePipeline().

Here is the call graph for this function:

◆ machineRFPort()

ObjectState * ADFSerializer::machineRFPort ( const ObjectState mdfPortState)
staticprivate

Creates an ObjectState instance that represents a register file port in machine object model format.

The ObjectState instance is created according to the given ObjectState instance that represents a port in mdf format. The given instance must have an attribute called 'name' and up to two 'connects-to' children.

Parameters
mdfPortStateObjectState instance representing a normal port in mdf format.
Returns
The newly created ObjectState instance representing a normal port in machine object model format.

Definition at line 1792 of file ADFSerializer.cc.

1792 {
1793
1795 port->setAttribute(
1796 RFPort::OSKEY_NAME, mdfPortState->stringAttribute(PORT_NAME));
1797
1798 for (int i = 0; i < mdfPortState->childCount(); i++) {
1799 ObjectState* conn = mdfPortState->child(i);
1800 if (i == 0) {
1801 port->setAttribute(
1803 } else {
1804 port->setAttribute(
1806 }
1807 }
1808
1809 return port;
1810}

References ObjectState::child(), ObjectState::childCount(), TTAMachine::Port::OSKEY_FIRST_SOCKET, TTAMachine::Port::OSKEY_SECOND_SOCKET, TTAMachine::RFPort::OSNAME_RFPORT, PORT_NAME, ObjectState::setAttribute(), ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by immediateUnitToMachine(), and registerFileToMachine().

Here is the call graph for this function:

◆ machineSRPort()

ObjectState * ADFSerializer::machineSRPort ( const ObjectState mdfSRPortState)
staticprivate

Creates an ObjectState instance that represents a special register port in machine object model format.

The ObjectState instance is created according to the given ObjectState instance that represents a special register port in mdf format.

Parameters
mdfSRPortStateObjectState instance representing a special register port in mdf format.
Returns
The newly created ObjectState instance representing a special register port in machine object model format.

Definition at line 1659 of file ADFSerializer.cc.

1659 {
1660
1661 assert(mdfSRPortState->name() == CU_SPECIAL_PORT);
1662 ObjectState* machPort =
1664 machPort->setAttribute(
1665 SpecialRegisterPort::OSKEY_NAME,
1666 mdfSRPortState->stringAttribute(PORT_NAME));
1667
1668 ObjectState* width = mdfSRPortState->childByName(FU_PORT_WIDTH);
1669 machPort->setAttribute(
1670 SpecialRegisterPort::OSKEY_WIDTH, width->stringValue());
1671
1672 int connIndex = 0;
1673 for (int i = 0; i < mdfSRPortState->childCount(); i++) {
1674 ObjectState* child = mdfSRPortState->child(i);
1675 if (child->name() == PORT_CONNECTS_TO) {
1676 connIndex++;
1677 if (connIndex == 1) {
1678 machPort->setAttribute(
1680 } else if (connIndex == 2) {
1681 machPort->setAttribute(
1683 } else {
1684 string procName = "ADFSerializer::machineSRPort";
1685 string errorMsg = "Too many connects-to elements in SR "
1686 "port.";
1688 __FILE__, __LINE__, procName, errorMsg);
1690 }
1691 }
1692 }
1693
1694 return machPort;
1695}
#define assert(condition)

References Application::abortProgram(), assert, ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), CU_SPECIAL_PORT, FU_PORT_WIDTH, ObjectState::name(), TTAMachine::Port::OSKEY_FIRST_SOCKET, TTAMachine::Port::OSKEY_SECOND_SOCKET, TTAMachine::SpecialRegisterPort::OSNAME_SPECIAL_REG_PORT, PORT_CONNECTS_TO, PORT_NAME, ObjectState::setAttribute(), ObjectState::stringAttribute(), ObjectState::stringValue(), and Application::writeToErrorLog().

Referenced by controlUnitToMachine().

Here is the call graph for this function:

◆ mdfFUPort()

ObjectState * ADFSerializer::mdfFUPort ( const ObjectState machineFUPortState)
staticprivate

Creates an ObjectState instance that represents a function unit port in mdf format.

The ObjectState instance is created according to the given ObjectState instance that represents a function unit port in machine object model format.

Parameters
machineFUPortStateObjectState instance representing a function unit port in machine object model format.
Returns
The newly created ObjectState instance representing a function unit port in mdf format.

Definition at line 1914 of file ADFSerializer.cc.

1914 {
1915
1916 ObjectState* mdfFUPort = mdfPort(machineFUPortState);
1918 width->setValue(machineFUPortState->stringAttribute(
1919 FUPort::OSKEY_WIDTH));
1920 mdfFUPort->addChild(width);
1921 if (machineFUPortState->intAttribute(FUPort::OSKEY_TRIGGERING)) {
1923 }
1924 if (machineFUPortState->intAttribute(FUPort::OSKEY_OPCODE_SETTING)) {
1926 }
1927
1928 if (machineFUPortState->intAttribute(FUPort::OSKEY_NO_REGISTER)) {
1930 }
1931
1932 return mdfFUPort;
1933}

References ObjectState::addChild(), FU_PORT_NO_REGISTER, FU_PORT_SETS_OPCODE, FU_PORT_TRIGGERS, FU_PORT_WIDTH, ObjectState::intAttribute(), mdfFUPort(), mdfPort(), TTAMachine::FUPort::OSKEY_NO_REGISTER, TTAMachine::FUPort::OSKEY_OPCODE_SETTING, TTAMachine::FUPort::OSKEY_TRIGGERING, ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by controlUnitToMDF(), functionUnitToMDF(), and mdfFUPort().

Here is the call graph for this function:

◆ mdfOperation()

ObjectState * ADFSerializer::mdfOperation ( const ObjectState machineOperationState)
staticprivate

Creates an ObjectState instance that represents an operation in mdf format.

The ObjectState instance is created according to the given ObjectState instance that represents an operation in machine object model format.

Parameters
machineOperationStateObjectState instance representing an operation in machine object model format.
Returns
The newly created ObjectState instance representing an operation in mdf format.

Definition at line 1994 of file ADFSerializer.cc.

1994 {
1995
1997 ObjectState* name = new ObjectState(FU_OP_NAME);
1998 mdfOperation->addChild(name);
1999 name->setValue(machineOperationState->stringAttribute(
2001
2002 // add bind elements
2003 for (int i = 0; i < machineOperationState->childCount(); i++) {
2004 ObjectState* child = machineOperationState->child(i);
2005 if (child->name() == HWOperation::OSNAME_OPERAND_BINDING) {
2006 ObjectState* bind = new ObjectState(FU_OP_BIND);
2007 mdfOperation->addChild(bind);
2008 bind->setAttribute(
2012 }
2013 }
2014
2015 ObjectState* machPipeline = machineOperationState->childByName(
2017 mdfOperation->addChild(mdfPipeline(machPipeline));
2018 return mdfOperation;
2019}

References ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), FU_OP_BIND, FU_OP_BIND_NAME, FU_OP_NAME, FU_OPERATION, mdfOperation(), mdfPipeline(), ObjectState::name(), TTAMachine::HWOperation::OSKEY_NAME, TTAMachine::HWOperation::OSKEY_OPERAND, TTAMachine::HWOperation::OSKEY_PORT, TTAMachine::HWOperation::OSNAME_OPERAND_BINDING, TTAMachine::ExecutionPipeline::OSNAME_PIPELINE, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by controlUnitToMDF(), functionUnitToMDF(), and mdfOperation().

Here is the call graph for this function:

◆ mdfPipeline()

ObjectState * ADFSerializer::mdfPipeline ( const ObjectState machinePipelineState)
staticprivate

Creates an ObjectState instance that represents a pipeline in mdf format.

The ObjectState instance is created according to the given ObjectState instance that represents a pipeline in machine object model format.

Parameters
machinePipelineStateObjectState instance representing a pipeline in machine object model format.
Returns
The newly created ObjectState instance representing a pipeline in mdf format.

Definition at line 2095 of file ADFSerializer.cc.

2095 {
2096
2098
2099 for (int i = 0; i < machinePipelineState->childCount(); i++) {
2100 ObjectState* resChild = machinePipelineState->child(i);
2101 ObjectState* mdfChild = NULL;
2103 mdfChild = new ObjectState(FU_OP_PL_RESOURCE);
2104 mdfChild->setAttribute(
2106 resChild->stringAttribute(
2108 } else if (resChild->name() ==
2110 mdfChild = new ObjectState(FU_OP_PL_READS);
2111 mdfChild->setAttribute(
2114 } else if (resChild->name() ==
2116 mdfChild = new ObjectState(FU_OP_PL_WRITES);
2117 mdfChild->setAttribute(
2120 } else {
2121 assert(false);
2122 }
2123
2124 mdfPipeline->addChild(mdfChild);
2126 mdfChild->addChild(startCycle);
2127 startCycle->setValue(
2130 mdfChild->addChild(cycles);
2131 cycles->setValue(
2133 }
2134
2135 return mdfPipeline;
2136}

References ObjectState::addChild(), assert, ObjectState::child(), ObjectState::childCount(), FU_OP_PIPELINE, FU_OP_PL_READS, FU_OP_PL_READS_NAME, FU_OP_PL_RES_CYCLES, FU_OP_PL_RES_NAME, FU_OP_PL_RES_START_CYCLE, FU_OP_PL_RESOURCE, FU_OP_PL_WRITES, FU_OP_PL_WRITES_NAME, mdfPipeline(), ObjectState::name(), TTAMachine::ExecutionPipeline::OSKEY_CYCLES, TTAMachine::ExecutionPipeline::OSKEY_OPERAND, TTAMachine::ExecutionPipeline::OSKEY_RESOURCE_NAME, TTAMachine::ExecutionPipeline::OSKEY_START_CYCLE, TTAMachine::ExecutionPipeline::OSNAME_OPERAND_READ, TTAMachine::ExecutionPipeline::OSNAME_OPERAND_WRITE, TTAMachine::ExecutionPipeline::OSNAME_RESOURCE_USAGE, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by machineOperation(), mdfOperation(), and mdfPipeline().

Here is the call graph for this function:

◆ mdfPort()

ObjectState * ADFSerializer::mdfPort ( const ObjectState machinePortState)
staticprivate

Creates an ObjectState instance that represents a normal port in mdf format.

The ObjectState instance is created according to the given ObjectState instance that represents a port in machine object model format.

Parameters
machinePortStateObjectState instance representing a normal port in machine object model format.
Returns
The newly created ObjectState instance representing a normal port in mdf format.

Definition at line 1826 of file ADFSerializer.cc.

1826 {
1827
1829 mdfPort->setAttribute(PORT_NAME, machinePortState->stringAttribute(
1831 if (machinePortState->hasAttribute(Port::OSKEY_FIRST_SOCKET)) {
1833 mdfPort->addChild(conn);
1834 conn->setValue(machinePortState->stringAttribute(
1836 }
1837 if (machinePortState->hasAttribute(Port::OSKEY_SECOND_SOCKET)) {
1839 mdfPort->addChild(conn);
1840 conn->setValue(machinePortState->stringAttribute(
1842 }
1843 return mdfPort;
1844}

References ObjectState::addChild(), ObjectState::hasAttribute(), mdfPort(), TTAMachine::Port::OSKEY_FIRST_SOCKET, TTAMachine::Port::OSKEY_NAME, TTAMachine::Port::OSKEY_SECOND_SOCKET, PORT, PORT_CONNECTS_TO, PORT_NAME, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by immediateUnitToMDF(), mdfFUPort(), mdfPort(), and registerFileToMDF().

Here is the call graph for this function:

◆ mdfSRPort()

ObjectState * ADFSerializer::mdfSRPort ( const ObjectState machineSRPortState)
staticprivate

Creates an ObjectState instance that represents a special register port in mdf format.

The ObjectState instance is created according to the given ObjectState instance that represents a special register port in machine object model format.

Parameters
machineSRPortStateObjectState instance representing a special register port in machine object model format.
Returns
The newly created ObjectState instance representing a special register port in mdf format.

Definition at line 1712 of file ADFSerializer.cc.

1712 {
1713
1714 assert(machineSRPortState->name() ==
1716
1718 string name =
1719 machineSRPortState->stringAttribute(SpecialRegisterPort::OSKEY_NAME);
1721
1722 if (machineSRPortState->hasAttribute(FUPort::OSKEY_FIRST_SOCKET)) {
1724 mdfSRPort->addChild(conn);
1725 conn->setValue(machineSRPortState->stringAttribute(
1726 FUPort::OSKEY_FIRST_SOCKET));
1727 }
1728
1729 if (machineSRPortState->hasAttribute(FUPort::OSKEY_SECOND_SOCKET)) {
1731 mdfSRPort->addChild(conn);
1732 conn->setValue(machineSRPortState->stringAttribute(
1733 FUPort::OSKEY_SECOND_SOCKET));
1734 }
1735
1737 mdfSRPort->addChild(width);
1738 width->setValue(
1739 machineSRPortState->stringAttribute(
1740 SpecialRegisterPort::OSKEY_WIDTH));
1741
1742 return mdfSRPort;
1743}

References ObjectState::addChild(), assert, CU_SPECIAL_PORT, FU_PORT_WIDTH, ObjectState::hasAttribute(), mdfSRPort(), ObjectState::name(), TTAMachine::SpecialRegisterPort::OSNAME_SPECIAL_REG_PORT, PORT_CONNECTS_TO, PORT_NAME, ObjectState::setAttribute(), ObjectState::setValue(), and ObjectState::stringAttribute().

Referenced by controlUnitToMDF(), and mdfSRPort().

Here is the call graph for this function:

◆ momTemplateSlot()

ObjectState * ADFSerializer::momTemplateSlot ( const ObjectState momITState,
const std::string &  slotName 
)
staticprivate

Looks for an ObjectState instance which represents a template slot in machine object model format.

The ObjectState instance is searched from inside the given ObjectState instance that represents an instruction template in machine object model format. The instance is seached by the given slot name. Returns NULL if such an instance is not found.

Parameters
momITStateAn ObjectState instance representing an instruction template in machine object model format.
busNameThe name of the slot to look the template slot for.
Returns
ObjectState instance representing a template slot in machine object model format or NULL.

Definition at line 2308 of file ADFSerializer.cc.

2310 {
2311
2312 for (int i = 0; i < momITState->childCount(); i++) {
2313 ObjectState* slot = momITState->child(i);
2314 if (slot->stringAttribute(TemplateSlot::OSKEY_SLOT) == slotName) {
2315 return slot;
2316 }
2317 }
2318
2319 return NULL;
2320}

References ObjectState::child(), ObjectState::childCount(), TTAMachine::TemplateSlot::OSKEY_SLOT, and ObjectState::stringAttribute().

Referenced by instructionTemplateToMachine().

Here is the call graph for this function:

◆ operator=()

ADFSerializer & ADFSerializer::operator= ( const ADFSerializer )
protected

Assingment forbidden.

◆ readMachine()

Machine * ADFSerializer::readMachine ( )

Reads the current MDF file set and creates a Machine according to it.

Returns
The newly created machine.
Exceptions
SerializerExceptionIf an error occurs while reading the MDF file.
ObjectStateLoadingExceptionIf an error occurs while creating Machine.

Definition at line 275 of file ADFSerializer.cc.

275 {
276 ObjectState* machineState = readState();
277 Machine* mach = new Machine();
278 mach->loadState(machineState);
279
280 delete machineState;
281 return mach;
282}
ObjectState * readState()
virtual void loadState(const ObjectState *state)
Definition Machine.cc:728

References TTAMachine::Machine::loadState(), and readState().

Referenced by llvm::TCETargetMachine::createMachine(), AddFUArchFromADFCmd::Do(), TTAMachine::Machine::loadFromADF(), loadInputs(), ProGe::ProGeUI::loadMachine(), loadMachine(), loadMachine(), SimulatorFrontend::loadMachine(), ProGe::ProGeUI::loadProcessorConfiguration(), main(), Model::Model(), readAdf(), and llvm::TCEStubTargetMachine::TCEStubTargetMachine().

Here is the call graph for this function:

◆ readState()

ObjectState * ADFSerializer::readState ( )
virtual

Reads the current MDF file set and creates an ObjectState tree which can be given to Machine::loadState to create a machine.

Returns
The newly created ObjectState tree.
Exceptions
SerializerExceptionIf an error occurs while reading.

Reimplemented from XMLSerializer.

Definition at line 238 of file ADFSerializer.cc.

238 {
240 ObjectState* machineState;
241 try {
242 machineState = convertToMachineFormat(mdfState);
243 } catch (const SerializerException&) {
244 delete mdfState;
245 throw;
246 }
247
248 delete mdfState;
249 return machineState;
250}
static ObjectState * convertToMachineFormat(const ObjectState *mdfState)
virtual ObjectState * readState()

References convertToMachineFormat(), and XMLSerializer::readState().

Referenced by DSDBManager::architecture(), readMachine(), and DSDBManager::writeArchitectureToFile().

Here is the call graph for this function:

◆ registerFileToMachine()

ObjectState * ADFSerializer::registerFileToMachine ( const ObjectState rfState)
staticprivate

Creates a new ObjectState tree which can be read by RegisterFile::loadState.

The ObjectState tree is created according to the given ObjectState tree which matches with the syntax of register file declaration in MDF file.

Parameters
rfStateThe ObjectState tree which matches with the syntax of register file declaration in MDF file.
Returns
The newly created ObjectState tree.

Definition at line 1304 of file ADFSerializer.cc.

1304 {
1305
1306 ObjectState* regFile =
1308
1309 // set name
1310 regFile->setAttribute(
1312
1313 // set type
1314 ObjectState* typeChild = rfState->childByName(RF_TYPE);
1315 string type = typeChild->stringValue();
1316 if (type == RF_TYPE_NORMAL) {
1317 regFile->setAttribute(
1319 } else if (type == RF_TYPE_RESERVED) {
1320 regFile->setAttribute(
1322 } else if (type == RF_TYPE_VOLATILE) {
1323 regFile->setAttribute(
1325 } else {
1326 string procName = "ADFSerializer::registerFileToMachine";
1327 string errorMsg = "Unknown register file type in ObjectState "
1328 "instance.";
1329 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
1331 }
1332
1333 // set size
1334 ObjectState* size = rfState->childByName(RF_SIZE);
1336
1337 // set width
1338 ObjectState* width = rfState->childByName(RF_WIDTH);
1339 regFile->setAttribute(
1341
1342 // set max reads
1343 ObjectState* maxReads = rfState->childByName(RF_MAX_READS);
1344 regFile->setAttribute(
1346
1347 // set max writes
1348 ObjectState* maxWrites = rfState->childByName(RF_MAX_WRITES);
1349 regFile->setAttribute(
1351
1352 // set guard latency
1353 if (rfState->hasChild(RF_GUARD_LATENCY)) {
1354 ObjectState* latencyChild = rfState->childByName(RF_GUARD_LATENCY);
1355 regFile->setAttribute(
1357 } else {
1359 }
1360
1361 // set ports
1362 for (int i = 0; i < rfState->childCount(); i++) {
1363 ObjectState* child = rfState->child(i);
1364 if (child->name() == PORT) {
1365 regFile->addChild(machineRFPort(child));
1366 }
1367 }
1368
1369 if (rfState->hasChild(RF_ZERO_REGISTER)) {
1370 ObjectState* zeroRegister = rfState->childByName(RF_ZERO_REGISTER);
1371 regFile->setAttribute(
1373 }
1374
1375 return regFile;
1376}
const string RF_TYPE_VOLATILE
const string RF_SIZE
const string RF_GUARD_LATENCY
const string RF_TYPE_RESERVED
const string RF_MAX_WRITES
const string RF_ZERO_REGISTER
const string RF_TYPE
const string RF_TYPE_NORMAL
const string RF_WIDTH
const string RF_NAME
static const std::string OSKEY_ZERO_REGISTER
ObjectState attribute key for zero register flag.
static const std::string OSKEY_GUARD_LATENCY
ObjectState attribute key for the guard latency.
static const std::string OSVALUE_RESERVED
ObjectState attribute value for reserved register file type.
static const std::string OSVALUE_VOLATILE
ObjectState attribute value for volatile register file type.
static const std::string OSVALUE_NORMAL
ObjectState attribute value for normal register file type.

References Application::abortProgram(), ObjectState::addChild(), ObjectState::boolValue(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), ObjectState::hasChild(), machineRFPort(), ObjectState::name(), TTAMachine::RegisterFile::OSKEY_GUARD_LATENCY, TTAMachine::RegisterFile::OSKEY_MAX_READS, TTAMachine::RegisterFile::OSKEY_MAX_WRITES, TTAMachine::Component::OSKEY_NAME, TTAMachine::BaseRegisterFile::OSKEY_SIZE, TTAMachine::RegisterFile::OSKEY_TYPE, TTAMachine::BaseRegisterFile::OSKEY_WIDTH, TTAMachine::RegisterFile::OSKEY_ZERO_REGISTER, TTAMachine::RegisterFile::OSNAME_REGISTER_FILE, TTAMachine::RegisterFile::OSVALUE_NORMAL, TTAMachine::RegisterFile::OSVALUE_RESERVED, TTAMachine::RegisterFile::OSVALUE_VOLATILE, PORT, RF_GUARD_LATENCY, RF_MAX_READS, RF_MAX_WRITES, RF_NAME, RF_SIZE, RF_TYPE, RF_TYPE_NORMAL, RF_TYPE_RESERVED, RF_TYPE_VOLATILE, RF_WIDTH, RF_ZERO_REGISTER, ObjectState::setAttribute(), ObjectState::stringAttribute(), ObjectState::stringValue(), and Application::writeToErrorLog().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ registerFileToMDF()

ObjectState * ADFSerializer::registerFileToMDF ( const ObjectState rfState)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by RegisterFile::saveState.

Parameters
rfStateRoot node of the ObjectState tree created by RegisterFile::saveState.
Returns
The newly created ObjectState tree.

Definition at line 671 of file ADFSerializer.cc.

671 {
672
673 ObjectState* regFile = new ObjectState(REGISTER_FILE);
674 regFile->setAttribute(
675 RF_NAME, rfState->stringAttribute(RegisterFile::OSKEY_NAME));
676
677 ObjectState* type = new ObjectState(RF_TYPE);
678 regFile->addChild(type);
679 string typeValue = rfState->stringAttribute(RegisterFile::OSKEY_TYPE);
680 if (typeValue == RegisterFile::OSVALUE_NORMAL) {
682 } else if (typeValue == RegisterFile::OSVALUE_RESERVED) {
684 } else if (typeValue == RegisterFile::OSVALUE_VOLATILE) {
686 } else {
687 string procName = "ADFSerializer::registerFileToMDF";
688 string errorMsg = "Unknown register file type in ObjectState "
689 "instance.";
690 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
692 }
693
694 ObjectState* size = new ObjectState(RF_SIZE);
695 regFile->addChild(size);
696 size->setValue(rfState->stringAttribute(RegisterFile::OSKEY_SIZE));
697
698 ObjectState* width = new ObjectState(RF_WIDTH);
699 regFile->addChild(width);
700 width->setValue(rfState->stringAttribute(RegisterFile::OSKEY_WIDTH));
701
702 ObjectState* maxReads = new ObjectState(RF_MAX_READS);
703 regFile->addChild(maxReads);
704 maxReads->setValue(
706
707 ObjectState* maxWrites = new ObjectState(RF_MAX_WRITES);
708 regFile->addChild(maxWrites);
709 maxWrites->setValue(
711
713 ObjectState* guardLatency = new ObjectState(RF_GUARD_LATENCY);
714 regFile->addChild(guardLatency);
715 guardLatency->setValue(
717 }
718
719 // add ports
720 for (int i = 0; i < rfState->childCount(); i++) {
721 ObjectState* child = rfState->child(i);
722 regFile->addChild(mdfPort(child));
723 }
724
726 ObjectState* zeroRegister = new ObjectState(RF_ZERO_REGISTER);
727 regFile->addChild(zeroRegister);
728 zeroRegister->setValue(
730 }
731
732 return regFile;
733}

References Application::abortProgram(), ObjectState::addChild(), ObjectState::boolAttribute(), ObjectState::child(), ObjectState::childCount(), ObjectState::hasAttribute(), ObjectState::intAttribute(), mdfPort(), TTAMachine::RegisterFile::OSKEY_GUARD_LATENCY, TTAMachine::RegisterFile::OSKEY_MAX_READS, TTAMachine::RegisterFile::OSKEY_MAX_WRITES, TTAMachine::RegisterFile::OSKEY_TYPE, TTAMachine::RegisterFile::OSKEY_ZERO_REGISTER, TTAMachine::RegisterFile::OSVALUE_NORMAL, TTAMachine::RegisterFile::OSVALUE_RESERVED, TTAMachine::RegisterFile::OSVALUE_VOLATILE, REGISTER_FILE, RF_GUARD_LATENCY, RF_MAX_READS, RF_MAX_WRITES, RF_NAME, RF_SIZE, RF_TYPE, RF_TYPE_NORMAL, RF_TYPE_RESERVED, RF_TYPE_VOLATILE, RF_WIDTH, RF_ZERO_REGISTER, ObjectState::setAttribute(), ObjectState::setValue(), ObjectState::stringAttribute(), and Application::writeToErrorLog().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ setIUExtensionMode()

void ADFSerializer::setIUExtensionMode ( const ObjectState mdfIUState,
ObjectState momIUState 
)
staticprivate

Sets extension mode of immediate unit to the given ObjectState tree representing immediate unit in machine object model format.

Parameters
mdfIUStateObjectState instance representing immediate unit in mdf format.
momIUStateObjectState instance representing immediate unit in machine object model format.

Definition at line 1756 of file ADFSerializer.cc.

1758 {
1759
1760 ObjectState* extension = mdfIUState->childByName(IU_EXTENSION);
1761 string extensionValue = extension->stringValue();
1762 if (extensionValue == SIGN_EXTENSION) {
1763 momIUState->setAttribute(
1765 } else if (extensionValue == ZERO_EXTENSION) {
1766 momIUState->setAttribute(
1768 } else {
1769 string procName = "ADFSerializer::setIUExtensionMode";
1770 string errorMsg = "Unknown extension attribute value in ObjectState "
1771 "instance.";
1772 Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
1774 }
1775}
static const std::string OSVALUE_SIGN
ObjectState attribute value for sign extension.
static const std::string OSVALUE_ZERO
ObjectState attribute value for zero extension.

References Application::abortProgram(), ObjectState::childByName(), IU_EXTENSION, TTAMachine::ImmediateUnit::OSKEY_EXTENSION, TTAMachine::ImmediateUnit::OSVALUE_SIGN, TTAMachine::ImmediateUnit::OSVALUE_ZERO, ObjectState::setAttribute(), SIGN_EXTENSION, ObjectState::stringValue(), Application::writeToErrorLog(), and ZERO_EXTENSION.

Referenced by immediateUnitToMachine().

Here is the call graph for this function:

◆ socketToMachine()

ObjectState * ADFSerializer::socketToMachine ( const ObjectState socketState)
staticprivate

Creates a new ObjectState tree which can be read by Socket::loadState and which corresponds with the given ObjectState tree declaring a socket by MDF syntax.

Parameters
socketStateThe ObjectState tree declaring a socket by MDF syntax.
Returns
The newly created ObjectState tree.

Definition at line 1176 of file ADFSerializer.cc.

1176 {
1177
1179
1180 // set name
1181 socket->setAttribute(
1183
1184 // set direction
1185 if (socketState->hasChild(SOCKET_READS_FROM) ||
1186 socketState->hasChild(SOCKET_WRITES_TO)) {
1187
1188 if (socketState->hasChild(SOCKET_READS_FROM)) {
1189 socket->setAttribute(
1191 } else {
1192 socket->setAttribute(
1194 }
1195
1196 // add connections
1197 for (int i = 0; i < socketState->childCount(); i++) {
1198 ObjectState* srcOrDest = socketState->child(i);
1199 ObjectState* conn = new ObjectState(
1201 socket->addChild(conn);
1202 conn->setAttribute(
1204 socketState->stringAttribute(SOCKET_NAME));
1205 ObjectState* bus = srcOrDest->childByName(SOCKET_BUS);
1207 ObjectState* segment = srcOrDest->childByName(SOCKET_SEGMENT);
1208 conn->setAttribute(
1210 }
1211
1212 } else {
1213 socket->setAttribute(
1215 }
1216
1217 return socket;
1218}
const string SOCKET_BUS
const string SOCKET_READS_FROM
const string SOCKET_WRITES_TO
const string SOCKET_SEGMENT
const string SOCKET_NAME
static const std::string OSKEY_SEGMENT
ObjectState attribute key for segment name.
Definition Connection.hh:64
static const std::string OSKEY_BUS
ObjectState attribute key for bus name.
Definition Connection.hh:62
static const std::string OSKEY_SOCKET
ObjectState attribute key for socket name.
Definition Connection.hh:60
static const std::string OSNAME_CONNECTION
ObjectState name for Connection.
Definition Connection.hh:58
static const std::string OSVALUE_INPUT
ObjectState attribute value for input direction.
Definition Socket.hh:104
static const std::string OSKEY_DIRECTION
ObjectState attribute key for socket direction.
Definition Socket.hh:102
static const std::string OSVALUE_OUTPUT
ObjectState attribute value for output direction.
Definition Socket.hh:106
static const std::string OSVALUE_UNKNOWN
ObjectState attribute value for unknown direction.
Definition Socket.hh:108

References ObjectState::addChild(), ObjectState::child(), ObjectState::childByName(), ObjectState::childCount(), ObjectState::hasChild(), TTAMachine::Connection::OSKEY_BUS, TTAMachine::Socket::OSKEY_DIRECTION, TTAMachine::Component::OSKEY_NAME, TTAMachine::Connection::OSKEY_SEGMENT, TTAMachine::Connection::OSKEY_SOCKET, TTAMachine::Connection::OSNAME_CONNECTION, TTAMachine::Socket::OSNAME_SOCKET, TTAMachine::Socket::OSVALUE_INPUT, TTAMachine::Socket::OSVALUE_OUTPUT, TTAMachine::Socket::OSVALUE_UNKNOWN, ObjectState::setAttribute(), SOCKET_BUS, SOCKET_NAME, SOCKET_READS_FROM, SOCKET_SEGMENT, SOCKET_WRITES_TO, ObjectState::stringAttribute(), and ObjectState::stringValue().

Referenced by convertToMachineFormat().

Here is the call graph for this function:

◆ socketToMDF()

ObjectState * ADFSerializer::socketToMDF ( const ObjectState socketState)
staticprivate

Creates a new ObjectState tree which matches one-to-one with MDF specs syntax.

The tree is created according to the given ObjectState tree created by Socket::saveState.

Parameters
socketStateRoot node of the ObjectState tree created by Socket::saveState.
Returns
The newly created ObjectState tree.

Definition at line 543 of file ADFSerializer.cc.

543 {
544
545 ObjectState* socket = new ObjectState(SOCKET);
546 socket->setAttribute(
547 SOCKET_NAME, socketState->stringAttribute(Socket::OSKEY_NAME));
548
549 bool input;
550 if (socketState->stringAttribute(Socket::OSKEY_DIRECTION) ==
552 input = true;
553 } else if (socketState->stringAttribute(Socket::OSKEY_DIRECTION) ==
555 input = false;
556 } else {
557 return socket;
558 }
559
560 for (int i = 0; i < socketState->childCount(); i++) {
561 ObjectState* child = socketState->child(i);
562 ObjectState* conn;
563 if (input) {
564 conn = new ObjectState(SOCKET_READS_FROM);
565 } else {
566 conn = new ObjectState(SOCKET_WRITES_TO);
567 }
568 socket->addChild(conn);
570 conn->addChild(bus);
572
573 ObjectState* segment = new ObjectState(SOCKET_SEGMENT);
574 conn->addChild(segment);
576 segment->setValue(
578 }
579 }
580
581 return socket;
582}

References ObjectState::addChild(), ObjectState::child(), ObjectState::childCount(), ObjectState::hasAttribute(), TTAMachine::Connection::OSKEY_BUS, TTAMachine::Socket::OSKEY_DIRECTION, TTAMachine::Connection::OSKEY_SEGMENT, TTAMachine::Socket::OSVALUE_INPUT, TTAMachine::Socket::OSVALUE_OUTPUT, ObjectState::setAttribute(), ObjectState::setValue(), SOCKET, SOCKET_BUS, SOCKET_NAME, SOCKET_READS_FROM, SOCKET_SEGMENT, SOCKET_WRITES_TO, and ObjectState::stringAttribute().

Referenced by convertToMDFFormat().

Here is the call graph for this function:

◆ writeMachine()

void ADFSerializer::writeMachine ( const TTAMachine::Machine machine)

Serializes the given machine to mdf file.

Parameters
machineThe machine to be serialized.
Exceptions
SerializerExceptionIf an error occurs while serializing.

Definition at line 259 of file ADFSerializer.cc.

259 {
260 ObjectState* machineState = machine.saveState();
261 writeState(machineState);
262 delete machineState;
263}
void writeState(const ObjectState *machineState)
virtual ObjectState * saveState() const
Definition Machine.cc:686

References machine, TTAMachine::Machine::saveState(), and writeState().

Referenced by CompileTools::compileAsC(), CompileTools::compileAsLLVM(), TTAMachine::Machine::hash(), MDFDocument::OnSaveDocument(), DesignSpaceExplorer::schedule(), and TTAMachine::Machine::writeToADF().

Here is the call graph for this function:

◆ writeState()

void ADFSerializer::writeState ( const ObjectState machineState)
virtual

Writes the given ObjectState tree created by Machine::saveState to the destination file.

Parameters
machineStateObjectState tree created by Machine::saveState.
Exceptions
SerializerExceptionIf an error occurs while serializing.

Reimplemented from XMLSerializer.

Definition at line 224 of file ADFSerializer.cc.

224 {
225 ObjectState* converted = convertToMDFFormat(machineState);
226 XMLSerializer::writeState(converted);
227 delete converted;
228}
static ObjectState * convertToMDFFormat(const ObjectState *machineState)
virtual void writeState(const ObjectState *rootState)

References convertToMDFFormat(), and XMLSerializer::writeState().

Referenced by DSDBManager::addArchitecture(), DSDBManager::writeArchitectureToFile(), and writeMachine().

Here is the call graph for this function:

The documentation for this class was generated from the following files: