OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MachineStateBuilder Class Reference

#include <MachineStateBuilder.hh>

Collaboration diagram for MachineStateBuilder:
Collaboration graph

Public Member Functions

 MachineStateBuilder (bool detailedSimulationModel=false)
 
virtual ~MachineStateBuilder ()
 
MachineStatebuild (const TTAMachine::Machine &machine, MemorySystem &memSys)
 
MachineStatebuild (const TTAMachine::Machine &machine, MemorySystem &memSys, FUConflictDetectorIndex &detectors, bool throwWhenConflict=true)
 
MachineStatebuild (const TTAMachine::Machine &machine, MemorySystem &memSys, StateLocator &locator)
 

Private Member Functions

 MachineStateBuilder (const MachineStateBuilder &)
 Copying not allowed. More...
 
MachineStateBuilderoperator= (const MachineStateBuilder &)
 Assignment not allowed. More...
 
MachineStatebuildMachineState (const TTAMachine::Machine &machine, MemorySystem &memSys, StateLocator &locator)
 
void addPortToFU (MachineState *machineState, TTAMachine::BaseFUPort *port, FUState *state, TTAMachine::FunctionUnit *fu, StateLocator &locator)
 
void addPortToFU (MachineState *machineState, TTAMachine::BaseFUPort *port, FUState *state, TTAMachine::FunctionUnit *fu, StateLocator &locator, SimValue &sharedRegister)
 
void bindPortsToOperands (OperationExecutor &executor, TTAMachine::HWOperation &hwOperation, MachineState &machineState, FUState &state, TTAMachine::FunctionUnit &unit)
 
void addVirtualOpcodeSettingPortsToFU (MachineState &machineState, FUState &state, TTAMachine::FunctionUnit &unit)
 

Private Attributes

FUConflictDetectorIndexdetectors_
 The FU resource conflict detectors. They are needed while building the machine state model. More...
 
bool throwWhenConflict_
 True in case the built model should throw an exception in case of a resource conflict. More...
 
bool detailedSimulationModel_
 Set to true in case should build a detailed model which simulates FU stages, possibly with an external system-level model. More...
 

Detailed Description

Builds MachineState from Machine Object Model.

Definition at line 62 of file MachineStateBuilder.hh.

Constructor & Destructor Documentation

◆ MachineStateBuilder() [1/2]

MachineStateBuilder::MachineStateBuilder ( bool  detailedSimulationModel = false)

Constructor.

Definition at line 84 of file MachineStateBuilder.cc.

84  :
85  throwWhenConflict_(true),
86  detailedSimulationModel_(detailedSimulationModel) {
87 }

◆ ~MachineStateBuilder()

MachineStateBuilder::~MachineStateBuilder ( )
virtual

Destructor.

Definition at line 92 of file MachineStateBuilder.cc.

92  {
93 }

◆ MachineStateBuilder() [2/2]

MachineStateBuilder::MachineStateBuilder ( const MachineStateBuilder )
private

Copying not allowed.

Member Function Documentation

◆ addPortToFU() [1/2]

void MachineStateBuilder::addPortToFU ( MachineState machineState,
TTAMachine::BaseFUPort port,
FUState state,
TTAMachine::FunctionUnit fu,
StateLocator locator 
)
private

Adds a port that does not share a register to FU.

Parameters
machineStateMachine state which is built.
portPort to be added.
stateFUState in which port is added.
fuFU of which FUState is build from.
locatorStateLocator.

Definition at line 644 of file MachineStateBuilder.cc.

649  {
650  addPortToFU(
651  machineState, port, state, unit, locator, NullSimValue::instance());
652 }

References NullSimValue::instance().

Referenced by buildMachineState().

Here is the call graph for this function:

◆ addPortToFU() [2/2]

void MachineStateBuilder::addPortToFU ( MachineState machineState,
TTAMachine::BaseFUPort port,
FUState state,
TTAMachine::FunctionUnit fu,
StateLocator locator,
SimValue sharedRegister 
)
private

Adds a port that shares a register to FU.

Parameters
machineStateMachine state which is built.
portPort to be added.
stateFUState in which port is added.
fuFU of which FUState is build from.
locatorStateLocator.
sharedRegisterThe register the FUPort shares, if any. If this is set to NullSimValue then a new register (SimValue) is created for the FUPort.

Definition at line 510 of file MachineStateBuilder.cc.

516  {
517 
518  bool inputPort = false;
519  // a shortcut for figuring whether the port shares a register (in practice,
520  // connected to the return address register)
521  const bool sharesRegister = (&sharedRegister != &NullSimValue::instance());
522 
523  // figure out the direction of the port
524  if (port->inputSocket() != NULL) {
525  inputPort = true;
526  } else if (port->outputSocket() != NULL) {
527  inputPort = false;
528  } else {
529  // Find out the direction of the port using operation<->port
530  // connections. This way we can simulate also individual function
531  // units which are not connected to any socket.
532  const TTAMachine::FunctionUnit& parentFU = *port->parentUnit();
533 
534  // find out an operation that is connected to this port
535  bool operationBindingFound = false;
536  const TTAMachine::FUPort* fuPort =
537  dynamic_cast<TTAMachine::FUPort*>(port);
538  for (int i = 0; fuPort != NULL && !operationBindingFound &&
539  i < parentFU.operationCount(); ++i) {
540  const TTAMachine::HWOperation& operation = *parentFU.operation(i);
541  if (!operation.isBound(*fuPort))
542  continue;
543 
544  const TTAMachine::ExecutionPipeline* pipe = operation.pipeline();
545 
546  if (pipe == NULL)
547  continue;
548  // find out if there's a R/W pipeline component connected to
549  // the port
550  for (int cycle = 0; cycle < pipe->latency(); ++cycle) {
551  if (pipe->isPortRead(*fuPort, cycle)) {
552  inputPort = true;
553  operationBindingFound = true;
554  break;
555  } else if (pipe->isPortWritten(*fuPort, cycle)) {
556  inputPort = false;
557  operationBindingFound = true;
558  break;
559  } else {
560  // no pipeline connection to this port at this cycle
561  continue;
562  }
563  }
564  }
565 
566  if (!operationBindingFound) {
568  << "warning: Cannot determine the direction of port "
569  << port->parentUnit()->name() + "." + port->name()
570  << ", omitting it from the simulation model."
571  << std::endl;
572  return;
573  }
574  }
575 
576  if (inputPort) {
577  if (port->isOpcodeSetting()) {
578 
579  TriggeringInputPortState* triggerPort = NULL;
580  if (sharesRegister) {
581  triggerPort =
582  new TriggeringInputPortState(*state, sharedRegister);
583  } else {
584  triggerPort =
585  new TriggeringInputPortState(*state, port->width());
586  }
587 
588  state->addInputPortState(*triggerPort);
589  machineState->addPortState(
590  triggerPort, port->name(), port->parentUnit()->name());
591  locator.addState(*port, *triggerPort);
592 
593  } else if (port->isTriggering()) {
594 
595  TriggeringInputPortState* input = NULL;
596  if (sharesRegister) {
597  input = new TriggeringInputPortState(*state, sharedRegister);
598  } else {
599  input = new TriggeringInputPortState(*state, port->width());
600  }
601 
602  machineState->addPortState(
603  input, port->name(), port->parentUnit()->name());
604  state->addInputPortState(*input);
605  locator.addState(*port, *input);
606  } else {
607  InputPortState* input = NULL;
608  if (sharesRegister) {
609  input = new InputPortState(*state, sharedRegister);
610  } else {
611  input = new InputPortState(*state, port->width());
612  }
613  machineState->addPortState(
614  input, port->name(), port->parentUnit()->name());
615  state->addInputPortState(*input);
616  locator.addState(*port, *input);
617  }
618  } else {
619  // port is an output port
620 
621  OutputPortState* output = NULL;
622  if (sharesRegister) {
623  output = new OutputPortState(*state, sharedRegister);
624  } else {
625  output = new OutputPortState(*state, port->width());
626  }
627  machineState->addPortState(
628  output, port->name(), port->parentUnit()->name());
629  state->addOutputPortState(*output);
630  locator.addState(*port, *output);
631  }
632 }

References FUState::addInputPortState(), FUState::addOutputPortState(), MachineState::addPortState(), StateLocator::addState(), TTAMachine::Port::inputSocket(), NullSimValue::instance(), TTAMachine::HWOperation::isBound(), TTAMachine::BaseFUPort::isOpcodeSetting(), TTAMachine::ExecutionPipeline::isPortRead(), TTAMachine::ExecutionPipeline::isPortWritten(), TTAMachine::BaseFUPort::isTriggering(), TTAMachine::ExecutionPipeline::latency(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::Port::outputSocket(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::HWOperation::pipeline(), Application::warningStream(), and TTAMachine::BaseFUPort::width().

Here is the call graph for this function:

◆ addVirtualOpcodeSettingPortsToFU()

void MachineStateBuilder::addVirtualOpcodeSettingPortsToFU ( MachineState machineState,
FUState state,
TTAMachine::FunctionUnit unit 
)
private

Adds the virtual opcode-setting ports to the FU.

Expects that the FU is otherwise completely built.

Parameters
machineStateThe machine state to use.
stateThe FUState to add the ports.
unitThe static function unit data from MOM.
Todo:
Improve this and change the naming to alu.add.p1, or save the virtual ports to different index!

Definition at line 368 of file MachineStateBuilder.cc.

371  {
372  for (int i = 0; i < unit.portCount(); i++) {
373  BaseFUPort& port = *unit.port(i);
374 
375  if (port.isOpcodeSetting()) {
376 
377  PortState* p = &machineState.portState(port.name(), unit.name());
379 
380  TriggeringInputPortState* triggerPort =
381  dynamic_cast<TriggeringInputPortState*>(p);
382 
383  if (triggerPort == NULL) {
384  throw IllegalMachine(
385  __FILE__, __LINE__, __func__,
386  std::string("The opcode setting port ") + port.name() +
387  " is not triggering.");
388  }
389 
390  // create a virtual port for all the opcodes that can be set
391  // through the port
392  for (int j = 0; j < unit.operationCount(); j++) {
393 
394  HWOperation& hwOp = *unit.operation(j);
396  Operation* operation = NULL;
397  try {
398  operation = &pool.operation(hwOp.name().c_str());
399  } catch (const DynamicLibraryException& e) {
400  throw IllegalMachine(
401  __FILE__, __LINE__, __func__, e.errorMessage());
402  }
403 
404  if (operation->isNull()) {
405  throw IllegalMachine(
406  __FILE__, __LINE__, __func__,
407  (boost::format(
408  "Operation '%s' not found in OSAL.") %
409  hwOp.name()).str());
410  }
411 
412  // add executor for the operation
413  OperationExecutor* executor = NULL;
414  GCUState* gcu = dynamic_cast<GCUState*>(&state);
415  if (gcu != NULL) {
416  executor = new TransportPipeline(*gcu);
417  } else {
418  if (hwOp.latency() == 0) {
419  throw IllegalMachine(
420  __FILE__, __LINE__, __func__,
421  std::string("Operation ") + hwOp.name() + " in " +
422  unit.name() + " has latency of 0, which is not " +
423  "supported by TCE.");
424  }
425 
426  bool conflictDetection = false;
427  if (detectors_ != NULL && unit.needsConflictDetection()) {
428  FUConflictDetectorIndex::iterator detectorI =
429  detectors_->find(unit.name());
430 
431  if (detectorI != detectors_->end()) {
432  conflictDetection = true;
433 
434  FUResourceConflictDetector& detector =
435  *(*detectorI).second;
436  // the FU has conflict detection enabled, always
437  // create a new ConflictDetectingOperationExecutor
438  // for all opcodes.
439  executor = new ConflictDetectingOperationExecutor(
440  detector, detector.operationID(hwOp.name()),
441  state, hwOp, throwWhenConflict_);
442  }
443  }
444 
445  if (!conflictDetection) {
446  bool multiLatencyOp = false;
447  const int totalLatency = hwOp.latency();
448  for (int i = operation->numberOfInputs() + 1;
449  i <= operation->numberOfInputs() +
450  operation->numberOfOutputs(); ++i) {
451  if (hwOp.latency(i) < totalLatency) {
452  multiLatencyOp = true;
453  break;
454  }
455  }
456 
457  if (multiLatencyOp || detailedSimulationModel_) {
458  executor = new MultiLatencyOperationExecutor(
459  state, hwOp);
460  } else if (totalLatency == 1) {
461  executor = new OneCycleOperationExecutor(state);
462  } else {
463  executor =
465  totalLatency, state);
466  }
467  }
468  }
469 
471  *executor, hwOp, machineState, state, unit);
472 
473  state.addOperationExecutor(*executor, *operation);
474  machineState.addOperationExecutor(executor);
475 
476  // virtual ports are put to the index with names like
477  // p1.add
478  /// @todo Improve this and change the naming to alu.add.p1,
479  /// or save the virtual ports to different index!
480  string name =
481  port.name() + "." +
482  StringTools::stringToLower(operation->name());
483  OperationExecutor* finalExecutor =
484  state.executor(*operation);
485  assert(executor != NULL);
488  *operation, *finalExecutor, state, *triggerPort);
489  state.addInputPortState(*opcodePort);
490  machineState.addPortState(
491  opcodePort, name, port.parentUnit()->name());
492  }
493  }
494  }
495 }

References __func__, FUState::addInputPortState(), FUState::addOperationExecutor(), MachineState::addOperationExecutor(), MachineState::addPortState(), assert, bindPortsToOperands(), detailedSimulationModel_, detectors_, Exception::errorMessage(), FUState::executor(), NullPortState::instance(), Operation::isNull(), TTAMachine::BaseFUPort::isOpcodeSetting(), TTAMachine::HWOperation::latency(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), TTAMachine::Component::name(), Operation::name(), TTAMachine::FunctionUnit::needsConflictDetection(), Operation::numberOfInputs(), Operation::numberOfOutputs(), OperationPool::operation(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), FUResourceConflictDetector::operationID(), SimulatorToolbox::operationPool(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::FunctionUnit::port(), TTAMachine::Unit::portCount(), MachineState::portState(), StringTools::stringToLower(), and throwWhenConflict_.

Referenced by buildMachineState().

Here is the call graph for this function:

◆ bindPortsToOperands()

void MachineStateBuilder::bindPortsToOperands ( OperationExecutor executor,
TTAMachine::HWOperation hwOperation,
MachineState machineState,
FUState state,
TTAMachine::FunctionUnit unit 
)
private

Binds ports to operands.

Operands are bound for OperationExecutor which is not yet inserted to the machine.

Parameters
executorOperationExecutor to bind the ports for.
machineStateMachineState to be built.
stateFUState of which ports are bound.
unitFunctionUnit that owns the ports that are bound.
Exceptions
IllegalMachineIf binding fails.

Definition at line 667 of file MachineStateBuilder.cc.

669  {
671  Operation& op = pool.operation(hwOperation.name().c_str());
672 
673  if (&op == &NullOperation::instance()) {
674  const string msg =
676  Texts::TXT_OPERATION_X_NOT_FOUND) % hwOperation.name()).str();
677  throw IllegalMachine(__FILE__, __LINE__, __func__, msg);
678  }
679 
680  const int operandCount = op.numberOfInputs() + op.numberOfOutputs();
681  for (int j = 1; j <= operandCount; j++) {
682 
683  FUPort* port = hwOperation.port(j);
684  if (port == NULL) {
685  // unused operand
686  continue;
687  }
688  PortState& portState =
689  machineState.portState(port->name(), unit.name());
690  try {
691  executor.addBinding(j, portState);
692  } catch (const Exception& e) {
693  string msg = "Problems while building machine state: " +
694  e.errorMessage();
695  throw IllegalMachine(__FILE__, __LINE__, __func__, msg);
696  }
697  }
698 }

References __func__, OperationExecutor::addBinding(), Exception::errorMessage(), NullOperation::instance(), TTAMachine::HWOperation::name(), TTAMachine::Port::name(), TTAMachine::Component::name(), Operation::numberOfInputs(), Operation::numberOfOutputs(), OperationPool::operation(), SimulatorToolbox::operationPool(), TTAMachine::HWOperation::port(), MachineState::portState(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), and Texts::TXT_OPERATION_X_NOT_FOUND.

Referenced by addVirtualOpcodeSettingPortsToFU().

Here is the call graph for this function:

◆ build() [1/3]

MachineState * MachineStateBuilder::build ( const TTAMachine::Machine machine,
MemorySystem memSys 
)

Builds machine state from given machine.

Parameters
machineThe machine of which machine state is built from.
memSysMemory system instance.
Returns
The created machine state.
Exceptions
IllegalMachineIf machine state building fails.

Definition at line 104 of file MachineStateBuilder.cc.

106  {
107 
108  StateLocator locator;
109  detectors_ = NULL;
110  return buildMachineState(machine, memSys, locator);
111 }

References buildMachineState(), detectors_, and machine.

Referenced by RFTestbenchGenerator::createMachineState(), FUTestbenchGenerator::createMachineState(), and SimulationController::SimulationController().

Here is the call graph for this function:

◆ build() [2/3]

MachineState * MachineStateBuilder::build ( const TTAMachine::Machine machine,
MemorySystem memSys,
FUConflictDetectorIndex detectors,
bool  throwWhenConflict = true 
)

Builds machine state from given machine.

This method allows giving an index of FU resource conflict detectors to create a model that detects FU resource conflicts.

Parameters
machineThe machine of which machine state is built from.
memSysMemory system instance.
detectorsThe FU resource conflict detectors.
throwWhenConflictBuilds a model that throws an exception in case of resource conflict is detected.
Returns
The created machine state.
Exceptions
IllegalMachineIf machine state building fails.

Definition at line 128 of file MachineStateBuilder.cc.

132  {
133 
134  StateLocator locator;
135  detectors_ = &detectors;
136  throwWhenConflict_ = throwWhenConflict;
137  return buildMachineState(machine, memSys, locator);
138 }

References buildMachineState(), detectors_, machine, and throwWhenConflict_.

Here is the call graph for this function:

◆ build() [3/3]

MachineState * MachineStateBuilder::build ( const TTAMachine::Machine machine,
MemorySystem memSys,
StateLocator locator 
)

Builds machine state from given machine.

Parameters
machineMachine of which machine state is build from.
memSysMemory system.
locatorIndexes states with components as keys.
Returns
The created machine state instance.
Exceptions
IllegalMachineIf machine state building fails.

Definition at line 150 of file MachineStateBuilder.cc.

153  {
154  detectors_ = NULL;
155  return buildMachineState(machine, memSys, locator);
156 }

References buildMachineState(), detectors_, and machine.

Here is the call graph for this function:

◆ buildMachineState()

MachineState * MachineStateBuilder::buildMachineState ( const TTAMachine::Machine machine,
MemorySystem memSys,
StateLocator locator 
)
private

Builds MachineState from given Machine.

Parameters
machineMachine.
memSysMemory system.
locatorState locator.
Returns
The created MachineState.
Exceptions
IllegalMachineIf machine state building fails.
Todo:
This assumes that natural word width of GCU is 4 MAUs!

Definition at line 168 of file MachineStateBuilder.cc.

171  {
172 
173  MachineState* machineState = new MachineState();
174 
175  int controlUnitGuardLatency = 0;
176  if (machine.controlUnit() != NULL) {
177  ControlUnit* controlUnit = machine.controlUnit();
178  /// @todo This assumes that natural word width of GCU is 4 MAUs!
179  int WordWidthInMAUs = 1;
180 
181  GCUState* gcu = new GCUState(
182  (controlUnit->delaySlots() + 1), 4, controlUnit->delaySlots(),
183  WordWidthInMAUs);
184  machineState->addGCUState(gcu);
185  controlUnitGuardLatency = controlUnit->globalGuardLatency();
186 
187  for (int i = 0; i < controlUnit->portCount(); i++) {
188  BaseFUPort* port = controlUnit->port(i);
189  if (controlUnit->hasReturnAddressPort() &&
190  dynamic_cast<SpecialRegisterPort*>(port) ==
191  controlUnit->returnAddressPort()) {
192  // return address port shares a register with the RA register
193  // which resides inside the GCU
194  addPortToFU(
195  machineState, port, gcu, controlUnit, locator,
196  gcu->returnAddressRegister());
197  } else {
198  addPortToFU(machineState, port, gcu, controlUnit, locator);
199  }
200  }
201  addVirtualOpcodeSettingPortsToFU(*machineState, *gcu, *controlUnit);
202  }
203 
205 
207  AddressSpaceCheck addressSpaceCheck(pool);
208  MachineCheckResults results;
209  if (!addressSpaceCheck.check(machine, results)) {
210  string msg = "Problems while building machine state: " +
211  results.error(0).second;
212  throw IllegalMachine(__FILE__, __LINE__, __func__, msg) ;
213  }
214 
215  for (int i = 0; i < FUs.count(); i++) {
216  FunctionUnit* unit = FUs.item(i);
217  FUState* state = NULL;
218  if (unit->addressSpace() != NULL) {
219  try {
220  MemorySystem::MemoryPtr memory = memSys.memory(*unit->addressSpace());
221  state = new MemoryAccessingFUState(unit->name(), *memory.get());
222  } catch (const Exception& i) {
223  string msg = "Problems building machine state: " +
224  i.errorMessage();
225  throw IllegalMachine(__FILE__, __LINE__, __func__, msg);
226  }
227  } else {
228  state = new FUState(unit->name());
229  }
230  machineState->addFUState(state, unit->name());
231 
232  for (int k = 0; k < unit->portCount(); k++) {
233  BaseFUPort* port = unit->port(k);
234  addPortToFU(machineState, port, state, unit, locator);
235  }
236 
237  addVirtualOpcodeSettingPortsToFU(*machineState, *state, *unit);
238  }
239 
240  Machine::ImmediateUnitNavigator immediateUnits =
242  for (int i = 0; i < immediateUnits.count(); i++) {
243  LongImmediateUnitState* state =
245  immediateUnits.item(i)->numberOfRegisters(),
246  immediateUnits.item(i)->latency(),
247  immediateUnits.item(i)->name(),
248  immediateUnits.item(i)->width(),
249  immediateUnits.item(i)->extensionMode() ==
251 
252  machineState->addLongImmediateUnitState(
253  state, immediateUnits.item(i)->name());
254  }
255 
257  for (int i = 0; i < registers.count(); i++) {
258  RegisterFile* regFile = registers.item(i);
259  RegisterFileState* state = NULL;
260  state = new RegisterFileState(
261  regFile->numberOfRegisters(), regFile->width(),
262  regFile->zeroRegister());
263  machineState->addRegisterFileState(state, regFile->name());
264  }
265 
267  for (int b = 0; b < busses.count(); ++b) {
268  Bus* bus = busses.item(b);
269  BusState* state = new BusState(bus->width());
270  machineState->addBusState(state, bus->name());
271  locator.addState(*bus, *state);
272 
273  for (int i = 0; i < bus->guardCount(); ++i) {
274  const Guard* guard = bus->guard(i);
275  assert(guard != NULL);
276 
277  const PortGuard* portGuard =
278  dynamic_cast<const PortGuard*>(guard);
279  const RegisterGuard* registerGuard =
280  dynamic_cast<const RegisterGuard*>(guard);
281  const UnconditionalGuard* uncondGuard =
282  dynamic_cast<const UnconditionalGuard*>(guard);
283 
284  int guardLatency = controlUnitGuardLatency;
285  ReadableState* targetRegister = NULL;
286  if (portGuard != NULL) {
287 
288  const BaseFUPort* thePort =
289  dynamic_cast<const BaseFUPort*>(portGuard->port());
290 
291  assert(thePort != NULL);
292 
293  PortState& port =
294  machineState->portState(
295  thePort->name(), thePort->parentUnit()->name());
296 
297  if (&port == &NullPortState::instance()) {
298  throw IllegalMachine(
299  __FILE__, __LINE__, __func__,
302  str());
303  }
304  targetRegister = &port;
305 
306  // 0-cycle guard latency means reading the value directly
307  // from the port.
308  if (guardLatency == 0) {
309  GuardState* guardState =
310  new DirectGuardState(*targetRegister);
311  machineState->addGuardState(guardState, *guard);
312  continue;
313  }
314  } else if (registerGuard != NULL) {
315 
316  RegisterFileState& unit =
317  machineState->registerFileState(
318  registerGuard->registerFile()->name());
319 
320  if (&unit == &NullRegisterFileState::instance()) {
321  throw IllegalMachine(
322  __FILE__, __LINE__, __func__,
325  ).str());
326  }
327  guardLatency += registerGuard->registerFile()->guardLatency();
328 
329  targetRegister =
330  &unit.registerState(registerGuard->registerIndex());
331 
332  // Values of registers are written later than guard are evaluated,
333  // so in case of 1-cycle register guard, can use direct guard
334  // without any pipeline.
335  if (guardLatency == 1) {
336  GuardState* guardState =
337  new DirectGuardState(*targetRegister);
338  machineState->addGuardState(guardState, *guard);
339  continue;
340  }
341  } else if (uncondGuard != NULL) {
342  // do not create a state object for unconditional guards,
343  // it makes no sense
344  continue;
345  } else {
346  abortWithError("Unknown guard type.");
347  }
348 
349  GuardState* guardState =
350  new GuardState(*targetRegister, guardLatency);
351  machineState->addGuardState(guardState, *guard);
352  }
353  }
354 
355  return machineState;
356 }

References __func__, abortWithError, MachineState::addBusState(), MachineState::addFUState(), MachineState::addGCUState(), MachineState::addGuardState(), MachineState::addLongImmediateUnitState(), addPortToFU(), MachineState::addRegisterFileState(), TTAMachine::FunctionUnit::addressSpace(), StateLocator::addState(), addVirtualOpcodeSettingPortsToFU(), assert, TTAMachine::Machine::busNavigator(), AddressSpaceCheck::check(), TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::ControlUnit::delaySlots(), MachineCheckResults::error(), Exception::errorMessage(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::ControlUnit::globalGuardLatency(), TTAMachine::Bus::guard(), TTAMachine::Bus::guardCount(), TTAMachine::RegisterFile::guardLatency(), TTAMachine::ControlUnit::hasReturnAddressPort(), TTAMachine::Machine::immediateUnitNavigator(), NullPortState::instance(), NullRegisterFileState::instance(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, MemorySystem::memory(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), SimulatorToolbox::operationPool(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::FunctionUnit::port(), TTAMachine::PortGuard::port(), TTAMachine::Unit::portCount(), MachineState::portState(), TTAMachine::RegisterGuard::registerFile(), TTAMachine::Machine::registerFileNavigator(), MachineState::registerFileState(), TTAMachine::RegisterGuard::registerIndex(), RegisterFileState::registerState(), TTAMachine::ControlUnit::returnAddressPort(), GCUState::returnAddressRegister(), TTAMachine::Machine::SIGN, SimulatorToolbox::textGenerator(), Texts::TXT_ILLEGAL_PROGRAM_PORT_STATE_NOT_FOUND, Texts::TXT_ILLEGAL_PROGRAM_RF_STATE_NOT_FOUND, TTAMachine::BaseRegisterFile::width(), TTAMachine::Bus::width(), and TTAMachine::RegisterFile::zeroRegister().

Referenced by build().

Here is the call graph for this function:

◆ operator=()

MachineStateBuilder& MachineStateBuilder::operator= ( const MachineStateBuilder )
private

Assignment not allowed.

Member Data Documentation

◆ detailedSimulationModel_

bool MachineStateBuilder::detailedSimulationModel_
private

Set to true in case should build a detailed model which simulates FU stages, possibly with an external system-level model.

Definition at line 128 of file MachineStateBuilder.hh.

Referenced by addVirtualOpcodeSettingPortsToFU().

◆ detectors_

FUConflictDetectorIndex* MachineStateBuilder::detectors_
private

The FU resource conflict detectors. They are needed while building the machine state model.

Definition at line 120 of file MachineStateBuilder.hh.

Referenced by addVirtualOpcodeSettingPortsToFU(), and build().

◆ throwWhenConflict_

bool MachineStateBuilder::throwWhenConflict_
private

True in case the built model should throw an exception in case of a resource conflict.

Definition at line 124 of file MachineStateBuilder.hh.

Referenced by addVirtualOpcodeSettingPortsToFU(), and build().


The documentation for this class was generated from the following files:
TTAMachine::Guard
Definition: Guard.hh:55
OperationPool::operation
Operation & operation(const char *name)
Definition: OperationPool.cc:99
TTAMachine::Port::inputSocket
virtual Socket * inputSocket() const
Definition: Port.cc:261
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
MachineState::addOperationExecutor
void addOperationExecutor(OperationExecutor *executor)
Definition: MachineState.cc:339
TTAMachine::PortGuard::port
FUPort * port() const
OperationExecutor::addBinding
void addBinding(int io, PortState &port)
Definition: OperationExecutor.cc:67
GCUState
Definition: GCUState.hh:46
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTAMachine::HWOperation
Definition: HWOperation.hh:52
OpcodeSettingVirtualInputPortState
Definition: OpcodeSettingVirtualInputPortState.hh:51
TTAMachine::RegisterGuard::registerIndex
int registerIndex() const
TTAMachine::BaseFUPort::parentUnit
FunctionUnit * parentUnit() const
Definition: BaseFUPort.cc:96
TTAMachine::Bus::width
int width() const
Definition: Bus.cc:149
MachineState::portState
PortState & portState(const std::string &portName, const std::string &fuName)
Definition: MachineState.cc:175
MachineStateBuilder::addVirtualOpcodeSettingPortsToFU
void addVirtualOpcodeSettingPortsToFU(MachineState &machineState, FUState &state, TTAMachine::FunctionUnit &unit)
Definition: MachineStateBuilder.cc:368
ReadableState
Definition: ReadableState.hh:41
TTAMachine::Bus
Definition: Bus.hh:53
TTAMachine::BaseFUPort
Definition: BaseFUPort.hh:44
FUState::addOperationExecutor
virtual void addOperationExecutor(OperationExecutor &opExec, Operation &op)
Definition: FUState.cc:232
NullSimValue::instance
static SimValue & instance()
Definition: SimValue.cc:1642
MachineStateBuilder::bindPortsToOperands
void bindPortsToOperands(OperationExecutor &executor, TTAMachine::HWOperation &hwOperation, MachineState &machineState, FUState &state, TTAMachine::FunctionUnit &unit)
Definition: MachineStateBuilder.cc:667
Operation::numberOfInputs
virtual int numberOfInputs() const
Definition: Operation.cc:192
SimulatorToolbox::operationPool
static OperationPool & operationPool()
Definition: SimulatorToolbox.cc:62
FUState::addInputPortState
virtual void addInputPortState(PortState &port)
Definition: FUState.cc:211
BusState
Definition: BusState.hh:48
NullPortState::instance
static NullPortState & instance()
Definition: PortState.cc:96
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
TTAMachine::Machine::Navigator::count
int count() const
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
NullOperation::instance
static NullOperation & instance()
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
OutputPortState
Definition: OutputPortState.hh:44
TTAMachine::BaseFUPort::isOpcodeSetting
virtual bool isOpcodeSetting() const =0
TTAMachine::BaseRegisterFile::numberOfRegisters
virtual int numberOfRegisters() const
MemorySystem::MemoryPtr
boost::shared_ptr< Memory > MemoryPtr
Definition: MemorySystem.hh:57
FUState
Definition: FUState.hh:58
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::UnconditionalGuard
Definition: Guard.hh:180
TTAMachine::HWOperation::port
virtual FUPort * port(int operand) const
Definition: HWOperation.cc:320
TTAMachine::FUPort
Definition: FUPort.hh:46
MachineState::addPortState
void addPortState(PortState *state, const std::string &name, const std::string &fuName)
Definition: MachineState.cc:280
InputPortState
Definition: InputPortState.hh:46
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
MachineState
Definition: MachineState.hh:61
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
GCUState::returnAddressRegister
SimValue & returnAddressRegister()
FUResourceConflictDetector
Definition: FUResourceConflictDetector.hh:45
TTAMachine::SpecialRegisterPort
Definition: SpecialRegisterPort.hh:48
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
TTAMachine::RegisterGuard
Definition: Guard.hh:137
MachineStateBuilder::throwWhenConflict_
bool throwWhenConflict_
True in case the built model should throw an exception in case of a resource conflict.
Definition: MachineStateBuilder.hh:124
DirectGuardState
Definition: GuardState.hh:123
Texts::TXT_ILLEGAL_PROGRAM_PORT_STATE_NOT_FOUND
@ TXT_ILLEGAL_PROGRAM_PORT_STATE_NOT_FOUND
Text of the exception thrown when FUPortState could not be found and there is instruction referring t...
Definition: SimulatorTextGenerator.hh:121
TTAMachine::ExecutionPipeline::isPortWritten
bool isPortWritten(const FUPort &port, int cycle) const
Definition: ExecutionPipeline.cc:386
TTAMachine::HWOperation::isBound
bool isBound(const FUPort &port) const
Definition: HWOperation.cc:338
MemoryAccessingFUState
Definition: MemoryAccessingFUState.hh:44
__func__
#define __func__
Definition: Application.hh:67
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
MachineStateBuilder::buildMachineState
MachineState * buildMachineState(const TTAMachine::Machine &machine, MemorySystem &memSys, StateLocator &locator)
Definition: MachineStateBuilder.cc:168
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
MachineState::addGCUState
void addGCUState(GCUState *state)
Definition: MachineState.cc:244
StateLocator
Definition: StateLocator.hh:51
NullRegisterFileState::instance
static NullRegisterFileState & instance()
Definition: RegisterFileState.cc:111
MachineCheckResults
Definition: MachineCheckResults.hh:46
TTAMachine::ControlUnit::delaySlots
int delaySlots() const
Exception
Definition: Exception.hh:54
MachineState::addLongImmediateUnitState
void addLongImmediateUnitState(LongImmediateUnitState *state, const std::string &name)
Definition: MachineState.cc:295
MultiLatencyOperationExecutor
Definition: MultiLatencyOperationExecutor.hh:61
PortState
Definition: PortState.hh:51
MachineState::addGuardState
void addGuardState(GuardState *state, const TTAMachine::Guard &guard)
Definition: MachineState.cc:325
TTAMachine::Bus::guardCount
int guardCount() const
Definition: Bus.cc:441
TTAMachine::Machine::SIGN
@ SIGN
Sign extension.
Definition: Machine.hh:82
TTAMachine::BaseFUPort::isTriggering
virtual bool isTriggering() const =0
OperationExecutor
Definition: OperationExecutor.hh:49
TTAMachine::Bus::guard
Guard * guard(int index) const
Definition: Bus.cc:456
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
Operation
Definition: Operation.hh:59
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
OneCycleOperationExecutor
Definition: OneCycleOperationExecutor.hh:45
MachineState::addRegisterFileState
void addRegisterFileState(RegisterFileState *state, const std::string &name)
Definition: MachineState.cc:310
TTAMachine::ExecutionPipeline::isPortRead
bool isPortRead(const FUPort &port, int cycle) const
Definition: ExecutionPipeline.cc:362
MachineState::addFUState
void addFUState(FUState *state, const std::string &name)
Definition: MachineState.cc:267
MachineStateBuilder::detailedSimulationModel_
bool detailedSimulationModel_
Set to true in case should build a detailed model which simulates FU stages, possibly with an externa...
Definition: MachineStateBuilder.hh:128
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
Texts::TXT_OPERATION_X_NOT_FOUND
@ TXT_OPERATION_X_NOT_FOUND
Definition: SimulatorTextGenerator.hh:130
IllegalMachine
Definition: Exception.hh:878
RegisterFileState::registerState
virtual RegisterState & registerState(int index)
Definition: RegisterFileState.cc:81
Operation::isNull
bool isNull() const
FUResourceConflictDetector::operationID
virtual OperationID operationID(const TCEString &operationName) const
Definition: FUResourceConflictDetector.cc:119
StateLocator::addState
void addState(const TTAMachine::MachinePart &momComponent, StateData &state)
Definition: StateLocator.cc:61
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
MemorySystem::memory
MemoryPtr memory(const TTAMachine::AddressSpace &as)
Definition: MemorySystem.cc:170
RegisterFileState
Definition: RegisterFileState.hh:49
TriggeringInputPortState
Definition: TriggeringInputPortState.hh:46
TTAMachine::Port::outputSocket
virtual Socket * outputSocket() const
Definition: Port.cc:281
TTAMachine::FunctionUnit::needsConflictDetection
bool needsConflictDetection() const
Definition: FunctionUnit.cc:804
FUState::addOutputPortState
virtual void addOutputPortState(PortState &port)
Definition: FUState.cc:221
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
TTAMachine::ExecutionPipeline
Definition: ExecutionPipeline.hh:55
GuardState
Definition: GuardState.hh:60
Application::warningStream
static std::ostream & warningStream()
Definition: Application.cc:188
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::PortGuard
Definition: Guard.hh:99
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
ConflictDetectingOperationExecutor
Definition: ConflictDetectingOperationExecutor.hh:49
MachineState::addBusState
void addBusState(BusState *state, const std::string &name)
Definition: MachineState.cc:255
TTAMachine::RegisterFile::guardLatency
virtual int guardLatency() const
Definition: RegisterFile.cc:333
TTAMachine::HWOperation::latency
int latency() const
Definition: HWOperation.cc:216
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
MachineStateBuilder::detectors_
FUConflictDetectorIndex * detectors_
The FU resource conflict detectors. They are needed while building the machine state model.
Definition: MachineStateBuilder.hh:120
OperationPool
Definition: OperationPool.hh:52
FUState::executor
virtual OperationExecutor * executor(Operation &op)
Definition: FUState.cc:358
TTAMachine::ControlUnit::globalGuardLatency
int globalGuardLatency() const
TTAMachine::ControlUnit::returnAddressPort
SpecialRegisterPort * returnAddressPort() const
Definition: ControlUnit.cc:307
DynamicLibraryException
Definition: Exception.hh:588
TTAMachine::BaseRegisterFile::width
virtual int width() const
TTAMachine::ExecutionPipeline::latency
int latency() const
Definition: ExecutionPipeline.cc:482
SimpleOperationExecutor
Definition: SimpleOperationExecutor.hh:48
TTAMachine::RegisterGuard::registerFile
const RegisterFile * registerFile() const
Operation::numberOfOutputs
virtual int numberOfOutputs() const
Definition: Operation.cc:202
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TransportPipeline
Definition: TransportPipeline.hh:49
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
MachineStateBuilder::addPortToFU
void addPortToFU(MachineState *machineState, TTAMachine::BaseFUPort *port, FUState *state, TTAMachine::FunctionUnit *fu, StateLocator &locator)
Definition: MachineStateBuilder.cc:644
TTAMachine::ControlUnit::hasReturnAddressPort
bool hasReturnAddressPort() const
Definition: ControlUnit.cc:295
Texts::TXT_ILLEGAL_PROGRAM_RF_STATE_NOT_FOUND
@ TXT_ILLEGAL_PROGRAM_RF_STATE_NOT_FOUND
Text of the exception thrown when RegisterFileState could not be found and there is instruction refer...
Definition: SimulatorTextGenerator.hh:118
LongImmediateUnitState
Definition: LongImmediateUnitState.hh:55
TTAMachine::BaseFUPort::width
virtual int width() const
Definition: BaseFUPort.cc:109
TTAMachine::RegisterFile::zeroRegister
virtual bool zeroRegister() const
Definition: RegisterFile.cc:629
AddressSpaceCheck
Definition: AddressSpaceCheck.hh:50
MachineCheckResults::error
Error error(int index) const
Definition: MachineCheckResults.cc:70
MachineState::registerFileState
RegisterFileState & registerFileState(const std::string &name)
Definition: MachineState.cc:213