TCE  1.21
Public Member Functions | Private Types | Private Attributes | List of all members
ResourceVectorSet Class Reference

#include <ResourceVectorSet.hh>

Collaboration diagram for 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 48 of file ResourceVectorSet.hh.

Member Typedef Documentation

◆ ResourceVectorIndex

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

Container for indexing the resource vectors by the operation name.

Definition at line 71 of file ResourceVectorSet.hh.

Constructor & Destructor Documentation

◆ ResourceVectorSet()

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 53 of file ResourceVectorSet.cc.

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

55  : width_(0) {
56  try {
57  // add the port usages of each operation and resource usages
58  for (int i = 0; i < functionUnit.operationCount(); ++i) {
59  const TTAMachine::HWOperation* op = functionUnit.operation(i);
60  ResourceVector* rv =
61  new ResourceVector(*op->pipeline());
63  width_ = std::max(width_, rv->width());
64  }
65  } catch (const Exception& e) {
66  InvalidData io(
67  __FILE__, __LINE__, __func__,
68  "Error building the resource vectors");
69  io.setCause(e);
70  throw io;
71  }
72 }
#define __func__
Definition: Application.hh:67
virtual int operationCount() const
std::size_t width_
Width of the longest resource vector.
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
const std::string & name() const
Definition: HWOperation.cc:139
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:198
virtual HWOperation * operation(const std::string &name) const
std::size_t width() const
ResourceVectorIndex vectors_
Storage for the resource vectors.
Here is the call graph for this function:

◆ ~ResourceVectorSet()

ResourceVectorSet::~ResourceVectorSet ( )
virtual

Destructor.

Definition at line 77 of file ResourceVectorSet.cc.

References AssocTools::deleteAllValues(), and vectors_.

77  {
79 }
static void deleteAllValues(ContainerType &aMap)
ResourceVectorIndex vectors_
Storage for the resource vectors.
Here is the call graph for this function:

Member Function Documentation

◆ operationIndex()

std::size_t 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 158 of file ResourceVectorSet.cc.

References __func__, and vectors_.

Referenced by ResourceVectorFUResourceConflictDetector::operationID().

158  {
159  int counter = 0;
160  for (ResourceVectorIndex::const_iterator i = vectors_.begin();
161  i != vectors_.end(); ++i) {
162  if ((*i).first == operationName)
163  return counter;
164  ++counter;
165  }
166  throw KeyNotFound(__FILE__, __LINE__, __func__, "Operation not found.");
167 }
#define __func__
Definition: Application.hh:67
std::string operationName(std::size_t index) const
ResourceVectorIndex vectors_
Storage for the resource vectors.

◆ operationName()

std::string 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 137 of file ResourceVectorSet.cc.

References vectors_.

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

◆ operator==()

bool 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 187 of file ResourceVectorSet.cc.

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

187  {
188 
189  if (resourceVectorCount() != rightHand.resourceVectorCount()) {
190  return false;
191  }
192  ResourceVectorIndex::const_iterator iter = vectors_.begin();
193  for (; iter != vectors_.end(); iter++) {
194  try {
195  if (!((*(*iter).second) ==
196  rightHand.resourceVector((*iter).first))) {
197  return false;
198  }
199  } catch (KeyNotFound& e) {
200  return false;
201  }
202  }
203  return true;
204 }
const ResourceVector & resourceVector(const std::string &operationName) const
ResourceVectorIndex vectors_
Storage for the resource vectors.
std::size_t resourceVectorCount() const
Here is the call graph for this function:

◆ resourceVector() [1/2]

const ResourceVector & 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 89 of file ResourceVectorSet.cc.

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

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

89  {
90  const std::string opName = StringTools::stringToUpper(operationName);
91  if (!AssocTools::containsKey(vectors_, opName)) {
92  std::string message = "No resource vector found for operation " +
93  operationName + ".";
94  throw KeyNotFound(
95  __FILE__, __LINE__, __func__, message);
96  }
97  return *(*vectors_.find(opName)).second;
98 }
#define __func__
Definition: Application.hh:67
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
std::string operationName(std::size_t index) const
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
ResourceVectorIndex vectors_
Storage for the resource vectors.
Here is the call graph for this function:

◆ resourceVector() [2/2]

const ResourceVector & 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 117 of file ResourceVectorSet.cc.

References vectors_.

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

◆ resourceVectorCount()

std::size_t ResourceVectorSet::resourceVectorCount ( ) const

Returns the count of resource vectors in the set.

Returns
The count.

Definition at line 106 of file ResourceVectorSet.cc.

References vectors_.

Referenced by operator==().

106  {
107  return vectors_.size();
108 }
ResourceVectorIndex vectors_
Storage for the resource vectors.

◆ width()

std::size_t ResourceVectorSet::width ( ) const

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

Returns
The width.

Definition at line 175 of file ResourceVectorSet.cc.

References width_.

175  {
176  return width_;
177 }
std::size_t width_
Width of the longest resource vector.

Member Data Documentation

◆ vectors_

ResourceVectorIndex ResourceVectorSet::vectors_
private

Storage for the resource vectors.

Definition at line 73 of file ResourceVectorSet.hh.

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

◆ width_

std::size_t ResourceVectorSet::width_
private

Width of the longest resource vector.

Definition at line 75 of file ResourceVectorSet.hh.

Referenced by ResourceVectorSet(), and width().


The documentation for this class was generated from the following files: