OpenASIP
2.0
|
#include <ProgramImageGenerator.hh>
Public Types | |
enum | OutputFormat { BINARY, ASCII, ARRAY, MIF, VHDL, COE, HEX, BIN2N } |
Different output formats of images. More... | |
typedef std::map< std::string, TPEF::Binary * > | TPEFMap |
Public Member Functions | |
ProgramImageGenerator () | |
virtual | ~ProgramImageGenerator () |
void | loadCompressorPlugin (const std::string &fileName) |
void | loadCompressorParameters (CodeCompressorPlugin::ParameterTable parameters) |
void | loadPrograms (TPEFMap programs) |
void | loadMachine (const TTAMachine::Machine &machine) |
void | loadBEM (const BinaryEncoding &bem) |
void | generateProgramImage (const std::string &programName, std::ostream &stream, OutputFormat format, int mausPerLine=0) |
void | generateDataImage (const std::string &programName, TPEF::Binary &program, const std::string &addressSpace, std::ostream &stream, OutputFormat format, int mausPerLine, bool usePregeneratedImage) |
void | generateDecompressor (std::ostream &stream, TCEString entityStr) |
int | imemMauWidth () const |
CodeCompressorPlugin & | compressor () |
void | setEntityName (const std::string &entity) |
void | writeDataSection (TPEF::Binary &program, BitVector &bitVector, const std::string &addressSpace, TPEF::Section §ion) |
Static Public Member Functions | |
static std::vector< std::string > | availableCompressors () |
static void | printCompressorDescription (const std::string &fileName, std::ostream &stream) |
Private Types | |
typedef std::set< TPEF::Binary * > | ProgramSet |
Typedef for program set. More... | |
Private Member Functions | |
TPEF::InstructionElement * | relocTarget (const TPEF::Binary &program, const TPEF::DataSection &dataSection, Word dataSectionOffset) const |
Static Private Member Functions | |
static CodeCompressorPlugin * | createCompressor (const std::string &fileName, PluginTools &pluginTool) |
Private Attributes | |
CodeCompressorPlugin * | compressor_ |
The code compressor. More... | |
std::string | entityName_ |
Toplevel entity name. More... | |
PluginTools | pluginTool_ |
The plugin tool. More... | |
The main class of program image generator module.
This class provides the interface that is available to different user interfaces.
Definition at line 67 of file ProgramImageGenerator.hh.
|
private |
Typedef for program set.
Definition at line 121 of file ProgramImageGenerator.hh.
typedef std::map<std::string, TPEF::Binary*> ProgramImageGenerator::TPEFMap |
Definition at line 81 of file ProgramImageGenerator.hh.
Different output formats of images.
Enumerator | |
---|---|
BINARY | Real binary format. |
ASCII | ASCII 1's and 0's. |
ARRAY | ASCII 1's and 0's in array form. |
MIF | MIF Memory Initialization File. |
VHDL | Array as a Vhdl package. |
COE | COE memory initialization format. |
HEX | HEX memory initialization format. |
BIN2N | Binary format padded to 2**n. |
Definition at line 71 of file ProgramImageGenerator.hh.
ProgramImageGenerator::ProgramImageGenerator | ( | ) |
The constructor.
program | The program. |
bem | The binary encoding map. |
machine | The machine. |
Definition at line 91 of file ProgramImageGenerator.cc.
|
virtual |
|
static |
Returns a vector containing paths to the compressors available.
Definition at line 609 of file ProgramImageGenerator.cc.
References Environment::codeCompressorPaths(), FileSystem::directoryContents(), FileSystem::fileExists(), FileSystem::fileExtension(), and FileSystem::fileIsDirectory().
Referenced by main().
|
inline |
Definition at line 106 of file ProgramImageGenerator.hh.
References compressor_.
Referenced by ProGe::RV32MicroCodeGenerator::constructBInstructions(), ProGe::RV32MicroCodeGenerator::constructIInstructions(), ProGe::RV32MicroCodeGenerator::constructRInstructions(), ProGe::RV32MicroCodeGenerator::constructSInstructions(), ProGe::RV32MicroCodeGenerator::constructUJInstructions(), ProGe::RV32MicroCodeGenerator::generateNOP(), and printCompressorDescription().
|
staticprivate |
Creates the code compressor from the given dynamic module.
fileName | Name of the file. |
pluginTool | The plugin tool to use. |
FileNotFound | If the given file is not found from the search paths of code compressor plugins. |
DynamicLibraryException | If the dynamic library cannot be opened. |
Definition at line 666 of file ProgramImageGenerator.cc.
References PluginTools::addSearchPath(), Environment::codeCompressorPaths(), FileSystem::fileExists(), PluginTools::importSymbol(), and PluginTools::registerModule().
Referenced by loadCompressorPlugin(), and printCompressorDescription().
void ProgramImageGenerator::generateDataImage | ( | const std::string & | programName, |
TPEF::Binary & | program, | ||
const std::string & | addressSpace, | ||
std::ostream & | stream, | ||
OutputFormat | format, | ||
int | mausPerLine, | ||
bool | usePregeneratedImage | ||
) |
Generates the data image of the given address space to the given output stream in the given format.
program | The program of which data image is generated. |
addressSpace | The address space. |
stream | The output stream. |
format | The output format. |
mausPerLine | Tells how many MAUs of data is generated on one line. |
usePregeneratedImage | Tells whether use the program image that was previously generated for relocation of data elements. |
InvalidData | If tried to use pregenerated program but it has not been generated or if the given program is not in the program set loaded or if machine is not loaded or if is does not have the given address space. |
OutOfRange | If the given MAUs per line is not positive. |
Definition at line 404 of file ProgramImageGenerator.cc.
References __func__, TTAMachine::Machine::addressSpaceNavigator(), ARRAY, ASCII, assert, BIN2N, BINARY, COE, CodeCompressorPlugin::compress(), compressor_, entityName_, Exception::errorMessage(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), HEX, TTAMachine::Machine::Navigator< ComponentType >::item(), CodeCompressorPlugin::machine(), MIF, program, VHDL, TTAMachine::AddressSpace::width(), writeDataSection(), and BitImageWriter::writeImage().
Referenced by main().
void ProgramImageGenerator::generateDecompressor | ( | std::ostream & | stream, |
TCEString | entityStr | ||
) |
Generates the decompressor to the given output stream.
Note! The program image should have been generated at first. Otherwise this may not function properly.
stream | The output stream. |
entityStr | The entity string used to make HDL entity/component names unique for multiprocessor designs. |
Definition at line 592 of file ProgramImageGenerator.cc.
References compressor_, and CodeCompressorPlugin::generateDecompressor().
Referenced by createCompressor().
void ProgramImageGenerator::generateProgramImage | ( | const std::string & | programName, |
std::ostream & | stream, | ||
OutputFormat | format, | ||
int | mausPerLine = 0 |
||
) |
Generates the program image to the given output stream in the given format.
If the output is in ASCII format, mausPerLine parameter defines the number of MAUs printed per line. If 0 is given, each instruction is printed on different line.
stream | The output stream. |
format | The output format. |
mausPerLine | If the output is ASCII format, defines the number of MAUs printed per line. |
InvalidData | If machine or BEM is not loaded or if they are erroneous or if the given program is not in the program set. |
OutOfRange | If mausPerLine is negative. |
Definition at line 185 of file ProgramImageGenerator.cc.
References __func__, TTAMachine::FunctionUnit::addressSpace(), ARRAY, ASCII, assert, BIN2N, BINARY, CodeCompressorPlugin::binaryEncoding(), TTAMachine::Machine::busNavigator(), COE, CodeCompressorPlugin::compress(), compressor_, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), CodeCompressorPlugin::currentProgram(), entityName_, HEX, TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::Program::instructionCount(), TTAProgram::Program::instructionVector(), TTAProgram::Terminal::isAddress(), TTAProgram::Terminal::isImmediate(), TTAProgram::Terminal::isInstructionAddress(), TTAProgram::Instruction::isNOP(), Application::logStream(), CodeCompressorPlugin::machine(), MIF, TTAProgram::Program::moveAt(), TTAProgram::Program::moveCount(), SimValue::sIntWordValue(), TTAProgram::Move::source(), TTAProgram::Program::targetProcessor(), TTAProgram::TerminalImmediate::value(), TTAProgram::Immediate::value(), TTAProgram::Terminal::value(), Application::verboseLevel(), VHDL, TTAMachine::AddressSpace::width(), BinaryEncoding::width(), and BitImageWriter::writeImage().
Referenced by RemoteController::loadIMemImage(), and main().
int ProgramImageGenerator::imemMauWidth | ( | ) | const |
Asks the instruction memory mau width from code compressor plugin and returns it
Definition at line 739 of file ProgramImageGenerator.cc.
References compressor_, and CodeCompressorPlugin::imemMauWidth().
Referenced by main().
void ProgramImageGenerator::loadBEM | ( | const BinaryEncoding & | bem | ) |
Sets the binary encoding map used when generating the program image.
bem | The binary encoding map. |
Definition at line 162 of file ProgramImageGenerator.cc.
References compressor_, and CodeCompressorPlugin::setBEM().
Referenced by RemoteController::loadIMemImage(), main(), and ProGe::RV32MicroCodeGenerator::RV32MicroCodeGenerator().
void ProgramImageGenerator::loadCompressorParameters | ( | CodeCompressorPlugin::ParameterTable | parameters | ) |
Loads the given code compressor plugin parameters to the plugin.
parameters | The parameters. |
Definition at line 127 of file ProgramImageGenerator.cc.
References compressor_, and CodeCompressorPlugin::setParameters().
Referenced by main().
void ProgramImageGenerator::loadCompressorPlugin | ( | const std::string & | fileName | ) |
Loads the code compressor plugin from the given object file.
fileName | The file name. |
FileNotFound | If the given file is not found from the search paths of code compressor plugins. |
DynamicLibraryException | If the dynamic library cannot be opened. |
Definition at line 114 of file ProgramImageGenerator.cc.
References compressor_, createCompressor(), and pluginTool_.
Referenced by main().
void ProgramImageGenerator::loadMachine | ( | const TTAMachine::Machine & | machine | ) |
Sets the machine which executes the programs.
machine | The machine. |
Definition at line 151 of file ProgramImageGenerator.cc.
References compressor_, machine, and CodeCompressorPlugin::setMachine().
Referenced by RemoteController::loadIMemImage(), main(), and ProGe::RV32MicroCodeGenerator::RV32MicroCodeGenerator().
void ProgramImageGenerator::loadPrograms | ( | TPEFMap | programs | ) |
Loads the programs to be generated to the compressor plugin.
programs | The programs. |
Definition at line 140 of file ProgramImageGenerator.cc.
References compressor_, and CodeCompressorPlugin::setPrograms().
Referenced by RemoteController::loadIMemImage(), and main().
|
static |
Loads the code compressor plugin from the given file and prints its description to the given stream.
fileName | The code compressor plugin file. |
stream | The output stream. |
FileNotFound | If the given file is not found from the search paths of code compressor plugins. |
DynamicLibraryException | If the dynamic library cannot be opened. |
Definition at line 645 of file ProgramImageGenerator.cc.
References compressor(), createCompressor(), and CodeCompressorPlugin::printDescription().
Referenced by main().
|
private |
Returns an InstructionElement that is relocation target of the data in data section at the given offset. Returns NULL if the data doesn't need to be altered.
dataSection | The data section, |
dataSectionOffset | The offset. |
Definition at line 694 of file ProgramImageGenerator.cc.
References assert, TPEF::RelocElement::destination(), TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::RelocElement::location(), TPEF::Chunk::offset(), program, and TPEF::RelocSection::referencedSection().
Referenced by writeDataSection().
void ProgramImageGenerator::setEntityName | ( | const std::string & | entity | ) |
Definition at line 746 of file ProgramImageGenerator.cc.
References entityName_.
Referenced by main().
void ProgramImageGenerator::writeDataSection | ( | TPEF::Binary & | program, |
BitVector & | bitVector, | ||
const std::string & | addressSpace, | ||
TPEF::Section & | section | ||
) |
Definition at line 510 of file ProgramImageGenerator.cc.
References __func__, TPEF::Section::aSpace(), TPEF::DataSection::byte(), TPEF::StringSection::chunk2String(), compressor_, CodeCompressorPlugin::currentProgram(), TPEF::CodeSection::indexOfInstruction(), TTAProgram::Program::instructionAt(), TTAMachine::Machine::isLittleEndian(), TPEF::DataSection::length(), CodeCompressorPlugin::machine(), CodeCompressorPlugin::memoryAddress(), TPEF::ASpaceElement::name(), program, BitVector::pushBack(), relocTarget(), and TPEF::Section::startingAddress().
Referenced by generateDataImage().
|
private |
The code compressor.
Definition at line 131 of file ProgramImageGenerator.hh.
Referenced by compressor(), generateDataImage(), generateDecompressor(), generateProgramImage(), imemMauWidth(), loadBEM(), loadCompressorParameters(), loadCompressorPlugin(), loadMachine(), loadPrograms(), writeDataSection(), and ~ProgramImageGenerator().
|
private |
Toplevel entity name.
Definition at line 133 of file ProgramImageGenerator.hh.
Referenced by generateDataImage(), generateProgramImage(), and setEntityName().
|
private |
The plugin tool.
Definition at line 135 of file ProgramImageGenerator.hh.
Referenced by loadCompressorPlugin().