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

#include <SmartHWOperation.hh>

Inheritance diagram for SmartHWOperation:
Inheritance graph
Collaboration diagram for SmartHWOperation:
Collaboration graph

Public Member Functions

 SmartHWOperation (const Operation &operation, UniversalFunctionUnit &parent)
 
virtual ~SmartHWOperation ()
 
virtual void setName (const std::string &name)
 
TTAMachine::FUPortport (int operand) const
 
UniversalFunctionUnitparentUnit () const
 
virtual void bindPort (int operand, const TTAMachine::FUPort &port)
 
virtual void unbindPort (const TTAMachine::FUPort &port)
 
virtual void loadState (const ObjectState *state)
 
- Public Member Functions inherited from TTAMachine::HWOperation
 HWOperation (const std::string &name, FunctionUnit &parent)
 
 HWOperation (const ObjectState *state, FunctionUnit &parent)
 
 ~HWOperation ()
 
const std::string & name () const
 
FunctionUnitparentUnit () const
 
ExecutionPipelinepipeline () const
 
int latency () const
 
int latency (int output) const
 
int slack (int input) const
 
int operandCount () const
 
bool isBound (const FUPort &port) const
 
bool isBound (int operand) const
 
int io (const FUPort &port) const
 
int numberOfInputs () const
 
int numberOfOutputs () const
 
virtual ObjectStatesaveState () const
 
- Public Member Functions inherited from Serializable
virtual ~Serializable ()
 

Private Member Functions

bool otherMandatoryInputsBound (int operand) const
 

Private Attributes

const Operationoperation_
 The operation represented by this SmartHWOperation instance. More...
 
bool is32BitOperation_
 Tells whether this operation has 32 bits wide operands. More...
 

Additional Inherited Members

- Static Public Attributes inherited from TTAMachine::HWOperation
static const std::string OSNAME_OPERATION = "operation"
 ObjectState name for HWOperation. More...
 
static const std::string OSKEY_NAME = "name"
 ObjectState attribute key for name of the operation. More...
 
static const std::string OSNAME_OPERAND_BINDING = "binding"
 ObjectState name for an operand binding. More...
 
static const std::string OSKEY_OPERAND = "operand"
 ObjectState attribute key for operand index. More...
 
static const std::string OSKEY_PORT = "port"
 ObjectState attribute key for port name. More...
 
- Protected Member Functions inherited from TTAMachine::SubComponent
 SubComponent ()
 
virtual ~SubComponent ()
 
- Protected Member Functions inherited from TTAMachine::MachinePart
 MachinePart ()
 
virtual ~MachinePart ()
 

Detailed Description

Represents an operation in a function unit. The smart operation automatically creates operand bindings on demand. This kind of operations are used in UniversalFunctionUnit. The last operand requested is bound to the operation code setting port.

Definition at line 47 of file SmartHWOperation.hh.

Constructor & Destructor Documentation

◆ SmartHWOperation()

SmartHWOperation::SmartHWOperation ( const Operation operation,
UniversalFunctionUnit parent 
)

The constructor.

Creates the pipeline automatically.

Parameters
operationThe operation to be constructed.
parentThe parent unit of the operation.
Exceptions
ComponentAlreadyExistsIf there is already an operation by the same name in the given function unit.
InvalidNameIf the given operation does not have a valid name.

Definition at line 54 of file SmartHWOperation.cc.

56  : HWOperation(operation.name(), parent), operation_(operation) {
59 
60  int inputs = operation.numberOfInputs();
61  int outputs = operation.numberOfOutputs();
62 
63  // create pipeline
64  ExecutionPipeline* pLine = pipeline();
65  for (int operand = 1; operand <= inputs; operand++) {
66  pLine->addPortRead(operand, 0, 1);
67  }
68  for (int operand = inputs + 1; operand <= inputs + outputs; operand++) {
69  pLine->addPortWrite(operand, 0, 1);
70  }
71 }

References TTAMachine::ExecutionPipeline::addPortRead(), TTAMachine::ExecutionPipeline::addPortWrite(), UniversalFunctionUnit::is32BitOperation(), is32BitOperation_, Operation::name(), Operation::numberOfInputs(), Operation::numberOfOutputs(), and TTAMachine::HWOperation::pipeline().

Here is the call graph for this function:

◆ ~SmartHWOperation()

SmartHWOperation::~SmartHWOperation ( )
virtual

The destructor.

Definition at line 76 of file SmartHWOperation.cc.

76  {
77 }

Member Function Documentation

◆ bindPort()

void SmartHWOperation::bindPort ( int  operand,
const TTAMachine::FUPort port 
)
virtual

Aborts the program. It is not allowed to bind ports manually. DO NOT CALL THIS METHOD!

Parameters
operandNever used.
portNever used.
Exceptions
IllegalRegistrationNever thrown.
ComponentAlreadyExistsNever thrown.
OutOfRangeNever thrown.

Reimplemented from TTAMachine::HWOperation.

Definition at line 205 of file SmartHWOperation.cc.

205  {
206  const string procName = "SmartHWOperation::bindPort";
207  const string errorMsg =
208  "Tried to bind port of SmartHWOperation manually!";
209  Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
211 }

References Application::abortProgram(), and Application::writeToErrorLog().

Here is the call graph for this function:

◆ loadState()

void SmartHWOperation::loadState ( const ObjectState state)
virtual

Aborts the program. It is not allowed to load state of SmartHWOperation from an ObjectState tree. DO NOT CALL THIS METHOD!

Parameters
stateNever used.
Exceptions
ObjectStateLoadingExceptionNever thrown.

Reimplemented from TTAMachine::HWOperation.

Definition at line 237 of file SmartHWOperation.cc.

237  {
238  const string procName = "SmartHWOperation::loadState";
239  const string errorMsg =
240  "Tried load state of SmartHWOperation from an ObjectState tree!";
241  Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
243 }

References Application::abortProgram(), and Application::writeToErrorLog().

Here is the call graph for this function:

◆ otherMandatoryInputsBound()

bool SmartHWOperation::otherMandatoryInputsBound ( int  operand) const
private

Tells whether other input operands except the given one are bound to some port.

Parameters
operandThe operand.
Returns
True if other inputs are bound, otherwise false.

Definition at line 253 of file SmartHWOperation.cc.

253  {
254 
255  assert(operand <= operation_.numberOfInputs());
256 
257  for (int opIndex = 1; opIndex <= operation_.numberOfInputs();
258  opIndex++) {
259  if (opIndex == operand) {
260  continue;
261  } else {
262  if (HWOperation::port(opIndex) == NULL) {
263  return false;
264  }
265  }
266  }
267 
268  return true;
269 }

References assert, Operation::numberOfInputs(), and operation_.

Referenced by port().

Here is the call graph for this function:

◆ parentUnit()

UniversalFunctionUnit * SmartHWOperation::parentUnit ( ) const

Returns the parent unit of the operation.

Returns
The parent unit.

Definition at line 185 of file SmartHWOperation.cc.

185  {
186  FunctionUnit* parent = HWOperation::parentUnit();
187  UniversalFunctionUnit* uFU =
188  dynamic_cast<UniversalFunctionUnit*>(parent);
189  assert(uFU != NULL);
190  return uFU;
191 }

References assert.

Referenced by port().

◆ port()

FUPort * SmartHWOperation::port ( int  operand) const
virtual

Returns the port bound to the given operand. If the given operand is not bound yet, it is automatically bound to a port.

The port to which the operand will be bound depends on the bindings of other operands. Input operands are bound to input ports and output operands to output ports, of course. If all the input operands are bound already except the given one, the given operand will be bound to the operation code setting port.

Parameters
operandThe operand.
Returns
The port to which the operand is bound.

Reimplemented from TTAMachine::HWOperation.

Definition at line 110 of file SmartHWOperation.cc.

110  {
111 
112  // if the operand is bound already, just return the port
113  if (HWOperation::port(operand) != NULL) {
114  return HWOperation::port(operand);
115  }
116 
117  bool input = true;
118 
119  // check whether the operand is input or output operand
120  if (operand > operation_.numberOfInputs() +
122  return NULL;
123  } else if (operand > operation_.numberOfInputs()) {
124  input = false;
125  }
126 
127  int bitWidth = is32BitOperation_ ? 32 : 64;
128  int portCount = parentUnit()->portCountWithWidth(bitWidth);
129 
130  if (input) {
131  if (otherMandatoryInputsBound(operand)) {
132  // bind to opcode port if other inputs are bound already
133  FUPort* opcodePort;
134  if (is32BitOperation_) {
135  opcodePort =
136  static_cast<FunctionUnit*>(parentUnit())->operationPort(
138  } else {
139  opcodePort =
140  static_cast<FunctionUnit*>(parentUnit())->operationPort(
142  }
143  const_cast<SmartHWOperation*>(this)->
144  HWOperation::bindPort(operand, *opcodePort);
145  return opcodePort;
146 
147  } else {
148  // bind to a non-opcode input port otherwise
149  for (int i = 0; i < portCount; i++) {
150  FUPort& port = parentUnit()->portWithWidth(i, bitWidth);
151  if (!isBound(port) && port.inputSocket() != NULL &&
152  !port.isOpcodeSetting()) {
153  const_cast<SmartHWOperation*>(this)->
154  HWOperation::bindPort(operand, port);
155  return &port;
156  }
157  }
158  }
159 
160  } else {
161  // bind to some output port
162  for (int i = 0; i < portCount; i++) {
163  FUPort& port = parentUnit()->portWithWidth(i, bitWidth);
164  if (!isBound(port) && port.outputSocket() != NULL) {
165  const_cast<SmartHWOperation*>(this)->
166  HWOperation::bindPort(operand, port);
167  return &port;
168  }
169  }
170  }
171 
172  assert(false);
173 
174  // dummy return to avoid compilation warning
175  return NULL;
176 }

References assert, TTAMachine::Port::inputSocket(), is32BitOperation_, TTAMachine::HWOperation::isBound(), TTAMachine::FUPort::isOpcodeSetting(), Operation::numberOfInputs(), Operation::numberOfOutputs(), UniversalFunctionUnit::OC_SETTING_PORT_32, UniversalFunctionUnit::OC_SETTING_PORT_64, operation_, otherMandatoryInputsBound(), TTAMachine::Port::outputSocket(), parentUnit(), UniversalFunctionUnit::portCountWithWidth(), and UniversalFunctionUnit::portWithWidth().

Here is the call graph for this function:

◆ setName()

void SmartHWOperation::setName ( const std::string &  name)
virtual

Aborts the program. It is not allowed to set the name of SmartHWOperation. DO NOT CALL THIS METHOD!

Parameters
nameNever used.
Exceptions
ComponentAlreadyExistsNever thrown.
InvalidNameNever thrown.

Reimplemented from TTAMachine::HWOperation.

Definition at line 89 of file SmartHWOperation.cc.

89  {
90  const string procName = "SmartHWOperation::setName";
91  const string errorMsg = "Tried to set name of SmartHWOperation!";
92  Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
94 }

References Application::abortProgram(), and Application::writeToErrorLog().

Here is the call graph for this function:

◆ unbindPort()

void SmartHWOperation::unbindPort ( const TTAMachine::FUPort port)
virtual

Aborts the program. It is not allowed to unbind ports manually. DO NOT CALL THIS METHOD!

Parameters
portNever used.

Reimplemented from TTAMachine::HWOperation.

Definition at line 220 of file SmartHWOperation.cc.

220  {
221  const string procName = "SmartHWOperation::unbindPort";
222  const string errorMsg =
223  "Tried unbind port of SmartHWOperation manually!";
224  Application::writeToErrorLog(__FILE__, __LINE__, procName, errorMsg);
226 }

References Application::abortProgram(), and Application::writeToErrorLog().

Here is the call graph for this function:

Member Data Documentation

◆ is32BitOperation_

bool SmartHWOperation::is32BitOperation_
private

Tells whether this operation has 32 bits wide operands.

Definition at line 68 of file SmartHWOperation.hh.

Referenced by port(), and SmartHWOperation().

◆ operation_

const Operation& SmartHWOperation::operation_
private

The operation represented by this SmartHWOperation instance.

Definition at line 66 of file SmartHWOperation.hh.

Referenced by otherMandatoryInputsBound(), and port().


The documentation for this class was generated from the following files:
TTAMachine::Port::inputSocket
virtual Socket * inputSocket() const
Definition: Port.cc:261
UniversalFunctionUnit::OC_SETTING_PORT_32
static const std::string OC_SETTING_PORT_32
Name of the 32 bit wide opcode setting port.
Definition: UniversalFunctionUnit.hh:66
UniversalFunctionUnit::is32BitOperation
static bool is32BitOperation(const std::string &opName)
Definition: UniversalFunctionUnit.cc:358
UniversalFunctionUnit::portCountWithWidth
int portCountWithWidth(int width) const
Definition: UniversalFunctionUnit.cc:164
TTAMachine::FUPort::isOpcodeSetting
virtual bool isOpcodeSetting() const
Definition: FUPort.cc:195
UniversalFunctionUnit::portWithWidth
TTAMachine::FUPort & portWithWidth(int index, int width) const
Definition: UniversalFunctionUnit.cc:190
Application::writeToErrorLog
static void writeToErrorLog(const std::string fileName, const int lineNumber, const std::string functionName, const std::string message, const int neededVerbosity=0)
Definition: Application.cc:224
Operation::numberOfInputs
virtual int numberOfInputs() const
Definition: Operation.cc:192
SmartHWOperation::parentUnit
UniversalFunctionUnit * parentUnit() const
Definition: SmartHWOperation.cc:185
UniversalFunctionUnit
Definition: UniversalFunctionUnit.hh:50
UniversalFunctionUnit::OC_SETTING_PORT_64
static const std::string OC_SETTING_PORT_64
Name of the 64 bit wide opcode setting port.
Definition: UniversalFunctionUnit.hh:68
SmartHWOperation
Definition: SmartHWOperation.hh:47
SmartHWOperation::operation_
const Operation & operation_
The operation represented by this SmartHWOperation instance.
Definition: SmartHWOperation.hh:66
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::FUPort
Definition: FUPort.hh:46
TTAMachine::HWOperation::isBound
bool isBound(const FUPort &port) const
Definition: HWOperation.cc:338
TTAMachine::ExecutionPipeline::addPortRead
void addPortRead(int operand, int start, int duration)
Definition: ExecutionPipeline.cc:141
SmartHWOperation::port
TTAMachine::FUPort * port(int operand) const
Definition: SmartHWOperation.cc:110
TTAMachine::HWOperation::HWOperation
HWOperation(const std::string &name, FunctionUnit &parent)
Definition: HWOperation.cc:67
TTAMachine::Port::outputSocket
virtual Socket * outputSocket() const
Definition: Port.cc:281
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
TTAMachine::ExecutionPipeline
Definition: ExecutionPipeline.hh:55
TTAMachine::ExecutionPipeline::addPortWrite
void addPortWrite(int operand, int start, int duration)
Definition: ExecutionPipeline.cc:167
Application::abortProgram
static void abortProgram() __attribute__((noreturn))
Definition: Application.cc:266
Operation::numberOfOutputs
virtual int numberOfOutputs() const
Definition: Operation.cc:202
SmartHWOperation::otherMandatoryInputsBound
bool otherMandatoryInputsBound(int operand) const
Definition: SmartHWOperation.cc:253
SmartHWOperation::is32BitOperation_
bool is32BitOperation_
Tells whether this operation has 32 bits wide operands.
Definition: SmartHWOperation.hh:68