#include <SimProgramBuilder.hh>
Creates InstructionMemory out of Program Object Model.
Definition at line 62 of file SimProgramBuilder.hh.
◆ SimProgramBuilder() [1/2]
SimProgramBuilder::SimProgramBuilder |
( |
| ) |
|
◆ ~SimProgramBuilder()
SimProgramBuilder::~SimProgramBuilder |
( |
| ) |
|
|
virtual |
◆ SimProgramBuilder() [2/2]
◆ build()
Builds the model of instruction memory ready to be simulated.
- Parameters
-
prog | Program from which the contents of instruction memory is built. |
state | The MachineState the program refers to. |
- Returns
- The created instruction memory, owned by client.
- Exceptions
-
IllegalProgram | If building fails for some reason. The exception message describes the reason. The message can be displayed in user interfaces as it's generated by SimulatorTextGenerator. |
Definition at line 472 of file SimProgramBuilder.cc.
494 if (currentInstruction->
size() > 0) {
497 processedInstruction);
501 processedInstruction);
508 (boost::format(
"Error while processing instruction %d "
509 "(with moves %s): %s")
References __func__, InstructionMemory::addExecutableInstruction(), InstructionMemory::addImplicitExecutableInstruction(), TTAProgram::Instruction::address(), POMDisassembler::disassemble(), Exception::errorMessage(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Address::location(), TTAProgram::Program::procedureAtIndex(), TTAProgram::Program::procedureCount(), processInstruction(), sequentialProgram_, TTAProgram::Instruction::size(), TTAProgram::Program::startAddress(), and TTAProgram::Program::targetProcessor().
Referenced by SimulationController::SimulationController().
◆ findGuardModel()
◆ operator=()
◆ processBidirTerminal()
Helper method for processing such terminals that can be both source and destination in the move.
- Parameters
-
theTerminal | The terminal to process. |
state | MachineState to fetch the state objects from. |
- Returns
- The StateData object created from the terminal.
- Exceptions
-
IllegalProgram | When the terminal is referring to illegal machine state or the terminal itself is illegal. |
Definition at line 111 of file SimProgramBuilder.cc.
114 if (theTerminal.
isGPR()) {
126 }
else if (theTerminal.
isFUPort()) {
134 "Could not find the FU port.");
136 std::string operationString =
"";
155 thePort->
name() + operationString,
177 std::string errorMsg =
References __func__, abortWithError, Exception::errorMessage(), TTAProgram::Terminal::index(), NullPortState::instance(), NullRegisterFileState::instance(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), TTAMachine::BaseFUPort::isOpcodeSetting(), TTAProgram::Terminal::isOpcodeSetting(), TTAMachine::Port::name(), TTAMachine::Component::name(), Operation::name(), TTAProgram::Terminal::operation(), TTAMachine::Port::parentUnit(), TTAProgram::Terminal::port(), MachineState::portState(), TTAProgram::Terminal::registerFile(), MachineState::registerFileState(), RegisterFileState::registerState(), StringTools::stringToLower(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_ILLEGAL_PROGRAM_OPCODE_NOT_FOUND, Texts::TXT_ILLEGAL_PROGRAM_PORT_STATE_NOT_FOUND, Texts::TXT_ILLEGAL_PROGRAM_RF_STATE_NOT_FOUND, and Texts::TXT_ILLEGAL_PROGRAM_UNKNOWN_MOVE_TERMINAL_TYPE.
Referenced by processMove(), and processSourceTerminal().
◆ processInstruction()
Processes a POM Instruction and produces an ExecutableInstruction.
- Parameters
-
instruction | The instruction to process. |
state | The MachineState the program refers to. |
- Returns
- The processed instruction.
- Exceptions
-
Definition at line 402 of file SimProgramBuilder.cc.
445 for (
int j = 0; j < instruction.
moveCount(); ++j) {
457 return processedInstruction;
References __func__, ExecutableInstruction::addExecutableMove(), ExecutableInstruction::addLongImmediateUpdateAction(), assert, TTAProgram::Immediate::destination(), POMDisassembler::disassemble(), Exception::errorMessage(), Exception::fileName(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), LongImmediateUnitState::immediateRegister(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), NullLongImmediateUnitState::instance(), TTAProgram::Terminal::isImmediateRegister(), Exception::lineNum(), MachineState::longImmediateUnitState(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAMachine::Component::name(), Exception::procedureName(), processMove(), SimulatorToolbox::textGenerator(), Texts::TXT_ILLEGAL_PROGRAM_IU_STATE_NOT_FOUND, TTAProgram::TerminalImmediate::value(), and TTAProgram::Immediate::value().
Referenced by build().
◆ processMove()
Processes a POM Move and produces an ExecutableMove.
- Parameters
-
move | The move to process. |
state | The MachineState the program refers to. |
- Returns
- The processed move.
- Exceptions
-
Definition at line 257 of file SimProgramBuilder.cc.
274 "Immediate of jump '%s' gets clipped due to the target "
275 "port being too narrow. Wrong execution would occur.")
278 __FILE__, __LINE__,
__func__, errorMsg);
286 "Immediate of jump '%s' gets clipped due to the target "
287 "port being too narrow. Wrong execution would occur.")
290 __FILE__, __LINE__,
__func__, errorMsg);
340 assert(immediateSource != NULL);
359 assert(immediateSource != NULL);
362 immediateSource, destination,
367 immediateSource, bus, destination,
375 *source, destination,
380 *source, bus, destination,
References __func__, assert, TTAProgram::Move::bus(), MachineState::busState(), TTAProgram::Move::destination(), findGuardModel(), TTAProgram::Terminal::functionUnit(), GCU_OPERATION_MOVES_VISIBLE_IN_BUS, TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), TTAMachine::Bus::immediateWidth(), NullBusState::instance(), TTAProgram::Move::isControlFlowMove(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isImmediate(), TTAMachine::Guard::isInverted(), TTAProgram::Move::isUnconditional(), TTAMachine::Component::name(), TTAProgram::Terminal::port(), processBidirTerminal(), processSourceTerminal(), MathTools::requiredBits(), MathTools::requiredBitsSigned(), sequentialProgram_, RegisterState::setValue(), TTAMachine::Bus::signExtends(), SimValue::signExtendTo(), SimValue::sLongWordValue(), TTAProgram::Move::source(), SimulatorToolbox::textGenerator(), TTAProgram::Move::toString(), Texts::TXT_ILLEGAL_PROGRAM_BUS_STATE_NOT_FOUND, SimValue::uLongWordValue(), TTAProgram::Terminal::value(), TTAMachine::Port::width(), TTAMachine::Bus::width(), and SimValue::zeroExtendTo().
Referenced by processInstruction().
◆ processSourceTerminal()
Helper method for processing source terminals.
- Parameters
-
theTerminal | The terminal to process. |
state | MachineState to fetch the state objects from. |
- Returns
- The StateData object created from the terminal.
- Exceptions
-
IllegalProgram | When the terminal is referring to illegal machine state or the terminal itself is illegal. |
Definition at line 194 of file SimProgramBuilder.cc.
References __func__, LongImmediateUnitState::immediateRegister(), TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), NullLongImmediateUnitState::instance(), TTAProgram::Terminal::isImmediateRegister(), MachineState::longImmediateUnitState(), TTAMachine::Component::name(), processBidirTerminal(), SimulatorToolbox::textGenerator(), Texts::TXT_ILLEGAL_PROGRAM_IU_STATE_NOT_FOUND, and Texts::TXT_ILLEGAL_PROGRAM_UNKNOWN_MOVE_TERMINAL_TYPE.
Referenced by processMove().
◆ sequentialProgram_
bool SimProgramBuilder::sequentialProgram_ |
|
private |
The documentation for this class was generated from the following files:
StateData * processSourceTerminal(const TTAProgram::Terminal &theTerminal, MachineState &state)
int immediateWidth() const
virtual bool isFUPort() const
@ TXT_ILLEGAL_PROGRAM_IU_STATE_NOT_FOUND
Text of the exception thrown when Immediate Unit state could not be found and there is instruction re...
std::string procedureName() const
LongImmediateUnitState & longImmediateUnitState(const std::string &name)
virtual TCEString name() const
@ TXT_ILLEGAL_PROGRAM_UNKNOWN_MOVE_TERMINAL_TYPE
Text of the exception thrown when the terminal type of a move is not regocnized.
void addImplicitExecutableInstruction(InstructionAddress addr, ExecutableInstruction *instruction)
virtual int index() const
SLongWord sLongWordValue() const
int procedureCount() const
Address startAddress() const
virtual const TTAMachine::RegisterFile & registerFile() const
PortState & portState(const std::string &portName, const std::string &fuName)
bool isUnconditional() const
virtual int width() const =0
Terminal & destination() const
const TTAMachine::Bus & bus() const
std::string toString() const
static NullPortState & instance()
virtual boost::format text(int textId)
virtual TCEString name() const
virtual bool isOpcodeSetting() const =0
virtual Operation & operation() const
const Procedure & procedureAtIndex(int index) const
std::string fileName() const
#define assert(condition)
virtual bool isImmediateRegister() const
#define abortWithError(message)
bool isControlFlowMove() const
GuardState & guardState(const TTAMachine::Guard &guard)
static NullGuardState & instance()
virtual int instructionCount() const
#define GCU_OPERATION_MOVES_VISIBLE_IN_BUS
BusState & busState(const std::string &name)
MoveGuard & guard() const
@ TXT_ILLEGAL_PROGRAM_PORT_STATE_NOT_FOUND
Text of the exception thrown when FUPortState could not be found and there is instruction referring t...
ULongWord uLongWordValue() const
virtual bool isGPR() const
virtual SimValue value() const
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
void addExecutableMove(ExecutableMove *move)
InstructionAddress location() const
static NullRegisterFileState & instance()
Immediate & immediate(int i) const
std::string errorMessage() const
virtual bool isOpcodeSetting() const
virtual const TTAMachine::FunctionUnit & functionUnit() const
static NullBusState & instance()
ExecutableInstruction * processInstruction(const TTAProgram::Instruction &instruction, MachineState &state)
@ TXT_ILLEGAL_PROGRAM_BUS_STATE_NOT_FOUND
Text of the exception thrown when FUPortState could not be found and there is instruction referring t...
void signExtendTo(int bitWidth)
static std::string disassemble(const TTAProgram::Move &move)
virtual bool isInverted() const
virtual RegisterState & registerState(int index)
virtual std::string name() const
int immediateCount() const
const ReadableState & findGuardModel(const TTAMachine::Guard &guard, MachineState &state)
TTAMachine::Machine & targetProcessor() const
virtual Instruction & instructionAtIndex(int index) const
Terminal & source() const
virtual const TTAMachine::Port & port() const
const TTAMachine::Guard & guard() const
virtual bool isImmediate() const
@ TXT_ILLEGAL_PROGRAM_OPCODE_NOT_FOUND
Text of the exception thrown when a port to be written is an opcode setting port and no opcode is fou...
ExecutableMove * processMove(const TTAProgram::Move &move, MachineState &state)
void addLongImmediateUpdateAction(LongImmUpdateAction *action)
StateData * processBidirTerminal(const TTAProgram::Terminal &theTerminal, MachineState &state)
void addExecutableInstruction(InstructionAddress addr, ExecutableInstruction *instruction)
@ TXT_ILLEGAL_PROGRAM_RF_STATE_NOT_FOUND
Text of the exception thrown when RegisterFileState could not be found and there is instruction refer...
virtual void setValue(const SimValue &value)
RegisterFileState & registerFileState(const std::string &name)
Unit * parentUnit() const