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

#include <MoveSlot.hh>

Inheritance diagram for MoveSlot:
Inheritance graph
Collaboration diagram for MoveSlot:
Collaboration graph

Public Member Functions

 MoveSlot (const std::string &busName, BinaryEncoding &parent)
 
 MoveSlot (const ObjectState *state, BinaryEncoding &parent)
 
virtual ~MoveSlot ()
 
BinaryEncodingparent () const
 
std::string name () const
 
void setName (const std::string &name)
 
void setGuardField (GuardField &field)
 
void unsetGuardField ()
 
bool hasGuardField () const
 
GuardFieldguardField () const
 
void setSourceField (SourceField &field)
 
void unsetSourceField ()
 
bool hasSourceField () const
 
SourceFieldsourceField () const
 
void setDestinationField (DestinationField &field)
 
void unsetDestinationField ()
 
bool hasDestinationField () const
 
DestinationFielddestinationField () const
 
virtual int childFieldCount () const
 
virtual InstructionFieldchildField (int position) const
 
virtual int width () const
 
virtual void loadState (const ObjectState *state)
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from InstructionField
virtual ~InstructionField ()
 
InstructionFieldparent () const
 
int bitPosition () const
 
int relativePosition () const
 
virtual void setRelativePosition (int position)
 
void setExtraBits (int bits)
 
int extraBits () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_MOVE_SLOT = "move_slot"
 ObjectState name for move slot.
 
static const std::string OSKEY_BUS_NAME = "bus_name"
 ObjectState attribute key for the name of the bus.
 
- Static Public Attributes inherited from InstructionField
static const std::string OSNAME_INSTRUCTION_FIELD = "instr_field"
 ObjectState name for instruction field.
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits.
 
static const std::string OSKEY_POSITION = "position"
 ObjectState attribute key for the relative position of the field.
 

Private Member Functions

void deleteGuardField ()
 
void deleteSourceField ()
 
void deleteDestinationField ()
 

Private Attributes

std::string name_
 The bus name.
 
GuardFieldguardField_
 The guard field.
 
SourceFieldsourceField_
 The source field.
 
DestinationFielddestinationField_
 The destination field.
 

Additional Inherited Members

- Protected Member Functions inherited from InstructionField
 InstructionField (InstructionField *parent)
 
 InstructionField (const ObjectState *state, InstructionField *parent)
 
void setParent (InstructionField *parent)
 
- Static Protected Member Functions inherited from InstructionField
static void reorderSubfields (ObjectState *state)
 

Detailed Description

The MoveSlot class represents move slots, fields of the TTA instruction dedicated to program data transports.

Move slots are subdivided into 2 or 3 fields: the guard (optional), source and destination fields. Each type of move slot field is modelled by a different class. MoveSlot has handles to the instances of these classes. A move slot is identified by the name of the transport bus it controls. MoveSlot instances cannot exist alone. They belong to a binary encoding and are always registered to a BinaryEncoding object.

Definition at line 60 of file MoveSlot.hh.

Constructor & Destructor Documentation

◆ MoveSlot() [1/2]

MoveSlot::MoveSlot ( const std::string &  busName,
BinaryEncoding parent 
)

The constructor.

Registers the move slot to the parent binary encoding automatically. The slot is added as the leftmost field of the instruction word.

Parameters
busNameName of the bus programmed by this move slot.
parentThe parent BinaryEncoding.
Exceptions
ObjectAlreadyExistsIf the parent binary encoding has a move slot with the same bus name already.

Definition at line 64 of file MoveSlot.cc.

66 name_(busName),
67 guardField_(NULL),
68 sourceField_(NULL),
69 destinationField_(NULL) {
70 setParent(NULL);
71 parent.addMoveSlot(*this);
73}
void addMoveSlot(MoveSlot &slot)
void setParent(InstructionField *parent)
BinaryEncoding * parent() const
Definition MoveSlot.cc:118
std::string name_
The bus name.
Definition MoveSlot.hh:106
GuardField * guardField_
The guard field.
Definition MoveSlot.hh:108
DestinationField * destinationField_
The destination field.
Definition MoveSlot.hh:112
SourceField * sourceField_
The source field.
Definition MoveSlot.hh:110

References BinaryEncoding::addMoveSlot(), parent(), and InstructionField::setParent().

Here is the call graph for this function:

◆ MoveSlot() [2/2]

MoveSlot::MoveSlot ( const ObjectState state,
BinaryEncoding parent 
)

The constructor.

Loads the state of the move slot from the given ObjectState tree.

Parameters
stateThe ObjectState tree.
parentThe parent binary encoding map.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Definition at line 85 of file MoveSlot.cc.

86 : InstructionField(state, &parent),
87 name_(""),
88 guardField_(NULL),
89 sourceField_(NULL),
90 destinationField_(NULL) {
91 loadState(state);
92 setParent(NULL);
93 parent.addMoveSlot(*this);
95}
virtual void loadState(const ObjectState *state)
Definition MoveSlot.cc:432

References BinaryEncoding::addMoveSlot(), loadState(), parent(), and InstructionField::setParent().

Here is the call graph for this function:

◆ ~MoveSlot()

MoveSlot::~MoveSlot ( )
virtual

The destructor.

Definition at line 100 of file MoveSlot.cc.

100 {
101
105
106 BinaryEncoding* parent = this->parent();
107 setParent(NULL);
108 parent->removeMoveSlot(*this);
109}
void removeMoveSlot(MoveSlot &slot)
void deleteSourceField()
Definition MoveSlot.cc:505
void deleteGuardField()
Definition MoveSlot.cc:493
void deleteDestinationField()
Definition MoveSlot.cc:516

References deleteDestinationField(), deleteGuardField(), deleteSourceField(), parent(), BinaryEncoding::removeMoveSlot(), and InstructionField::setParent().

Here is the call graph for this function:

Member Function Documentation

◆ childField()

InstructionField & MoveSlot::childField ( int  position) const
virtual

Returns the child field at the given relative position.

Parameters
positionThe position (0 is the rightmost position).
Exceptions
OutOfRangeIf the position is negative or not smaller than the number of child fields.

Reimplemented from InstructionField.

Definition at line 380 of file MoveSlot.cc.

380 {
382
383 if (hasGuardField() && guardField().relativePosition() == position) {
384 return guardField();
385 }
386
387 if (hasSourceField() && sourceField().relativePosition() == position) {
388 return sourceField();
389 }
390
391 if (hasDestinationField() &&
392 destinationField().relativePosition() == position) {
393 return destinationField();
394 }
395
396 assert(false);
398}
#define assert(condition)
virtual InstructionField & childField(int position) const
int relativePosition() const
SourceField & sourceField() const
Definition MoveSlot.cc:277
DestinationField & destinationField() const
Definition MoveSlot.cc:341
GuardField & guardField() const
Definition MoveSlot.cc:215
bool hasSourceField() const
Definition MoveSlot.cc:264
bool hasDestinationField() const
Definition MoveSlot.cc:327
bool hasGuardField() const
Definition MoveSlot.cc:202
static NullInstructionField & instance()

References assert, InstructionField::childField(), destinationField(), guardField(), hasDestinationField(), hasGuardField(), hasSourceField(), NullInstructionField::instance(), InstructionField::relativePosition(), and sourceField().

Referenced by CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), and printMoveSlotLayout().

Here is the call graph for this function:

◆ childFieldCount()

int MoveSlot::childFieldCount ( ) const
virtual

Returns the number of child fields (guard, source, destination) within the move slot.

Returns
The number of child fields.

Implements InstructionField.

Definition at line 357 of file MoveSlot.cc.

357 {
358 int count(0);
359 if (hasGuardField()) {
360 count++;
361 }
362 if (hasSourceField()) {
363 count++;
364 }
365 if (hasDestinationField()) {
366 count++;
367 }
368 return count;
369}

References hasDestinationField(), hasGuardField(), and hasSourceField().

Referenced by CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), and printMoveSlotLayout().

Here is the call graph for this function:

◆ deleteDestinationField()

void MoveSlot::deleteDestinationField ( )
private

Deletes the destination field of the move slot.

Definition at line 516 of file MoveSlot.cc.

516 {
517 if (destinationField_ != NULL) {
518 delete destinationField_;
519 destinationField_ = NULL;
520 }
521}

References destinationField_.

Referenced by loadState(), and ~MoveSlot().

◆ deleteGuardField()

void MoveSlot::deleteGuardField ( )
private

Deletes the guard field of the move slot.

Definition at line 493 of file MoveSlot.cc.

493 {
494 if (guardField_ != NULL) {
495 delete guardField_;
496 guardField_ = NULL;
497 }
498}

References guardField_.

Referenced by loadState(), and ~MoveSlot().

◆ deleteSourceField()

void MoveSlot::deleteSourceField ( )
private

Deletes the source field of the move slot.

Definition at line 505 of file MoveSlot.cc.

505 {
506 if (sourceField_ != NULL) {
507 delete sourceField_;
508 sourceField_ = NULL;
509 }
510}

References sourceField_.

Referenced by loadState(), and ~MoveSlot().

◆ destinationField()

DestinationField & MoveSlot::destinationField ( ) const

◆ guardField()

GuardField & MoveSlot::guardField ( ) const

Returns the guard field of the move slot.

Returns NullGuardField instance if the guard field is missing.

Returns
The guard field of the move slot.

Definition at line 215 of file MoveSlot.cc.

215 {
216 if (hasGuardField()) {
217 return *guardField_;
218 } else {
220 }
221}
static NullGuardField & instance()

References guardField_, hasGuardField(), and NullGuardField::instance().

Referenced by BEMTester::canAddComponentPriorityEncoding(), BEMValidator::checkGuardField(), childField(), CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), printGuardFieldEncodings(), saveState(), unsetGuardField(), width(), DefaultDecoderGenerator::writeInstructionDismembering(), DefaultDecoderGenerator::writeMoveFieldSignals(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

Here is the call graph for this function:

◆ hasDestinationField()

bool MoveSlot::hasDestinationField ( ) const

◆ hasGuardField()

bool MoveSlot::hasGuardField ( ) const

◆ hasSourceField()

bool MoveSlot::hasSourceField ( ) const

Tells whether the move slot has a source field.

Returns
True if the move slot has a source field, otherwise false.

Definition at line 264 of file MoveSlot.cc.

264 {
265 return sourceField_ != NULL;
266}

References sourceField_.

Referenced by BEMValidator::checkSourceField(), childField(), childFieldCount(), GuardField::GuardField(), printSourceFieldEncodings(), saveState(), setSourceField(), sourceField(), SourceField::SourceField(), unsetSourceField(), width(), DefaultDecoderGenerator::writeInstructionDismembering(), and DefaultDecoderGenerator::writeMoveFieldSignals().

◆ loadState()

void MoveSlot::loadState ( const ObjectState state)
virtual

Loads the state of the move slot from the given ObjectState tree.

Parameters
stateThe ObjectState tree.
Exceptions
ObjectStateLoadingExceptionIf an error occurs while loading the state.

Reimplemented from InstructionField.

Definition at line 432 of file MoveSlot.cc.

432 {
436
437 ObjectState* newState = new ObjectState(*state);
438 reorderSubfields(newState);
440
441 try {
443 for (int i = 0; i < newState->childCount(); i++) {
444 ObjectState* child = newState->child(i);
445 if (child->name() == GuardField::OSNAME_GUARD_FIELD) {
446 new GuardField(child, *this);
447 } else if (child->name() == SourceField::OSNAME_SOURCE_FIELD) {
448 new SourceField(child, *this);
449 } else if (
451 new DestinationField(child, *this);
452 }
453 }
454 } catch (const Exception& exception) {
455 const string procName = "MoveSlot::loadState";
457 __FILE__, __LINE__, procName, exception.errorMessage());
458 }
459
460 delete newState;
461}
static const std::string OSNAME_DESTINATION_FIELD
ObjectState name for destination field.
std::string errorMessage() const
Definition Exception.cc:123
static const std::string OSNAME_GUARD_FIELD
ObjectState name for guard field.
Definition GuardField.hh:99
virtual void loadState(const ObjectState *state)
static void reorderSubfields(ObjectState *state)
void setName(const std::string &name)
Definition MoveSlot.cc:149
static const std::string OSKEY_BUS_NAME
ObjectState attribute key for the name of the bus.
Definition MoveSlot.hh:98
ObjectState * child(int index) const
std::string stringAttribute(const std::string &name) const
std::string name() const
int childCount() const
static const std::string OSNAME_SOURCE_FIELD
ObjectState name for source field.

References ObjectState::child(), ObjectState::childCount(), deleteDestinationField(), deleteGuardField(), deleteSourceField(), Exception::errorMessage(), InstructionField::loadState(), ObjectState::name(), OSKEY_BUS_NAME, DestinationField::OSNAME_DESTINATION_FIELD, GuardField::OSNAME_GUARD_FIELD, SourceField::OSNAME_SOURCE_FIELD, InstructionField::reorderSubfields(), setName(), and ObjectState::stringAttribute().

Referenced by MoveSlot().

Here is the call graph for this function:

◆ name()

std::string MoveSlot::name ( ) const

Returns the bus name programmed by this move slot in the instruction word.

Returns
Name of the bus.

Definition at line 136 of file MoveSlot.cc.

136 {
137 return name_;
138}

References name_.

Referenced by CodeCompressorPlugin::addBitsForDestinationField(), CodeCompressorPlugin::addBitsForGuardField(), CodeCompressorPlugin::addBitsForMoveSlot(), CodeCompressorPlugin::addBitsForSourceField(), BEMGenerator::addEncodings(), BEMGenerator::addEncodings(), BEMGenerator::addEncodings(), BinaryEncoding::addMoveSlot(), BEMGenerator::addSubfields(), BEMValidator::checkSocketCodeTable(), CodeCompressorPlugin::encodeFUTerminal(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeIUTerminal(), CodeCompressorPlugin::encodeMove(), CodeCompressorPlugin::encodeNOP(), CodeCompressorPlugin::encodeRFTerminal(), ProGe::RV32MicroCodeGenerator::findBusWidths(), DefaultDecoderGenerator::findGuard(), DefaultDecoderGenerator::findGuard(), BinaryEncoding::hasMoveSlot(), BEMGenerator::maxLongImmSlotWidth(), BinaryEncoding::moveSlot(), BEMValidator::needsSourceField(), DefaultDecoderGenerator::portCodeCondition(), printInstructionLayout(), printMoveSlot(), DefaultDecoderGenerator::rfOpcodeFromSrcOrDstField(), saveState(), SourceField::setImmediateEncoding(), setName(), DefaultDecoderGenerator::socketEncodingCondition(), DefaultDecoderGenerator::writeControlRulesOfFUInputPort(), DefaultDecoderGenerator::writeInstructionDismembering(), DefaultDecoderGenerator::writeMoveFieldSignals(), and DefaultDecoderGenerator::writeSquashSignalGenerationProcess().

◆ parent()

BinaryEncoding * MoveSlot::parent ( ) const

Returns the parent binary encoding.

Returns
The parent binary encoding.

Definition at line 118 of file MoveSlot.cc.

118 {
120 if (parent == NULL) {
121 return NULL;
122 } else {
123 BinaryEncoding* bem = dynamic_cast<BinaryEncoding*>(parent);
124 assert(bem != NULL);
125 return bem;
126 }
127}
InstructionField * parent() const

References assert, InstructionField::parent(), and parent().

Referenced by BinaryEncoding::addMoveSlot(), DestinationField::DestinationField(), MoveSlot(), MoveSlot(), parent(), BinaryEncoding::removeMoveSlot(), setName(), SocketEncoding::SocketEncoding(), SourceField::SourceField(), unsetDestinationField(), unsetGuardField(), unsetSourceField(), and ~MoveSlot().

Here is the call graph for this function:

◆ saveState()

ObjectState * MoveSlot::saveState ( ) const
virtual

Saves the state of the move slot to an ObjectState tree.

Returns
The newly created ObjectState tree.

Reimplemented from InstructionField.

Definition at line 469 of file MoveSlot.cc.

469 {
470
474
475 if (hasGuardField()) {
476 state->addChild(guardField().saveState());
477 }
478 if (hasSourceField()) {
479 state->addChild(sourceField().saveState());
480 }
481 if (hasDestinationField()) {
483 }
484
485 return state;
486}
virtual ObjectState * saveState() const
virtual ObjectState * saveState() const
Definition MoveSlot.cc:469
std::string name() const
Definition MoveSlot.cc:136
static const std::string OSNAME_MOVE_SLOT
ObjectState name for move slot.
Definition MoveSlot.hh:96
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)
void addChild(ObjectState *child)

References ObjectState::addChild(), destinationField(), guardField(), hasDestinationField(), hasGuardField(), hasSourceField(), name(), OSKEY_BUS_NAME, OSNAME_MOVE_SLOT, InstructionField::saveState(), saveState(), ObjectState::setAttribute(), ObjectState::setName(), and sourceField().

Referenced by BinaryEncoding::saveState(), and saveState().

Here is the call graph for this function:

◆ setDestinationField()

void MoveSlot::setDestinationField ( DestinationField field)

Adds the given destination field to the move slot.

This method is to be called from the constructor of DestinationField.

Parameters
fieldThe destination field to be added.
Exceptions
ObjectAlreadyExistsIf the move slot has a destination field already.

Definition at line 296 of file MoveSlot.cc.

296 {
297 // verify that this is called from DestinationField constructor
298 assert(field.parent() == NULL);
299
300 if (hasDestinationField()) {
301 const string procName = "MoveSlot::setDestinationField";
302 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
303 }
304
305 destinationField_ = &field;
306}
MoveSlot * parent() const
Definition SlotField.cc:98

References assert, destinationField_, hasDestinationField(), and SlotField::parent().

Referenced by DestinationField::DestinationField(), and DestinationField::DestinationField().

Here is the call graph for this function:

◆ setGuardField()

void MoveSlot::setGuardField ( GuardField field)

Adds the given guard field to the move slot.

This method is to be called from the constructor of GuardField.

Parameters
fieldThe guard field to be added.
Exceptions
ObjectAlreadyExistsIf the move slot has a guard field already.

Definition at line 171 of file MoveSlot.cc.

171 {
172 // verify that this is called from GuardField constructor
173 assert(field.parent() == NULL);
174
175 if (hasGuardField()) {
176 const string procName = "MoveSlot::setGuardField";
177 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
178 }
179
180 guardField_ = &field;
181}
MoveSlot * parent() const

References assert, guardField_, hasGuardField(), and GuardField::parent().

Referenced by GuardField::GuardField(), and GuardField::GuardField().

Here is the call graph for this function:

◆ setName()

void MoveSlot::setName ( const std::string &  name)

Sets the name of the bus programmed by this move slot.

Parameters
nameName of the bus.
Exceptions
ObjectAlreadyExistsIf there is a move slot that programs the given bus already.

Definition at line 149 of file MoveSlot.cc.

149 {
150 if (name == this->name()) {
151 return;
152 }
153
154 if (parent()->hasMoveSlot(name)) {
155 const string procName = "MoveSlot::setName";
156 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
157 }
158
159 name_ = name;
160}

References name(), name_, and parent().

Referenced by loadState().

Here is the call graph for this function:

◆ setSourceField()

void MoveSlot::setSourceField ( SourceField field)

Adds the given source field to the move slot.

This method is to be called from the constructor of SourceField.

Parameters
fieldThe source field to be added.
Exceptions
ObjectAlreadyExistsIf the move slot has a source field already.

Definition at line 233 of file MoveSlot.cc.

233 {
234 // verify that this is called from SourceField constructor
235 assert(field.parent() == NULL);
236
237 if (hasSourceField()) {
238 const string procName = "MoveSlot::setSourceField";
239 throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
240 }
241
242 sourceField_ = &field;
243}

References assert, hasSourceField(), SlotField::parent(), and sourceField_.

Referenced by SourceField::SourceField(), and SourceField::SourceField().

Here is the call graph for this function:

◆ sourceField()

SourceField & MoveSlot::sourceField ( ) const

◆ unsetDestinationField()

void MoveSlot::unsetDestinationField ( )

Removes the destination field from the move slot.

This method is to be called from the destructor of DestinationField.

Definition at line 314 of file MoveSlot.cc.

314 {
316 assert(destinationField().parent() == NULL);
317 destinationField_ = NULL;
318}

References assert, destinationField(), destinationField_, hasDestinationField(), and parent().

Referenced by DestinationField::~DestinationField().

Here is the call graph for this function:

◆ unsetGuardField()

void MoveSlot::unsetGuardField ( )

Removes the guard field from the move slot.

This method is to be called from the destructor of GuardField.

Definition at line 189 of file MoveSlot.cc.

189 {
191 assert(guardField().parent() == NULL);
192 guardField_ = NULL;
193}

References assert, guardField(), guardField_, hasGuardField(), and parent().

Referenced by GuardField::~GuardField().

Here is the call graph for this function:

◆ unsetSourceField()

void MoveSlot::unsetSourceField ( )

Removes the source field from the move slot.

This method is to be called from the destructor of SourceField.

Definition at line 251 of file MoveSlot.cc.

251 {
253 assert(sourceField().parent() == NULL);
254 sourceField_ = NULL;
255}

References assert, hasSourceField(), parent(), sourceField(), and sourceField_.

Referenced by SourceField::~SourceField().

Here is the call graph for this function:

◆ width()

int MoveSlot::width ( ) const
virtual

Member Data Documentation

◆ destinationField_

DestinationField* MoveSlot::destinationField_
private

The destination field.

Definition at line 112 of file MoveSlot.hh.

Referenced by deleteDestinationField(), destinationField(), hasDestinationField(), setDestinationField(), and unsetDestinationField().

◆ guardField_

GuardField* MoveSlot::guardField_
private

The guard field.

Definition at line 108 of file MoveSlot.hh.

Referenced by deleteGuardField(), guardField(), hasGuardField(), setGuardField(), and unsetGuardField().

◆ name_

std::string MoveSlot::name_
private

The bus name.

Definition at line 106 of file MoveSlot.hh.

Referenced by name(), and setName().

◆ OSKEY_BUS_NAME

const std::string MoveSlot::OSKEY_BUS_NAME = "bus_name"
static

ObjectState attribute key for the name of the bus.

Definition at line 98 of file MoveSlot.hh.

Referenced by loadState(), BEMSerializer::moveSlotToFile(), BEMSerializer::moveSlotToOM(), and saveState().

◆ OSNAME_MOVE_SLOT

const std::string MoveSlot::OSNAME_MOVE_SLOT = "move_slot"
static

◆ sourceField_

SourceField* MoveSlot::sourceField_
private

The source field.

Definition at line 110 of file MoveSlot.hh.

Referenced by deleteSourceField(), hasSourceField(), setSourceField(), sourceField(), and unsetSourceField().


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