OpenASIP  2.0
Public Member Functions | Private Types | Private Attributes | List of all members
TTAMachine::ResourceVectorSet Class Reference

#include <ResourceVectorSet.hh>

Collaboration diagram for TTAMachine::ResourceVectorSet:
Collaboration graph

Public Member Functions

 ResourceVectorSet (const TTAMachine::FunctionUnit &functionUnit)
 
virtual ~ResourceVectorSet ()
 
const ResourceVectorresourceVector (const std::string &operationName) const
 
std::size_t operationIndex (const std::string &operationName) const
 
std::size_t resourceVectorCount () const
 
const ResourceVectorresourceVector (std::size_t index) const
 
std::string operationName (std::size_t index) const
 
std::size_t width () const
 
bool operator== (const ResourceVectorSet &rightHand) const
 

Private Types

typedef std::map< std::string, ResourceVector * > ResourceVectorIndex
 Container for indexing the resource vectors by the operation name. More...
 

Private Attributes

ResourceVectorIndex vectors_
 Storage for the resource vectors. More...
 
std::size_t width_
 Width of the longest resource vector. More...
 

Detailed Description

Represents a set of resource vectors used in building the states in case of an function unit FSA.

Definition at line 47 of file ResourceVectorSet.hh.

Member Typedef Documentation

◆ ResourceVectorIndex

typedef std::map<std::string, ResourceVector*> TTAMachine::ResourceVectorSet::ResourceVectorIndex
private

Container for indexing the resource vectors by the operation name.

Definition at line 70 of file ResourceVectorSet.hh.

Constructor & Destructor Documentation

◆ ResourceVectorSet()

TTAMachine::ResourceVectorSet::ResourceVectorSet ( const TTAMachine::FunctionUnit functionUnit)

Builds the resource vectors for the given FU.

Resource vectors are built for all operations in the FU.

Parameters
functionUnitThe function unit to build the resource vectors for.
Exceptions
InvalidDataIn case the function unit is incomplete to build resource vectors for (e.g., missing operand-port bindings).

Definition at line 55 of file ResourceVectorSet.cc.

57  : width_(0) {
58  try {
59  // add the port usages of each operation and resource usages
60  for (int i = 0; i < functionUnit.operationCount(); ++i) {
61  const TTAMachine::HWOperation* op = functionUnit.operation(i);
62  ResourceVector* rv =
63  new ResourceVector(*op->pipeline());
65  width_ = std::max(width_, rv->width());
66  }
67  } catch (const Exception& e) {
68  InvalidData io(
69  __FILE__, __LINE__, __func__,
70  "Error building the resource vectors");
71  io.setCause(e);
72  throw io;
73  }
74 }

References __func__, TTAMachine::HWOperation::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), TTAMachine::HWOperation::pipeline(), Exception::setCause(), StringTools::stringToUpper(), vectors_, TTAMachine::ResourceVector::width(), and width_.

Here is the call graph for this function:

◆ ~ResourceVectorSet()

TTAMachine::ResourceVectorSet::~ResourceVectorSet ( )
virtual

Destructor.

Definition at line 79 of file ResourceVectorSet.cc.

References AssocTools::deleteAllValues(), and vectors_.

Here is the call graph for this function:

Member Function Documentation

◆ operationIndex()

std::size_t TTAMachine::ResourceVectorSet::operationIndex ( const std::string &  operationName) const

Returns the index of the operation with the given name.

Parameters
operationNameThe name of the operation.
Returns
Index of the operation.
Exceptions
KeyNotFoundIf the operation is not found.

Definition at line 160 of file ResourceVectorSet.cc.

160  {
161  int counter = 0;
162  for (ResourceVectorIndex::const_iterator i = vectors_.begin();
163  i != vectors_.end(); ++i) {
164  if ((*i).first == operationName)
165  return counter;
166  ++counter;
167  }
168  throw KeyNotFound(__FILE__, __LINE__, __func__, "Operation not found.");
169 }

References __func__, operationName(), and vectors_.

Referenced by ResourceVectorFUResourceConflictDetector::operationID().

Here is the call graph for this function:

◆ operationName()

std::string TTAMachine::ResourceVectorSet::operationName ( std::size_t  index) const

Returns the name of the operation of the resource vector at the given index.

Parameters
indexThe index.
Returns
The operation name.

Definition at line 139 of file ResourceVectorSet.cc.

139  {
140 
141  int counter = index;
142  for (ResourceVectorIndex::const_iterator i = vectors_.begin();
143  i != vectors_.end(); ++i) {
144  if (counter == 0)
145  return (*i).first;
146  --counter;
147  }
148  // should never get here
149  return (*vectors_.end()).first;
150 }

References vectors_.

Referenced by operationIndex(), and resourceVector().

◆ operator==()

bool TTAMachine::ResourceVectorSet::operator== ( const ResourceVectorSet rightHand) const

Compares two ResourceVectorSets.

Parameters
rightHandRight hand operand.
Returns
True is the two sets match false otherwise.

Definition at line 189 of file ResourceVectorSet.cc.

189  {
190 
191  if (resourceVectorCount() != rightHand.resourceVectorCount()) {
192  return false;
193  }
194  ResourceVectorIndex::const_iterator iter = vectors_.begin();
195  for (; iter != vectors_.end(); iter++) {
196  try {
197  if (!((*(*iter).second) ==
198  rightHand.resourceVector((*iter).first))) {
199  return false;
200  }
201  } catch (KeyNotFound& e) {
202  return false;
203  }
204  }
205  return true;
206 }

References resourceVector(), resourceVectorCount(), and vectors_.

Here is the call graph for this function:

◆ resourceVector() [1/2]

const ResourceVector & TTAMachine::ResourceVectorSet::resourceVector ( const std::string &  operationName) const

Returns the resource vector associated with the given operation.

Parameters
operationNameThe operation name.
Returns
The resource vector.
Exceptions
KeyNotFoundIf the operation is not found.

Definition at line 91 of file ResourceVectorSet.cc.

91  {
92  const std::string opName = StringTools::stringToUpper(operationName);
93  if (!AssocTools::containsKey(vectors_, opName)) {
94  std::string message = "No resource vector found for operation " +
95  operationName + ".";
96  throw KeyNotFound(
97  __FILE__, __LINE__, __func__, message);
98  }
99  return *(*vectors_.find(opName)).second;
100 }

References __func__, AssocTools::containsKey(), operationName(), StringTools::stringToUpper(), and vectors_.

Referenced by ResourceVectorFUResourceConflictDetector::issueOperation(), and operator==().

Here is the call graph for this function:

◆ resourceVector() [2/2]

const ResourceVector & TTAMachine::ResourceVectorSet::resourceVector ( std::size_t  index) const

Returns the resource vector at the given index.

Parameters
indexThe index.
Returns
The resource vector.

Definition at line 119 of file ResourceVectorSet.cc.

119  {
120 
121  int counter = index;
122  for (ResourceVectorIndex::const_iterator i = vectors_.begin();
123  i != vectors_.end(); ++i) {
124  if (counter == 0)
125  return *((*i).second);
126  --counter;
127  }
128  // should never get here
129  return *((*vectors_.end()).second);
130 }

References vectors_.

◆ resourceVectorCount()

std::size_t TTAMachine::ResourceVectorSet::resourceVectorCount ( ) const

Returns the count of resource vectors in the set.

Returns
The count.

Definition at line 108 of file ResourceVectorSet.cc.

108  {
109  return vectors_.size();
110 }

References vectors_.

Referenced by operator==().

◆ width()

std::size_t TTAMachine::ResourceVectorSet::width ( ) const

Returns the width of the longest resource vector in the resource vector set.

Returns
The width.

Definition at line 177 of file ResourceVectorSet.cc.

177  {
178  return width_;
179 }

References width_.

Member Data Documentation

◆ vectors_

ResourceVectorIndex TTAMachine::ResourceVectorSet::vectors_
private

Storage for the resource vectors.

Definition at line 72 of file ResourceVectorSet.hh.

Referenced by operationIndex(), operationName(), operator==(), resourceVector(), resourceVectorCount(), ResourceVectorSet(), and ~ResourceVectorSet().

◆ width_

std::size_t TTAMachine::ResourceVectorSet::width_
private

Width of the longest resource vector.

Definition at line 74 of file ResourceVectorSet.hh.

Referenced by ResourceVectorSet(), and width().


The documentation for this class was generated from the following files:
TTAMachine::HWOperation
Definition: HWOperation.hh:52
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
TTAMachine::ResourceVectorSet::vectors_
ResourceVectorIndex vectors_
Storage for the resource vectors.
Definition: ResourceVectorSet.hh:72
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
InvalidData
Definition: Exception.hh:149
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
Exception
Definition: Exception.hh:54
TTAMachine::ResourceVectorSet::resourceVectorCount
std::size_t resourceVectorCount() const
Definition: ResourceVectorSet.cc:108
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
KeyNotFound
Definition: Exception.hh:285
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine::ResourceVectorSet::operationName
std::string operationName(std::size_t index) const
Definition: ResourceVectorSet.cc:139
AssocTools::deleteAllValues
static void deleteAllValues(ContainerType &aMap)
TTAMachine::ResourceVectorSet::width_
std::size_t width_
Width of the longest resource vector.
Definition: ResourceVectorSet.hh:74