OpenASIP  2.0
Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
SocketCodeTable Class Reference

#include <SocketCodeTable.hh>

Inheritance diagram for SocketCodeTable:
Inheritance graph
Collaboration diagram for SocketCodeTable:
Collaboration graph

Public Member Functions

 SocketCodeTable (const std::string &name, BinaryEncoding &parent)
 
 SocketCodeTable (const ObjectState *state, BinaryEncoding &parent)
 
virtual ~SocketCodeTable ()
 
BinaryEncodingparent () const
 
std::string name () const
 
void setName (const std::string &name)
 
void setExtraBits (int bits)
 
int extraBits () const
 
int width () const
 
int maxCodeWidth () const
 
void addFUPortCode (FUPortCode &code)
 
void removeFUPortCode (FUPortCode &code)
 
int fuPortCodeCount () const
 
FUPortCodefuPortCode (int index) const
 
bool hasFUPortCode (const std::string &fu, const std::string &port) const
 
bool hasFUPortCode (const std::string &fu, const std::string &port, const std::string &operation) const
 
FUPortCodefuPortCode (const std::string &fu, const std::string &port) const
 
FUPortCodefuPortCode (const std::string &fu, const std::string &port, const std::string &operation) const
 
void addRFPortCode (RFPortCode &code)
 
void removeRFPortCode (RFPortCode &code)
 
int rfPortCodeCount () const
 
RFPortCoderfPortCode (int index) const
 
bool hasRFPortCode (const std::string &regFile) const
 
RFPortCoderfPortCode (const std::string &regFile) const
 
void addIUPortCode (IUPortCode &code)
 
void removeIUPortCode (IUPortCode &code)
 
int iuPortCodeCount () const
 
IUPortCodeiuPortCode (int index) const
 
bool hasIUPortCode (const std::string &immediateUnit) const
 
IUPortCodeiuPortCode (const std::string &immediateUnit) const
 
int portCodeCount () const
 
PortCodeportCode (int index) const
 
virtual void loadState (const ObjectState *state)
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Static Public Attributes

static const std::string OSNAME_SOCKET_CODE_TABLE = "sc_table"
 ObjectState name for socket code table. More...
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for name of the table. More...
 
static const std::string OSKEY_EXTRA_BITS = "extra_bits"
 ObjectState attribute key for the number of extra bits. More...
 

Private Types

typedef std::vector< FUPortCode * > FUPortCodeTable
 Container type for FU port codes. More...
 
typedef std::vector< RFPortCode * > RFPortCodeTable
 Container type for RF port codes. More...
 
typedef std::vector< IUPortCode * > IUPortCodeTable
 Container type for IU port codes. More...
 

Private Member Functions

void removeReferences (SlotField &field) const
 
bool hasParentSCTable (const std::string &name) const
 
void deleteRFPortCodes ()
 
void deleteFUPortCodes ()
 
void deleteIUPortCodes ()
 
bool hasRFOrIUPortCodeWithoutEncoding () const
 
bool containsPortCode () const
 

Private Attributes

BinaryEncodingparent_
 The parent binary encoding map. More...
 
std::string name_
 Name of the table. More...
 
FUPortCodeTable fuPortCodes_
 FU port codes. More...
 
RFPortCodeTable rfPortCodes_
 RF port codes. More...
 
IUPortCodeTable iuPortCodes_
 IU port codes. More...
 
int extraBits_
 The number of extra bits. More...
 

Detailed Description

If a socket is attached to several ports, each port is identified by a different control code. This control code forms the variable part of the socket encoding and is defined by SocketCodeTable class.

The SocketCodeTable class contains objects that represent port control codes, namely FUPortCode, RFPortCode and IUPortCode. Because a single SocketCodeTable instance is shared by several socket encodings, it is not owned by SocketEncoding objects. Instead, socket code tables are owned by BinaryEncoding class, which provides methods to access and handle them.

Port codes consists of one or two parts: port ID and/or register index. Port IDs are aligned to the left end of the field and register indices to the right end. That is, if port ID + register index do not take all the bits of the width reserved for the table, there are unused bits between port ID and register index.

Definition at line 68 of file SocketCodeTable.hh.

Member Typedef Documentation

◆ FUPortCodeTable

typedef std::vector<FUPortCode*> SocketCodeTable::FUPortCodeTable
private

Container type for FU port codes.

Definition at line 129 of file SocketCodeTable.hh.

◆ IUPortCodeTable

typedef std::vector<IUPortCode*> SocketCodeTable::IUPortCodeTable
private

Container type for IU port codes.

Definition at line 133 of file SocketCodeTable.hh.

◆ RFPortCodeTable

typedef std::vector<RFPortCode*> SocketCodeTable::RFPortCodeTable
private

Container type for RF port codes.

Definition at line 131 of file SocketCodeTable.hh.

Constructor & Destructor Documentation

◆ SocketCodeTable() [1/2]

SocketCodeTable::SocketCodeTable ( const std::string &  name,
BinaryEncoding parent 
)

The constructor.

Creates a code table and registers it to a binary encoding map.

Parameters
nameName of the table.
parentThe encoding map.
Exceptions
ObjectAlreadyExistsIf the parent encoding map already contains a socket code table with the same name.

Definition at line 68 of file SocketCodeTable.cc.

70  : parent_(NULL), name_(name), extraBits_(0) {
72  parent_ = &parent;
73 }

References BinaryEncoding::addSocketCodeTable(), parent(), and parent_.

Here is the call graph for this function:

◆ SocketCodeTable() [2/2]

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

The constructor.

Loads the state of the table 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 SocketCodeTable.cc.

87  : parent_(&parent), name_(""), extraBits_(0) {
88  loadState(state);
89  parent_ = NULL;
91  parent_ = &parent;
92 }

References BinaryEncoding::addSocketCodeTable(), loadState(), parent(), and parent_.

Here is the call graph for this function:

◆ ~SocketCodeTable()

SocketCodeTable::~SocketCodeTable ( )
virtual

The destructor.

Removes the all the references to the socket code table from socket encodings.

Definition at line 100 of file SocketCodeTable.cc.

100  {
101 
102  BinaryEncoding* parent = this->parent();
103  for (int i = 0; i < parent->moveSlotCount(); i++) {
104  MoveSlot& slot = parent->moveSlot(i);
105  SlotField& src = slot.sourceField();
106  removeReferences(src);
107  SlotField& dst = slot.destinationField();
108  removeReferences(dst);
109  }
110 
114 
115  parent_ = NULL;
117 }

References deleteFUPortCodes(), deleteIUPortCodes(), deleteRFPortCodes(), MoveSlot::destinationField(), BinaryEncoding::moveSlot(), BinaryEncoding::moveSlotCount(), parent(), parent_, removeReferences(), BinaryEncoding::removeSocketCodeTable(), and MoveSlot::sourceField().

Here is the call graph for this function:

Member Function Documentation

◆ addFUPortCode()

void SocketCodeTable::addFUPortCode ( FUPortCode code)

Adds the given control code that identifies a port of a function unit.

This method is to be called from the constructor of FUPortCode class.

Parameters
codeThe code to be added.
Exceptions
ObjectAlreadyExistsIf the port is already encoded in this table or if the encoding is ambiguous with other encodings in the socket code table.

Definition at line 249 of file SocketCodeTable.cc.

249  {
250  const string procName = "SocketCodeTable::addFUPortCode";
251 
253  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
254  }
255 
257  *this, code.encoding(), code.extraBits())) {
258  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
259  }
260 
261  if (code.hasOperation()) {
262  if (hasFUPortCode(
263  code.unitName(), code.portName(), code.operationName())) {
264  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
265  }
266  } else {
267  if (hasFUPortCode(code.unitName(), code.portName())) {
268  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
269  }
270  }
271 
272  fuPortCodes_.push_back(&code);
273 }

References BEMTester::canAddPortEncoding(), PortCode::encoding(), PortCode::extraBits(), fuPortCodes_, hasFUPortCode(), FUPortCode::hasOperation(), hasRFOrIUPortCodeWithoutEncoding(), FUPortCode::operationName(), FUPortCode::portName(), and PortCode::unitName().

Referenced by FUPortCode::FUPortCode().

Here is the call graph for this function:

◆ addIUPortCode()

void SocketCodeTable::addIUPortCode ( IUPortCode code)

Adds a control code that identifies an immediate unit.

In fact, the control code identifies a IU port, but which port is irrelevant, since all ports are identical and each must be attached to a different socket. This method is to be called from the constructor of IUPortCode class.

Parameters
codeThe control code to be added.
Exceptions
ObjectAlreadyExistsIf the register file is already encoded in this table or if the encoding is ambiguous with another encoding in the socket code table.

Definition at line 544 of file SocketCodeTable.cc.

544  {
545  assert(code.parent() == NULL);
546  const string procName = "SocketCodeTable::addIUPortCode";
547 
548  if (!code.hasEncoding() && containsPortCode()) {
549  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
550  }
551 
552  if (code.hasEncoding()) {
554  *this, code.encoding(), code.extraBits())) {
555  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
556  }
557  }
558 
559  if (hasIUPortCode(code.unitName())) {
560  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
561  }
562 
563  iuPortCodes_.push_back(&code);
564 }

References assert, BEMTester::canAddPortEncoding(), containsPortCode(), PortCode::encoding(), PortCode::extraBits(), PortCode::hasEncoding(), hasIUPortCode(), iuPortCodes_, PortCode::parent(), and PortCode::unitName().

Referenced by IUPortCode::IUPortCode().

Here is the call graph for this function:

◆ addRFPortCode()

void SocketCodeTable::addRFPortCode ( RFPortCode code)

Adds a control code that identifies a register file.

In fact, the control code identifies a RF port, but which port is irrelevant, since all ports are identical and each must be attached to a different socket. This method is to be called from the constructor of RFPortCode class.

Parameters
codeThe control code to be added.
Exceptions
ObjectAlreadyExistsIf the register file is already encoded in this table or if the encoding is ambiguous with another encoding in the socket code table.

Definition at line 428 of file SocketCodeTable.cc.

428  {
429  assert(code.parent() == NULL);
430  const string procName = "SocketCodeTable::addRFPortCode";
431 
432  if (!code.hasEncoding() && containsPortCode()) {
433  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
434  }
435 
436  if (code.hasEncoding()) {
438  *this, code.encoding(), code.extraBits())) {
439  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
440  }
441  }
442 
443  if (hasRFPortCode(code.unitName())) {
444  throw ObjectAlreadyExists(__FILE__, __LINE__, procName);
445  }
446 
447  rfPortCodes_.push_back(&code);
448 }

References assert, BEMTester::canAddPortEncoding(), containsPortCode(), PortCode::encoding(), PortCode::extraBits(), PortCode::hasEncoding(), hasRFPortCode(), PortCode::parent(), rfPortCodes_, and PortCode::unitName().

Referenced by RFPortCode::RFPortCode().

Here is the call graph for this function:

◆ containsPortCode()

bool SocketCodeTable::containsPortCode ( ) const
private

Tells whether the socket code table contains at least one port code.

Returns
True if the table contains at least one port code, otherwise false.

Definition at line 833 of file SocketCodeTable.cc.

833  {
834  if (fuPortCodeCount() != 0 || rfPortCodeCount() != 0 ||
835  iuPortCodeCount() != 0) {
836  return true;
837  } else {
838  return false;
839  }
840 }

References fuPortCodeCount(), iuPortCodeCount(), and rfPortCodeCount().

Referenced by addIUPortCode(), and addRFPortCode().

Here is the call graph for this function:

◆ deleteFUPortCodes()

void SocketCodeTable::deleteFUPortCodes ( )
private

Deletes all the FU port codes from the table.

Definition at line 793 of file SocketCodeTable.cc.

References SequenceTools::deleteAllItems(), and fuPortCodes_.

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

Here is the call graph for this function:

◆ deleteIUPortCodes()

void SocketCodeTable::deleteIUPortCodes ( )
private

Deletes all the IU port codes from the table.

Definition at line 802 of file SocketCodeTable.cc.

References SequenceTools::deleteAllItems(), and iuPortCodes_.

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

Here is the call graph for this function:

◆ deleteRFPortCodes()

void SocketCodeTable::deleteRFPortCodes ( )
private

Deletes all the RF port codes from the table.

Definition at line 784 of file SocketCodeTable.cc.

References SequenceTools::deleteAllItems(), and rfPortCodes_.

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

Here is the call graph for this function:

◆ extraBits()

int SocketCodeTable::extraBits ( ) const

Returns the number of extra bits.

Returns
The number of extra bits.

Definition at line 189 of file SocketCodeTable.cc.

189  {
190  return extraBits_;
191 }

References extraBits_.

Referenced by saveState(), and width().

◆ fuPortCode() [1/3]

FUPortCode & SocketCodeTable::fuPortCode ( const std::string &  fu,
const std::string &  port 
) const

Returns the code for the given port of the given function unit.

Returns a NullFUPortCode instance if the requested code is not found.

Parameters
fuName of the function unit.
portName of the port.
Returns
The control code for the requested port.

Definition at line 365 of file SocketCodeTable.cc.

367  {
368 
369  int codes = fuPortCodeCount();
370  for (int i = 0; i < codes; i++) {
371  FUPortCode& code = fuPortCode(i);
372  if (code.unitName() == fu && code.portName() == port &&
373  !code.hasOperation()) {
374  return code;
375  }
376  }
377 
378  return NullFUPortCode::instance();
379 }

References fuPortCode(), fuPortCodeCount(), FUPortCode::hasOperation(), NullFUPortCode::instance(), FUPortCode::portName(), and PortCode::unitName().

Here is the call graph for this function:

◆ fuPortCode() [2/3]

FUPortCode & SocketCodeTable::fuPortCode ( const std::string &  fu,
const std::string &  port,
const std::string &  operation 
) const

Returns the code that identifies the given operation and the port that carries it.

Returns a NullFUPortCode instance if the requested code is not found.

Parameters
fuName of the function unit.
portName of the port.
operationName of the operation.
Returns
The control code for the requested port.

Definition at line 394 of file SocketCodeTable.cc.

397  {
398 
399  int codes = fuPortCodeCount();
400  for (int i = 0; i < codes; i++) {
401  FUPortCode& code = fuPortCode(i);
402  if (code.unitName() == fu && code.portName() == port &&
403  code.hasOperation() &&
404  StringTools::ciEqual(code.operationName(), operation)) {
405  return code;
406  }
407  }
408 
409  return NullFUPortCode::instance();
410 }

References StringTools::ciEqual(), fuPortCode(), fuPortCodeCount(), FUPortCode::hasOperation(), NullFUPortCode::instance(), FUPortCode::operationName(), FUPortCode::portName(), and PortCode::unitName().

Here is the call graph for this function:

◆ fuPortCode() [3/3]

FUPortCode & SocketCodeTable::fuPortCode ( int  index) const

Returns the FU port code stored at the given position in the table.

Parameters
indexThe position.
Exceptions
OutOfRangeIf the index is negative or not smaller than the number of FU port codes in the table.

Definition at line 308 of file SocketCodeTable.cc.

308  {
309  if (index < 0 || index >= fuPortCodeCount()) {
310  const string procName = "SocketCodeTable::fuPortCode";
311  throw OutOfRange(__FILE__, __LINE__, procName);
312  }
313 
314  return *fuPortCodes_[index];
315 }

References fuPortCodeCount(), and fuPortCodes_.

Referenced by BEMTester::canAddPortEncoding(), CodeCompressorPlugin::encodeFUTerminal(), fuPortCode(), hasFUPortCode(), maxCodeWidth(), portCode(), printSlotFieldEncodings(), saveState(), DefaultDecoderGenerator::writeControlRulesOfFUInputPort(), and DefaultDecoderGenerator::writeControlRulesOfFUOutputPort().

Here is the call graph for this function:

◆ fuPortCodeCount()

int SocketCodeTable::fuPortCodeCount ( ) const

Returns the number of FU port codes in this table.

Returns
The number of FU port codes.

Definition at line 295 of file SocketCodeTable.cc.

295  {
296  return fuPortCodes_.size();
297 }

References fuPortCodes_.

Referenced by BEMTester::canAddPortEncoding(), containsPortCode(), fuPortCode(), maxCodeWidth(), portCode(), portCodeCount(), printSlotFieldEncodings(), and saveState().

◆ hasFUPortCode() [1/2]

bool SocketCodeTable::hasFUPortCode ( const std::string &  fu,
const std::string &  port 
) const

Tells whether the table has a control code for the port of the function unit.

Parameters
fuName of the function unit.
portName of the port.
Returns
True if the table has the control code, otherwise false.

Definition at line 326 of file SocketCodeTable.cc.

328  {
329 
330  FUPortCode& code = fuPortCode(fu, port);
331  return &code != &NullFUPortCode::instance();
332 }

References fuPortCode(), and NullFUPortCode::instance().

Referenced by addFUPortCode(), BEMValidator::checkSocketCodeTable(), and CodeCompressorPlugin::encodeFUTerminal().

Here is the call graph for this function:

◆ hasFUPortCode() [2/2]

bool SocketCodeTable::hasFUPortCode ( const std::string &  fu,
const std::string &  port,
const std::string &  operation 
) const

Tells whether the table has a control code that identifies the given operation and the port that carries it.

Parameters
fuName of the function unit.
portName of the port.
operationName of the operation.
Returns
True if the table has the control code, otherwise false.

Definition at line 345 of file SocketCodeTable.cc.

348  {
349 
350  FUPortCode& code = fuPortCode(fu, port, operation);
351  return &code != &NullFUPortCode::instance();
352 }

References fuPortCode(), and NullFUPortCode::instance().

Here is the call graph for this function:

◆ hasIUPortCode()

bool SocketCodeTable::hasIUPortCode ( const std::string &  immediateUnit) const

Tells whether the socket code table contains a control code for the given immediate unit.

Parameters
immediateUnitName of the immediate unit.
Returns
True If the socket code table contains the control code, otherwise false.

Definition at line 618 of file SocketCodeTable.cc.

618  {
619  return &iuPortCode(immediateUnit) != &NullIUPortCode::instance();
620 }

References NullIUPortCode::instance(), and iuPortCode().

Referenced by addIUPortCode(), BEMValidator::checkSocketCodeTable(), and CodeCompressorPlugin::encodeIUTerminal().

Here is the call graph for this function:

◆ hasParentSCTable()

bool SocketCodeTable::hasParentSCTable ( const std::string &  name) const
private

Tells whether the parent binary encoding table has a socket code table with the given name.

Parameters
nameThe name.
Returns
True if the parent has a socket code table with the given name, otherwise false.

Definition at line 768 of file SocketCodeTable.cc.

768  {
769  BinaryEncoding* parent = this->parent();
770  for (int i = 0; i < parent->socketCodeTableCount(); i++) {
772  if (table.name() == name) {
773  return true;
774  }
775  }
776  return false;
777 }

References name(), parent(), BinaryEncoding::socketCodeTable(), and BinaryEncoding::socketCodeTableCount().

Referenced by setName().

Here is the call graph for this function:

◆ hasRFOrIUPortCodeWithoutEncoding()

bool SocketCodeTable::hasRFOrIUPortCodeWithoutEncoding ( ) const
private

Tells whether the socket code table contains a RF or IU port code without port encoding.

Returns
True If the socket code table contains a RF or IU port code without port encoding, otherwise false.

Definition at line 815 of file SocketCodeTable.cc.

815  {
816  if (rfPortCodeCount() == 1 && !rfPortCode(0).hasEncoding()) {
817  return true;
818  }
819  if (iuPortCodeCount() == 1 && !iuPortCode(0).hasEncoding()) {
820  return true;
821  }
822  return false;
823 }

References iuPortCode(), iuPortCodeCount(), rfPortCode(), and rfPortCodeCount().

Referenced by addFUPortCode().

Here is the call graph for this function:

◆ hasRFPortCode()

bool SocketCodeTable::hasRFPortCode ( const std::string &  regFile) const

Tells whether the socket code table contains a control code for the given register file.

Parameters
regFileName of the register file.
Returns
True If the socket code table contains the control code, otherwise false.

Definition at line 502 of file SocketCodeTable.cc.

502  {
503  return &rfPortCode(regFile) != &NullRFPortCode::instance();
504 }

References NullRFPortCode::instance(), and rfPortCode().

Referenced by addRFPortCode(), BEMValidator::checkSocketCodeTable(), and CodeCompressorPlugin::encodeRFTerminal().

Here is the call graph for this function:

◆ iuPortCode() [1/2]

IUPortCode & SocketCodeTable::iuPortCode ( const std::string &  immediateUnit) const

Returns the code for the given immediate unit.

Returns a NullIUPortCode instance if there is no code for the given register file in the table.

Parameters
immediateUnitName of the immediate unit.

Definition at line 632 of file SocketCodeTable.cc.

632  {
633  int codes = iuPortCodeCount();
634  for (int i = 0; i < codes; i++) {
635  IUPortCode& code = iuPortCode(i);
636  if (code.unitName() == immediateUnit) {
637  return code;
638  }
639  }
640 
641  return NullIUPortCode::instance();
642 }

References NullIUPortCode::instance(), iuPortCode(), iuPortCodeCount(), and PortCode::unitName().

Here is the call graph for this function:

◆ iuPortCode() [2/2]

IUPortCode & SocketCodeTable::iuPortCode ( int  index) const

Returns the IU code stored at the given position.

Parameters
indexThe position.
Exceptions
OutOfRangeIf the index is negative or not smaller than the number of IU codes in this table.

Definition at line 600 of file SocketCodeTable.cc.

600  {
601  if (index < 0 || index >= iuPortCodeCount()) {
602  const string procName = "SocketCodeTable::iuPortCode";
603  throw OutOfRange(__FILE__, __LINE__, procName);
604  }
605 
606  return *iuPortCodes_[index];
607 }

References iuPortCodeCount(), and iuPortCodes_.

Referenced by BEMTester::canAddPortEncoding(), CodeCompressorPlugin::encodeIUTerminal(), hasIUPortCode(), hasRFOrIUPortCodeWithoutEncoding(), iuPortCode(), maxCodeWidth(), portCode(), printSlotFieldEncodings(), saveState(), and DefaultDecoderGenerator::writeControlRulesOfRFReadPort().

Here is the call graph for this function:

◆ iuPortCodeCount()

int SocketCodeTable::iuPortCodeCount ( ) const

Returns the number of immediate unit sources or destinations encoded in this table.

Returns
The number of immediate unit sources or destinations.

Definition at line 587 of file SocketCodeTable.cc.

587  {
588  return iuPortCodes_.size();
589 }

References iuPortCodes_.

Referenced by BEMTester::canAddPortEncoding(), containsPortCode(), hasRFOrIUPortCodeWithoutEncoding(), iuPortCode(), maxCodeWidth(), portCodeCount(), printSlotFieldEncodings(), and saveState().

◆ loadState()

void SocketCodeTable::loadState ( const ObjectState state)
virtual

Loads the state of the socket code table from the given ObjectState instance.

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

Implements Serializable.

Definition at line 685 of file SocketCodeTable.cc.

685  {
689 
690  try {
693 
694  for (int i = 0; i < state->childCount(); i++) {
695  ObjectState* child = state->child(i);
696  if (child->name() == FUPortCode::OSNAME_FU_PORT_CODE) {
697  new FUPortCode(child, *this);
698  } else if (child->name() == RFPortCode::OSNAME_RF_PORT_CODE) {
699  new RFPortCode(child, *this);
700  } else if (child->name() == IUPortCode::OSNAME_IU_PORT_CODE) {
701  new IUPortCode(child, *this);
702  }
703  }
704  } catch (const Exception& exception) {
705  const string procName = "SocketCodeTable::loadState";
706  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
707  }
708 }

References ObjectState::child(), ObjectState::childCount(), deleteFUPortCodes(), deleteIUPortCodes(), deleteRFPortCodes(), ObjectState::intAttribute(), ObjectState::name(), OSKEY_EXTRA_BITS, OSKEY_NAME, FUPortCode::OSNAME_FU_PORT_CODE, IUPortCode::OSNAME_IU_PORT_CODE, RFPortCode::OSNAME_RF_PORT_CODE, setExtraBits(), setName(), and ObjectState::stringAttribute().

Referenced by SocketCodeTable().

Here is the call graph for this function:

◆ maxCodeWidth()

int SocketCodeTable::maxCodeWidth ( ) const

Returns the bit width of the longest control code.

This does not account the extra bits of the socket table.

Returns
The bit width.

Definition at line 212 of file SocketCodeTable.cc.

212  {
213  int width(0);
214 
215  for (int i = 0; i < fuPortCodeCount(); i++) {
216  FUPortCode& code = fuPortCode(i);
217  if (width < code.width()) {
218  width = code.width();
219  }
220  }
221 
222  for (int i = 0; i < rfPortCodeCount(); i++) {
223  RFPortCode& code = rfPortCode(i);
224  if (width < code.width()) {
225  width = code.width();
226  }
227  }
228 
229  for (int i = 0; i < iuPortCodeCount(); i++) {
230  IUPortCode& code = iuPortCode(i);
231  if (width < code.width()) {
232  width = code.width();
233  }
234  }
235  return width;
236 }

References fuPortCode(), fuPortCodeCount(), iuPortCode(), iuPortCodeCount(), rfPortCode(), rfPortCodeCount(), PortCode::width(), and width().

Referenced by width().

Here is the call graph for this function:

◆ name()

std::string SocketCodeTable::name ( ) const

Returns the name of the socket code table.

Returns
The name.

Definition at line 137 of file SocketCodeTable.cc.

137  {
138  return name_;
139 }

References name_.

Referenced by BinaryEncoding::addSocketCodeTable(), hasParentSCTable(), BinaryEncoding::hasSocketCodeTable(), saveState(), setName(), and BinaryEncoding::socketCodeTable().

◆ parent()

BinaryEncoding * SocketCodeTable::parent ( ) const

Returns the parent binary encoding map.

Returns
The parent binary encoding map.

Definition at line 126 of file SocketCodeTable.cc.

126  {
127  return parent_;
128 }

References parent_.

Referenced by BinaryEncoding::addSocketCodeTable(), hasParentSCTable(), BinaryEncoding::removeSocketCodeTable(), SocketCodeTable(), and ~SocketCodeTable().

◆ portCode()

PortCode & SocketCodeTable::portCode ( int  index) const

Returns the port code stored at the given position.

The possible kinds of port codes are FUPortCode, RFPortCode and IUPortCode.

Parameters
indexThe position.
Exceptions
OutOfRangeIf the index is negative or not smaller than the number of portCodeCount().

Definition at line 662 of file SocketCodeTable.cc.

662  {
663  if (index < 0 || index >= portCodeCount()) {
664  THROW_EXCEPTION(OutOfRange, "The given index is out of bounds. ");
665  }
666 
667  if (index < fuPortCodeCount()) {
668  return fuPortCode(index);
669  } else if (index < fuPortCodeCount() + rfPortCodeCount()) {
670  return rfPortCode(index - fuPortCodeCount());
671  } else {
672  return iuPortCode(index - fuPortCodeCount() - rfPortCodeCount());
673  }
674 }

References fuPortCode(), fuPortCodeCount(), iuPortCode(), portCodeCount(), rfPortCode(), rfPortCodeCount(), and THROW_EXCEPTION.

Referenced by BEMTester::conflictsWithSocketTableEncodings().

Here is the call graph for this function:

◆ portCodeCount()

int SocketCodeTable::portCodeCount ( ) const

Returns count of all types of port codes defined in the socket table.

Definition at line 648 of file SocketCodeTable.cc.

648  {
650 }

References fuPortCodeCount(), iuPortCodeCount(), and rfPortCodeCount().

Referenced by BEMTester::conflictsWithSocketTableEncodings(), and portCode().

Here is the call graph for this function:

◆ removeFUPortCode()

void SocketCodeTable::removeFUPortCode ( FUPortCode code)

Removes the given FU port code from the socket code table.

This method is to be called from the destructor of FUPortCode class.

Parameters
codeThe code to be removed.

Definition at line 283 of file SocketCodeTable.cc.

283  {
284  assert(code.parent() == NULL);
286 }

References assert, fuPortCodes_, PortCode::parent(), and ContainerTools::removeValueIfExists().

Referenced by FUPortCode::~FUPortCode().

Here is the call graph for this function:

◆ removeIUPortCode()

void SocketCodeTable::removeIUPortCode ( IUPortCode code)

Removes the given IU port code.

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

Parameters
codeThe code to be removed.

Definition at line 574 of file SocketCodeTable.cc.

574  {
575  assert(code.parent() == NULL);
577 }

References assert, iuPortCodes_, PortCode::parent(), and ContainerTools::removeValueIfExists().

Referenced by IUPortCode::~IUPortCode().

Here is the call graph for this function:

◆ removeReferences()

void SocketCodeTable::removeReferences ( SlotField field) const
private

Removes all the references to this socket code table from the socket encodings of the given slot field.

Definition at line 749 of file SocketCodeTable.cc.

749  {
750  for (int i = 0; i < field.socketEncodingCount(); i++) {
751  SocketEncoding& encoding = field.socketEncoding(i);
752  if (&encoding.socketCodes() == this) {
753  encoding.unsetSocketCodes();
754  }
755  }
756 }

References SocketEncoding::socketCodes(), SlotField::socketEncoding(), SlotField::socketEncodingCount(), and SocketEncoding::unsetSocketCodes().

Referenced by ~SocketCodeTable().

Here is the call graph for this function:

◆ removeRFPortCode()

void SocketCodeTable::removeRFPortCode ( RFPortCode code)

Removes the given RF port code.

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

Parameters
codeThe code to be removed.

Definition at line 458 of file SocketCodeTable.cc.

458  {
459  assert(code.parent() == NULL);
461 }

References assert, PortCode::parent(), ContainerTools::removeValueIfExists(), and rfPortCodes_.

Referenced by RFPortCode::~RFPortCode().

Here is the call graph for this function:

◆ rfPortCode() [1/2]

RFPortCode & SocketCodeTable::rfPortCode ( const std::string &  regFile) const

Returns the code for the given register file.

Returns a NullRFPortCode instance if there is no code for the given register file in the table.

Parameters
regFileName of the register file.

Definition at line 516 of file SocketCodeTable.cc.

516  {
517  int codes = rfPortCodeCount();
518  for (int i = 0; i < codes; i++) {
519  RFPortCode& code = rfPortCode(i);
520  if (code.unitName() == regFile) {
521  return code;
522  }
523  }
524 
525  return NullRFPortCode::instance();
526 }

References NullRFPortCode::instance(), rfPortCode(), rfPortCodeCount(), and PortCode::unitName().

Here is the call graph for this function:

◆ rfPortCode() [2/2]

RFPortCode & SocketCodeTable::rfPortCode ( int  index) const

Returns the RF code stored at the given position.

Parameters
indexThe position.
Exceptions
OutOfRangeIf the index is negative or not smaller than the number of RF codes in this table.

Definition at line 484 of file SocketCodeTable.cc.

484  {
485  if (index < 0 || index >= rfPortCodeCount()) {
486  const string procName = "SocketCodeTable::rfPortCode";
487  throw OutOfRange(__FILE__, __LINE__, procName);
488  }
489 
490  return *rfPortCodes_[index];
491 }

References rfPortCodeCount(), and rfPortCodes_.

Referenced by BEMTester::canAddPortEncoding(), CodeCompressorPlugin::encodeRFTerminal(), hasRFOrIUPortCodeWithoutEncoding(), hasRFPortCode(), maxCodeWidth(), portCode(), printSlotFieldEncodings(), rfPortCode(), saveState(), DefaultDecoderGenerator::writeControlRulesOfRFReadPort(), and DefaultDecoderGenerator::writeControlRulesOfRFWritePort().

Here is the call graph for this function:

◆ rfPortCodeCount()

int SocketCodeTable::rfPortCodeCount ( ) const

Returns the number of register file sources or destinations encoded in this table.

Returns
The number of register file sources or destinations.

Definition at line 471 of file SocketCodeTable.cc.

471  {
472  return rfPortCodes_.size();
473 }

References rfPortCodes_.

Referenced by BEMTester::canAddPortEncoding(), containsPortCode(), hasRFOrIUPortCodeWithoutEncoding(), maxCodeWidth(), portCode(), portCodeCount(), printSlotFieldEncodings(), rfPortCode(), and saveState().

◆ saveState()

ObjectState * SocketCodeTable::saveState ( ) const
virtual

Saves the state of the socket code table to an ObjectState tree.

Returns
The newly created ObjectState tree.

Implements Serializable.

Definition at line 716 of file SocketCodeTable.cc.

716  {
717 
719  state->setAttribute(OSKEY_NAME, name());
721 
722  // add FU port codes
723  for (int i = 0; i < fuPortCodeCount(); i++) {
724  FUPortCode& code = fuPortCode(i);
725  state->addChild(code.saveState());
726  }
727 
728  // add RF port codes
729  for (int i = 0; i < rfPortCodeCount(); i++) {
730  RFPortCode& code = rfPortCode(i);
731  state->addChild(code.saveState());
732  }
733 
734  // add IU port codes
735  for (int i = 0; i < iuPortCodeCount(); i++) {
736  IUPortCode& code = iuPortCode(i);
737  state->addChild(code.saveState());
738  }
739 
740  return state;
741 }

References ObjectState::addChild(), extraBits(), fuPortCode(), fuPortCodeCount(), iuPortCode(), iuPortCodeCount(), name(), OSKEY_EXTRA_BITS, OSKEY_NAME, OSNAME_SOCKET_CODE_TABLE, rfPortCode(), rfPortCodeCount(), IUPortCode::saveState(), RFPortCode::saveState(), FUPortCode::saveState(), and ObjectState::setAttribute().

Referenced by BinaryEncoding::saveState().

Here is the call graph for this function:

◆ setExtraBits()

void SocketCodeTable::setExtraBits ( int  bits)

Sets the number of extra zero bits for the table.

The bit width of the table can be forced longer than necessary by defining some number of extra zero bits that always exists in the right end of the table field.

Parameters
bitsThe number of extra zero bits.
Exceptions
OutOfRangeIf the given number is negative.

Definition at line 174 of file SocketCodeTable.cc.

174  {
175  if (bits < 0) {
176  const string procName = "SocketCodeTable::setExtraBits";
177  throw OutOfRange(__FILE__, __LINE__, procName);
178  }
179 
180  extraBits_ = bits;
181 }

References extraBits_.

Referenced by loadState().

◆ setName()

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

Sets new name for the socket code table.

Parameters
nameThe new name.
Exceptions
ObjectAlreadyExistsIf the parent binary encoding map already has a socket code table with the same name.

Definition at line 150 of file SocketCodeTable.cc.

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

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

Referenced by loadState().

Here is the call graph for this function:

◆ width()

int SocketCodeTable::width ( ) const

Member Data Documentation

◆ extraBits_

int SocketCodeTable::extraBits_
private

The number of extra bits.

Definition at line 154 of file SocketCodeTable.hh.

Referenced by extraBits(), and setExtraBits().

◆ fuPortCodes_

FUPortCodeTable SocketCodeTable::fuPortCodes_
private

FU port codes.

Definition at line 148 of file SocketCodeTable.hh.

Referenced by addFUPortCode(), deleteFUPortCodes(), fuPortCode(), fuPortCodeCount(), and removeFUPortCode().

◆ iuPortCodes_

IUPortCodeTable SocketCodeTable::iuPortCodes_
private

IU port codes.

Definition at line 152 of file SocketCodeTable.hh.

Referenced by addIUPortCode(), deleteIUPortCodes(), iuPortCode(), iuPortCodeCount(), and removeIUPortCode().

◆ name_

std::string SocketCodeTable::name_
private

Name of the table.

Definition at line 146 of file SocketCodeTable.hh.

Referenced by name(), and setName().

◆ OSKEY_EXTRA_BITS

const std::string SocketCodeTable::OSKEY_EXTRA_BITS = "extra_bits"
static

ObjectState attribute key for the number of extra bits.

Definition at line 125 of file SocketCodeTable.hh.

Referenced by loadState(), saveState(), BEMSerializer::socketCodeTableToFile(), and BEMSerializer::socketCodeTableToOM().

◆ OSKEY_NAME

const std::string SocketCodeTable::OSKEY_NAME = "name"
static

ObjectState attribute key for name of the table.

Definition at line 123 of file SocketCodeTable.hh.

Referenced by loadState(), saveState(), BEMSerializer::socketCodeTableToFile(), and BEMSerializer::socketCodeTableToOM().

◆ OSNAME_SOCKET_CODE_TABLE

const std::string SocketCodeTable::OSNAME_SOCKET_CODE_TABLE = "sc_table"
static

◆ parent_

BinaryEncoding* SocketCodeTable::parent_
private

The parent binary encoding map.

Definition at line 144 of file SocketCodeTable.hh.

Referenced by parent(), SocketCodeTable(), and ~SocketCodeTable().

◆ rfPortCodes_

RFPortCodeTable SocketCodeTable::rfPortCodes_
private

RF port codes.

Definition at line 150 of file SocketCodeTable.hh.

Referenced by addRFPortCode(), deleteRFPortCodes(), removeRFPortCode(), rfPortCode(), and rfPortCodeCount().


The documentation for this class was generated from the following files:
SocketCodeTable::removeReferences
void removeReferences(SlotField &field) const
Definition: SocketCodeTable.cc:749
BinaryEncoding
Definition: BinaryEncoding.hh:61
FUPortCode::operationName
std::string operationName() const
Definition: FUPortCode.cc:160
ObjectState::stringAttribute
std::string stringAttribute(const std::string &name) const
Definition: ObjectState.cc:249
SocketCodeTable::rfPortCodeCount
int rfPortCodeCount() const
Definition: SocketCodeTable.cc:471
MoveSlot
Definition: MoveSlot.hh:60
SocketCodeTable::rfPortCodes_
RFPortCodeTable rfPortCodes_
RF port codes.
Definition: SocketCodeTable.hh:150
ObjectStateLoadingException
Definition: Exception.hh:551
NullIUPortCode::instance
static NullIUPortCode & instance()
Definition: NullIUPortCode.cc:62
SocketCodeTable::fuPortCode
FUPortCode & fuPortCode(int index) const
Definition: SocketCodeTable.cc:308
SocketCodeTable::containsPortCode
bool containsPortCode() const
Definition: SocketCodeTable.cc:833
OutOfRange
Definition: Exception.hh:320
SocketCodeTable::hasRFPortCode
bool hasRFPortCode(const std::string &regFile) const
Definition: SocketCodeTable.cc:502
IUPortCode
Definition: IUPortCode.hh:41
SocketCodeTable::setExtraBits
void setExtraBits(int bits)
Definition: SocketCodeTable.cc:174
BinaryEncoding::socketCodeTableCount
int socketCodeTableCount() const
Definition: BinaryEncoding.cc:569
ObjectState
Definition: ObjectState.hh:59
SocketCodeTable::rfPortCode
RFPortCode & rfPortCode(int index) const
Definition: SocketCodeTable.cc:484
RFPortCode
Definition: RFPortCode.hh:44
FUPortCode
Definition: FUPortCode.hh:47
SocketCodeTable::fuPortCodeCount
int fuPortCodeCount() const
Definition: SocketCodeTable.cc:295
SocketCodeTable::fuPortCodes_
FUPortCodeTable fuPortCodes_
FU port codes.
Definition: SocketCodeTable.hh:148
RFPortCode::OSNAME_RF_PORT_CODE
static const std::string OSNAME_RF_PORT_CODE
ObjectState name for RF port code.
Definition: RFPortCode.hh:57
FUPortCode::OSNAME_FU_PORT_CODE
static const std::string OSNAME_FU_PORT_CODE
ObjectState name for FU port code.
Definition: FUPortCode.hh:66
SlotField::socketEncoding
SocketEncoding & socketEncoding(int index) const
Definition: SlotField.cc:170
BinaryEncoding::socketCodeTable
SocketCodeTable & socketCodeTable(int index) const
Definition: BinaryEncoding.cc:583
SocketCodeTable::portCodeCount
int portCodeCount() const
Definition: SocketCodeTable.cc:648
SocketCodeTable
Definition: SocketCodeTable.hh:68
PortCode::unitName
std::string unitName() const
Definition: PortCode.cc:140
assert
#define assert(condition)
Definition: Application.hh:86
SocketCodeTable::parent
BinaryEncoding * parent() const
Definition: SocketCodeTable.cc:126
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
PortCode::extraBits
unsigned int extraBits() const
Definition: PortCode.cc:177
SocketCodeTable::loadState
virtual void loadState(const ObjectState *state)
Definition: SocketCodeTable.cc:685
PortCode::width
int width() const
Definition: PortCode.cc:188
THROW_EXCEPTION
#define THROW_EXCEPTION(exceptionType, message)
Exception wrapper macro that automatically includes file name, line number and function name where th...
Definition: Exception.hh:39
ContainerTools::removeValueIfExists
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)
FUPortCode::saveState
virtual ObjectState * saveState() const
Definition: FUPortCode.cc:187
SocketCodeTable::extraBits
int extraBits() const
Definition: SocketCodeTable.cc:189
SocketCodeTable::iuPortCode
IUPortCode & iuPortCode(int index) const
Definition: SocketCodeTable.cc:600
SocketCodeTable::maxCodeWidth
int maxCodeWidth() const
Definition: SocketCodeTable.cc:212
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
ObjectState::addChild
void addChild(ObjectState *child)
Definition: ObjectState.cc:376
SocketCodeTable::hasFUPortCode
bool hasFUPortCode(const std::string &fu, const std::string &port) const
Definition: SocketCodeTable.cc:326
SocketCodeTable::hasRFOrIUPortCodeWithoutEncoding
bool hasRFOrIUPortCodeWithoutEncoding() const
Definition: SocketCodeTable.cc:815
ObjectState::childCount
int childCount() const
StringTools::ciEqual
static bool ciEqual(const std::string &a, const std::string &b)
Definition: StringTools.cc:240
Exception
Definition: Exception.hh:54
NullRFPortCode::instance
static NullRFPortCode & instance()
Definition: NullRFPortCode.cc:62
SocketCodeTable::hasIUPortCode
bool hasIUPortCode(const std::string &immediateUnit) const
Definition: SocketCodeTable.cc:618
BinaryEncoding::removeSocketCodeTable
void removeSocketCodeTable(SocketCodeTable &table)
Definition: BinaryEncoding.cc:645
MoveSlot::sourceField
SourceField & sourceField() const
Definition: MoveSlot.cc:277
ObjectState::name
std::string name() const
SocketCodeTable::OSKEY_NAME
static const std::string OSKEY_NAME
ObjectState attribute key for name of the table.
Definition: SocketCodeTable.hh:123
BEMTester::canAddPortEncoding
static bool canAddPortEncoding(SocketCodeTable &table, unsigned int encoding, unsigned int extraBits)
Definition: BEMTester.cc:247
SocketCodeTable::setName
void setName(const std::string &name)
Definition: SocketCodeTable.cc:150
IUPortCode::saveState
virtual ObjectState * saveState() const
Definition: IUPortCode.cc:136
SocketCodeTable::deleteFUPortCodes
void deleteFUPortCodes()
Definition: SocketCodeTable.cc:793
SocketCodeTable::parent_
BinaryEncoding * parent_
The parent binary encoding map.
Definition: SocketCodeTable.hh:144
SocketCodeTable::iuPortCodeCount
int iuPortCodeCount() const
Definition: SocketCodeTable.cc:587
SocketCodeTable::name_
std::string name_
Name of the table.
Definition: SocketCodeTable.hh:146
IUPortCode::OSNAME_IU_PORT_CODE
static const std::string OSNAME_IU_PORT_CODE
ObjectState name for RF port code.
Definition: IUPortCode.hh:55
ObjectAlreadyExists
Definition: Exception.hh:1002
FUPortCode::hasOperation
bool hasOperation() const
Definition: FUPortCode.cc:176
SlotField
Definition: SlotField.hh:58
SocketCodeTable::iuPortCodes_
IUPortCodeTable iuPortCodes_
IU port codes.
Definition: SocketCodeTable.hh:152
BinaryEncoding::addSocketCodeTable
void addSocketCodeTable(SocketCodeTable &table)
Definition: BinaryEncoding.cc:625
SocketEncoding::unsetSocketCodes
void unsetSocketCodes()
Definition: SocketEncoding.cc:165
SocketCodeTable::OSNAME_SOCKET_CODE_TABLE
static const std::string OSNAME_SOCKET_CODE_TABLE
ObjectState name for socket code table.
Definition: SocketCodeTable.hh:121
SlotField::socketEncodingCount
int socketEncodingCount() const
Definition: SlotField.cc:156
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
RFPortCode::saveState
virtual ObjectState * saveState() const
Definition: RFPortCode.cc:136
BinaryEncoding::moveSlot
MoveSlot & moveSlot(int index) const
Definition: BinaryEncoding.cc:121
PortCode::hasEncoding
bool hasEncoding() const
Definition: PortCode.cc:151
MoveSlot::destinationField
DestinationField & destinationField() const
Definition: MoveSlot.cc:341
PortCode::parent
SocketCodeTable * parent() const
Definition: PortCode.cc:226
SocketCodeTable::hasParentSCTable
bool hasParentSCTable(const std::string &name) const
Definition: SocketCodeTable.cc:768
SocketCodeTable::extraBits_
int extraBits_
The number of extra bits.
Definition: SocketCodeTable.hh:154
BinaryEncoding::moveSlotCount
int moveSlotCount() const
Definition: BinaryEncoding.cc:104
SocketEncoding::socketCodes
SocketCodeTable & socketCodes() const
Definition: SocketEncoding.cc:191
SocketEncoding
Definition: SocketEncoding.hh:51
PortCode::encoding
unsigned int encoding() const
Definition: PortCode.cc:164
NullFUPortCode::instance
static NullFUPortCode & instance()
Definition: NullFUPortCode.cc:62
SocketCodeTable::deleteIUPortCodes
void deleteIUPortCodes()
Definition: SocketCodeTable.cc:802
SocketCodeTable::width
int width() const
Definition: SocketCodeTable.cc:200
SocketCodeTable::deleteRFPortCodes
void deleteRFPortCodes()
Definition: SocketCodeTable.cc:784
SocketCodeTable::name
std::string name() const
Definition: SocketCodeTable.cc:137
SocketCodeTable::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: SocketCodeTable.hh:125
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
FUPortCode::portName
std::string portName() const
Definition: FUPortCode.cc:147