OpenASIP
2.0
|
#include <SimValue.hh>
Public Types | |
typedef DoubleWord | DoubleFloatWord |
Public Member Functions | |
SimValue () | |
SimValue (int width) | |
SimValue (SLongWord value, int width) | |
SimValue (const SimValue &source) | |
~SimValue () | |
int | width () const |
void | setBitWidth (int width) |
SimValue & | operator= (const SIntWord &source) |
SimValue & | operator= (const UIntWord &source) |
SimValue & | operator= (const SLongWord &source) |
SimValue & | operator= (const ULongWord &source) |
SimValue & | operator= (const HalfFloatWord &source) |
SimValue & | operator= (const FloatWord &source) |
SimValue & | operator= (const DoubleWord &source) |
SimValue & | operator= (const SimValue &source) |
void | deepCopy (const SimValue &source) |
const SimValue | operator+ (const SIntWord &rightHand) |
const SimValue | operator+ (const UIntWord &rightHand) |
const SimValue | operator+ (const SLongWord &rightHand) |
const SimValue | operator+ (const ULongWord &rightHand) |
const SimValue | operator+ (const HalfFloatWord &rightHand) |
const SimValue | operator+ (const FloatWord &rightHand) |
const SimValue | operator+ (const DoubleWord &rightHand) |
const SimValue | operator- (const SIntWord &rightHand) |
const SimValue | operator- (const UIntWord &rightHand) |
const SimValue | operator- (const SLongWord &rightHand) |
const SimValue | operator- (const ULongWord &rightHand) |
const SimValue | operator- (const HalfFloatWord &rightHand) |
const SimValue | operator- (const FloatWord &rightHand) |
const SimValue | operator- (const DoubleWord &rightHand) |
const SimValue | operator/ (const SIntWord &rightHand) |
const SimValue | operator/ (const UIntWord &rightHand) |
const SimValue | operator/ (const SLongWord &rightHand) |
const SimValue | operator/ (const ULongWord &rightHand) |
const SimValue | operator/ (const HalfFloatWord &rightHand) |
const SimValue | operator/ (const FloatWord &rightHand) |
const SimValue | operator/ (const DoubleWord &rightHand) |
const SimValue | operator* (const SIntWord &rightHand) |
const SimValue | operator* (const UIntWord &rightHand) |
const SimValue | operator* (const SLongWord &rightHand) |
const SimValue | operator* (const ULongWord &rightHand) |
const SimValue | operator* (const HalfFloatWord &rightHand) |
const SimValue | operator* (const FloatWord &rightHand) |
const SimValue | operator* (const DoubleWord &rightHand) |
int | operator== (const SimValue &rightHand) const |
int | operator== (const SIntWord &rightHand) const |
int | operator== (const UIntWord &rightHand) const |
int | operator== (const SLongWord &rightHand) const |
int | operator== (const ULongWord &rightHand) const |
int | operator== (const HalfFloatWord &rightHand) const |
int | operator== (const FloatWord &rightHand) const |
int | operator== (const DoubleWord &rightHand) const |
int | intValue () const |
unsigned int | unsignedValue () const |
SIntWord | sIntWordValue () const |
UIntWord | uIntWordValue () const |
SLongWord | sLongWordValue () const |
ULongWord | uLongWordValue () const |
DoubleWord | doubleWordValue () const |
FloatWord | floatWordValue () const |
HalfFloatWord | halfFloatWordValue () const |
TCEString | binaryValue () const |
TCEString | hexValue (bool noHexIdentifier=false) const |
Word | wordElement (size_t elementIndex) const |
SIntWord | sIntWordElement (size_t elementIndex) const |
UIntWord | uIntWordElement (size_t elementIndex) const |
HalfWord | halfWordElement (size_t elementIndex) const |
HalfFloatWord | halfFloatElement (size_t elementIndex) const |
FloatWord | floatElement (size_t elementIndex) const |
DoubleFloatWord | doubleFloatElement (size_t elementIndex) const |
Byte | byteElement (size_t elementIndex) const |
UIntWord | bitElement (size_t elementIndex) const |
Word | element (size_t elementIndex, size_t elementWidth) const |
void | setWordElement (size_t elementIndex, Word data) |
void | setHalfWordElement (size_t elementIndex, HalfWord data) |
void | setByteElement (size_t elementIndex, Byte data) |
void | setBitElement (size_t elementIndex, UIntWord data) |
void | setElement (size_t elementIndex, size_t elementWidth, Word data) |
void | setHalfFloatElement (size_t elementIndex, HalfFloatWord data) |
void | setFloatElement (size_t elementIndex, FloatWord data) |
void | setDoubleFloatElement (size_t elementIndex, DoubleFloatWord data) |
void | setValue (TCEString hexValue) |
void | clearToZero (int bitWidth) |
void | clearToZero () |
void | signExtendTo (int bitWidth) |
void | zeroExtendTo (int bitWidth) |
TCEString | dump () const |
Public Attributes | |
Byte | rawData_ [SIMVALUE_MAX_BYTE_SIZE] |
Array that contains SimValue's underlaying bytes in little endian. More... | |
int | bitWidth_ |
The bitwidth of the value. More... | |
Private Member Functions | |
template<typename T > | |
T | vectorElement (size_t elementIndex) const |
template<typename T > | |
void | setVectorElement (size_t elementIndex, T data) |
void | swapByteOrder (const Byte *from, size_t byteCount, Byte *to) const |
Private Attributes | |
ULongWord | mask_ |
Mask for masking extra bits when returning unsigned value. More... | |
Class that represents values in simulation.
This class represents any data type that can be manipulated by operations of the target architecture template, and provides the interface to access the data in predefined types.
Values are always (regardless of the endianness of the machine) stored in little-endian convention in the rawData_ byte array. This is to model closer the internal registers and buses where the convention is to:
This is to avoid the need to implement two variations of function unit implementations, for both endianness modes.
This also means that big endian machines need endianness-aware load/stores as they need to swap the elements to the little-endian "internal format". However, as we lean towards using little-endian with vector machines (for example due to buggy LLVM BE/vector code gen), it means we usually use endianness-unaware "chunk" memory operations that can be uses both for scalar and vector data.
When a user wants to interpret SimValue as any primitive value (FloatWord, UIntWord, etc.), depending on the user's machine endianness the interpreted bytes are swapped correctly to be either in big-endian or little-endian convention. For instance, if the user has a big-endian machine and calls the uIntWordValue() function for a SimValue, which has the above value, it gets swapped so the OSAL operations can treat the result as a host integer to model the computation with.
The same swapping convention also occurs when a primitive value is assigned to SimValue. If the value to be assigned is in big-endian and its bytes are 0xabcd0000, the last four bytes in the SimValue are as 0x0000cdab.
SimValue users don't need to worry about the possible byte swapping since it is automatic and is done only if the user's machine is a little-endian machine. However, users shouldn't access the public rawData_ member directly unless they know exactly what they are doing, and always use the accessors for getting/setting lane data.
Definition at line 96 of file SimValue.hh.
typedef DoubleWord SimValue::DoubleFloatWord |
Definition at line 99 of file SimValue.hh.
SimValue::SimValue | ( | ) |
Default constructor.
To allow creation of SimValue arrays. Constructs a SimValue with width of SIMULATOR_MAX_INTWORD_BITWIDTH bits.
Definition at line 47 of file SimValue.cc.
References setBitWidth(), and SIMULATOR_MAX_LONGWORD_BITWIDTH.
|
explicit |
Constructor.
width | The bit width of the created SimValue. |
Definition at line 58 of file SimValue.cc.
References setBitWidth(), and width().
|
explicit |
Constructor.
value | The numeric value of this SimValue (in host endianness). |
width | The bit width of the created SimValue. |
Definition at line 71 of file SimValue.cc.
References BYTE_BITWIDTH, rawData_, setBitWidth(), swapByteOrder(), and width().
SimValue::SimValue | ( | const SimValue & | source | ) |
Copy constructor.
source | The source object from which to copy data. |
Definition at line 93 of file SimValue.cc.
References deepCopy().
|
inline |
Definition at line 104 of file SimValue.hh.
TCEString SimValue::binaryValue | ( | ) | const |
Returns the value as a 2's complement (MSB left) binary string in ascii.
Definition at line 1121 of file SimValue.cc.
References bitWidth_, BYTE_BITWIDTH, rawData_, and Conversion::toBinary().
Referenced by TesterContext::toOutputFormat().
UIntWord SimValue::bitElement | ( | size_t | elementIndex | ) | const |
Returns desired 1-bit bit element.
Definition at line 1288 of file SimValue.cc.
References assert, BYTE_BITWIDTH, rawData_, and SIMD_WORD_WIDTH.
Referenced by element(), and signExtendTo().
Byte SimValue::byteElement | ( | size_t | elementIndex | ) | const |
Returns desired 8-bit byte element.
Definition at line 1274 of file SimValue.cc.
References assert, rawData_, and SIMVALUE_MAX_BYTE_SIZE.
void SimValue::clearToZero | ( | ) |
Sets all SimValue bytes to 0.
Definition at line 1516 of file SimValue.cc.
References SIMD_WORD_WIDTH.
Referenced by setBitWidth(), signExtendTo(), and zeroExtendTo().
void SimValue::clearToZero | ( | int | bitWidth | ) |
Sets SimValue bytes to 0 for the given bitwidth.
bitWidth | The width that is to be nullified. |
Definition at line 1504 of file SimValue.cc.
References assert, BYTE_BITWIDTH, rawData_, and SIMD_WORD_WIDTH.
void SimValue::deepCopy | ( | const SimValue & | source | ) |
Copies the source SimValue completely.
source | The source value. |
Definition at line 307 of file SimValue.cc.
References bitWidth_, BYTE_BITWIDTH, mask_, and rawData_.
Referenced by OperationDAGBehavior::areValid(), OperationDAGBehavior::simulateTrigger(), and SimValue().
SimValue::DoubleFloatWord SimValue::doubleFloatElement | ( | size_t | elementIndex | ) | const |
Definition at line 1266 of file SimValue.cc.
DoubleWord SimValue::doubleWordValue | ( | ) | const |
Returns the SimValue as a host endian DoubleWord value.
Definition at line 1052 of file SimValue.cc.
References rawData_, and swapByteOrder().
Referenced by ExecutionTrace::addBusActivity(), SimulateDialog::formattedValue(), operator*(), operator+(), operator-(), operator/(), operator==(), and TesterContext::toOutputFormat().
TCEString SimValue::dump | ( | ) | const |
Dumps raw data encoded in the SimValue in hexadecimal format.
Definition at line 1593 of file SimValue.cc.
References mask_, rawData_, SIMVALUE_MAX_BYTE_SIZE, Conversion::toBinary(), Conversion::toHexString(), Conversion::toString(), and width().
Word SimValue::element | ( | size_t | elementIndex, |
size_t | elementWidth | ||
) | const |
Get element function for arbitrary element width.
Values by width are stored in power of 2 byte boundaries (1, 2 or 4). elementWidth must be in range of (0, 32].
Definition at line 1311 of file SimValue.cc.
References assert, bitElement(), rawData_, MathTools::roundUpToPowerTwo(), and swapByteOrder().
FloatWord SimValue::floatElement | ( | size_t | elementIndex | ) | const |
Definition at line 1261 of file SimValue.cc.
FloatWord SimValue::floatWordValue | ( | ) | const |
Returns the SimValue as a host endian FloatWord value.
Definition at line 1075 of file SimValue.cc.
References rawData_, and swapByteOrder().
Referenced by SimulateDialog::formattedValue(), operator*(), operator+(), operator-(), operator/(), operator==(), and TesterContext::toOutputFormat().
HalfFloatWord SimValue::halfFloatElement | ( | size_t | elementIndex | ) | const |
Definition at line 1254 of file SimValue.cc.
HalfFloatWord SimValue::halfFloatWordValue | ( | ) | const |
Returns the SimValue as a host endian HalfFloatWord value.
Definition at line 1098 of file SimValue.cc.
References rawData_, and swapByteOrder().
Referenced by operator*(), operator+(), operator-(), operator/(), operator==(), and TesterContext::toOutputFormat().
HalfWord SimValue::halfWordElement | ( | size_t | elementIndex | ) | const |
Returns desired 16-bit short integer word element in host endianness.
Definition at line 1249 of file SimValue.cc.
Returns the value as a big endian ordered (C-literal style) hex ascii string.
noHexIdentifier | Leaves "0x" prefix out if set to true. |
Definition at line 1150 of file SimValue.cc.
References bitWidth_, BYTE_BITWIDTH, rawData_, Conversion::toHexString(), uIntWordValue(), and uLongWordValue().
Referenced by BusTracker::handleEvent(), InfoRegistersCommand::registerDescription(), SimulationController::registerFileValue(), CompiledSimController::registerFileValue(), setValue(), and TesterContext::toOutputFormat().
int SimValue::intValue | ( | ) | const |
Returns SimValue as a sign extended host integer.
Definition at line 895 of file SimValue.cc.
References bitWidth_, MathTools::fastSignExtendTo(), rawData_, and swapByteOrder().
Referenced by LoopAnalyzer::analyze(), OffsetAliasAnalyzer::analyze(), ITemplateBroker::assign(), ITemplateBroker::assignImmediate(), ControlFlowGraph::buildMBBFromBB(), POMValidator::checkLongImmediates(), SimulatorFrontend::compareState(), BF2Scheduler::countLoopInvariantValueUsages(), MemoryAliasAnalyzer::detectConstantScale(), InfoImmediatesCommand::execute(), InfoPortsCommand::execute(), InfoSegmentsCommand::execute(), LoopAnalyzer::findEndCond(), MemoryAliasAnalyzer::findIncrement(), LoopAnalyzer::findInitAndUpdate(), DataDependenceGraph::findLoopIndexUpdate(), CompiledSimCodeGenerator::generateInstruction(), StackAliasAnalyzer::getStackOffset(), ProximRegisterWindow::loadImmediateUnit(), ProximRegisterWindow::loadRegisterFile(), main(), FUTestbenchGenerator::readValuesFromOutPorts(), MemoryAliasAnalyzer::searchLoopIndexBasedIncrement(), PreOptimizer::tryToRemoveEq(), PreOptimizer::tryToRemoveXor(), LoopAnalyzer::tryTrackCommonAncestor(), and ProximPortWindow::update().
const SimValue SimValue::operator* | ( | const DoubleWord & | rightHand | ) |
Explicit multiplication operator to DoubleWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 760 of file SimValue.cc.
References doubleWordValue().
Explicit multiplication operator to FloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 744 of file SimValue.cc.
References floatWordValue().
const SimValue SimValue::operator* | ( | const HalfFloatWord & | rightHand | ) |
Explicit multiply operator to HalfFloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 664 of file SimValue.cc.
References halfFloatWordValue().
Explicit multiplication operator to SIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 680 of file SimValue.cc.
References sIntWordValue().
Explicit multiplication operator to SLongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 712 of file SimValue.cc.
References sLongWordValue().
Explicit multiplication operator to UIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 696 of file SimValue.cc.
References uIntWordValue().
Explicit multiplication operator to UIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 728 of file SimValue.cc.
References uLongWordValue().
const SimValue SimValue::operator+ | ( | const DoubleWord & | rightHand | ) |
Explicit addition operator to DoubleWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 423 of file SimValue.cc.
References doubleWordValue().
Explicit addition operator to FloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 407 of file SimValue.cc.
References floatWordValue().
const SimValue SimValue::operator+ | ( | const HalfFloatWord & | rightHand | ) |
Explicit addition operator to HalfFloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 391 of file SimValue.cc.
References halfFloatWordValue().
Explicit addition operator to SIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 327 of file SimValue.cc.
References sIntWordValue().
Explicit addition operator to SlongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 359 of file SimValue.cc.
References sLongWordValue().
Explicit addition operator to UIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 343 of file SimValue.cc.
References uIntWordValue().
Explicit addition operator to ULongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 375 of file SimValue.cc.
References uLongWordValue().
const SimValue SimValue::operator- | ( | const DoubleWord & | rightHand | ) |
Explicit subtraction operator to DoubleWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 536 of file SimValue.cc.
References doubleWordValue().
Explicit subtraction operator to FloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 520 of file SimValue.cc.
References floatWordValue().
const SimValue SimValue::operator- | ( | const HalfFloatWord & | rightHand | ) |
Explicit subtraction operator to HalfFloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 440 of file SimValue.cc.
References halfFloatWordValue().
Explicit subtraction operator to SIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 456 of file SimValue.cc.
References sIntWordValue().
Explicit subtraction operator to SLongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 488 of file SimValue.cc.
References sLongWordValue().
Explicit subtraction operator to UIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 472 of file SimValue.cc.
References uIntWordValue().
Explicit subtraction operator to ULongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 504 of file SimValue.cc.
References uLongWordValue().
const SimValue SimValue::operator/ | ( | const DoubleWord & | rightHand | ) |
Explicit division operator to DoubleWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 648 of file SimValue.cc.
References doubleWordValue().
Explicit division operator to FloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 632 of file SimValue.cc.
References floatWordValue().
const SimValue SimValue::operator/ | ( | const HalfFloatWord & | rightHand | ) |
Explicit division operator to HalfFloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 552 of file SimValue.cc.
References halfFloatWordValue().
Explicit division operator to SIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 568 of file SimValue.cc.
References sIntWordValue().
Explicit division operator to SLongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 600 of file SimValue.cc.
References sLongWordValue().
Explicit division operator to UIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 584 of file SimValue.cc.
References uIntWordValue().
Explicit division operator to UIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the addition. |
Definition at line 616 of file SimValue.cc.
References uLongWordValue().
SimValue & SimValue::operator= | ( | const DoubleWord & | source | ) |
Assignment operator for source value of type DoubleWord.
source | The source value. |
Definition at line 258 of file SimValue.cc.
References BYTE_BITWIDTH, rawData_, setBitWidth(), and swapByteOrder().
Assignment operator for source value of type FloatWord.
source | The source value. |
Definition at line 237 of file SimValue.cc.
References BYTE_BITWIDTH, rawData_, setBitWidth(), and swapByteOrder().
SimValue & SimValue::operator= | ( | const HalfFloatWord & | source | ) |
Assignment operator for source value of type HalfFloatWord.
source | The source value. |
Definition at line 215 of file SimValue.cc.
References BYTE_BITWIDTH, HalfFloatWord::getBinaryRep(), rawData_, setBitWidth(), and swapByteOrder().
Assignment operator for source value of type SimValue.
source | The source value. |
Definition at line 282 of file SimValue.cc.
References bitWidth_, BYTE_BITWIDTH, and rawData_.
Assignment operator for source value of type SIntWord.
source | The source value. |
Definition at line 138 of file SimValue.cc.
References rawData_, and swapByteOrder().
Assignment operator for source value of type SLongWord.
source | The source value. |
Definition at line 176 of file SimValue.cc.
References rawData_, and swapByteOrder().
Assignment operator for source value of type UIntWord.
source | The source value. |
Definition at line 157 of file SimValue.cc.
References rawData_, and swapByteOrder().
Assignment operator for source value of type ULongWord.
source | The source value. |
Definition at line 195 of file SimValue.cc.
References rawData_, and swapByteOrder().
int SimValue::operator== | ( | const DoubleWord & | rightHand | ) | const |
Explicit equality operator for DoubleWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 887 of file SimValue.cc.
References doubleWordValue().
int SimValue::operator== | ( | const FloatWord & | rightHand | ) | const |
Explicit equality operator for FloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 872 of file SimValue.cc.
References floatWordValue().
int SimValue::operator== | ( | const HalfFloatWord & | rightHand | ) | const |
Explicit equality operator for HalfFloatWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 857 of file SimValue.cc.
References HalfFloatWord::getBinaryRep(), and halfFloatWordValue().
int SimValue::operator== | ( | const SimValue & | rightHand | ) | const |
Explicit equality operator for SimValue type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 780 of file SimValue.cc.
References uIntWordValue().
int SimValue::operator== | ( | const SIntWord & | rightHand | ) | const |
Explicit equality operator for SIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 797 of file SimValue.cc.
References sIntWordValue().
int SimValue::operator== | ( | const SLongWord & | rightHand | ) | const |
Explicit equality operator for SLongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 827 of file SimValue.cc.
References sLongWordValue().
int SimValue::operator== | ( | const UIntWord & | rightHand | ) | const |
Explicit equality operator for UIntWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 812 of file SimValue.cc.
References uIntWordValue().
int SimValue::operator== | ( | const ULongWord & | rightHand | ) | const |
Explicit equality operator for ULongWord type.
These operators are defined to avoid ambiguous overload because of built-in operators.
rightHand | The right hand side of the comparison. |
Definition at line 842 of file SimValue.cc.
References uLongWordValue().
void SimValue::setBitElement | ( | size_t | elementIndex, |
UIntWord | data | ||
) |
Sets bit element at a certain index to given value.
elementIndex | Bit element index. |
data | Bit element data. |
Definition at line 1397 of file SimValue.cc.
References assert, BYTE_BITWIDTH, rawData_, and SIMD_WORD_WIDTH.
Referenced by setElement().
void SimValue::setBitWidth | ( | int | width | ) |
Sets SimValue's bitwidth and clears bytes to 0 for the whole width.
width | The new bit width. |
Definition at line 113 of file SimValue.cc.
References assert, bitWidth_, BYTE_BITWIDTH, clearToZero(), mask_, SIMD_WORD_WIDTH, and width().
Referenced by CmdMem::execute(), operator=(), SimValue(), and SimpleOperationExecutor::startOperation().
void SimValue::setByteElement | ( | size_t | elementIndex, |
Byte | data | ||
) |
Definition at line 1386 of file SimValue.cc.
References setVectorElement().
void SimValue::setDoubleFloatElement | ( | size_t | elementIndex, |
DoubleFloatWord | data | ||
) |
Definition at line 1381 of file SimValue.cc.
References setVectorElement().
void SimValue::setElement | ( | size_t | elementIndex, |
size_t | elementWidth, | ||
Word | data | ||
) |
Set element function for arbitrary element width.
Values by width are stored in power of 2 byte boundaries (1, 2 or 4). elementWidth must be in range of (0, 32].
Definition at line 1422 of file SimValue.cc.
References assert, rawData_, MathTools::roundUpToPowerTwo(), setBitElement(), SIMVALUE_MAX_BYTE_SIZE, and swapByteOrder().
void SimValue::setFloatElement | ( | size_t | elementIndex, |
FloatWord | data | ||
) |
Definition at line 1376 of file SimValue.cc.
References setVectorElement().
void SimValue::setHalfFloatElement | ( | size_t | elementIndex, |
HalfFloatWord | data | ||
) |
Definition at line 1371 of file SimValue.cc.
References setVectorElement().
void SimValue::setHalfWordElement | ( | size_t | elementIndex, |
HalfWord | data | ||
) |
Sets half word (a.k.a. short 16-bit integer) element at a certain index to given value.
elementIndex | Half word element index. |
data | Half word element data. |
Definition at line 1366 of file SimValue.cc.
References setVectorElement().
void SimValue::setValue | ( | TCEString | hexValue | ) |
Sets SimValue to correspond the hex value.
Given hex string must be in big-endian order when it is given. For instance, if the user wants to set integer value 5 through this function, the function should be called "setValue("0x00000005");". Add leading zeroes if you want to clear bytes before the byte that has value 5.
hexValue | New value in hex format. |
Definition at line 1460 of file SimValue.cc.
References __func__, bitWidth_, hexValue(), rawData_, SIMD_WORD_WIDTH, SIMVALUE_MAX_BYTE_SIZE, swapByteOrder(), and Conversion::toRawData().
|
private |
Definition at line 1339 of file SimValue.cc.
References assert, rawData_, SIMVALUE_MAX_BYTE_SIZE, and swapByteOrder().
Referenced by setByteElement(), setDoubleFloatElement(), setFloatElement(), setHalfFloatElement(), setHalfWordElement(), and setWordElement().
void SimValue::setWordElement | ( | size_t | elementIndex, |
Word | data | ||
) |
Definition at line 1354 of file SimValue.cc.
References setVectorElement().
void SimValue::signExtendTo | ( | int | bitWidth | ) |
Overwrites all bits that do not fit in the given bit width with the sign bit (the bit at position width - 1).
This operation corresponds to reinterpreting the value as a signed word of given bit width.
bitWidth | Number of meaningful bits in the given integer. |
OutOfRange | If width > value size |
Definition at line 1531 of file SimValue.cc.
References __func__, bitElement(), bitWidth_, BYTE_BITWIDTH, clearToZero(), MathTools::fastSignExtendTo(), rawData_, and SIMD_WORD_WIDTH.
Referenced by SimProgramBuilder::processMove().
SIntWord SimValue::sIntWordElement | ( | size_t | elementIndex | ) | const |
Returns desired element at given index as signed integer.
Definition at line 1227 of file SimValue.cc.
References wordElement().
SIntWord SimValue::sIntWordValue | ( | ) | const |
Returns the SimValue as SIntWord value.
Definition at line 944 of file SimValue.cc.
References bitWidth_, BYTE_BITWIDTH, MathTools::fastSignExtendTo(), rawData_, and swapByteOrder().
Referenced by ProximBusDetailsCmd::Do(), ProximIUDetailsCmd::Do(), ExecutableMove::evaluateGuard(), SimulateDialog::formattedValue(), ProgramImageGenerator::generateProgramImage(), operator*(), operator+(), operator-(), operator/(), and operator==().
SLongWord SimValue::sLongWordValue | ( | ) | const |
Returns the SimValue as SIntWord value.
Definition at line 997 of file SimValue.cc.
References bitWidth_, BYTE_BITWIDTH, MathTools::fastSignExtendTo(), rawData_, and swapByteOrder().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), BuslessExecutableMove::executeWrite(), operator*(), operator+(), operator-(), operator/(), operator==(), SimProgramBuilder::processMove(), InfoRegistersCommand::registerDescription(), MachineConnectivityCheck::requiredImmediateWidth(), LongImmediateRegisterState::setValue(), TesterContext::toOutputFormat(), DisassemblyImmediate::toString(), and DisassemblyImmediateAssignment::toString().
Copies the byte order from source array in opposite order to target array.
from | Array from which the bytes are copied. |
byteCount | How many bytes are copied. |
to | Array to which the bytes are copied in opposite order. |
Definition at line 1621 of file SimValue.cc.
References assert.
Referenced by doubleWordValue(), element(), floatWordValue(), halfFloatWordValue(), intValue(), operator=(), setElement(), setValue(), setVectorElement(), SimValue(), sIntWordValue(), sLongWordValue(), uIntWordValue(), uLongWordValue(), unsignedValue(), and vectorElement().
UIntWord SimValue::uIntWordElement | ( | size_t | elementIndex | ) | const |
Returns desired element at given index as unsigned integer.
Definition at line 1240 of file SimValue.cc.
References wordElement().
UIntWord SimValue::uIntWordValue | ( | ) | const |
Returns the SimValue as host endian UIntWord value.
Definition at line 972 of file SimValue.cc.
References mask_, rawData_, and swapByteOrder().
Referenced by ExecutionTrace::addBusActivity(), ProximFUDetailsCmd::Do(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeLongImmediate(), SimulateDialog::formattedValue(), hexValue(), operator*(), operator+(), operator-(), operator/(), operator==(), and SimulationInfoDialog::updateList().
ULongWord SimValue::uLongWordValue | ( | ) | const |
Returns the SimValue as an ULongWord.
Definition at line 1027 of file SimValue.cc.
References mask_, rawData_, and swapByteOrder().
Referenced by TTAProgram::ProgramWriter::createCodeSection(), POMDisassembler::createMove(), hexValue(), operator*(), operator+(), operator-(), operator/(), operator==(), SimProgramBuilder::processMove(), MachineConnectivityCheck::requiredImmediateWidth(), LongImmediateRegisterState::setValue(), TesterContext::toOutputFormat(), DisassemblyImmediate::toString(), and DisassemblyImmediateAssignment::toString().
unsigned int SimValue::unsignedValue | ( | ) | const |
Returns SimValue as a zero extended unsigned host integer.
Definition at line 919 of file SimValue.cc.
References bitWidth_, MathTools::fastZeroExtendTo(), rawData_, and swapByteOrder().
Referenced by StaticProgramAnalyzer::addProgram(), TTAProgram::TerminalAddress::address(), ITemplateBroker::assign(), ITemplateBroker::assignImmediate(), POMValidator::checkLongImmediates(), TTAProgram::ProgramWriter::createCodeSection(), RFTestbenchGenerator::createStimulus(), ProximFUPortDetailsCmd::Do(), ProximRFDetailsCmd::Do(), CompiledSimCodeGenerator::generateInstruction(), ConstantAliasAnalyzer::getConstantAddress(), BUBasicBlockScheduler::handleLoopDDG(), ProximRegisterWindow::loadImmediateUnit(), ProximRegisterWindow::loadRegisterFile(), CompiledSimSymbolGenerator::moveOperandSymbol(), BasicBlockScheduler::scheduleMove(), and ProximPortWindow::update().
|
private |
Definition at line 1187 of file SimValue.cc.
References assert, rawData_, SIMVALUE_MAX_BYTE_SIZE, and swapByteOrder().
int SimValue::width | ( | ) | const |
Returns the bit width of the SimValue.
Definition at line 103 of file SimValue.cc.
References bitWidth_.
Referenced by ITemplateBroker::assign(), POMValidator::checkLongImmediates(), dump(), BUBasicBlockScheduler::handleLoopDDG(), BasicBlockScheduler::scheduleMove(), setBitWidth(), LongImmediateRegisterState::setValue(), SimValue(), TesterContext::toOutputFormat(), DisassemblyImmediate::toString(), BusState::width(), and FUTestbenchGenerator::writeInputPortStimulus().
Word SimValue::wordElement | ( | size_t | elementIndex | ) | const |
Returns the desired 32-bit word element in host endianness.
The element ordering of SimValue storage is always the memory order, first vector elements in the first locations.
elementIndex | Index of the element (from 0 upwards). |
Definition at line 1219 of file SimValue.cc.
Referenced by sIntWordElement(), and uIntWordElement().
void SimValue::zeroExtendTo | ( | int | bitWidth | ) |
Overwrites all bits that do not fit in the given bit width with 0
This operation corresponds to reinterpreting the value as an unsigned word of given bit width.
bitWidth | Number of meaningful bits in the given integer. |
OutOfRange | If width > value size |
Definition at line 1567 of file SimValue.cc.
References __func__, bitWidth_, BYTE_BITWIDTH, clearToZero(), MathTools::fastZeroExtendTo(), rawData_, and SIMD_WORD_WIDTH.
Referenced by SimProgramBuilder::processMove().
int SimValue::bitWidth_ |
The bitwidth of the value.
Definition at line 205 of file SimValue.hh.
Referenced by binaryValue(), deepCopy(), hexValue(), intValue(), operator=(), setBitWidth(), setValue(), signExtendTo(), sIntWordValue(), sLongWordValue(), unsignedValue(), width(), and zeroExtendTo().
|
private |
Mask for masking extra bits when returning unsigned value.
Definition at line 223 of file SimValue.hh.
Referenced by deepCopy(), dump(), setBitWidth(), uIntWordValue(), and uLongWordValue().
Byte SimValue::rawData_[SIMVALUE_MAX_BYTE_SIZE] |
Array that contains SimValue's underlaying bytes in little endian.
Definition at line 202 of file SimValue.hh.
Referenced by binaryValue(), bitElement(), byteElement(), clearToZero(), deepCopy(), doubleWordValue(), dump(), element(), floatWordValue(), halfFloatWordValue(), hexValue(), intValue(), operator=(), setBitElement(), setElement(), setValue(), setVectorElement(), signExtendTo(), SimValue(), sIntWordValue(), sLongWordValue(), uIntWordValue(), uLongWordValue(), unsignedValue(), vectorElement(), and zeroExtendTo().