OpenASIP  2.0
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SimpleOperationExecutor Class Reference

#include <SimpleOperationExecutor.hh>

Inheritance diagram for SimpleOperationExecutor:
Inheritance graph
Collaboration diagram for SimpleOperationExecutor:
Collaboration graph

Classes

struct  BufferCell
 

Public Member Functions

 SimpleOperationExecutor (int latency, FUState &parent)
 
virtual ~SimpleOperationExecutor ()
 
virtual int latency () const
 
virtual void startOperation (Operation &op)
 
virtual void advanceClock ()
 
virtual OperationExecutorcopy ()
 
virtual void setContext (OperationContext &context)
 
- Public Member Functions inherited from OperationExecutor
 OperationExecutor ()
 
 OperationExecutor (FUState &parent)
 
virtual ~OperationExecutor ()
 
FUStateparent () const
 
void setParent (FUState &parent)
 
void addBinding (int io, PortState &port)
 
PortStatebinding (int io) const
 
bool hasPendingOperations () const
 
virtual void reset ()
 

Private Types

typedef std::vector< BufferCellBuffer
 Ring buffer type for the pipeline slots. More...
 

Private Member Functions

SimpleOperationExecutoroperator= (const SimpleOperationExecutor &)
 Assignment not allowed. More...
 

Private Attributes

int nextSlot_
 Position of the ring buffer where to put the next triggered operation. More...
 
Buffer buffer_
 Ring buffer for the pipeline slots. More...
 
OperationContextcontext_
 Operation context. More...
 
std::size_t pendingOperations_
 Count of pending operations in the pipeline. More...
 

Additional Inherited Members

- Protected Attributes inherited from OperationExecutor
std::vector< PortState * > bindings_
 PortStates that are bound to a certain input or output operand. More...
 
bool hasPendingOperations_
 This is set to true if the OperationExecutor is not in 'idle' mode. More...
 

Detailed Description

Simple implementation of OperationExecutor.

Definition at line 48 of file SimpleOperationExecutor.hh.

Member Typedef Documentation

◆ Buffer

typedef std::vector<BufferCell> SimpleOperationExecutor::Buffer
private

Ring buffer type for the pipeline slots.

Definition at line 93 of file SimpleOperationExecutor.hh.

Constructor & Destructor Documentation

◆ SimpleOperationExecutor()

SimpleOperationExecutor::SimpleOperationExecutor ( int  latency,
FUState parent 
)

Constructor.

Parameters
latencyLatency of the operation.
parentParent of the OperationExecutor.

Definition at line 54 of file SimpleOperationExecutor.cc.

56  :
59 
60  for (int i = 0; i < latency; i++) {
61  BufferCell cell;
62  buffer_.push_back(cell);
63  }
64  hasPendingOperations_ = true;
65 }

References buffer_, OperationExecutor::hasPendingOperations_, and latency().

Referenced by copy().

Here is the call graph for this function:

◆ ~SimpleOperationExecutor()

SimpleOperationExecutor::~SimpleOperationExecutor ( )
virtual

Destructor.

Definition at line 70 of file SimpleOperationExecutor.cc.

70  {
71 }

Member Function Documentation

◆ advanceClock()

void SimpleOperationExecutor::advanceClock ( )
virtual

Advances clock by one cycle.

Takes the oldest result in the pipeline and makes it visible in the function unit's ports.

Implements OperationExecutor.

Definition at line 138 of file SimpleOperationExecutor.cc.

138  {
139 
140  int index = (nextSlot_ + 1) % buffer_.size();
141 
142  BufferCell& oldestEntry = buffer_[index];
143  Operation* oldestOperation = oldestEntry.operation_;
144  if (oldestOperation != NULL) {
145 
146  const std::size_t inputOperands = oldestOperation->numberOfInputs();
147  const std::size_t outputOperands = oldestOperation->numberOfOutputs();
148  const std::size_t operandCount = inputOperands + outputOperands;
149  for (std::size_t i = inputOperands + 1; i <= operandCount; ++i) {
150  PortState& port = binding(i);
151  port.setValue(*oldestEntry.io_[i - 1]);
152  }
153  // results now moved to the FU output ports, "lifetime" of this
154  // operation execution ends in this FU
155  oldestEntry.operation_ = NULL;
158  }
159  nextSlot_++;
160  nextSlot_ = nextSlot_ % buffer_.size();
161 }

References OperationExecutor::binding(), buffer_, OperationExecutor::hasPendingOperations_, SimpleOperationExecutor::BufferCell::io_, nextSlot_, Operation::numberOfInputs(), Operation::numberOfOutputs(), SimpleOperationExecutor::BufferCell::operation_, pendingOperations_, and RegisterState::setValue().

Here is the call graph for this function:

◆ copy()

OperationExecutor * SimpleOperationExecutor::copy ( )
virtual

Copies OperationExecutor.

Returns
The copied OperationExecutor.

Implements OperationExecutor.

Definition at line 169 of file SimpleOperationExecutor.cc.

169  {
170  return new SimpleOperationExecutor(*this);
171 }

References SimpleOperationExecutor().

Here is the call graph for this function:

◆ latency()

int SimpleOperationExecutor::latency ( ) const
virtual

Returns the latency of the executor.

Returns
The latency of the executor.

Definition at line 79 of file SimpleOperationExecutor.cc.

79  {
80  return buffer_.size();
81 }

References buffer_.

Referenced by SimpleOperationExecutor().

◆ operator=()

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

Assignment not allowed.

◆ setContext()

void SimpleOperationExecutor::setContext ( OperationContext context)
virtual

Sets the OperationContext for the OperationExecutor.

Parameters
contextNew OperationContext.

Implements OperationExecutor.

Definition at line 179 of file SimpleOperationExecutor.cc.

179  {
180  context_ = &context;
181 }

References context_.

◆ startOperation()

void SimpleOperationExecutor::startOperation ( Operation op)
virtual

Starts new operation.

First original inputs and outputs are stored. Then outputs of the operation are stored. Then operation is triggered.

Parameters
opOperation to be triggered.
Todo:
This can be optimized a lot: try to initialize the vector as rarely as possible.
Todo:
create valueConst() and value() to avoid these uglies
Todo:
Fix! This should not probably be assumed, or at least user should be notified if his operand ids are not what are expected.

Implements OperationExecutor.

Definition at line 94 of file SimpleOperationExecutor.cc.

94  {
95 
96  BufferCell& nextSlot = buffer_[nextSlot_];
97 
98  const bool reuseBindings =
99  nextSlot.boundOperation_ != NULL && nextSlot.boundOperation_ == &op;
100 
101  if (!reuseBindings) {
102  const std::size_t inputOperands = op.numberOfInputs();
103  const std::size_t outputOperands = op.numberOfOutputs();
104  const std::size_t operandCount = inputOperands + outputOperands;
105 
106  assert(operandCount <= EXECUTOR_MAX_OPERAND_COUNT);
107  // let the operation access the input port values directly,
108  for (std::size_t i = 1; i <= inputOperands; ++i) {
109  /// @todo create valueConst() and value() to avoid these uglies
110  nextSlot.io_[i - 1] = &(const_cast<SimValue&>(binding(i).value()));
111  }
112 
113  // create new temporary SimValues for the outputs, assume
114  // indexing of outputs starts after inputs
115  /// @todo Fix! This should not probably be assumed, or at least
116  /// user should be notified if his operand ids are not what
117  /// are expected.
118  for (std::size_t i = inputOperands + 1; i <= operandCount; ++i) {
119  nextSlot.ioOrig_[i - 1].setBitWidth(op.operand(i).width());
120  nextSlot.io_[i - 1] = &nextSlot.ioOrig_[i - 1];
121  }
122  nextSlot.boundOperation_ = &op;
123  }
124 
125  nextSlot.operation_ = &op;
126  nextSlot.ready_ = op.simulateTrigger(nextSlot.io_, *context_);
128  hasPendingOperations_ = true;
129 }

References assert, OperationExecutor::binding(), SimpleOperationExecutor::BufferCell::boundOperation_, buffer_, context_, EXECUTOR_MAX_OPERAND_COUNT, OperationExecutor::hasPendingOperations_, SimpleOperationExecutor::BufferCell::io_, SimpleOperationExecutor::BufferCell::ioOrig_, nextSlot_, Operation::numberOfInputs(), Operation::numberOfOutputs(), Operation::operand(), SimpleOperationExecutor::BufferCell::operation_, pendingOperations_, SimpleOperationExecutor::BufferCell::ready_, SimValue::setBitWidth(), Operation::simulateTrigger(), RegisterState::value(), and Operand::width().

Here is the call graph for this function:

Member Data Documentation

◆ buffer_

Buffer SimpleOperationExecutor::buffer_
private

Ring buffer for the pipeline slots.

Definition at line 97 of file SimpleOperationExecutor.hh.

Referenced by advanceClock(), latency(), SimpleOperationExecutor(), and startOperation().

◆ context_

OperationContext* SimpleOperationExecutor::context_
private

Operation context.

Definition at line 99 of file SimpleOperationExecutor.hh.

Referenced by setContext(), and startOperation().

◆ nextSlot_

int SimpleOperationExecutor::nextSlot_
private

Position of the ring buffer where to put the next triggered operation.

Definition at line 95 of file SimpleOperationExecutor.hh.

Referenced by advanceClock(), and startOperation().

◆ pendingOperations_

std::size_t SimpleOperationExecutor::pendingOperations_
private

Count of pending operations in the pipeline.

Definition at line 101 of file SimpleOperationExecutor.hh.

Referenced by advanceClock(), and startOperation().


The documentation for this class was generated from the following files:
SimpleOperationExecutor::latency
virtual int latency() const
Definition: SimpleOperationExecutor.cc:79
SimpleOperationExecutor::buffer_
Buffer buffer_
Ring buffer for the pipeline slots.
Definition: SimpleOperationExecutor.hh:97
OperationExecutor::OperationExecutor
OperationExecutor()
Definition: OperationExecutor.hh:51
EXECUTOR_MAX_OPERAND_COUNT
#define EXECUTOR_MAX_OPERAND_COUNT
Maximum count of operation operands supported by the executors. This is used to allocate some static ...
Definition: OperationExecutor.hh:84
Operand::width
virtual int width() const
Definition: Operand.cc:318
Operation::numberOfInputs
virtual int numberOfInputs() const
Definition: Operation.cc:192
SimValue
Definition: SimValue.hh:96
assert
#define assert(condition)
Definition: Application.hh:86
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
SimpleOperationExecutor::SimpleOperationExecutor
SimpleOperationExecutor(int latency, FUState &parent)
Definition: SimpleOperationExecutor.cc:54
OperationExecutor::hasPendingOperations_
bool hasPendingOperations_
This is set to true if the OperationExecutor is not in 'idle' mode.
Definition: OperationExecutor.hh:73
SimpleOperationExecutor::context_
OperationContext * context_
Operation context.
Definition: SimpleOperationExecutor.hh:99
PortState
Definition: PortState.hh:51
Operation
Definition: Operation.hh:59
SimpleOperationExecutor::nextSlot_
int nextSlot_
Position of the ring buffer where to put the next triggered operation.
Definition: SimpleOperationExecutor.hh:95
OperationExecutor::parent
FUState & parent() const
Operation::operand
virtual Operand & operand(int id) const
Definition: Operation.cc:541
SimpleOperationExecutor::pendingOperations_
std::size_t pendingOperations_
Count of pending operations in the pipeline.
Definition: SimpleOperationExecutor.hh:101
Operation::simulateTrigger
virtual bool simulateTrigger(SimValue **, OperationContext &context) const
Definition: Operation.cc:555
Operation::numberOfOutputs
virtual int numberOfOutputs() const
Definition: Operation.cc:202
OperationExecutor::binding
PortState & binding(int io) const
RegisterState::setValue
virtual void setValue(const SimValue &value)
Definition: RegisterState.cc:80