OpenASIP
2.0
|
#include <CompiledSimCodeGenerator.hh>
Classes | |
struct | DelayedAssignment |
Public Types | |
typedef std::set< std::string > | StringSet |
A type for std::string sets. More... | |
typedef std::map< InstructionAddress, InstructionAddress > | AddressMap |
A type for storing address-to-address combinations. More... | |
Public Member Functions | |
CompiledSimCodeGenerator (const TTAMachine::Machine &machine, const TTAProgram::Program &program, const TTASimulationController &controller, bool fuResourceConflictDetection, bool handleCycleEnd, bool dynamicCompilation, bool basicBlockPerFile=false, bool functionPerFile=true, const TCEString &globalSymbolPrefix="") | |
virtual | ~CompiledSimCodeGenerator () |
virtual void | generateToDirectory (const std::string &dirName) |
virtual StringSet | createdFiles () const |
virtual AddressMap | basicBlocks () const |
virtual ProcedureBBRelations | procedureBBRelations () const |
Static Public Member Functions | |
static TCETools::CIStringSet | supportedMemoryOperations () |
Private Types | |
typedef std::multimap< std::string, std::string > | OperationSymbolDeclarations |
A type for operation symbol declarations: 1=op.name 2=op.symbol. More... | |
typedef std::multimap< int, DelayedAssignment > | DelayedAssignments |
FU Result writes. More... | |
typedef std::map< std::string, int > | FUResultWrites |
typedef std::map< std::string, int > | SimValueSymbolDeclarations |
Type for SimValue symbol declarations: string=symbolname, int=width. More... | |
typedef std::map< std::string, int > | GuardPipeline |
Static Private Member Functions | |
static bool | isStoreOperation (const std::string &opName) |
static bool | isLoadOperation (const std::string &opName) |
Private Attributes | |
const TTAMachine::Machine & | machine_ |
The machine used for simulation. More... | |
const TTAProgram::Program & | program_ |
The simulated program. More... | |
const TTASimulationController & | simController_ |
The simulator frontend. More... | |
const TTAMachine::ControlUnit & | gcu_ |
GCU. More... | |
bool | handleCycleEnd_ |
Should we let frontend handle each cycle end. More... | |
bool | dynamicCompilation_ |
Is this a dynamic compiled simulation? More... | |
bool | basicBlockPerFile_ |
Should the generator generate only one basic block per code file. More... | |
bool | functionPerFile_ |
Should the generator start with a new file after function end. More... | |
SimValueSymbolDeclarations | declaredSymbols_ |
A list of all symbols that are declared after the program code is ready. More... | |
StringSet | declaredFunctions_ |
A set of all the declared functions. More... | |
StringSet | createdFiles_ |
A list of the code files created during the process. More... | |
OperationSymbolDeclarations | usedOperations_ |
A list of used operations. More... | |
int | instructionNumber_ |
Absolute instruction # being processed. More... | |
int | instructionCounter_ |
Istruction counter for checking how many instructions to put per file. More... | |
int | moveCounter_ |
How many moves have we been through with? More... | |
bool | isProcedureBegin_ |
Are we at the beginning of a new procedure? More... | |
const TTAProgram::Procedure * | currentProcedure_ |
Pointer to the current Procedure being processed. More... | |
InstructionAddress | lastInstructionOfBB_ |
last instruction of the current basic block More... | |
std::string | lastGuardBool_ |
name of the last used guard variable More... | |
std::map< std::string, std::string > | usedGuardSymbols_ |
Temporary list of the used guard bool symbols per instruction. More... | |
std::set< InstructionAddress > | exitPoints_ |
Program exit point addresses. More... | |
AddressMap | bbStarts_ |
The basic block map referred by start of the block as a key. More... | |
AddressMap | bbEnds_ |
The basic block map referred by end of the block as a key. More... | |
ProcedureBBRelations | procedureBBRelations_ |
Basic blocks relations to procedures and vice versa. More... | |
DelayedAssignments | delayedFUResultWrites_ |
Delayed FU Result assignments. More... | |
FUResultWrites | lastFUWrites_ |
Last known FU result writes. More... | |
OperationPool | operationPool_ |
The operation pool. More... | |
std::string | targetDirectory_ |
Directory where to write the source files of the engine. More... | |
std::string | className_ |
Name of the class to be created. More... | |
std::string | headerFile_ |
Header filename. More... | |
std::string | mainFile_ |
Main source filename. This includes the constructor and the simulateCycle(). More... | |
std::fstream | currentFile_ |
Current file being processed. More... | |
std::string | currentFileName_ |
Name of the current file being processed. More... | |
std::ostream * | os_ |
Current output stream i.e. the above file. More... | |
CompiledSimSymbolGenerator | symbolGen_ |
The symbol generator. More... | |
ConflictDetectionCodeGenerator | conflictDetectionGenerator_ |
Conflict detection code generator. More... | |
unsigned | maxInstructionsPerFile_ |
Maximum number of instructions per engine source code file, computed from the instruction width (bus count) to control simulation engine code size explosion with wider simulated machines. More... | |
unsigned | maxInstructionsPerSimulationFunction_ |
Max for each simulation function. More... | |
GuardPipeline | guardPipeline_ |
bool | needGuardPipeline_ |
TCEString | globalSymbolSuffix_ |
A class that generates C/C++ code from the given POM and MOM
Used for the compiled simulation
Definition at line 99 of file CompiledSimCodeGenerator.hh.
typedef std::map<InstructionAddress, InstructionAddress> CompiledSimCodeGenerator::AddressMap |
A type for storing address-to-address combinations.
Definition at line 104 of file CompiledSimCodeGenerator.hh.
|
private |
FU Result writes.
Definition at line 148 of file CompiledSimCodeGenerator.hh.
|
private |
Definition at line 149 of file CompiledSimCodeGenerator.hh.
|
private |
Definition at line 300 of file CompiledSimCodeGenerator.hh.
|
private |
A type for operation symbol declarations: 1=op.name 2=op.symbol.
Definition at line 145 of file CompiledSimCodeGenerator.hh.
|
private |
Type for SimValue symbol declarations: string=symbolname, int=width.
Definition at line 226 of file CompiledSimCodeGenerator.hh.
typedef std::set<std::string> CompiledSimCodeGenerator::StringSet |
A type for std::string sets.
Definition at line 102 of file CompiledSimCodeGenerator.hh.
CompiledSimCodeGenerator::CompiledSimCodeGenerator | ( | const TTAMachine::Machine & | machine, |
const TTAProgram::Program & | program, | ||
const TTASimulationController & | controller, | ||
bool | fuResourceConflictDetection, | ||
bool | handleCycleEnd, | ||
bool | dynamicCompilation, | ||
bool | basicBlockPerFile = false , |
||
bool | functionPerFile = true , |
||
const TCEString & | globalSymbolSuffix = "" |
||
) |
The constructor
Gets the settings for compiled simulation code generation.
machine | The machine to run the simulation on |
program | The simulated program |
controller | Compiled Simulation controller |
fuResourceConflictDetection | is the conflict detection on? |
handleCycleEnd | should we let frontend handle each cycle end |
basicBlockPerFile | Should we generate only one BB per code file? |
Definition at line 160 of file CompiledSimCodeGenerator.cc.
References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::ControlUnit::globalGuardLatency(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), TTAMachine::RegisterFile::guardLatency(), guardPipeline_, TTAMachine::Machine::Navigator< ComponentType >::item(), MachineInfo::longestGuardLatency(), machine, maxInstructionsPerFile_, maxInstructionsPerSimulationFunction_, needGuardPipeline_, TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), CompiledSimSymbolGenerator::registerSymbol(), and symbolGen_.
|
virtual |
|
private |
Copying not allowed.
|
private |
Adds a new declared symbol to the map
name | name of the symbol |
width | SimValue width |
Definition at line 909 of file CompiledSimCodeGenerator.cc.
References declaredSymbols_.
Referenced by generateHeaderAndMainCode().
|
private |
|
virtual |
Returns a list of basic blocks of the program
Definition at line 317 of file CompiledSimCodeGenerator.cc.
References bbEnds_, bbStarts_, and findBasicBlocks().
Referenced by CompiledSimController::reset().
|
virtual |
Returns a list of the created .cpp filenames
Definition at line 307 of file CompiledSimCodeGenerator.cc.
References createdFiles_.
|
private |
|
private |
Finds all basic blocks of the program and stores them in two std::maps
Big basic blocks are split to smaller ones to reduce the engine compilation memory consumption.
Definition at line 621 of file CompiledSimCodeGenerator.cc.
References bbEnds_, bbStarts_, TTAMachine::Machine::controlUnit(), TTAMachine::ControlUnit::delaySlots(), BasicBlockNode::isNormalBB(), Application::logStream(), machine_, maxInstructionsPerSimulationFunction_, BoostGraph< GraphNode, GraphEdge >::node(), BoostGraph< GraphNode, GraphEdge >::nodeCount(), BasicBlockNode::originalEndAddress(), BasicBlockNode::originalStartAddress(), TTAProgram::Program::procedure(), TTAProgram::Program::procedureCount(), and program_.
Referenced by basicBlocks(), and generateSimulationCode().
|
private |
Returns the output ports of a function unit
fu | The function unit |
Definition at line 1788 of file CompiledSimCodeGenerator.cc.
References TTAMachine::Port::isOutput(), TTAMachine::FunctionUnit::port(), and TTAMachine::Unit::portCount().
Referenced by generateFUOutputUpdater(), generateHeaderAndMainCode(), and updateDeclaredSymbolsList().
|
private |
Generates code for adding a result to FU's output port
Handles static latency simulation in case it is possible, otherwise reverts back to older dynamic model.
The case this function tracks is the following:
1) Instruction address > basic block start + latency 2) Trigger not inside a guard 3) Result must be ready in the same basic block 4) No overlapping writes of any kind
resultPort | FU result port to set the value to |
value | value to set as a result |
latency | latency of the operation |
Definition at line 1682 of file CompiledSimCodeGenerator.cc.
References bbEnds_, delayedFUResultWrites_, TTAProgram::Move::destination(), TTAProgram::Terminal::functionUnit(), CompiledSimSymbolGenerator::FUResultSymbol(), TTAProgram::Program::instructionAt(), instructionNumber_, TTAProgram::Terminal::isGPR(), TTAProgram::Move::isTriggering(), lastFUWrites_, lastGuardBool_, TTAMachine::FunctionUnit::maxLatency(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::BaseFUPort::parentUnit(), TTAProgram::Terminal::port(), CompiledSimSymbolGenerator::portSymbol(), program_, TTAProgram::Move::source(), and symbolGen_.
Referenced by generateLoadTrigger(), generateTriggerCode(), and handleOperationWithoutDag().
|
private |
Generates code for advancing clocks of various items per cycle
Definition at line 783 of file CompiledSimCodeGenerator.cc.
References ConflictDetectionCodeGenerator::advanceClockCode(), conflictDetectionGenerator_, generateGuardPipelineAdvance(), needGuardPipeline_, and os_.
Referenced by generateHeaderAndMainCode().
|
private |
Generates code for the class constructor in the main .cpp file.
Definition at line 513 of file CompiledSimCodeGenerator.cc.
References TTAMachine::FunctionUnit::addressSpace(), CompiledSimSymbolGenerator::basicBlockSymbol(), bbStarts_, className_, conflictDetectionGenerator_, TTAMachine::Machine::Navigator< ComponentType >::count(), createdFiles_, currentFile_, CompiledSimSymbolGenerator::DAMemorySymbol(), FileSystem::DIRECTORY_SEPARATOR, CompiledSimSymbolGenerator::disablePrefix(), DS, ConflictDetectionCodeGenerator::extraInitialization(), TTAMachine::Machine::functionUnitNavigator(), generateConstructorParameters(), generateFUOutputUpdater(), generateJumpTableCode(), generateSimulationGetter(), headerFile_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, mainFile_, TTAMachine::HWOperation::name(), ConflictDetectionCodeGenerator::notifyOfConflicts(), TTAMachine::FunctionUnit::operation(), CompiledSimSymbolGenerator::operationContextSymbol(), TTAMachine::FunctionUnit::operationCount(), CompiledSimSymbolGenerator::operationSymbol(), os_, symbolGen_, targetDirectory_, updateDeclaredSymbolsList(), and updateSymbolsMap().
Referenced by generateHeaderAndMainCode().
|
private |
Generates the parameter list for the constructor.
Definition at line 497 of file CompiledSimCodeGenerator.cc.
References className_, and os_.
Referenced by generateConstructorCode(), and generateHeaderAndMainCode().
|
private |
Generates a function that is used to update all FU outputs from the "result buffer".
Definition at line 721 of file CompiledSimCodeGenerator.cc.
References className_, TTAMachine::Machine::Navigator< ComponentType >::count(), CompiledSimSymbolGenerator::enablePrefix(), TTAMachine::Machine::functionUnitNavigator(), fuOutputPorts(), CompiledSimSymbolGenerator::FUResultSymbol(), generateFUResultRead(), globalSymbolSuffix_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, os_, CompiledSimSymbolGenerator::portSymbol(), and symbolGen_.
Referenced by generateConstructorCode().
|
private |
Generates code for reading FU results from result symbol to result port
destination | destination port symbol |
resultSymbol | results symbol |
Definition at line 1752 of file CompiledSimCodeGenerator.cc.
Referenced by generateFUOutputUpdater(), and generateInstruction().
|
private |
Generates the condition simulation code for a guarded move.
move | guarded move |
Definition at line 1089 of file CompiledSimCodeGenerator.cc.
References TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), CompiledSimSymbolGenerator::guardBoolSymbol(), TTAMachine::Guard::isInverted(), lastGuardBool_, TTAMachine::PortGuard::port(), CompiledSimSymbolGenerator::portSymbol(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), CompiledSimSymbolGenerator::registerSymbol(), symbolGen_, and usedGuardSymbols_.
Referenced by generateInstruction().
|
private |
Definition at line 1799 of file CompiledSimCodeGenerator.cc.
References guardPipeline_.
Referenced by generateAdvanceClockCode().
|
private |
Definition at line 1812 of file CompiledSimCodeGenerator.cc.
References guardPipeline_.
Referenced by generateHeaderAndMainCode().
|
private |
Generates code for reading a guard value before an instruction with moves guarded with the value is simulated.
move | guarded move |
Definition at line 1035 of file CompiledSimCodeGenerator.cc.
References TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), CompiledSimSymbolGenerator::guardBoolSymbol(), guardPipelineTopSymbol(), lastGuardBool_, needGuardPipeline_, TTAMachine::PortGuard::port(), CompiledSimSymbolGenerator::portSymbol(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), CompiledSimSymbolGenerator::registerSymbol(), symbolGen_, and usedGuardSymbols_.
Referenced by generateInstruction().
|
private |
Generates code for halting the simulation
message | Reason for the halt |
Definition at line 775 of file CompiledSimCodeGenerator.cc.
|
private |
Creates a header file to be used for all the .cpp files and the main source file which includes the constructor and the main simulation loop.
Initializes all variables required by the simulation
Sets up new SimValue variables for all the FUs, registers, FU pipeline stages and so on. Variables are created as member variables.
Definition at line 345 of file CompiledSimCodeGenerator.cc.
References addDeclaredSymbol(), TTAMachine::FunctionUnit::addressSpace(), TTAMachine::Machine::busNavigator(), CompiledSimSymbolGenerator::busSymbol(), className_, ConflictDetectionCodeGenerator::conflictDetectionEnabled(), conflictDetectionGenerator_, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), currentFile_, currentFileName_, CompiledSimSymbolGenerator::DAMemorySymbol(), FileSystem::DIRECTORY_SEPARATOR, CompiledSimSymbolGenerator::disablePrefix(), DS, TTAMachine::Machine::functionUnitNavigator(), fuOutputPorts(), CompiledSimSymbolGenerator::FUResultSymbol(), generateAdvanceClockCode(), generateConstructorCode(), generateConstructorParameters(), generateGuardPipelineVariables(), generateSymbolDeclarations(), globalSymbolSuffix_, headerFile_, CompiledSimSymbolGenerator::immediateRegisterSymbol(), TTAMachine::Machine::immediateUnitNavigator(), ConflictDetectionCodeGenerator::includes(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::HWOperation::name(), needGuardPipeline_, TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::FunctionUnit::operation(), CompiledSimSymbolGenerator::operationContextSymbol(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::FunctionUnit::operationPortCount(), CompiledSimSymbolGenerator::operationSymbol(), os_, CompiledSimSymbolGenerator::portSymbol(), TTAMachine::Machine::registerFileNavigator(), CompiledSimSymbolGenerator::registerSymbol(), TTAMachine::ControlUnit::specialRegisterPort(), TTAMachine::ControlUnit::specialRegisterPortCount(), ConflictDetectionCodeGenerator::symbolDeclaration(), symbolGen_, targetDirectory_, usedOperations_, TTAMachine::BaseFUPort::width(), TTAMachine::BaseRegisterFile::width(), and TTAMachine::Bus::width().
Referenced by generateToDirectory().
|
private |
Generates simulation code of the given instruction
instruction | instruction to generate the code from |
Definition at line 1136 of file CompiledSimCodeGenerator.cc.
References TTAProgram::Instruction::address(), ProcedureBBRelations::basicBlockFiles, basicBlockPerFile_, ProcedureBBRelations::basicBlockStarts, CompiledSimSymbolGenerator::basicBlockSymbol(), bbEnds_, bbStarts_, className_, ConflictDetectionCodeGenerator::conflictDetectionEnabled(), conflictDetectionGenerator_, AssocTools::containsKey(), CompiledSimMove::copyToBusCode(), createdFiles_, currentFile_, currentFileName_, currentProcedure_, declaredFunctions_, delayedFUResultWrites_, TTAProgram::Immediate::destination(), TTAProgram::Move::destination(), ConflictDetectionCodeGenerator::detectConflicts(), FileSystem::DIRECTORY_SEPARATOR, DS, CompiledSimSymbolGenerator::enablePrefix(), exitPoints_, functionPerFile_, TTAProgram::Terminal::functionUnit(), CompiledSimSymbolGenerator::FUResultSymbol(), generateFUResultRead(), generateGuardCondition(), generateGuardRead(), generateShutdownCode(), globalSymbolSuffix_, handleCycleEnd_, handleOperation(), handleRegisterWrite(), headerFile_, TTAProgram::TerminalFUPort::hwOperation(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), CompiledSimSymbolGenerator::immediateRegisterSymbol(), TTAProgram::Terminal::immediateUnit(), instructionCounter_, instructionNumber_, SimValue::intValue(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediateRegister(), isProcedureBegin_, isStoreOperation(), TTAProgram::Move::isTriggering(), TTAProgram::Move::isUnconditional(), lastFUWrites_, lastGuardBool_, TTAProgram::Program::lastInstruction(), lastInstructionOfBB_, TTAProgram::Address::location(), maxInstructionsPerFile_, TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), moveCounter_, CompiledSimSymbolGenerator::moveOperandSymbol(), TTAMachine::HWOperation::name(), TTAProgram::Procedure::name(), needGuardPipeline_, os_, TTAProgram::Terminal::port(), procedureBBRelations_, ProcedureBBRelations::procedureStart, program_, CompiledSimSymbolGenerator::registerSymbol(), TTAMachine::ImmediateUnit::signExtends(), TTAProgram::Move::source(), symbolGen_, targetDirectory_, SimValue::unsignedValue(), usedGuardSymbols_, TTAProgram::TerminalImmediate::value(), TTAProgram::Immediate::value(), and TTAMachine::Port::width().
Referenced by generateProcedureCode().
|
private |
Generates code that updates the jump table and finds out all the basic blocks
Definition at line 889 of file CompiledSimCodeGenerator.cc.
References CompiledSimSymbolGenerator::basicBlockSymbol(), bbStarts_, dynamicCompilation_, os_, and symbolGen_.
Referenced by generateConstructorCode().
|
private |
Generates a faster version of specific load triggers
op | The load operation (either ldw, ldq, ldh, ldhu, or ldqu) |
Definition at line 1617 of file CompiledSimCodeGenerator.cc.
References TTAMachine::FunctionUnit::addressSpace(), CompiledSimSymbolGenerator::DAMemorySymbol(), generateAddFUResult(), CompiledSimSymbolGenerator::generateTempVariable(), TTAMachine::HWOperation::latency(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), TTAMachine::HWOperation::parentUnit(), TTAMachine::HWOperation::port(), CompiledSimSymbolGenerator::portSymbol(), symbolGen_, Conversion::toString(), and TTAMachine::AddressSpace::width().
Referenced by generateTriggerCode().
|
private |
Generates a Makefile for compiling the simulation engine.
Definition at line 245 of file CompiledSimCodeGenerator.cc.
References CompiledSimCompiler::COMPILED_SIM_CPP_FLAGS, CompiledSimCompiler::COMPILED_SIM_SO_FLAGS, currentFileName_, FileSystem::DIRECTORY_SEPARATOR, Environment::includeDirPaths(), and targetDirectory_.
Referenced by generateToDirectory().
|
private |
Generates code for each instruction in a procedure
procedure | the procedure to generate code from |
InstanceNotFound | if the first instruction wasn't found |
Definition at line 691 of file CompiledSimCodeGenerator.cc.
References currentProcedure_, generateInstruction(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), instructionCounter_, instructionNumber_, and isProcedureBegin_.
Referenced by generateSimulationCode().
|
private |
Generates shutdown code for the given instruction address
address | Address location of the instruction. Will be saved in the PC |
Definition at line 710 of file CompiledSimCodeGenerator.cc.
References os_.
Referenced by generateInstruction().
|
private |
Generates the simulateCycle() function that is called outside the .so file
The generated function simulates one basic block at a time by calling the according basic block methods.
Definition at line 598 of file CompiledSimCodeGenerator.cc.
References currentFile_, currentFileName_, exitPoints_, findBasicBlocks(), TTASimulationController::findProgramExitPoints(), generateProcedureCode(), machine_, os_, TTAProgram::Program::procedure(), TTAProgram::Program::procedureCount(), program_, and simController_.
Referenced by generateToDirectory().
|
private |
Generates code for a C function that returns an instance of the compiled sim
Definition at line 749 of file CompiledSimCodeGenerator.cc.
References className_, globalSymbolSuffix_, and os_.
Referenced by generateConstructorCode().
|
private |
Generates a faster version of specific store triggers
o | The store operation (either stw, sth or stq) |
Definition at line 1588 of file CompiledSimCodeGenerator.cc.
References CompiledSimSymbolGenerator::DAMemorySymbol(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), TTAMachine::HWOperation::parentUnit(), TTAMachine::HWOperation::port(), CompiledSimSymbolGenerator::portSymbol(), and symbolGen_.
Referenced by generateTriggerCode().
|
private |
Generates declarations for all the symbols in the declared symbols -list
(SimValues, bool guards...)
Definition at line 874 of file CompiledSimCodeGenerator.cc.
References declaredSymbols_, CompiledSimSymbolGenerator::disablePrefix(), os_, and symbolGen_.
Referenced by generateHeaderAndMainCode().
|
virtual |
Generates compiled simulation code to the given directory.
directory | Directory where all the code is to be generated at |
IOException | if the directory could not be opened for writing |
Definition at line 231 of file CompiledSimCodeGenerator.cc.
References generateHeaderAndMainCode(), generateMakefile(), generateSimulationCode(), headerFile_, mainFile_, and targetDirectory_.
Referenced by CompiledSimController::reset().
|
private |
Generates code for calling triggered operations
op | The operation to be triggered |
Definition at line 1501 of file CompiledSimCodeGenerator.cc.
References __func__, OperationDAGConverter::createSimulationCode(), Operation::dag(), generateAddFUResult(), generateLoadTrigger(), generateStoreTrigger(), CompiledSimSymbolGenerator::generateTempVariable(), TTAMachine::Port::isInput(), isLoadOperation(), TTAMachine::Port::isOutput(), isStoreOperation(), TTAMachine::HWOperation::latency(), TTAMachine::HWOperation::name(), OperationPool::operation(), operationPool_, TTAMachine::HWOperation::port(), CompiledSimSymbolGenerator::portSymbol(), symbolGen_, and Conversion::toString().
Referenced by handleOperation().
|
private |
Definition at line 1824 of file CompiledSimCodeGenerator.cc.
References assert, guardPipeline_, TTAMachine::Component::name(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::RegisterGuard::registerIndex(), DisassemblyRegister::registerName(), and Conversion::toString().
Referenced by generateGuardRead().
|
private |
Generates code for a jump operation
op | A jump or call operation |
Definition at line 921 of file CompiledSimCodeGenerator.cc.
References assert, TTAMachine::ControlUnit::delaySlots(), gcu_, instructionNumber_, TTAMachine::HWOperation::name(), TTAMachine::HWOperation::port(), CompiledSimSymbolGenerator::portSymbol(), CompiledSimSymbolGenerator::returnAddressSymbol(), and symbolGen_.
Referenced by handleOperation(), and handleOperationWithoutDag().
|
private |
Generates code for a triggered operation.
op | The triggered operation |
Definition at line 941 of file CompiledSimCodeGenerator.cc.
References Operation::dagCount(), generateTriggerCode(), handleJump(), handleOperationWithoutDag(), TTAMachine::HWOperation::latency(), TTAMachine::HWOperation::name(), OperationPool::operation(), CompiledSimSymbolGenerator::operationContextSymbol(), operationPool_, TTAMachine::HWOperation::parentUnit(), and symbolGen_.
Referenced by generateInstruction().
|
private |
Generates code for a triggered operation that has no DAG available
op | The triggered operation |
Definition at line 974 of file CompiledSimCodeGenerator.cc.
References generateAddFUResult(), CompiledSimSymbolGenerator::generateTempVariable(), handleJump(), TTAMachine::Port::isOutput(), TTAMachine::HWOperation::latency(), TTAMachine::HWOperation::name(), CompiledSimSymbolGenerator::operationContextSymbol(), CompiledSimSymbolGenerator::operationSymbol(), TTAMachine::HWOperation::parentUnit(), TTAMachine::HWOperation::port(), CompiledSimSymbolGenerator::portSymbol(), symbolGen_, and TTAMachine::BaseFUPort::width().
Referenced by handleOperation().
|
private |
Definition at line 1838 of file CompiledSimCodeGenerator.cc.
References guardPipeline_.
Referenced by generateInstruction().
|
staticprivate |
|
staticprivate |
Definition at line 1878 of file CompiledSimCodeGenerator.cc.
Referenced by generateInstruction(), and generateTriggerCode().
|
private |
Returns the maximum possible latency from the FUs & GCU
Definition at line 1769 of file CompiledSimCodeGenerator.cc.
References TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::ControlUnit::globalGuardLatency(), TTAMachine::Machine::Navigator< ComponentType >::item(), and machine_.
|
private |
Assignment not allowed.
|
virtual |
Returns a struct of basic blocks and their corresponding code files
Definition at line 330 of file CompiledSimCodeGenerator.cc.
References procedureBBRelations_.
Referenced by CompiledSimController::reset().
|
static |
Returns list of all supported memory accessing operations for compiled simulation.
Definition at line 1868 of file CompiledSimCodeGenerator.cc.
|
private |
Updates the declared symbols list after the program code is generated.
Generates constructor calls for each declared symbol.
Definition at line 799 of file CompiledSimCodeGenerator.cc.
References TTAMachine::FunctionUnit::addressSpace(), conflictDetectionGenerator_, TTAMachine::Machine::Navigator< ComponentType >::count(), CompiledSimSymbolGenerator::DAMemorySymbol(), declaredSymbols_, CompiledSimSymbolGenerator::disablePrefix(), TTAMachine::Machine::functionUnitNavigator(), fuOutputPorts(), CompiledSimSymbolGenerator::FUResultSymbol(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::FunctionUnit::maxLatency(), TTAMachine::Component::name(), os_, symbolGen_, Conversion::toString(), ConflictDetectionCodeGenerator::updateSymbolDeclarations(), and usedOperations_.
Referenced by generateConstructorCode().
|
private |
Updates the Symbols map of the CompiledSimulation class
Definition at line 859 of file CompiledSimCodeGenerator.cc.
References declaredSymbols_, and os_.
Referenced by generateConstructorCode().
|
private |
Should the generator generate only one basic block per code file.
Definition at line 221 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction().
|
mutableprivate |
The basic block map referred by end of the block as a key.
Definition at line 260 of file CompiledSimCodeGenerator.hh.
Referenced by basicBlocks(), findBasicBlocks(), generateAddFUResult(), and generateInstruction().
|
mutableprivate |
The basic block map referred by start of the block as a key.
Definition at line 258 of file CompiledSimCodeGenerator.hh.
Referenced by basicBlocks(), findBasicBlocks(), generateConstructorCode(), generateInstruction(), and generateJumpTableCode().
|
private |
Name of the class to be created.
Definition at line 274 of file CompiledSimCodeGenerator.hh.
Referenced by generateConstructorCode(), generateConstructorParameters(), generateFUOutputUpdater(), generateHeaderAndMainCode(), generateInstruction(), and generateSimulationGetter().
|
private |
Conflict detection code generator.
Definition at line 290 of file CompiledSimCodeGenerator.hh.
Referenced by generateAdvanceClockCode(), generateConstructorCode(), generateHeaderAndMainCode(), generateInstruction(), and updateDeclaredSymbolsList().
|
private |
A list of the code files created during the process.
Definition at line 233 of file CompiledSimCodeGenerator.hh.
Referenced by createdFiles(), generateConstructorCode(), and generateInstruction().
|
private |
Current file being processed.
Definition at line 280 of file CompiledSimCodeGenerator.hh.
Referenced by generateConstructorCode(), generateHeaderAndMainCode(), generateInstruction(), and generateSimulationCode().
|
private |
Name of the current file being processed.
Definition at line 282 of file CompiledSimCodeGenerator.hh.
Referenced by generateHeaderAndMainCode(), generateInstruction(), generateMakefile(), and generateSimulationCode().
|
private |
Pointer to the current Procedure being processed.
Definition at line 246 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction(), and generateProcedureCode().
|
private |
A set of all the declared functions.
Definition at line 231 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction().
|
private |
A list of all symbols that are declared after the program code is ready.
Definition at line 228 of file CompiledSimCodeGenerator.hh.
Referenced by addDeclaredSymbol(), generateSymbolDeclarations(), updateDeclaredSymbolsList(), and updateSymbolsMap().
|
private |
Delayed FU Result assignments.
Definition at line 264 of file CompiledSimCodeGenerator.hh.
Referenced by generateAddFUResult(), and generateInstruction().
|
private |
Is this a dynamic compiled simulation?
Definition at line 219 of file CompiledSimCodeGenerator.hh.
Referenced by generateJumpTableCode().
|
private |
Program exit point addresses.
Definition at line 255 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction(), and generateSimulationCode().
|
private |
Should the generator start with a new file after function end.
Definition at line 223 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction().
|
private |
|
private |
Definition at line 305 of file CompiledSimCodeGenerator.hh.
Referenced by generateFUOutputUpdater(), generateHeaderAndMainCode(), generateInstruction(), and generateSimulationGetter().
|
private |
Definition at line 301 of file CompiledSimCodeGenerator.hh.
Referenced by CompiledSimCodeGenerator(), generateGuardPipelineAdvance(), generateGuardPipelineVariables(), guardPipelineTopSymbol(), and handleRegisterWrite().
|
private |
Should we let frontend handle each cycle end.
Definition at line 217 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction().
|
private |
Header filename.
Definition at line 276 of file CompiledSimCodeGenerator.hh.
Referenced by generateConstructorCode(), generateHeaderAndMainCode(), generateInstruction(), and generateToDirectory().
|
private |
Istruction counter for checking how many instructions to put per file.
Definition at line 240 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction(), and generateProcedureCode().
|
private |
Absolute instruction # being processed.
Definition at line 238 of file CompiledSimCodeGenerator.hh.
Referenced by generateAddFUResult(), generateInstruction(), generateProcedureCode(), and handleJump().
|
private |
Are we at the beginning of a new procedure?
Definition at line 244 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction(), and generateProcedureCode().
|
private |
Last known FU result writes.
Definition at line 266 of file CompiledSimCodeGenerator.hh.
Referenced by generateAddFUResult(), and generateInstruction().
|
private |
name of the last used guard variable
Definition at line 251 of file CompiledSimCodeGenerator.hh.
Referenced by generateAddFUResult(), generateGuardCondition(), generateGuardRead(), and generateInstruction().
|
private |
last instruction of the current basic block
Definition at line 249 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction().
|
private |
The machine used for simulation.
Definition at line 208 of file CompiledSimCodeGenerator.hh.
Referenced by findBasicBlocks(), generateConstructorCode(), generateFUOutputUpdater(), generateHeaderAndMainCode(), generateSimulationCode(), maxLatency(), and updateDeclaredSymbolsList().
|
private |
Main source filename. This includes the constructor and the simulateCycle().
Definition at line 278 of file CompiledSimCodeGenerator.hh.
Referenced by generateConstructorCode(), and generateToDirectory().
|
private |
Maximum number of instructions per engine source code file, computed from the instruction width (bus count) to control simulation engine code size explosion with wider simulated machines.
Definition at line 296 of file CompiledSimCodeGenerator.hh.
Referenced by CompiledSimCodeGenerator(), and generateInstruction().
|
private |
Max for each simulation function.
Definition at line 298 of file CompiledSimCodeGenerator.hh.
Referenced by CompiledSimCodeGenerator(), and findBasicBlocks().
|
private |
How many moves have we been through with?
Definition at line 242 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction().
|
private |
Definition at line 303 of file CompiledSimCodeGenerator.hh.
Referenced by CompiledSimCodeGenerator(), generateAdvanceClockCode(), generateGuardRead(), generateHeaderAndMainCode(), and generateInstruction().
|
private |
The operation pool.
Definition at line 269 of file CompiledSimCodeGenerator.hh.
Referenced by generateTriggerCode(), and handleOperation().
|
private |
Current output stream i.e. the above file.
Definition at line 284 of file CompiledSimCodeGenerator.hh.
Referenced by generateAdvanceClockCode(), generateConstructorCode(), generateConstructorParameters(), generateFUOutputUpdater(), generateHeaderAndMainCode(), generateInstruction(), generateJumpTableCode(), generateShutdownCode(), generateSimulationCode(), generateSimulationGetter(), generateSymbolDeclarations(), updateDeclaredSymbolsList(), and updateSymbolsMap().
|
private |
Basic blocks relations to procedures and vice versa.
Definition at line 262 of file CompiledSimCodeGenerator.hh.
Referenced by generateInstruction(), and procedureBBRelations().
|
private |
The simulated program.
Definition at line 210 of file CompiledSimCodeGenerator.hh.
Referenced by findBasicBlocks(), generateAddFUResult(), generateInstruction(), and generateSimulationCode().
|
private |
The simulator frontend.
Definition at line 212 of file CompiledSimCodeGenerator.hh.
Referenced by generateSimulationCode().
|
private |
The symbol generator.
Definition at line 287 of file CompiledSimCodeGenerator.hh.
Referenced by CompiledSimCodeGenerator(), generateAddFUResult(), generateConstructorCode(), generateFUOutputUpdater(), generateGuardCondition(), generateGuardRead(), generateHeaderAndMainCode(), generateInstruction(), generateJumpTableCode(), generateLoadTrigger(), generateStoreTrigger(), generateSymbolDeclarations(), generateTriggerCode(), handleJump(), handleOperation(), handleOperationWithoutDag(), and updateDeclaredSymbolsList().
|
private |
Directory where to write the source files of the engine.
Definition at line 272 of file CompiledSimCodeGenerator.hh.
Referenced by generateConstructorCode(), generateHeaderAndMainCode(), generateInstruction(), generateMakefile(), and generateToDirectory().
|
private |
Temporary list of the used guard bool symbols per instruction.
Definition at line 253 of file CompiledSimCodeGenerator.hh.
Referenced by generateGuardCondition(), generateGuardRead(), and generateInstruction().
|
private |
A list of used operations.
Definition at line 235 of file CompiledSimCodeGenerator.hh.
Referenced by generateHeaderAndMainCode(), and updateDeclaredSymbolsList().