OpenASIP  2.0
Static Public Member Functions | Static Private Member Functions | List of all members
BEMTester Class Reference

#include <BEMTester.hh>

Collaboration diagram for BEMTester:
Collaboration graph

Static Public Member Functions

static bool canAddComponentEncoding (SlotField &field, unsigned int encoding, unsigned int extraBits)
 
static bool canAddComponentPriorityEncoding (MoveSlot &slot, unsigned int encoding, unsigned int extraBits, int offset=0)
 
static bool canAddPortEncoding (SocketCodeTable &table, unsigned int encoding, unsigned int extraBits)
 

Static Private Member Functions

static int commonBitCount (unsigned int enc1, unsigned int extraBits1, unsigned int enc2, unsigned int extraBits2, int alignment)
 
static int calculateAlignment (unsigned int enc1, unsigned int enc2, const SlotField &field)
 
static bool fieldsOverlap (const InstructionField &with, unsigned int toFieldWidth, int toFieldPos)
 
static bool fieldsOverlap (unsigned width1, int pos1, unsigned width2, int pos2)
 
static bool conflictsWithGuardEncoding (const GuardField &field, unsigned int encoding, unsigned int width, int offset)
 
static bool conflictsWithSourceEncodings (const SourceField &field, unsigned int encoding, unsigned int width, int offset)
 
static bool conflictsWithDestinationEncodings (const DestinationField &field, unsigned int encoding, unsigned int width, int offset)
 
static bool conflictsWithSocketTableEncodings (const SocketCodeTable &scTable, unsigned int encoding, unsigned int width, int offset)
 
static std::tuple< unsigned, unsigned, int > splitEncoding (unsigned encoding, unsigned encodingWidth, unsigned targetWidth, int offsetToTarget)
 
static std::tuple< unsigned, unsigned, int > splitEncodingTo (const SocketEncoding &socketEncoding, unsigned encoding, unsigned encodingWidth, int offsetToTarget)
 

Detailed Description

BEMTester is a helper class which provides useful validity checking methods for the BEM module itself and for other clients.

Definition at line 53 of file BEMTester.hh.

Member Function Documentation

◆ calculateAlignment()

int BEMTester::calculateAlignment ( unsigned int  enc1Width,
unsigned int  enc2Width,
const SlotField field 
)
staticprivate

Calculates the alignment of encodings that has the given widths when they are added to the given slot field.

Parameters
enc1WidthWidth of the first encoding.
enc2WidthWidth of the second encoding.
fieldThe slot field.
Returns
The alignment.

Definition at line 352 of file BEMTester.cc.

355  {
356 
358  return 0;
359  } else {
360  return enc2Width - enc1Width;
361  }
362 }

References SlotField::componentIDPosition(), and BinaryEncoding::RIGHT.

Referenced by canAddComponentEncoding().

Here is the call graph for this function:

◆ canAddComponentEncoding()

bool BEMTester::canAddComponentEncoding ( SlotField field,
unsigned int  encoding,
unsigned int  extraBits 
)
static

Tests whether the given encoding can be added to the given slot field.

The encoding can not be added to the slot field if some other socket encoding, bridge encoding, immediate encoding or NOP encoding has exactly the same bits in same positions. For example, if socket (and bridge) ID's are in the left end of the slot field, the encodings '1001' and '10' would conflict, since in both cases the two leftmost bits in the field are '10'.

Parameters
fieldThe slot field.
encodingThe encoding.
extraBitsThe number of extra bits in the encoding.
Returns
True if the encoding can be added to the slot field, otherwise false.

Definition at line 73 of file BEMTester.cc.

76  {
77 
78  unsigned int encodingWidth = MathTools::bitLength(encoding) +
79  extraBits;
80 
81  int socketEncodings = field.socketEncodingCount();
82  for (int i = 0; i < socketEncodings; i++) {
83  SocketEncoding& existingEnc = field.socketEncoding(i);
84  int alignment = calculateAlignment(
85  encodingWidth, existingEnc.socketIDWidth(), field);
86  int commonBits = commonBitCount(
87  encoding, extraBits, existingEnc.encoding(),
88  existingEnc.extraBits(), alignment);
89  if (commonBits == static_cast<int>(MathTools::bitLength(encoding))
90  + static_cast<int>(extraBits) ||
91  commonBits == existingEnc.socketIDWidth()) {
92  return false;
93  }
94  }
95 
96  SourceField* sField = dynamic_cast<SourceField*>(&field);
97  if (sField != NULL) {
98  int bridgeEncodings = sField->bridgeEncodingCount();
99  for (int i = 0; i < bridgeEncodings; i++) {
100  BridgeEncoding& existingEnc = sField->bridgeEncoding(i);
101  int alignment = calculateAlignment(
102  encodingWidth, existingEnc.width(), field);
103  int commonBits = commonBitCount(
104  encoding, extraBits, existingEnc.encoding(),
105  existingEnc.extraBits(), alignment);
106  if (commonBits == static_cast<int>(
107  MathTools::bitLength(encoding)) +
108  static_cast<int>(extraBits) ||
109  commonBits == existingEnc.width()) {
110  return false;
111  }
112  }
113 
114  if (sField->hasImmediateEncoding()) {
115  ImmediateEncoding& immEnc = sField->immediateEncoding();
116  int alignment = calculateAlignment(
117  encodingWidth, immEnc.width(), field);
118  int commonBits = commonBitCount(
119  encoding, extraBits, immEnc.encoding(), immEnc.extraBits(),
120  alignment);
121  if (commonBits ==
122  static_cast<int>(MathTools::bitLength(encoding)) +
123  static_cast<int>(extraBits) ||
124  commonBits == immEnc.width()) {
125  return false;
126  }
127  }
128 
129  if (sField->hasNoOperationEncoding()) {
130  NOPEncoding& nopEnc = sField->noOperationEncoding();
131  int alignment = calculateAlignment(
132  encodingWidth, nopEnc.width(), field);
133  int commonBits = commonBitCount(
134  encoding, extraBits, nopEnc.encoding(), nopEnc.extraBits(),
135  alignment);
136  if (commonBits == static_cast<int>(
137  MathTools::bitLength(encoding)) +
138  static_cast<int>(extraBits) ||
139  commonBits == nopEnc.width()) {
140  return false;
141  }
142  }
143 
144  }
145  return true;
146 }

References MathTools::bitLength(), SourceField::bridgeEncoding(), SourceField::bridgeEncodingCount(), calculateAlignment(), commonBitCount(), Encoding::encoding(), Encoding::extraBits(), SourceField::hasImmediateEncoding(), SlotField::hasNoOperationEncoding(), SourceField::immediateEncoding(), SlotField::noOperationEncoding(), SlotField::socketEncoding(), SlotField::socketEncodingCount(), SocketEncoding::socketIDWidth(), Encoding::width(), and ImmediateEncoding::width().

Referenced by SourceField::addBridgeEncoding(), SlotField::addSocketEncoding(), SourceField::setImmediateEncoding(), and SlotField::setNoOperationEncoding().

Here is the call graph for this function:

◆ canAddComponentPriorityEncoding()

bool BEMTester::canAddComponentPriorityEncoding ( MoveSlot slot,
unsigned int  encoding,
unsigned int  extraBits,
int  offset = 0 
)
static

Tests whether the given priority encoding can be added to the given move slot field.

The encoding can be added to the slot if it distinguishable from the other encodings in the slot. The encoding is distinguishable if there is no guard, source and destination field encoding combination that could be misunderstood as the given encoding.

The tested encoding is treated as it has higher priority in decoding. That is, is the given encoding is present in the move slot, then any other encoding bits (non-overlapping with the given encoding) in the slot does not have effect.

The tested encoding can cross boundaries of guard, source and destination fields, overlapping multiple fields. A par of the encoding (i.e. overlapping some slot field) may be indistinguishable as long as some other parts are distinguishable.

Parameters
slotThe slot where the encoding could be added.
encodingThe encoding value. Avoid using zero value since its bit width is zero too. Instead, use one extrabit denote zero value.
extraBitsThe extra bits (zeroes) of the the encoding at the left side.
offsetThe position of the encoding from LSB position of the slot. Zero means that the given encoding is right aligned in the slot.
Returns
True if the encoding is distinguishable from the other encodings and, therefore, can be added to the slot.

Definition at line 180 of file BEMTester.cc.

182  {
183  bool canAdd = false;
184  int encWidth = BEMTools::encodingWidth(encoding, extraBits);
185  unsigned truncatedEnc;
186  unsigned truncatedWidth;
187  int offsetInField;
188 
189  if (encWidth + offset > slot.width()) {
190  // The move NOP encoding can be always added if (part of the) it is
191  // located out side of the move slot fields.
192  // note: this assumes that the move slot does not have other kinds of
193  // move encodings.
194  return true;
195  }
196 
197  if (fieldsOverlap(slot.guardField(), encWidth, offset)) {
198  std::tie(truncatedEnc, truncatedWidth, offsetInField) = splitEncoding(
199  encoding, encWidth, slot.guardField().width(),
200  offset - slot.guardField().bitPosition());
201 
202  canAdd = canAdd || !conflictsWithGuardEncoding(
203  slot.guardField(), truncatedEnc,
204  truncatedWidth, offsetInField);
205  }
206 
207  if (fieldsOverlap(slot.sourceField(), encWidth, offset)) {
208  const SourceField& field = slot.sourceField();
209  std::tie(truncatedEnc, truncatedWidth, offsetInField) = splitEncoding(
210  encoding, encWidth, field.width(), offset - field.bitPosition());
211 
212  canAdd =
213  canAdd || !conflictsWithSourceEncodings(
214  field, truncatedEnc, truncatedWidth, offsetInField);
215  }
216 
217  if (fieldsOverlap(slot.destinationField(), encWidth, offset)) {
218  const DestinationField& field = slot.destinationField();
219  std::tie(truncatedEnc, truncatedWidth, offsetInField) = splitEncoding(
220  encoding, encWidth, field.width(), offset - field.bitPosition());
221 
222  canAdd =
224  field, truncatedEnc, truncatedWidth, offsetInField);
225  }
226 
227  return canAdd;
228 }

References InstructionField::bitPosition(), conflictsWithDestinationEncodings(), conflictsWithGuardEncoding(), conflictsWithSourceEncodings(), MoveSlot::destinationField(), BEMTools::encodingWidth(), fieldsOverlap(), MoveSlot::guardField(), MoveSlot::sourceField(), splitEncoding(), SourceField::width(), SlotField::width(), MoveSlot::width(), and GuardField::width().

Here is the call graph for this function:

◆ canAddPortEncoding()

bool BEMTester::canAddPortEncoding ( SocketCodeTable table,
unsigned int  encoding,
unsigned int  extraBits 
)
static

Tells whether the given port encoding can be added to the given socket code table.

The given encoding is be ambiguous with some other FU port encoding or RF port encoding in the socket code table if all the bits of the encoding are the same with the bits of another encoding in the same position of the field. For example, encodings 1011 and 11 are ambiguous if the LSBs of the encodings are in the same position.

Parameters
tableThe socket code table.
encodingThe encoding.
extraBitsThe number of extra bits in the encoding.
Returns
True if the encoding can be added to the socket code table, otherwise false.

Definition at line 247 of file BEMTester.cc.

250  {
251 
252  int encodingWidth = MathTools::bitLength(encoding) + extraBits;
253 
254  int fuPortEncodings = table.fuPortCodeCount();
255  for (int i = 0; i < fuPortEncodings; i++) {
256  FUPortCode& code = table.fuPortCode(i);
257  int commonBits = commonBitCount(
258  encoding, extraBits, code.encoding(), code.extraBits(),
259  code.encodingWidth() - encodingWidth);
260  if (commonBits == encodingWidth ||
261  commonBits == code.encodingWidth()) {
262  return false;
263  }
264  }
265 
266  int rfPortEncodings = table.rfPortCodeCount();
267  for (int i = 0; i < rfPortEncodings; i++) {
268  RFPortCode& code = table.rfPortCode(i);
269  int commonBits = commonBitCount(
270  encoding, extraBits, code.encoding(), code.extraBits(),
271  code.encodingWidth() - encodingWidth);
272  if (commonBits == encodingWidth ||
273  commonBits == code.encodingWidth()) {
274  return false;
275  }
276  }
277 
278  int iuPortEncodings = table.iuPortCodeCount();
279  for (int i = 0; i < iuPortEncodings; i++) {
280  IUPortCode& code = table.iuPortCode(i);
281  int commonBits = commonBitCount(
282  encoding, extraBits, code.encoding(), code.extraBits(),
283  code.encodingWidth() - encodingWidth);
284  if (commonBits == encodingWidth ||
285  commonBits == code.encodingWidth()) {
286  return false;
287  }
288  }
289 
290  return true;
291 }

References MathTools::bitLength(), commonBitCount(), PortCode::encoding(), PortCode::encodingWidth(), PortCode::extraBits(), SocketCodeTable::fuPortCode(), SocketCodeTable::fuPortCodeCount(), SocketCodeTable::iuPortCode(), SocketCodeTable::iuPortCodeCount(), SocketCodeTable::rfPortCode(), and SocketCodeTable::rfPortCodeCount().

Referenced by SocketCodeTable::addFUPortCode(), SocketCodeTable::addIUPortCode(), and SocketCodeTable::addRFPortCode().

Here is the call graph for this function:

◆ commonBitCount()

int BEMTester::commonBitCount ( unsigned int  enc1,
unsigned int  extraBits1,
unsigned int  enc2,
unsigned int  extraBits2,
int  alignment 
)
staticprivate

Tells the number of common bits in the same positions in the given encodings. The LSB bit of the encodings may not be in the same position. That is defined by the alignment parameter.

Parameters
enc1The first encoding.
extraBits1The number of extra zero bits in the first encoding.
enc2The second encoding.
extraBits2The number of extra zero bits in the second encoding.
alignmentThe number of bits the second encoding has in the right side of the first encoding (negative if the LSB bit of the second encoding is on the left side of the LSB bit of the first encoding).

Definition at line 309 of file BEMTester.cc.

314  {
315 
316  int commonBits(0);
317 
318  int enc1Offset = 0;
319  int enc2Offset = 0;
320 
321  if (alignment > 0) {
322  enc2Offset = alignment;
323  } else if (alignment < 0) {
324  enc1Offset = alignment * (-1);
325  }
326 
327  int maxEnc1Offset = MathTools::bitLength(enc1) + extraBits1 - 1;
328  int maxEnc2Offset = MathTools::bitLength(enc2) + extraBits2 - 1;
329 
330  while (enc1Offset <= maxEnc1Offset && enc2Offset <= maxEnc2Offset) {
331  if (MathTools::bit(enc1, enc1Offset) ==
332  MathTools::bit(enc2, enc2Offset)) {
333  commonBits++;
334  }
335  enc1Offset++;
336  enc2Offset++;
337  }
338 
339  return commonBits;
340 }

References MathTools::bit(), and MathTools::bitLength().

Referenced by canAddComponentEncoding(), and canAddPortEncoding().

Here is the call graph for this function:

◆ conflictsWithDestinationEncodings()

bool BEMTester::conflictsWithDestinationEncodings ( const DestinationField field,
unsigned int  encoding,
unsigned int  width,
int  offset 
)
staticprivate

Checks that the given encoding and others in the field can be distinguished from each other.

Parameters
fieldThe destination field.
encodingThe encoding.
widthThe width of the encoding where the encoding value is right aligned.
offsetThe relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa.
Returns
True if the encoding can not be distinguished from another encoding.

Definition at line 560 of file BEMTester.cc.

562  {
563  unsigned truncatedEncoding;
564  unsigned truncatedWidth;
565  unsigned truncatedOffset;
566 
567  for (int i = 0; i < field.socketEncodingCount(); i++) {
568  const SocketEncoding& socketEnc = field.socketEncoding(i);
569  std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
570  splitEncodingTo(socketEnc, encoding, width, offset);
571 
572  bool socketIDOverlap = fieldsOverlap(
573  socketEnc.socketIDWidth(), socketEnc.socketIDPosition(), width,
574  offset);
575  bool socketIDMatch = MathTools::bitFieldsEquals(
576  socketEnc.encoding(), truncatedOffset, truncatedEncoding, 0,
577  truncatedWidth);
578 
579  const SocketCodeTable& scTable = socketEnc.socketCodes();
580  // Get the part that overlaps with port codes.
581  std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
583  encoding, width, scTable.width(),
584  offset - socketEnc.socketCodePosition());
585 
586  bool socketCodeOverlap = truncatedWidth > 0;
587  bool socketCodeMatch = conflictsWithSocketTableEncodings(
588  scTable, truncatedEncoding, truncatedWidth, truncatedOffset);
589 
590  if (socketIDOverlap) {
591  if (socketCodeOverlap && socketIDMatch && socketCodeMatch) {
592  return true;
593  } else if (!socketCodeOverlap && socketIDMatch) {
594  return true;
595  }
596  } else if (socketCodeOverlap && socketCodeMatch) {
597  return true;
598  }
599  }
600 
601  return false;
602 }

References MathTools::bitFieldsEquals(), conflictsWithSocketTableEncodings(), Encoding::encoding(), fieldsOverlap(), SocketEncoding::socketCodePosition(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SlotField::socketEncodingCount(), SocketEncoding::socketIDPosition(), SocketEncoding::socketIDWidth(), splitEncoding(), splitEncodingTo(), and SocketCodeTable::width().

Referenced by canAddComponentPriorityEncoding().

Here is the call graph for this function:

◆ conflictsWithGuardEncoding()

bool BEMTester::conflictsWithGuardEncoding ( const GuardField field,
unsigned int  encoding,
unsigned int  width,
int  offset 
)
staticprivate

Checks that the given encoding and others in the field can be distinguished from each other.

Parameters
fieldThe guard field.
encodingThe encoding.
widthThe width of the encoding where the encoding value is right aligned.
offsetThe relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa.
Returns
True if the encoding can not be distinguished from another encoding.

Definition at line 430 of file BEMTester.cc.

432  {
433  for (int i = 0; i < field.gprGuardEncodingCount(); i++) {
434  const GPRGuardEncoding& grdEnc = field.gprGuardEncoding(i);
435 
437  grdEnc.encoding(), 0, encoding, offset, field.width())) {
438  return true;
439  }
440  }
441 
442  for (int i = 0; i < field.fuGuardEncodingCount(); i++) {
443  const FUGuardEncoding& grdEnc = field.fuGuardEncoding(i);
444 
446  grdEnc.encoding(), 0, encoding, offset, field.width())) {
447  return true;
448  }
449  }
450 
451  if (field.hasUnconditionalGuardEncoding(false)) {
452  const UnconditionalGuardEncoding& grdEnc =
453  field.unconditionalGuardEncoding(false);
454 
456  grdEnc.encoding(), 0, encoding, offset, field.width())) {
457  return true;
458  }
459  }
460 
461  if (field.hasUnconditionalGuardEncoding(true)) {
462  const UnconditionalGuardEncoding& grdEnc =
463  field.unconditionalGuardEncoding(true);
464 
466  grdEnc.encoding(), 0, encoding, offset, field.width())) {
467  return true;
468  }
469  }
470 
471  return false;
472 }

References MathTools::bitFieldsEquals(), GuardEncoding::encoding(), GuardField::fuGuardEncoding(), GuardField::fuGuardEncodingCount(), GuardField::gprGuardEncoding(), GuardField::gprGuardEncodingCount(), GuardField::hasUnconditionalGuardEncoding(), GuardField::unconditionalGuardEncoding(), and GuardField::width().

Referenced by canAddComponentPriorityEncoding().

Here is the call graph for this function:

◆ conflictsWithSocketTableEncodings()

bool BEMTester::conflictsWithSocketTableEncodings ( const SocketCodeTable scTable,
unsigned int  encoding,
unsigned int  width,
int  offset 
)
staticprivate

Checks that the given encoding and others in the socket table can be distinguished from each other.

Parameters
scTableThe socket code table.
encodingThe encoding.
widthThe width of the encoding where the encoding value is right aligned.
offsetThe relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa.
Returns
True if the encoding can not be distinguished from another encoding.

Definition at line 618 of file BEMTester.cc.

620  {
621  // The conflict checking assumes that port code is encoded as:
622  // |<- width ->|
623  // | encoding |<- (offset > 0) ------------------------|
624  // | extrabits | port code encoding | unused bits | index width |
625  // |<- socket code table width ->|
626  // msb lsb: 0
627  // note: port code encoding is left aligned and index bits are right
628  // aligned, leaving unused bits between them if table width
629  // is wider than the port code width.
630 
631  for (int i = 0; i < scTable.portCodeCount(); i++) {
632  const PortCode& portCode = scTable.portCode(i);
633  // Check port code encoding
634  if (portCode.encodingWidth() > 0) {
635  // note: extrabits of SocketCodeTable are not considered.
637  encoding, 0, portCode.encoding(),
638  portCode.encodingWidth() - width, width)) {
639  return true;
640  }
641  }
642 
643  // Check index part
644  if (portCode.indexWidth() > 0) {
645  if (fieldsOverlap(portCode.indexWidth(), 0, width, offset)) {
646  // todo/note: check if suggested encoding lands on unused
647  // index (when isMaxIndexSet() == true. Currently the feature
648  // is not used anywhere).
649  return true;
650  }
651  }
652  }
653  return false;
654 }

References MathTools::bitFieldsEquals(), PortCode::encoding(), PortCode::encodingWidth(), fieldsOverlap(), PortCode::indexWidth(), SocketCodeTable::portCode(), and SocketCodeTable::portCodeCount().

Referenced by conflictsWithDestinationEncodings(), and conflictsWithSourceEncodings().

Here is the call graph for this function:

◆ conflictsWithSourceEncodings()

bool BEMTester::conflictsWithSourceEncodings ( const SourceField field,
unsigned int  encoding,
unsigned int  width,
int  offset 
)
staticprivate

Checks that the given encoding and others in the field can be distinguished from each other.

Parameters
fieldThe source field.
encodingThe encoding.
widthThe width of the encoding where the encoding value is right aligned.
offsetThe relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa.
Returns
True if the encoding can not be distinguished from another encoding.

Definition at line 488 of file BEMTester.cc.

490  {
491  unsigned truncatedEncoding;
492  unsigned truncatedWidth;
493  unsigned truncatedOffset;
494 
495  for (int i = 0; i < field.socketEncodingCount(); i++) {
496  const SocketEncoding& socketEnc = field.socketEncoding(i);
497 
498  bool socketIDOverlap = fieldsOverlap(
499  socketEnc.socketIDWidth(), socketEnc.socketIDPosition(), width,
500  offset);
501  std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
502  splitEncodingTo(socketEnc, encoding, width, offset);
503  bool socketIDMatch = MathTools::bitFieldsEquals(
504  socketEnc.encoding(), truncatedOffset, truncatedEncoding, 0,
505  truncatedWidth);
506 
507  const SocketCodeTable& scTable = socketEnc.socketCodes();
508  // Get the part that overlaps with port codes.
509  std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
511  encoding, width, scTable.width(),
512  offset - socketEnc.socketCodePosition());
513  bool socketCodeOverlap = truncatedWidth > 0;
514  bool socketCodeMatch = conflictsWithSocketTableEncodings(
515  scTable, truncatedEncoding, truncatedWidth, truncatedOffset);
516 
517  if (socketIDOverlap) {
518  if (socketCodeMatch && socketIDMatch && socketCodeMatch) {
519  return true;
520  } else if (!socketCodeOverlap && socketIDMatch) {
521  return true;
522  }
523  } else if (socketCodeOverlap && socketCodeMatch) {
524  return true;
525  }
526  }
527 
528  // check against simm
529  if (field.hasImmediateEncoding()) {
530  const ImmediateEncoding& simmEnc = field.immediateEncoding();
531  std::tie(truncatedEncoding, truncatedWidth, truncatedOffset) =
533  encoding, width, simmEnc.encodingWidth(),
534  offset - simmEnc.encodingPosition());
535 
537  simmEnc.encoding(), truncatedOffset, truncatedEncoding, 0,
538  truncatedWidth)) {
539  return true;
540  }
541  }
542 
543  return false;
544 }

References MathTools::bitFieldsEquals(), conflictsWithSocketTableEncodings(), Encoding::encoding(), ImmediateEncoding::encodingPosition(), ImmediateEncoding::encodingWidth(), fieldsOverlap(), SourceField::hasImmediateEncoding(), SourceField::immediateEncoding(), SocketEncoding::socketCodePosition(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SlotField::socketEncodingCount(), SocketEncoding::socketIDPosition(), SocketEncoding::socketIDWidth(), splitEncoding(), splitEncodingTo(), and SocketCodeTable::width().

Referenced by canAddComponentPriorityEncoding().

Here is the call graph for this function:

◆ fieldsOverlap() [1/2]

bool BEMTester::fieldsOverlap ( const InstructionField with,
unsigned int  toFieldWidth,
int  toFieldPos 
)
staticprivate

Checks if a field relatively at position to an instruction field do overlap.

*       |<- instruction field ->|
*    |<-- width -->|<---- pos --|
* ------------------------------0
* => true
* 
Parameters
with
toFieldWidth
toFieldPosThe relative position of the field to the instruction field.
Returns
True if the fields do overlap. Otherwise false.

Definition at line 382 of file BEMTester.cc.

383  {
384  return fieldsOverlap(
385  with.width(), with.bitPosition(), toFieldWidth, toFieldPos);
386 }

References InstructionField::bitPosition(), and InstructionField::width().

Referenced by canAddComponentPriorityEncoding(), conflictsWithDestinationEncodings(), conflictsWithSocketTableEncodings(), and conflictsWithSourceEncodings().

Here is the call graph for this function:

◆ fieldsOverlap() [2/2]

bool BEMTester::fieldsOverlap ( unsigned  width1,
int  pos1,
unsigned  width2,
int  pos2 
)
staticprivate

Checks if the given fields overlaps

*                              |- pos1 -->|
*                  |<------ width1 ------>|
*       |<- width2 ->|         |
*                    |<- pos2 -|
*                        <- +  0
*                ->| |<- overlaps => true
* 
Parameters
width1The width of the 1st field.
pos1The position of the 1st field.
width2The width of the 2nd field.
pos2The position of the 2nd field.
Returns
True if there is overlap. Otherwise return false.

Definition at line 407 of file BEMTester.cc.

408  {
409  // positive = overlapping width, negative = separation width
410  return (std::min(
411  pos1 + static_cast<int>(width1),
412  pos2 + static_cast<int>(width2)) -
413  std::max(pos1, pos2)) > 0;
414 }

◆ splitEncoding()

std::tuple< unsigned, unsigned, int > BEMTester::splitEncoding ( unsigned  encoding,
unsigned  encodingWidth,
unsigned  targetWidth,
int  offsetToTarget 
)
staticprivate

Splits encoding to the target field.

the splitted encoding is returned as tuple where the 1st item is encoding bits leaving out non-overlapping bits, the 2nd item is resulted width (width of overlap) and the 3rd item is position of the resulted encoding within the target field.

*    msb                  lsb
*     |<- encoding width ->|
*     |00001010110100100100|
*                          |<-- offset (>0) --|
*                  |<-  target width        ->|
*----------------------------------------------
* result encoding: |0100100|
*    result width: |<----->|<-- offset (>0) --|
* 

Definition at line 677 of file BEMTester.cc.

679  {
680  long int resultWidth =
681  std::min(
682  static_cast<int>(targetWidth),
683  offsetToTarget + static_cast<int>(encodingWidth)) -
684  std::max(0, offsetToTarget);
685 
686  if (offsetToTarget > static_cast<int>(targetWidth) || resultWidth <= 0) {
687  return std::make_tuple(0, 0, 0);
688  }
689 
690  unsigned resultEncoding = encoding;
691  int resultOffset = offsetToTarget;
692 
693  if (offsetToTarget < 0) {
694  assert(-offsetToTarget < 32 && "Invalid shift amount.");
695  resultEncoding = resultEncoding >> -offsetToTarget;
696  resultOffset = 0;
697  }
698  assert(resultWidth < 32 && "Invalid shift amount.");
699  unsigned mask = ~(~(0u) << resultWidth);
700  resultEncoding &= mask;
701  return std::make_tuple(resultEncoding, resultWidth, resultOffset);
702 }

References assert.

Referenced by canAddComponentPriorityEncoding(), conflictsWithDestinationEncodings(), conflictsWithSourceEncodings(), and splitEncodingTo().

◆ splitEncodingTo()

std::tuple< unsigned, unsigned, int > BEMTester::splitEncodingTo ( const SocketEncoding socketEncoding,
unsigned  encoding,
unsigned  encodingWidth,
int  offsetToTarget 
)
staticprivate

Splits the given encoding that overlaps with the SocketEncoding.

Returns tuple where the 1st item is encoding bits leaving out non-overlapping bits, the 2nd item is resulted width (width of the overlap) and the 3rd item is position of the resulted encoding within the SocketEncoding.

Definition at line 713 of file BEMTester.cc.

715  {
716  return splitEncoding(
717  encoding, encodingWidth, socketEncoding.socketIDWidth(),
718  offsetToTarget - socketEncoding.socketIDPosition());
719 }

References SocketEncoding::socketIDPosition(), SocketEncoding::socketIDWidth(), and splitEncoding().

Referenced by conflictsWithDestinationEncodings(), and conflictsWithSourceEncodings().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
SlotField::noOperationEncoding
NOPEncoding & noOperationEncoding() const
Definition: SlotField.cc:281
InstructionField::bitPosition
int bitPosition() const
Definition: InstructionField.cc:132
SocketCodeTable::rfPortCodeCount
int rfPortCodeCount() const
Definition: SocketCodeTable.cc:471
PortCode
Definition: PortCode.hh:45
DestinationField
Definition: DestinationField.hh:44
GuardField::fuGuardEncoding
FUGuardEncoding & fuGuardEncoding(int index) const
Definition: GuardField.cc:387
SocketCodeTable::fuPortCode
FUPortCode & fuPortCode(int index) const
Definition: SocketCodeTable.cc:308
SourceField::hasImmediateEncoding
bool hasImmediateEncoding() const
Definition: SourceField.cc:279
IUPortCode
Definition: IUPortCode.hh:41
BridgeEncoding
Definition: BridgeEncoding.hh:47
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
SocketEncoding::socketCodePosition
int socketCodePosition() const
Definition: SocketEncoding.cc:203
GuardField::unconditionalGuardEncoding
UnconditionalGuardEncoding & unconditionalGuardEncoding(bool inverted) const
Definition: GuardField.cc:490
SlotField::hasNoOperationEncoding
bool hasNoOperationEncoding() const
Definition: SlotField.cc:267
BEMTester::fieldsOverlap
static bool fieldsOverlap(const InstructionField &with, unsigned int toFieldWidth, int toFieldPos)
Definition: BEMTester.cc:382
FUGuardEncoding
Definition: FUGuardEncoding.hh:47
SlotField::socketEncoding
SocketEncoding & socketEncoding(int index) const
Definition: SlotField.cc:170
ImmediateEncoding::width
virtual int width() const
Definition: ImmediateEncoding.cc:207
SocketCodeTable::portCodeCount
int portCodeCount() const
Definition: SocketCodeTable.cc:648
SocketCodeTable
Definition: SocketCodeTable.hh:68
BEMTester::conflictsWithGuardEncoding
static bool conflictsWithGuardEncoding(const GuardField &field, unsigned int encoding, unsigned int width, int offset)
Definition: BEMTester.cc:430
assert
#define assert(condition)
Definition: Application.hh:86
GuardField::gprGuardEncoding
GPRGuardEncoding & gprGuardEncoding(int index) const
Definition: GuardField.cc:290
Encoding::width
virtual int width() const
Definition: Encoding.cc:130
PortCode::extraBits
unsigned int extraBits() const
Definition: PortCode.cc:177
PortCode::indexWidth
int indexWidth() const
Definition: PortCode.cc:215
MoveSlot::guardField
GuardField & guardField() const
Definition: MoveSlot.cc:215
SourceField::immediateEncoding
ImmediateEncoding & immediateEncoding() const
Definition: SourceField.cc:293
InstructionField::width
virtual int width() const =0
SocketCodeTable::iuPortCode
IUPortCode & iuPortCode(int index) const
Definition: SocketCodeTable.cc:600
SlotField::width
virtual int width() const
Definition: SlotField.cc:307
BEMTester::commonBitCount
static int commonBitCount(unsigned int enc1, unsigned int extraBits1, unsigned int enc2, unsigned int extraBits2, int alignment)
Definition: BEMTester.cc:309
BEMTester::calculateAlignment
static int calculateAlignment(unsigned int enc1, unsigned int enc2, const SlotField &field)
Definition: BEMTester.cc:352
SourceField::width
virtual int width() const
Definition: SourceField.cc:308
Encoding::encoding
unsigned int encoding() const
Definition: Encoding.cc:108
GuardField::hasUnconditionalGuardEncoding
bool hasUnconditionalGuardEncoding(bool inverted) const
Definition: GuardField.cc:471
SlotField::componentIDPosition
BinaryEncoding::Position componentIDPosition() const
Definition: SlotField.cc:296
GuardEncoding::encoding
unsigned int encoding() const
Definition: GuardEncoding.cc:112
MoveSlot::width
virtual int width() const
Definition: MoveSlot.cc:406
MoveSlot::sourceField
SourceField & sourceField() const
Definition: MoveSlot.cc:277
NOPEncoding
Definition: NOPEncoding.hh:44
BEMTester::conflictsWithDestinationEncodings
static bool conflictsWithDestinationEncodings(const DestinationField &field, unsigned int encoding, unsigned int width, int offset)
Definition: BEMTester.cc:560
MathTools::bit
static bool bit(ULongWord integer, unsigned int index)
PortCode::encodingWidth
int encodingWidth() const
Definition: PortCode.cc:204
GuardField::gprGuardEncodingCount
int gprGuardEncodingCount() const
Definition: GuardField.cc:276
ImmediateEncoding::encodingWidth
int encodingWidth() const
Definition: ImmediateEncoding.cc:155
SocketEncoding::socketIDWidth
int socketIDWidth() const
Definition: SocketEncoding.cc:264
BEMTester::splitEncoding
static std::tuple< unsigned, unsigned, int > splitEncoding(unsigned encoding, unsigned encodingWidth, unsigned targetWidth, int offsetToTarget)
Definition: BEMTester.cc:677
SocketEncoding::socketIDPosition
int socketIDPosition() const
Definition: SocketEncoding.cc:249
SocketCodeTable::iuPortCodeCount
int iuPortCodeCount() const
Definition: SocketCodeTable.cc:587
GuardField::fuGuardEncodingCount
int fuGuardEncodingCount() const
Definition: GuardField.cc:373
BinaryEncoding::RIGHT
@ RIGHT
Definition: BinaryEncoding.hh:65
BEMTester::splitEncodingTo
static std::tuple< unsigned, unsigned, int > splitEncodingTo(const SocketEncoding &socketEncoding, unsigned encoding, unsigned encodingWidth, int offsetToTarget)
Definition: BEMTester.cc:713
BEMTester::conflictsWithSourceEncodings
static bool conflictsWithSourceEncodings(const SourceField &field, unsigned int encoding, unsigned int width, int offset)
Definition: BEMTester.cc:488
MathTools::bitLength
static unsigned int bitLength(long unsigned int number)
ImmediateEncoding::encodingPosition
int encodingPosition() const
Definition: ImmediateEncoding.cc:166
SourceField::bridgeEncodingCount
int bridgeEncodingCount() const
Definition: SourceField.cc:209
SlotField::socketEncodingCount
int socketEncodingCount() const
Definition: SlotField.cc:156
SocketCodeTable::portCode
PortCode & portCode(int index) const
Definition: SocketCodeTable.cc:662
MoveSlot::destinationField
DestinationField & destinationField() const
Definition: MoveSlot.cc:341
SourceField::bridgeEncoding
BridgeEncoding & bridgeEncoding(const std::string &bridge) const
Definition: SourceField.cc:191
ImmediateEncoding
Definition: ImmediateEncoding.hh:44
SocketEncoding::socketCodes
SocketCodeTable & socketCodes() const
Definition: SocketEncoding.cc:191
SocketEncoding
Definition: SocketEncoding.hh:51
BEMTester::conflictsWithSocketTableEncodings
static bool conflictsWithSocketTableEncodings(const SocketCodeTable &scTable, unsigned int encoding, unsigned int width, int offset)
Definition: BEMTester.cc:618
GPRGuardEncoding
Definition: GPRGuardEncoding.hh:47
PortCode::encoding
unsigned int encoding() const
Definition: PortCode.cc:164
UnconditionalGuardEncoding
Definition: UnconditionalGuardEncoding.hh:47
BEMTools::encodingWidth
static unsigned encodingWidth(unsigned encoding, unsigned extrabits)
Definition: BEMTools.cc:46
SocketCodeTable::width
int width() const
Definition: SocketCodeTable.cc:200
Encoding::extraBits
unsigned int extraBits() const
Definition: Encoding.cc:119
GuardField::width
virtual int width() const
Definition: GuardField.cc:533
MathTools::bitFieldsEquals
static bool bitFieldsEquals(unsigned enc1, unsigned pos1, unsigned enc2, unsigned pos2, unsigned width)
SourceField
Definition: SourceField.hh:48