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

#include <MathTools.hh>

Collaboration diagram for MathTools:
Collaboration graph

Static Public Member Functions

static unsigned int bitLength (long unsigned int number)
 
static bool bitFieldsEquals (unsigned enc1, unsigned pos1, unsigned enc2, unsigned pos2, unsigned width)
 
static long unsigned int concatenateBits (long unsigned int msbBitField, unsigned msbWidth, long unsigned int lsbBitField, unsigned lsbWidth)
 
static int ceil_log2 (long unsigned int number)
 
template<typename NumberType >
static int ceil_div (NumberType dividee, NumberType diveder)
 
static int requiredBits (unsigned long int number)
 
static int requiredBits0Bit0 (long unsigned int number)
 
static int requiredBitsSigned (SLongWord number)
 
static int requiredBitsSigned (int number)
 
static int requiredBitsSigned (UInt32 number)
 
static int requiredBitsSigned (ULongWord number)
 
static SLongWord signExtendTo (SLongWord value, int width)
 
static ULongWord zeroExtendTo (ULongWord value, int width)
 
static SLongWord fastSignExtendTo (SLongWord value, int width)
 
static ULongWord fastZeroExtendTo (ULongWord value, int width)
 
template<class IntegerType >
static void setBit (IntegerType &bits, unsigned int index, bool bitState=true)
 
static int random (int, int)
 
static unsigned int roundUpToPowerTwo (unsigned int number)
 
static int roundUpToPowerTwo (int number)
 
static SLongWord roundDownToPowerTwo (SLongWord number)
 
static bool isInPowerOfTwo (unsigned int number)
 
template<typename ResultNumberTypeS , typename ResultNumberTypeU = ResultNumberTypeS>
static std::pair< ResultNumberTypeS, ResultNumberTypeU > bitsToIntegerRange (unsigned bitWidth, bool signExtending)
 
static bool bit (ULongWord integer, unsigned int index)
 
static ULongWord roundDownToPowerTwo (ULongWord number)
 

Detailed Description

Definition at line 42 of file MathTools.hh.

Member Function Documentation

◆ bit()

static bool MathTools::bit ( ULongWord  integer,
unsigned int  index 
)
static

◆ bitFieldsEquals()

static bool MathTools::bitFieldsEquals ( unsigned  enc1,
unsigned  pos1,
unsigned  enc2,
unsigned  pos2,
unsigned  width 
)
static

◆ bitLength()

static unsigned int MathTools::bitLength ( long unsigned int  number)
static

◆ bitsToIntegerRange()

template<typename ResultNumberTypeS , typename ResultNumberTypeU = ResultNumberTypeS>
static std::pair<ResultNumberTypeS, ResultNumberTypeU> MathTools::bitsToIntegerRange ( unsigned  bitWidth,
bool  signExtending 
)
static

◆ ceil_div()

template<typename NumberType >
static int MathTools::ceil_div ( NumberType  dividee,
NumberType  diveder 
)
static

◆ ceil_log2()

static int MathTools::ceil_log2 ( long unsigned int  number)
static

◆ concatenateBits()

unsigned long int MathTools::concatenateBits ( long unsigned int  msbBitField,
unsigned  msbWidth,
long unsigned int  lsbBitField,
unsigned  lsbWidth 
)
static

Concatenates two bit fields together.

Example:

* concatenateBits(12, 4, 13, 3)
*   -> (0b1100, 0b1101)
*   -> 0b1100 + 0b101
*   -> 0b1100101
* 

Definition at line 47 of file MathTools.cc.

49  {
50 
51  const unsigned long int allOnes = -1ul;
52 
53  return ((msbBitField & ~(allOnes << msbWidth)) << lsbWidth) |
54  (lsbBitField & ~(allOnes << lsbWidth));
55 }

◆ fastSignExtendTo()

static SLongWord MathTools::fastSignExtendTo ( SLongWord  value,
int  width 
)
static

◆ fastZeroExtendTo()

static ULongWord MathTools::fastZeroExtendTo ( ULongWord  value,
int  width 
)
static

◆ isInPowerOfTwo()

static bool MathTools::isInPowerOfTwo ( unsigned int  number)
static

◆ random()

static int MathTools::random ( int  ,
int   
)
static

◆ requiredBits()

static int MathTools::requiredBits ( unsigned long int  number)
static

Referenced by ProGe::NetlistGenerator::addBaseRFToNetlist(), TTAProgram::Instruction::addImmediate(), ProGe::ProcessorWrapperBlock::addInstructionMemory(), MoveSlotDictionary::addInstructions(), InstructionDictionary::addInstructions(), TPEF::DataSection::addMAU(), StaticProgramAnalyzer::addProgram(), MachineInfo::canEncodeImmediateInteger(), ImmInfo::canTakeImmediate(), MachineValidator::checkIMemAddrWidth(), POMValidator::checkLongImmediates(), InstructionDictionary::compress(), MoveSlotDictionary::compress(), TTAProgram::ProgramWriter::createCodeSection(), InstructionDictionary::createDictionary(), OpsetDialog::createOperation(), VectorLSGenerator::createVectorLSU(), TTAProgram::DataDefinition::DataDefinition(), MoveSlotDictionary::evaluateMoveSlotBoundaries(), TPEF::TPEFRelocSectionReader::finalize(), CodeSectionCreator::finalize(), TTAProgram::TPEFProgramFactory::findInstrTemplate(), ITemplateBroker::findITemplates(), InstructionBitVector::fixBits(), FUGen::FUGen(), ProGe::CUOpcodeGenerator::gcuOpcodeWidth(), InstructionDictionary::generateDecompressor(), ProGe::ProcessorGenerator::iMemAddressWidth(), ProGe::NetlistGenerator::instructionMemoryAddressWidth(), HDB::FUImplementation::maxOpcodeWidth(), AddressSpaceDialog::onMaxAddress(), RFTestbenchGenerator::opcodePortWidth(), ProGe::NetlistGenerator::opcodePortWidth(), MoveSlotDictionary::printDetails(), SimProgramBuilder::processMove(), ProGe::ProGeUI::readImemParameters(), PlatformIntegrator::readLsuParameters(), MachineConnectivityCheck::requiredImmediateWidth(), SegmentFigure::SegmentFigure(), TTAProgram::Instruction::setInstructionTemplate(), DataSectionCreator::sizeInWords(), UnitPortFigure::UnitPortFigure(), and AddressSpacesDialog::updateASList().

◆ requiredBits0Bit0()

static int MathTools::requiredBits0Bit0 ( long unsigned int  number)
static

◆ requiredBitsSigned() [1/4]

static int MathTools::requiredBitsSigned ( int  number)
static

◆ requiredBitsSigned() [2/4]

static int MathTools::requiredBitsSigned ( SLongWord  number)
static

◆ requiredBitsSigned() [3/4]

static int MathTools::requiredBitsSigned ( UInt32  number)
static

◆ requiredBitsSigned() [4/4]

static int MathTools::requiredBitsSigned ( ULongWord  number)
static

◆ roundDownToPowerTwo() [1/2]

static SLongWord MathTools::roundDownToPowerTwo ( SLongWord  number)
static

◆ roundDownToPowerTwo() [2/2]

static ULongWord MathTools::roundDownToPowerTwo ( ULongWord  number)
static

◆ roundUpToPowerTwo() [1/2]

static int MathTools::roundUpToPowerTwo ( int  number)
static

◆ roundUpToPowerTwo() [2/2]

static unsigned int MathTools::roundUpToPowerTwo ( unsigned int  number)
static

◆ setBit()

template<class IntegerType >
static void MathTools::setBit ( IntegerType &  bits,
unsigned int  index,
bool  bitState = true 
)
static

◆ signExtendTo()

static SLongWord MathTools::signExtendTo ( SLongWord  value,
int  width 
)
static

◆ zeroExtendTo()

static ULongWord MathTools::zeroExtendTo ( ULongWord  value,
int  width 
)
static

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