OpenASIP
2.0
|
#include <CodeCompressorPlugin.hh>
Classes | |
struct | Parameter |
Parameter struct. More... | |
Public Types | |
typedef std::vector< Parameter > | ParameterTable |
Table for passing plugin parameters. More... | |
Public Member Functions | |
virtual | ~CodeCompressorPlugin () |
void | setParameters (ParameterTable parameters) |
void | setPrograms (std::map< std::string, TPEF::Binary * > &programs) |
void | setMachine (const TTAMachine::Machine &machine) |
void | setBEM (const BinaryEncoding &bem) |
const BinaryEncoding & | binaryEncoding () const |
const TTAMachine::Machine & | machine () const |
virtual InstructionBitVector * | compress (const std::string &program)=0 |
virtual void | generateDecompressor (std::ostream &stream, TCEString entityStr)=0 |
virtual void | printDescription (std::ostream &stream)=0 |
unsigned int | memoryAddress (const TTAProgram::Instruction &instruction) const |
TTAProgram::Program & | currentProgram () const |
int | imemMauWidth () const |
InstructionBitVector * | bemInstructionBits (const TTAProgram::Instruction &) |
Protected Types | |
typedef std::map< std::string, TPEF::Binary * > | TPEFMap |
Map type for handling programs. More... | |
Protected Member Functions | |
CodeCompressorPlugin () | |
InstructionBitVector * | bemBits (const TTAProgram::Program &program) |
int | moveSlotCount () const |
int | moveSlotWidth (int index) const |
int | firstMoveSlotIndex () const |
void | startNewProgram (const std::string &programName) |
void | addInstruction (const TTAProgram::Instruction &instruction, InstructionBitVector *bits) |
void | setInstructionToStartAtBeginningOfMAU (const TTAProgram::Instruction &instruction) |
void | setAllInstructionsToStartAtBeginningOfMAU () |
InstructionBitVector * | programBits () const |
bool | hasParameter (const std::string ¶mName) const |
std::string | parameterValue (const std::string ¶mName) const |
void | setImemWidth (int mau, int widthInMaus=1) |
int | numberOfPrograms () const |
TPEFMap::const_iterator | programElement (int index) const |
std::string | indentation (int level) |
Private Types | |
typedef std::set< const TTAProgram::Instruction * > | InstructionSet |
Set type for Instructions. More... | |
typedef std::set< const TTAProgram::Immediate * > | ImmediateSet |
Set type for Immediates. More... | |
typedef std::set< const TTAProgram::Terminal * > | TerminalSet |
Set type for Terminals. More... | |
typedef std::map< const TTAProgram::Immediate *, const TTAProgram::Instruction * > | RelocMap |
Map type that maps Immediates to the Instructions they are referring to. More... | |
typedef std::map< const TTAProgram::Immediate *, std::vector< IndexBound > > | IndexTable |
Map type that maps Immediates to a vector of indexes. More... | |
typedef std::map< const TTAProgram::Instruction *, unsigned int > | InstructionAddressMap |
Map type for addresses of instructions. More... | |
Static Private Member Functions | |
static void | addBitsForDestinationField (const DestinationField &dstField, const TTAProgram::Move &move, BitVector &bitVector) |
static void | addBitsForGuardField (const GuardField &guardField, const TTAProgram::Move &move, BitVector &bitVector) |
static void | encodeNOP (const MoveSlot &slot, BitVector &bitVector) |
static void | encodeIUTerminal (const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector) |
static void | encodeRFTerminal (const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector) |
static void | encodeFUTerminal (const SlotField &field, const TTAProgram::Terminal &terminal, BitVector &bitVector) |
static void | encodeSlotField (const SlotField &field, const BitVector &componentIDBits, const BitVector &socketCodeBits, BitVector &BitVector) |
static BitVector | socketCodeBits (const SocketCodeTable &socketCodes, const PortCode &portCode, unsigned int registerIndex) |
static void | addBits (unsigned int number, int leftmostBit, int rightmostBit, BitVector &bitVector) |
Private Attributes | |
TPEFMap | tpefPrograms_ |
Programs run in the machine. More... | |
TPEF::Binary * | currentTPEF_ |
The current TPEF. More... | |
TTAProgram::Program * | currentPOM_ |
The current program in POM. More... | |
std::string | currentProgram_ |
The current program. More... | |
const BinaryEncoding * | bem_ |
The binary encoding map. More... | |
const TTAMachine::Machine * | machine_ |
The machine. More... | |
ParameterTable | parameters_ |
Parameters for the plugin. More... | |
InstructionBitVector * | programBits_ |
The bits of the program. More... | |
bool | allStartsAtBeginningOfMAU_ |
Tells whether all the instructions starts at the beginning of MAU. More... | |
int | mau_ |
The size of the minimum addressable unit. More... | |
int | addressSpaceOffset_ |
The offset of the instruction memory (the address of the first instruction). More... | |
InstructionSet | instructionsAtBeginningOfMAU_ |
Set of instructions that start at the beginning of MAU. More... | |
ImmediateSet | immediatesToRelocate_ |
Set of (long) immediates that refer to an instruction. More... | |
TerminalSet | terminalsToRelocate_ |
Set of (short) immediate terminals that refer to an instruction. More... | |
RelocMap | relocMap_ |
Contains information to which instructions the immediates are referring to. More... | |
IndexTable | indexTable_ |
A table of indexes used when encoding long immediates. More... | |
InstructionAddressMap | instructionAddresses_ |
Contains the addresses of instructions. More... | |
The base class for different code compressors.
Definition at line 84 of file CodeCompressorPlugin.hh.
|
private |
Set type for Immediates.
Definition at line 174 of file CodeCompressorPlugin.hh.
|
private |
Map type that maps Immediates to a vector of indexes.
Definition at line 183 of file CodeCompressorPlugin.hh.
|
private |
Map type for addresses of instructions.
Definition at line 186 of file CodeCompressorPlugin.hh.
|
private |
Set type for Instructions.
Definition at line 172 of file CodeCompressorPlugin.hh.
typedef std::vector<Parameter> CodeCompressorPlugin::ParameterTable |
Table for passing plugin parameters.
Definition at line 94 of file CodeCompressorPlugin.hh.
|
private |
Map type that maps Immediates to the Instructions they are referring to.
Definition at line 180 of file CodeCompressorPlugin.hh.
|
private |
Set type for Terminals.
Definition at line 176 of file CodeCompressorPlugin.hh.
|
protected |
Map type for handling programs.
Definition at line 138 of file CodeCompressorPlugin.hh.
|
virtual |
The destructor.
Definition at line 117 of file CodeCompressorPlugin.cc.
References currentPOM_, and programBits_.
|
protected |
|
staticprivate |
Adds the bits of the given number to the given bit vector.
The bits added are determined by leftmostBit and rightmostBit parameters.
number | The number. |
leftmost | The leftmost bit of the number which is added to the bit vector. |
rightmost | The rightmost bit of the number which is added to the bit vector. |
bitVector | The bit vector to which the bits are added. |
Definition at line 1688 of file CodeCompressorPlugin.cc.
References MathTools::bit().
Referenced by encodeLongImmediate().
|
staticprivate |
Adds bits for a destination field to the given bit vector.
dstField | The destination field that determines the encoding rules. |
move | The move that is being encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 800 of file CodeCompressorPlugin.cc.
References assert, TTAProgram::Move::bus(), TTAProgram::Move::destination(), encodeFUTerminal(), encodeRFTerminal(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), MoveSlot::name(), TTAMachine::Component::name(), and SlotField::parent().
Referenced by encodeMove().
|
private |
Adds the bits of the given destination register field to the bit vector.
field | The long immediate destination register field. |
instruction | The instruction. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the instruction or BEM is erroneous. |
Definition at line 960 of file CodeCompressorPlugin.cc.
References __func__, TTAProgram::Immediate::destination(), Exception::errorMessage(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), LImmDstRegisterField::immediateUnit(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), instructionTemplate(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), BitVector::pushBack(), and LImmDstRegisterField::width().
Referenced by bemInstructionBits().
|
staticprivate |
Adds bits for a guard field to the given bit vector.
guardField | The guard field that determines the encoding rules. |
move | The move that is being encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 824 of file CodeCompressorPlugin.cc.
References assert, GuardEncoding::encoding(), GuardField::fuGuardEncoding(), GuardField::gprGuardEncoding(), TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), NullFUGuardEncoding::instance(), NullGPRGuardEncoding::instance(), NullUnconditionalGuardEncoding::instance(), TTAMachine::Guard::isInverted(), TTAProgram::Move::isUnconditional(), TTAMachine::Port::name(), MoveSlot::name(), TTAMachine::Component::name(), GuardField::parent(), TTAMachine::Port::parentUnit(), TTAMachine::PortGuard::port(), BitVector::pushBack(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_ALWAYS_TRUE_GUARD_ENCODING_MISSING, PIGTextGenerator::TXT_FU_GUARD_ENCODING_MISSING, PIGTextGenerator::TXT_GPR_GUARD_ENCODING_MISSING, and GuardField::width().
Referenced by encodeMove().
|
private |
Adds bits for immediate control field to the given bit vector.
icField | The immediate control field that determines the encoding. |
instruction | The instruction that is being encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM or machine is erroneous. |
Definition at line 669 of file CodeCompressorPlugin.cc.
References __func__, Exception::errorMessage(), instructionTemplate(), BitVector::pushBack(), ImmediateControlField::templateEncoding(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_TEMPLATE_ENCODING_MISSING, and ImmediateControlField::width().
Referenced by bemInstructionBits().
|
private |
Adds the immediate bits of the given immediate slot to the bit vector.
immSlot | The immediate slot. |
instruction | The instruction that contains the immediate. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 911 of file CodeCompressorPlugin.cc.
References assert, encodeLongImmediate(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), instructionTemplate(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), ImmediateSlotField::name(), BitVector::pushBack(), Texts::TextGenerator::text(), TTAMachine::InstructionTemplate::usesSlot(), and ImmediateSlotField::width().
Referenced by bemInstructionBits().
|
private |
Adds bits for a move slot to the given bit vector.
slot | The move slot that determines the encoding. |
instruction | The instruction that is being encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 709 of file CodeCompressorPlugin.cc.
References assert, TTAMachine::Machine::busNavigator(), encodeLongImmediate(), encodeMove(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), instructionTemplate(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), MoveSlot::name(), TTAMachine::Component::name(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_BEM_DEFINES_SLOT_FOR_NONEXISTING_BUS, TTAMachine::InstructionTemplate::usesSlot(), and MoveSlot::width().
Referenced by bemInstructionBits().
|
private |
Adds bits for a source field to the given bit vector.
srcField | The source field that determines the encoding rules. |
move | The move that is being encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 770 of file CodeCompressorPlugin.cc.
References assert, TTAProgram::Move::bus(), encodeFUTerminal(), encodeImmediateTerminal(), encodeIUTerminal(), encodeRFTerminal(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediate(), TTAProgram::Terminal::isImmediateRegister(), MoveSlot::name(), TTAMachine::Component::name(), SlotField::parent(), TTAProgram::Move::source(), and SourceField::width().
Referenced by encodeMove().
|
protected |
Adds the given instruction to the program.
instruction | The instruction. |
bits | The bits that models the instruction. |
InvalidData | If new program is not started by startNewProgram. |
OutOfRange | If some immediate would become too large to fit in its space due to the address of the instruction being added. |
Definition at line 384 of file CodeCompressorPlugin.cc.
References __func__, addressSpaceOffset_, InstructionBitVector::fixInstructionAddress(), instructionAddresses_, InstructionBitVector::markInstructionStartingPoint(), mau_, memoryAddress(), nextAddressablePositionFrom(), programBits_, InstructionBitVector::pushBack(), and startsAtBeginningOfMAU().
Referenced by DEFAULT_Compressor::compress().
|
protected |
Returns the bit image of the program encoded as the BEM determines.
program | The program. |
InvalidData | If the BEM is erroneous. |
Definition at line 205 of file CodeCompressorPlugin.cc.
References assert, bem_, bemInstructionBits(), indexTable_, TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), program, InstructionBitVector::pushBack(), relocMap_, and BinaryEncoding::width().
InstructionBitVector * CodeCompressorPlugin::bemInstructionBits | ( | const TTAProgram::Instruction & | instruction | ) |
Returns bit vector that represents the given instruction as the BEM determines.
instruction | The instruction. |
InvalidData | If the BEM is erroneous. |
Definition at line 454 of file CodeCompressorPlugin.cc.
References __func__, addBitsForDstRegisterField(), addBitsForICField(), addBitsForImmediateSlot(), addBitsForMoveSlot(), InstructionBitVector::addIndexBoundsForReference(), assert, bem_, binaryEncoding(), BinaryEncoding::childField(), MapTools::containsKey(), indexTable_, relocMap_, InstructionBitVector::startSettingInstructionReference(), MapTools::valueForKey(), ImmediateSlotField::width(), LImmDstRegisterField::width(), ImmediateControlField::width(), and MoveSlot::width().
Referenced by bemBits(), DEFAULT_Compressor::compress(), ProGe::RV32MicroCodeGenerator::constructBInstructions(), ProGe::RV32MicroCodeGenerator::constructIInstructions(), ProGe::RV32MicroCodeGenerator::constructRInstructions(), ProGe::RV32MicroCodeGenerator::constructSInstructions(), ProGe::RV32MicroCodeGenerator::constructUJInstructions(), and ProGe::RV32MicroCodeGenerator::generateNOP().
const BinaryEncoding & CodeCompressorPlugin::binaryEncoding | ( | ) | const |
Returns the binary encoding map.
NotAvailable | If the BEM is not set. |
Definition at line 280 of file CodeCompressorPlugin.cc.
References __func__, and bem_.
Referenced by bemInstructionBits(), and ProgramImageGenerator::generateProgramImage().
|
pure virtual |
Generates bit image of the program.
InvalidData | If the BEM is erroneous. |
Implemented in MoveSlotDictionary, InstructionDictionary, and DEFAULT_Compressor.
Referenced by ProgramImageGenerator::generateDataImage(), and ProgramImageGenerator::generateProgramImage().
TTAProgram::Program & CodeCompressorPlugin::currentProgram | ( | ) | const |
Returns the program (POM) being processed currently.
NotAvailable | If there is no program being processed. |
Definition at line 295 of file CodeCompressorPlugin.cc.
References __func__, and currentPOM_.
Referenced by DEFAULT_Compressor::compress(), ProgramImageGenerator::generateProgramImage(), and ProgramImageGenerator::writeDataSection().
|
staticprivate |
Encodes the given function unit terminal to the given bit vector.
field | The slot field that determines the encoding rules. |
terminal | The terminal to be encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 1418 of file CodeCompressorPlugin.cc.
References assert, encodeSlotField(), Encoding::encoding(), PortCode::encoding(), TTAProgram::Terminal::functionUnit(), SocketCodeTable::fuPortCode(), SocketCodeTable::hasFUPortCode(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), TTAProgram::TerminalFUPort::hwOperation(), TTAMachine::Port::inputSocket(), NullOperation::instance(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isOpcodeSetting(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), MoveSlot::name(), TTAMachine::Component::name(), Operation::name(), TTAProgram::Terminal::operation(), TTAMachine::Port::outputSocket(), SlotField::parent(), TTAProgram::Terminal::port(), BitVector::pushBack(), socketCodeBits(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SocketEncoding::socketIDWidth(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_FU_OC_PORT_CODE_MISSING, PIGTextGenerator::TXT_FU_PORT_CODE_MISSING, PIGTextGenerator::TXT_OSAL_OC_MISSING, PIGTextGenerator::TXT_SOCKET_ENCODING_MISSING, and SocketCodeTable::width().
Referenced by addBitsForDestinationField(), and addBitsForSourceField().
|
private |
Encodes the given immediate terminal to the given bit vector.
field | The source field which determines the encoding rules. |
terminal | The immediate terminal to be encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 1503 of file CodeCompressorPlugin.cc.
References InstructionBitVector::addIndexBoundsForReference(), assert, SlotField::componentIDPosition(), AssocTools::containsKey(), currentPOM_, Encoding::encoding(), ImmediateEncoding::encodingWidth(), SourceField::immediateEncoding(), NullImmediateEncoding::instance(), TTAProgram::Program::instructionAt(), TTAProgram::Terminal::isImmediate(), BinaryEncoding::LEFT, MoveSlot::name(), SlotField::parent(), InstructionBitVector::pushBack(), InstructionBitVector::startSettingInstructionReference(), terminalsToRelocate_, Texts::TextGenerator::text(), PIGTextGenerator::TXT_IMMEDIATE_ENCODING_MISSING, SimValue::uIntWordValue(), TTAProgram::Terminal::value(), and SourceField::width().
Referenced by addBitsForSourceField().
|
staticprivate |
Encodes the immediate unit register terminal to the given bit vector.
field | The slot field that determines the encoding rules. |
terminal | The terminal to be encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 1288 of file CodeCompressorPlugin.cc.
References assert, encodeSlotField(), Encoding::encoding(), SocketCodeTable::hasIUPortCode(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), TTAMachine::Port::inputSocket(), TTAProgram::Terminal::isImmediateRegister(), SocketCodeTable::iuPortCode(), MoveSlot::name(), TTAMachine::Component::name(), TTAMachine::Port::outputSocket(), SlotField::parent(), TTAProgram::Terminal::port(), BitVector::pushBack(), socketCodeBits(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SocketEncoding::socketIDWidth(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_IU_PORT_CODE_MISSING, and PIGTextGenerator::TXT_SOCKET_ENCODING_MISSING.
Referenced by addBitsForSourceField().
|
private |
Encodes the instruction's long immediate bits that belong to the given (move or immediate) slot to the bit vector.
slotName | Name of the slot. |
width | Bit width of the slot. |
instruction | The instruction that is being encoded. |
bitVector | The bit vector to which the bits are added. |
Definition at line 1066 of file CodeCompressorPlugin.cc.
References addBits(), assert, MapTools::containsKey(), AssocTools::containsKey(), currentPOM_, TTAMachine::InstructionTemplate::destinationOfSlot(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), immediatesToRelocate_, indexTable_, TTAProgram::Program::instructionAt(), TTAProgram::Instruction::instructionTemplate(), TTAMachine::InstructionTemplate::numberOfSlots(), relocMap_, TTAMachine::InstructionTemplate::slotOfDestination(), TTAMachine::InstructionTemplate::supportedWidth(), SimValue::uIntWordValue(), TTAMachine::InstructionTemplate::usesSlot(), TTAProgram::TerminalImmediate::value(), and TTAProgram::Immediate::value().
Referenced by addBitsForImmediateSlot(), and addBitsForMoveSlot().
|
private |
Encodes a move to the given bit vector.
slot | The move slot that determines the encoding rules. |
instruction | The instruction that is being encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 1151 of file CodeCompressorPlugin.cc.
References addBitsForDestinationField(), addBitsForGuardField(), addBitsForSourceField(), assert, TTAProgram::Move::bus(), TTAMachine::Machine::busNavigator(), MoveSlot::childField(), MoveSlot::childFieldCount(), MoveSlot::destinationField(), encodeNOP(), MoveSlot::guardField(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), MoveSlot::name(), MoveSlot::sourceField(), SourceField::width(), SlotField::width(), MoveSlot::width(), and GuardField::width().
Referenced by addBitsForMoveSlot().
Encodes a NOP to the given bitVector.
slot | The move slot that determines the encoding rules. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM does not define encoding for NOP. |
Definition at line 1204 of file CodeCompressorPlugin.cc.
References __func__, MoveSlot::childField(), MoveSlot::childFieldCount(), SlotField::componentIDPosition(), MoveSlot::destinationField(), GuardEncoding::encoding(), Encoding::encoding(), MoveSlot::guardField(), SlotField::hasNoOperationEncoding(), GuardField::hasUnconditionalGuardEncoding(), NullNOPEncoding::instance(), BinaryEncoding::LEFT, MoveSlot::name(), SlotField::noOperationEncoding(), BitVector::pushBack(), MoveSlot::sourceField(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_NOP_ENCODING_MISSING, GuardField::unconditionalGuardEncoding(), Encoding::width(), SourceField::width(), SlotField::width(), and GuardField::width().
Referenced by encodeMove().
|
staticprivate |
Encodes the given register file terminal to the given bit vector.
field | The slot field that determines the encoding rules. |
terminal | The terminal to be encoded. |
bitVector | The bit vector to which the bits are added. |
InvalidData | If the BEM is erroneous. |
Definition at line 1354 of file CodeCompressorPlugin.cc.
References assert, encodeSlotField(), Encoding::encoding(), SocketCodeTable::hasRFPortCode(), SocketEncoding::hasSocketCodes(), SlotField::hasSocketEncoding(), TTAProgram::Terminal::index(), TTAMachine::Port::inputSocket(), TTAProgram::Terminal::isGPR(), MoveSlot::name(), TTAMachine::Component::name(), TTAMachine::Port::outputSocket(), SlotField::parent(), TTAProgram::Terminal::port(), BitVector::pushBack(), TTAProgram::Terminal::registerFile(), SocketCodeTable::rfPortCode(), socketCodeBits(), SocketEncoding::socketCodes(), SlotField::socketEncoding(), SocketEncoding::socketIDWidth(), Texts::TextGenerator::text(), PIGTextGenerator::TXT_RF_PORT_CODE_MISSING, and PIGTextGenerator::TXT_SOCKET_ENCODING_MISSING.
Referenced by addBitsForDestinationField(), and addBitsForSourceField().
|
staticprivate |
Encodes the given source or destination field with the given bit vectors.
field | The source or destination field which determines the encoding order of component ID bits and socket code bits. |
componentIDBits | The encoding for component ID. |
socketCodeBits | The encoding for socket code. |
bitVector | The bit vector to which the bits are added. |
Definition at line 1556 of file CodeCompressorPlugin.cc.
References assert, SlotField::componentIDPosition(), BinaryEncoding::LEFT, BitVector::pushBack(), socketCodeBits(), and SlotField::width().
Referenced by encodeFUTerminal(), encodeIUTerminal(), and encodeRFTerminal().
|
protected |
Returns the index of first move slot defined in bem
Definition at line 242 of file CodeCompressorPlugin.cc.
References bem_, BinaryEncoding::hasImmediateControlField(), BinaryEncoding::immediateControlField(), BinaryEncoding::longImmDstRegisterField(), BinaryEncoding::longImmDstRegisterFieldCount(), LImmDstRegisterField::width(), and ImmediateControlField::width().
|
pure virtual |
Generates the HDL code of the decompressor block.
stream | The stream to write. |
Implemented in InstructionDictionary, MoveSlotDictionary, and DEFAULT_Compressor.
Referenced by ProgramImageGenerator::generateDecompressor().
|
protected |
Tells whether the plugin has the given parameter defined.
paramName | Name of the parameter. |
Definition at line 558 of file CodeCompressorPlugin.cc.
References CodeCompressorPlugin::Parameter::name, and parameters_.
int CodeCompressorPlugin::imemMauWidth | ( | ) | const |
Returns the mau of instruction memory.
Before compression this is the original width and after compression it returns the compressed instruction width
Definition at line 600 of file CodeCompressorPlugin.cc.
References mau_.
Referenced by ProgramImageGenerator::imemMauWidth().
|
private |
Returns the immediate terminal that matches with the given ImmediateElement instance.
codeSection | The code section that contains the immediate element. |
elementIndex | The index at which the instruction containing the immediate element starts. |
immElem | The immediate element. |
instruction | The instruction that contains the immediate terminal. |
Definition at line 1712 of file CodeCompressorPlugin.cc.
References assert, TPEF::InstructionElement::begin(), TPEF::MoveElement::bus(), TTAProgram::Move::bus(), currentTPEF_, TPEF::ImmediateElement::destinationIndex(), TPEF::CodeSection::element(), TPEF::Section::elementCount(), TPEF::ImmediateElement::isInline(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAMachine::Component::name(), TTAProgram::Move::source(), TPEF::MoveElement::sourceIndex(), and TPEF::MoveElement::sourceType().
Referenced by initializeRelocations().
|
protected |
Returns the indentation string of the given level.
level | The indentation level. |
Definition at line 652 of file CodeCompressorPlugin.cc.
|
private |
Initializes the immediatesToRelocate_ and terminalsToRelocate_ members.
Definition at line 1608 of file CodeCompressorPlugin.cc.
References assert, TPEF::InstructionElement::begin(), AssocTools::containsKey(), currentPOM_, currentTPEF_, TPEF::RelocElement::destination(), TPEF::CodeSection::element(), TPEF::Section::element(), TPEF::Section::elementCount(), TTAProgram::Program::firstInstruction(), immediatesToRelocate_, immediateTerminal(), TPEF::InstructionElement::isImmediate(), TPEF::RelocElement::location(), TTAProgram::Program::nextInstruction(), programImmediate(), TPEF::RelocSection::referencedSection(), TPEF::Binary::section(), TPEF::Binary::sectionCount(), and terminalsToRelocate_.
Referenced by startNewProgram().
|
private |
Returns the name of the instruction template of the given instruction.
instruction | The instruction. |
InstanceNotFound | If the machine does not have such an instruction template. |
Definition at line 997 of file CodeCompressorPlugin.cc.
References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAProgram::Instruction::immediateCount(), TTAProgram::Instruction::instructionTemplate(), TTAMachine::Machine::instructionTemplateNavigator(), TTAMachine::InstructionTemplate::isEmpty(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine(), TTAMachine::Component::name(), Texts::TextGenerator::text(), and PIGTextGenerator::TXT_EMPTY_ITEMP_MISSING.
Referenced by addBitsForDstRegisterField(), addBitsForICField(), addBitsForImmediateSlot(), and addBitsForMoveSlot().
const Machine & CodeCompressorPlugin::machine | ( | ) | const |
Returns the machine.
NotAvailable | If the machine is not set. |
Definition at line 310 of file CodeCompressorPlugin.cc.
References __func__, and machine_.
Referenced by addBitsForImmediateSlot(), addBitsForMoveSlot(), encodeMove(), ProgramImageGenerator::generateDataImage(), ProgramImageGenerator::generateProgramImage(), instructionTemplate(), setMachine(), and ProgramImageGenerator::writeDataSection().
unsigned int CodeCompressorPlugin::memoryAddress | ( | const TTAProgram::Instruction & | instruction | ) | const |
Tells the memory address of the given instruction.
instruction | The instruction. |
InstanceNotFound | If the program does not contain the given instruction. |
Definition at line 262 of file CodeCompressorPlugin.cc.
References MapTools::containsKey(), and instructionAddresses_.
Referenced by addInstruction(), and ProgramImageGenerator::writeDataSection().
|
protected |
Returns the number of move slots
Definition at line 226 of file CodeCompressorPlugin.cc.
References bem_, and BinaryEncoding::moveSlotCount().
|
protected |
Returns the width of the move slot in the given index
index | Index of move slot |
Definition at line 235 of file CodeCompressorPlugin.cc.
References bem_, BinaryEncoding::moveSlot(), and MoveSlot::width().
|
private |
Returns the next addressable position in the bit vector calculated from the given position.
position | The position. |
Definition at line 1045 of file CodeCompressorPlugin.cc.
References mau_.
Referenced by addInstruction().
|
protected |
Returns the number of programs to be compressed
Definition at line 623 of file CodeCompressorPlugin.cc.
References tpefPrograms_.
|
protected |
Returns the value of the given parameter.
paramName | Name of the parameter. |
NotAvailable | If the given parameter is not defined. |
Definition at line 578 of file CodeCompressorPlugin.cc.
References __func__, CodeCompressorPlugin::Parameter::name, parameters_, and CodeCompressorPlugin::Parameter::value.
|
pure virtual |
Prints description of the plugin to the given stream.
Implemented in InstructionDictionary, MoveSlotDictionary, and DEFAULT_Compressor.
Referenced by ProgramImageGenerator::printCompressorDescription().
|
protected |
Returns the bits of the program constructed by calling addInstruction method several times.
This method creates a copy of the constructed bit vector and add extra bits to the end to make sure the length of the vector is divisible by MAU.
Definition at line 533 of file CodeCompressorPlugin.cc.
References mau_, and programBits_.
Referenced by DEFAULT_Compressor::compress().
|
protected |
Returns a const iterator to program map element at the given index
OutOfRange | If index is out of range |
Definition at line 634 of file CodeCompressorPlugin.cc.
References __func__, and tpefPrograms_.
|
private |
Returns the immediate in the given instruction that matches with the given immediate element.
immElem | The immediate element. |
instruction | The instruction. |
Definition at line 1764 of file CodeCompressorPlugin.cc.
References assert, currentTPEF_, TTAProgram::Immediate::destination(), TPEF::ImmediateElement::destinationUnit(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::isImmediateRegister(), TPEF::ImmediateElement::isInline(), and TTAMachine::Component::name().
Referenced by initializeRelocations().
|
protected |
Sets all instructions to start at the beginning of MAU.
This method must be called before any instructions are added to the bit vector.
Definition at line 440 of file CodeCompressorPlugin.cc.
References allStartsAtBeginningOfMAU_.
Referenced by DEFAULT_Compressor::compress().
void CodeCompressorPlugin::setBEM | ( | const BinaryEncoding & | bem | ) |
Sets the binary encoding map.
bem | The BEM. |
Definition at line 192 of file CodeCompressorPlugin.cc.
References bem_.
Referenced by ProgramImageGenerator::loadBEM().
|
protected |
Sets the imem width to the given mau * widthInMaus and mau to given mau
mau | Mau of instruction memory |
widthInMaus | Memory width in maus (default = 1) |
Definition at line 612 of file CodeCompressorPlugin.cc.
References TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::controlUnit(), machine_, mau_, and TTAMachine::AddressSpace::setWidth().
Referenced by setMachine().
|
protected |
Sets the given instruction to start at the beginning of MAU.
This method must be called before the instruction is added to the bit vector.
instruction | The instruction. |
Definition at line 426 of file CodeCompressorPlugin.cc.
References instructionsAtBeginningOfMAU_.
void CodeCompressorPlugin::setMachine | ( | const TTAMachine::Machine & | machine | ) |
Sets the machine.
Machine must be set before generating the program image. BEM must be set before calling this
machine | The machine. |
InvalidData | If the machine does not have control unit. |
InvalidData | If bem is not set |
Definition at line 161 of file CodeCompressorPlugin.cc.
References __func__, TTAMachine::FunctionUnit::addressSpace(), addressSpaceOffset_, bem_, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::isRISCVMachine(), machine(), machine_, mau_, setImemWidth(), TTAMachine::AddressSpace::start(), TTAMachine::AddressSpace::width(), and BinaryEncoding::width().
Referenced by ProgramImageGenerator::loadMachine().
void CodeCompressorPlugin::setParameters | ( | ParameterTable | parameters | ) |
Sets the plugin parameters.
parameters | The parameters. |
Definition at line 133 of file CodeCompressorPlugin.cc.
References parameters_.
Referenced by ProgramImageGenerator::loadCompressorParameters().
void CodeCompressorPlugin::setPrograms | ( | std::map< std::string, TPEF::Binary * > & | programs | ) |
Sets the programs to be executed in the machine.
program | Map of programs. |
Definition at line 144 of file CodeCompressorPlugin.cc.
References tpefPrograms_.
Referenced by ProgramImageGenerator::loadPrograms().
|
staticprivate |
Creates a bit vector that encodes the given register file terminal.
socketCodes | The socket code table that contains the port codes. |
portCode | The port code that defines the encoding. |
registerIndex | The register index to be encoded. |
Definition at line 1588 of file CodeCompressorPlugin.cc.
References assert, PortCode::encoding(), PortCode::hasEncoding(), PortCode::indexWidth(), BitVector::pushBack(), PortCode::width(), and SocketCodeTable::width().
Referenced by encodeFUTerminal(), encodeIUTerminal(), encodeRFTerminal(), and encodeSlotField().
|
protected |
Starts generating new program image.
This function must be called always before starting to add instructions to the program image.
programName | The program of which to generate the image. |
InvalidData | If the program object model cannot be created. |
Definition at line 328 of file CodeCompressorPlugin.cc.
References __func__, TTAProgram::TPEFProgramFactory::build(), currentPOM_, currentTPEF_, Exception::errorMessage(), immediatesToRelocate_, initializeRelocations(), machine_, program, programBits_, terminalsToRelocate_, and tpefPrograms_.
Referenced by DEFAULT_Compressor::compress().
|
private |
Tells whether the given instruction starts at the beginning of MAU.
instruction | The instruction. |
Definition at line 1025 of file CodeCompressorPlugin.cc.
References allStartsAtBeginningOfMAU_, AssocTools::containsKey(), and instructionsAtBeginningOfMAU_.
Referenced by addInstruction().
|
private |
The offset of the instruction memory (the address of the first instruction).
Definition at line 283 of file CodeCompressorPlugin.hh.
Referenced by addInstruction(), and setMachine().
|
private |
Tells whether all the instructions starts at the beginning of MAU.
Definition at line 278 of file CodeCompressorPlugin.hh.
Referenced by setAllInstructionsToStartAtBeginningOfMAU(), and startsAtBeginningOfMAU().
|
private |
The binary encoding map.
Definition at line 269 of file CodeCompressorPlugin.hh.
Referenced by bemBits(), bemInstructionBits(), binaryEncoding(), firstMoveSlotIndex(), moveSlotCount(), moveSlotWidth(), setBEM(), and setMachine().
|
private |
The current program in POM.
Definition at line 264 of file CodeCompressorPlugin.hh.
Referenced by currentProgram(), encodeImmediateTerminal(), encodeLongImmediate(), initializeRelocations(), startNewProgram(), and ~CodeCompressorPlugin().
|
private |
The current program.
Definition at line 266 of file CodeCompressorPlugin.hh.
|
private |
The current TPEF.
Definition at line 262 of file CodeCompressorPlugin.hh.
Referenced by immediateTerminal(), initializeRelocations(), programImmediate(), and startNewProgram().
|
private |
Set of (long) immediates that refer to an instruction.
Definition at line 288 of file CodeCompressorPlugin.hh.
Referenced by encodeLongImmediate(), initializeRelocations(), and startNewProgram().
|
private |
A table of indexes used when encoding long immediates.
Definition at line 296 of file CodeCompressorPlugin.hh.
Referenced by bemBits(), bemInstructionBits(), and encodeLongImmediate().
|
private |
Contains the addresses of instructions.
Definition at line 299 of file CodeCompressorPlugin.hh.
Referenced by addInstruction(), and memoryAddress().
|
private |
Set of instructions that start at the beginning of MAU.
Definition at line 286 of file CodeCompressorPlugin.hh.
Referenced by setInstructionToStartAtBeginningOfMAU(), and startsAtBeginningOfMAU().
|
private |
The machine.
Definition at line 271 of file CodeCompressorPlugin.hh.
Referenced by machine(), setImemWidth(), setMachine(), and startNewProgram().
|
private |
The size of the minimum addressable unit.
Definition at line 280 of file CodeCompressorPlugin.hh.
Referenced by addInstruction(), imemMauWidth(), nextAddressablePositionFrom(), programBits(), setImemWidth(), and setMachine().
|
private |
Parameters for the plugin.
Definition at line 273 of file CodeCompressorPlugin.hh.
Referenced by hasParameter(), parameterValue(), and setParameters().
|
private |
The bits of the program.
Definition at line 276 of file CodeCompressorPlugin.hh.
Referenced by addInstruction(), programBits(), startNewProgram(), and ~CodeCompressorPlugin().
|
private |
Contains information to which instructions the immediates are referring to.
Definition at line 294 of file CodeCompressorPlugin.hh.
Referenced by bemBits(), bemInstructionBits(), and encodeLongImmediate().
|
private |
Set of (short) immediate terminals that refer to an instruction.
Definition at line 290 of file CodeCompressorPlugin.hh.
Referenced by encodeImmediateTerminal(), initializeRelocations(), and startNewProgram().
|
private |
Programs run in the machine.
Definition at line 260 of file CodeCompressorPlugin.hh.
Referenced by numberOfPrograms(), programElement(), setPrograms(), and startNewProgram().