OpenASIP
2.0
|
#include <BEMTester.hh>
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) |
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.
|
staticprivate |
Calculates the alignment of encodings that has the given widths when they are added to the given slot field.
enc1Width | Width of the first encoding. |
enc2Width | Width of the second encoding. |
field | The slot field. |
Definition at line 352 of file BEMTester.cc.
References SlotField::componentIDPosition(), and BinaryEncoding::RIGHT.
Referenced by canAddComponentEncoding().
|
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'.
field | The slot field. |
encoding | The encoding. |
extraBits | The number of extra bits in the encoding. |
Definition at line 73 of file BEMTester.cc.
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().
|
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.
slot | The slot where the encoding could be added. |
encoding | The encoding value. Avoid using zero value since its bit width is zero too. Instead, use one extrabit denote zero value. |
extraBits | The extra bits (zeroes) of the the encoding at the left side. |
offset | The position of the encoding from LSB position of the slot. Zero means that the given encoding is right aligned in the slot. |
Definition at line 180 of file BEMTester.cc.
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().
|
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.
table | The socket code table. |
encoding | The encoding. |
extraBits | The number of extra bits in the encoding. |
Definition at line 247 of file BEMTester.cc.
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().
|
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.
enc1 | The first encoding. |
extraBits1 | The number of extra zero bits in the first encoding. |
enc2 | The second encoding. |
extraBits2 | The number of extra zero bits in the second encoding. |
alignment | The 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.
References MathTools::bit(), and MathTools::bitLength().
Referenced by canAddComponentEncoding(), and canAddPortEncoding().
|
staticprivate |
Checks that the given encoding and others in the field can be distinguished from each other.
field | The destination field. |
encoding | The encoding. |
width | The width of the encoding where the encoding value is right aligned. |
offset | The relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa. |
Definition at line 560 of file BEMTester.cc.
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().
|
staticprivate |
Checks that the given encoding and others in the field can be distinguished from each other.
field | The guard field. |
encoding | The encoding. |
width | The width of the encoding where the encoding value is right aligned. |
offset | The relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa. |
Definition at line 430 of file BEMTester.cc.
References MathTools::bitFieldsEquals(), GuardEncoding::encoding(), GuardField::fuGuardEncoding(), GuardField::fuGuardEncodingCount(), GuardField::gprGuardEncoding(), GuardField::gprGuardEncodingCount(), GuardField::hasUnconditionalGuardEncoding(), GuardField::unconditionalGuardEncoding(), and GuardField::width().
Referenced by canAddComponentPriorityEncoding().
|
staticprivate |
Checks that the given encoding and others in the socket table can be distinguished from each other.
scTable | The socket code table. |
encoding | The encoding. |
width | The width of the encoding where the encoding value is right aligned. |
offset | The relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa. |
Definition at line 618 of file BEMTester.cc.
References MathTools::bitFieldsEquals(), PortCode::encoding(), PortCode::encodingWidth(), fieldsOverlap(), PortCode::indexWidth(), SocketCodeTable::portCode(), and SocketCodeTable::portCodeCount().
Referenced by conflictsWithDestinationEncodings(), and conflictsWithSourceEncodings().
|
staticprivate |
Checks that the given encoding and others in the field can be distinguished from each other.
field | The source field. |
encoding | The encoding. |
width | The width of the encoding where the encoding value is right aligned. |
offset | The relative position of the encoding to the field's LSB. Positive shifts the encoding towards MSB and vice versa. |
Definition at line 488 of file BEMTester.cc.
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().
|
staticprivate |
Checks if a field relatively at position to an instruction field do overlap.
* |<- instruction field ->| * |<-- width -->|<---- pos --| * ------------------------------0 * => true *
with | |
toFieldWidth | |
toFieldPos | The relative position of the field to the instruction field. |
Definition at line 382 of file BEMTester.cc.
References InstructionField::bitPosition(), and InstructionField::width().
Referenced by canAddComponentPriorityEncoding(), conflictsWithDestinationEncodings(), conflictsWithSocketTableEncodings(), and conflictsWithSourceEncodings().
|
staticprivate |
Checks if the given fields overlaps
* |- pos1 -->| * |<------ width1 ------>| * |<- width2 ->| | * |<- pos2 -| * <- + 0 * ->| |<- overlaps => true *
width1 | The width of the 1st field. |
pos1 | The position of the 1st field. |
width2 | The width of the 2nd field. |
pos2 | The position of the 2nd field. |
Definition at line 407 of file BEMTester.cc.
|
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.
References assert.
Referenced by canAddComponentPriorityEncoding(), conflictsWithDestinationEncodings(), conflictsWithSourceEncodings(), and splitEncodingTo().
|
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.
References SocketEncoding::socketIDPosition(), SocketEncoding::socketIDWidth(), and splitEncoding().
Referenced by conflictsWithDestinationEncodings(), and conflictsWithSourceEncodings().