OpenASIP  2.0
Public Member Functions | List of all members
InfoPortsCommand Class Reference
Inheritance diagram for InfoPortsCommand:
Inheritance graph
Collaboration diagram for InfoPortsCommand:
Collaboration graph

Public Member Functions

 InfoPortsCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~InfoPortsCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
- Public Member Functions inherited from SimControlLanguageSubCommand
 SimControlLanguageSubCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~SimControlLanguageSubCommand ()
 
virtual SimControlLanguageCommandparent ()
 

Detailed Description

Implementation of "info ports".

Definition at line 501 of file InfoCommand.cc.

Constructor & Destructor Documentation

◆ InfoPortsCommand()

InfoPortsCommand::InfoPortsCommand ( SimControlLanguageCommand parentCommand)
inline

Constructor.

Definition at line 506 of file InfoCommand.cc.

506  :
507  SimControlLanguageSubCommand(parentCommand) {
508  }

◆ ~InfoPortsCommand()

virtual InfoPortsCommand::~InfoPortsCommand ( )
inlinevirtual

Destructor.

Definition at line 513 of file InfoCommand.cc.

513  {
514  }

Member Function Documentation

◆ execute()

virtual bool InfoPortsCommand::execute ( const std::vector< DataObject > &  arguments)
inlinevirtual

Executes the "info ports" command.

"info ports" prints info of FU ports.

Parameters
argumentsNo arguments should be given.
Returns
Always true.

Implements SimControlLanguageSubCommand.

Definition at line 524 of file InfoCommand.cc.

524  {
525 
526  const int argumentCount = arguments.size() - 2;
527 
528  if (!parent().checkMachineLoaded()) {
529  return false;
530  }
531 
532  if (!parent().checkArgumentCount(argumentCount, 1, 2)) {
533  return false;
534  }
535  const TTAMachine::Machine& mach =
537 
538  const std::string functionUnit = arguments.at(2).stringValue();
539 
541  mach.functionUnitNavigator();
542 
543  TTAMachine::FunctionUnit* fu = NULL;
544  if (nav.hasItem(functionUnit)) {
545  fu = nav.item(functionUnit);
546  } else if (functionUnit == mach.controlUnit()->name()) {
547  fu = mach.controlUnit();
548  }
549 
550  if (fu == NULL) {
553  Texts::TXT_FU_NOT_FOUND).str());
554  return false;
555  }
556 
557  if (argumentCount == 1) {
558  std::string result = "";
559  bool isFirst = true;
560  for (int i = 0; i < fu->portCount(); ++i) {
561  if (!isFirst)
562  result += "\n";
563  std::string portName = fu->port(i)->name();
564  DisassemblyFUPort portString(functionUnit, portName);
566  functionUnit, portName);
568  portString.toString(), portValue);
569  isFirst = false;
570  }
571  parent().interpreter()->setResult(result);
572  return true;
573  } else if (argumentCount == 2) {
574  const std::string portName = arguments.at(3).stringValue();
575  try {
576  // @todo printing of double values (size > 32)
578  functionUnit, portName);
579  parent().interpreter()->setResult(portValue.intValue());
580  return true;
581  } catch (const Exception& e) {
585  return false;
586  }
587  }
588  return false;
589  }

References TTAMachine::Machine::controlUnit(), TTAMachine::Machine::functionUnitNavigator(), SimulatorFrontend::FUPortValue(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), CustomCommand::interpreter(), SimValue::intValue(), TTAMachine::Machine::Navigator< ComponentType >::item(), SimulatorFrontend::machine(), TTAMachine::Port::name(), TTAMachine::Component::name(), SimControlLanguageSubCommand::parent(), TTAMachine::FunctionUnit::port(), TTAMachine::Unit::portCount(), InfoRegistersCommand::registerDescription(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimControlLanguageCommand::simulatorFrontend(), SimulatorToolbox::textGenerator(), DisassemblyFUPort::toString(), Texts::TXT_FU_NOT_FOUND, and Texts::TXT_FUPORT_NOT_FOUND.

Here is the call graph for this function:

The documentation for this class was generated from the following file:
SimValue::intValue
int intValue() const
Definition: SimValue.cc:895
SimControlLanguageSubCommand::parent
virtual SimControlLanguageCommand & parent()
Definition: SimControlLanguageCommand.cc:842
SimControlLanguageSubCommand::SimControlLanguageSubCommand
SimControlLanguageSubCommand(SimControlLanguageCommand &parentCommand)
Definition: SimControlLanguageCommand.cc:824
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
Texts::TXT_FUPORT_NOT_FOUND
@ TXT_FUPORT_NOT_FOUND
Definition: SimulatorTextGenerator.hh:58
SimValue
Definition: SimValue.hh:96
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
Exception
Definition: Exception.hh:54
SimulatorFrontend::FUPortValue
virtual SimValue FUPortValue(const std::string &fuName, const std::string &portName)
Definition: SimulatorFrontend.cc:767
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
Texts::TXT_FU_NOT_FOUND
@ TXT_FU_NOT_FOUND
Definition: SimulatorTextGenerator.hh:56
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
DisassemblyFUPort
Definition: DisassemblyFUPort.hh:41
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
InfoRegistersCommand::registerDescription
static std::string registerDescription(const std::string &regName, const SimValue &value)
Definition: InfoCommand.cc:195
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::Machine
Definition: Machine.hh:73