OpenASIP  2.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
SchedulingResource Class Referenceabstract

#include <SchedulingResource.hh>

Inheritance diagram for SchedulingResource:
Inheritance graph
Collaboration diagram for SchedulingResource:
Collaboration graph

Public Member Functions

virtual ~SchedulingResource ()
 
 SchedulingResource (const std::string &name, const unsigned int ii=0)
 
virtual bool isInUse (const int cycle) const =0
 
virtual bool isAvailable (const int cycle) const =0
 
virtual bool canAssign (const int cycle, const MoveNode &node) const =0
 
virtual void assign (const int cycle, MoveNode &node)=0
 
virtual void unassign (const int cycle, MoveNode &node)=0
 
virtual int relatedResourceGroupCount () const
 
virtual int dependentResourceGroupCount () const
 
int relatedResourceCount (const int group) const
 
int dependentResourceCount (const int group) const
 
virtual void addToRelatedGroup (const int group, SchedulingResource &resource)
 
virtual void addToDependentGroup (const int group, SchedulingResource &resource)
 
virtual SchedulingResourcerelatedResource (const int group, const int index) const
 
virtual SchedulingResourcedependentResource (const int group, const int index) const
 
virtual bool hasRelatedResource (const SchedulingResource &sResource) const
 
virtual bool hasDependentResource (const SchedulingResource &sResource) const
 
virtual const std::string & name () const
 
virtual int useCount () const
 
virtual void increaseUseCount ()
 
virtual void decreaseUseCount ()
 
virtual bool isInputPSocketResource () const
 
virtual bool isOutputPSocketResource () const
 
virtual bool isShortImmPSocketResource () const
 
virtual bool isInputFUResource () const
 
virtual bool isOutputFUResource () const
 
virtual bool isExecutionPipelineResource () const
 
virtual bool isBusResource () const
 
virtual bool isSegmentResource () const
 
virtual bool isIUResource () const
 
virtual bool isITemplateResource () const
 
int instructionIndex (int cycle) const
 
void setInitiationInterval (unsigned int ii)
 
int initiationInterval () const
 
virtual bool operator< (const SchedulingResource &other) const
 
virtual void clear ()
 
virtual void setMaxCycle (unsigned int)
 

Protected Member Functions

virtual bool validateDependentGroups ()
 
virtual bool validateRelatedGroups ()
 

Protected Attributes

int initiationInterval_
 

Private Types

typedef std::vector< SchedulingResource * > SchedulingResourceVector
 
typedef std::vector< SchedulingResourceVectorSchedulingResourceGroup
 
typedef std::set< const SchedulingResource * > SchedulingResourceSet
 

Private Member Functions

 SchedulingResource (const SchedulingResource &)
 
SchedulingResourceoperator= (const SchedulingResource &)
 

Private Attributes

SchedulingResourceGroup relatedResourceGroup_
 
SchedulingResourceGroup dependentResourceGroup_
 
std::string name_
 
SchedulingResourceSet relatedResourceSet_
 
int useCount_
 

Friends

class ResourceBroker
 

Detailed Description

An interface for scheduling resources of Resource Model The base class SchedulingResource

Definition at line 52 of file SchedulingResource.hh.

Member Typedef Documentation

◆ SchedulingResourceGroup

Definition at line 138 of file SchedulingResource.hh.

◆ SchedulingResourceSet

Definition at line 151 of file SchedulingResource.hh.

◆ SchedulingResourceVector

Definition at line 136 of file SchedulingResource.hh.

Constructor & Destructor Documentation

◆ ~SchedulingResource()

SchedulingResource::~SchedulingResource ( )
virtual

Destructor.

Definition at line 43 of file SchedulingResource.cc.

43  {
44 }

◆ SchedulingResource() [1/2]

SchedulingResource::SchedulingResource ( const std::string &  name,
const unsigned int  ii = 0 
)

Constructor.

Parameters
nameName of resource.

Definition at line 51 of file SchedulingResource.cc.

51  :
53 }

◆ SchedulingResource() [2/2]

SchedulingResource::SchedulingResource ( const SchedulingResource )
private

Member Function Documentation

◆ addToDependentGroup()

void SchedulingResource::addToDependentGroup ( const int  group,
SchedulingResource resource 
)
virtual

Add resource to group of dependent resources.

Parameters
groupGroup to which resource add.
resourceResource to add to group.

Definition at line 101 of file SchedulingResource.cc.

103  {
104 
105  if (group >= dependentResourceGroupCount()) {
106  dependentResourceGroup_.resize(group+1);
107  }
108  dependentResourceGroup_.at(group).push_back(&resource);
109 }

References dependentResourceGroup_, and dependentResourceGroupCount().

Referenced by OutputFUBroker::setupResourceLinks(), InputFUBroker::setupResourceLinks(), and ITemplateBroker::setupResourceLinks().

Here is the call graph for this function:

◆ addToRelatedGroup()

void SchedulingResource::addToRelatedGroup ( const int  group,
SchedulingResource resource 
)
virtual

Add resource to group of related resources.

Parameters
groupGroup to which resource add.
resourceResource to add to group.

Definition at line 82 of file SchedulingResource.cc.

84  {
85 
86  relatedResourceSet_.insert(&resource);
87 
88  if (group >= relatedResourceGroupCount()) {
89  relatedResourceGroup_.resize(group+1);
90  }
91  relatedResourceGroup_.at(group).push_back(&resource);
92 }

References relatedResourceGroup_, relatedResourceGroupCount(), and relatedResourceSet_.

Referenced by ExecutionPipelineBroker::setupResourceLinks(), InputPSocketBroker::setupResourceLinks(), OutputPSocketBroker::setupResourceLinks(), IUBroker::setupResourceLinks(), and BusBroker::setupResourceLinks().

Here is the call graph for this function:

◆ assign()

virtual void SchedulingResource::assign ( const int  cycle,
MoveNode node 
)
pure virtual

◆ canAssign()

virtual bool SchedulingResource::canAssign ( const int  cycle,
const MoveNode node 
) const
pure virtual

◆ clear()

void SchedulingResource::clear ( )
virtual

Clears bookkeeping of the scheduling resource.

After this call the state of the resource should be identical to a newly-created and initialized resource.

Reimplemented in ExecutionPipelineResource, IUResource, BusResource, ITemplateResource, OutputPSocketResource, and PSocketResource.

Definition at line 397 of file SchedulingResource.cc.

397  {
398  useCount_ = 0;
399 }

References useCount_.

Referenced by PSocketResource::clear(), ITemplateResource::clear(), BusResource::clear(), IUResource::clear(), and ExecutionPipelineResource::clear().

◆ decreaseUseCount()

void SchedulingResource::decreaseUseCount ( )
virtual

Decrease use count of Schedulign Resource by 1

Definition at line 364 of file SchedulingResource.cc.

364  {
365  useCount_--;
366 }

References useCount_.

Referenced by PSocketResource::unassign(), InputFUResource::unassign(), and OutputFUResource::unassign().

◆ dependentResource()

SchedulingResource & SchedulingResource::dependentResource ( const int  group,
const int  index 
) const
virtual

Return dependent resource from group with position.

Parameters
groupGroup from which to return resource.
indexIndex of resource in particular group.
Returns
Reference to SchedulingResource [group][index].
Exceptions
OutOfRangeWhen group or index requested does not exist.

Definition at line 158 of file SchedulingResource.cc.

160  {
161 
162  if (group < dependentResourceGroupCount()) {
163  if (index < dependentResourceCount(group)) {
164  return *dependentResourceGroup_.at(group).at(index);
165  } else {
166  std::string msg = "Requested dependent resource [";
167  msg += Conversion::toString(index);
168  msg += "] does not exists";
169  msg += " in group [";
170  msg += Conversion::toString(group);
171  msg += "] of ";
172  msg += name();
173  msg += ". Group count is: ";
175  msg += ".";
176  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
177  }
178  } else {
179  std::string msg = "Requested dependent resource group ";
180  msg += Conversion::toString(group);
181  msg += " does not exists in ";
182  msg += name();
183  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
184  }
185 }

References __func__, dependentResourceCount(), dependentResourceGroup_, dependentResourceGroupCount(), name(), and Conversion::toString().

Referenced by InputFUResource::assign(), OutputFUResource::assign(), OutputFUResource::canAssign(), InputFUResource::canAssign(), hasDependentResource(), FUResource::isAvailable(), InputFUResource::isAvailable(), FUResource::isInUse(), InputFUResource::isInUse(), FUResource::operator<(), InputFUResource::unassign(), OutputFUResource::unassign(), OutputFUResource::validateDependentGroups(), ITemplateResource::validateDependentGroups(), and InputFUResource::validateDependentGroups().

Here is the call graph for this function:

◆ dependentResourceCount()

int SchedulingResource::dependentResourceCount ( const int  group) const
inline

◆ dependentResourceGroupCount()

int SchedulingResource::dependentResourceGroupCount ( ) const
virtual

◆ hasDependentResource()

bool SchedulingResource::hasDependentResource ( const SchedulingResource sResource) const
virtual

Return true if resource contains given dependent resource.

Parameters
sResourceResource to test.
Returns
True if resource contains given dependent resource.

Definition at line 207 of file SchedulingResource.cc.

208  {
209  for (int i = 0; i < dependentResourceGroupCount();i++) {
210  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
211  if (dependentResource(i, j).name() == sResource.name()) {
212  return true;
213  }
214  }
215  }
216  return false;
217 }

References dependentResource(), dependentResourceCount(), dependentResourceGroupCount(), and name().

Referenced by InputFUResource::canAssign().

Here is the call graph for this function:

◆ hasRelatedResource()

bool SchedulingResource::hasRelatedResource ( const SchedulingResource sResource) const
virtual

Return true if resource contains given related resource.

Parameters
sResourceResource to test.
Returns
True if resource contains given related resource.

Definition at line 194 of file SchedulingResource.cc.

195  {
196  return relatedResourceSet_.find(&sResource) !=
197  relatedResourceSet_.end();
198 }

References relatedResourceSet_.

Referenced by BusResource::canAssign(), and BusResource::isAvailable().

◆ increaseUseCount()

void SchedulingResource::increaseUseCount ( )
virtual

Increases use count of Scheduling Resource by 1

Definition at line 355 of file SchedulingResource.cc.

355  {
356  useCount_++;
357 }

References useCount_.

Referenced by InputFUResource::assign(), PSocketResource::assign(), BusResource::assign(), and OutputFUResource::assign().

◆ initiationInterval()

int SchedulingResource::initiationInterval ( ) const

Get initiation interval, if ii = 0 then initiation interval is not used.

Returns
initiation interval

Definition at line 385 of file SchedulingResource.cc.

386 {
387  return initiationInterval_;
388 }

References initiationInterval_.

Referenced by ExecutionPipelineResource::operandAllowedAtCycle(), and ExecutionPipelineResource::resourcesAllowTrigger().

◆ instructionIndex()

int SchedulingResource::instructionIndex ( int  cycle) const
inline

Referenced by PSocketResource::assign(), OutputPSocketResource::assign(), BusResource::assign(), ITemplateResource::assign(), ExecutionPipelineResource::assignDestination(), ExecutionPipelineResource::assignSource(), OutputPSocketResource::canAssign(), IUResource::canAssign(), IUResource::canAssignUse(), ExecutionPipelineResource::checkOperandAllowed(), ExecutionPipelineResource::cyclesOverlap(), IUResource::findAvailable(), ExecutionPipelineResource::hasConflictingResultsOnCycle(), PSocketResource::isAvailable(), IUResource::isAvailable(), ExecutionPipelineResource::isAvailable(), PSocketResource::isInUse(), BusResource::isInUse(), ITemplateResource::isInUse(), IUResource::isInUse(), ExecutionPipelineResource::isInUse(), ExecutionPipelineResource::nextResultCycle(), ExecutionPipelineResource::operandAllowedAtCycle(), ExecutionPipelineResource::operandOverwritten(), ExecutionPipelineResource::operandPossibleAtCycle(), ExecutionPipelineResource::operandSharePreventsTriggerForScheduledResult(), ExecutionPipelineResource::otherTriggerBeforeMyTrigger(), ExecutionPipelineResource::resourcesAllowTrigger(), ExecutionPipelineResource::resultAllowedAtCycle(), ExecutionPipelineResource::resultCausesTriggerBetweenOperandSharing(), ExecutionPipelineResource::resultNotOverWritten(), ExecutionPipelineResource::setOperandUsed(), ExecutionPipelineResource::setResultWriten(), PSocketResource::unassign(), OutputPSocketResource::unassign(), BusResource::unassign(), ITemplateResource::unassign(), ExecutionPipelineResource::unassignDestination(), ExecutionPipelineResource::unassignSource(), ExecutionPipelineResource::unsetOperandUsed(), and ExecutionPipelineResource::unsetResultWriten().

◆ isAvailable()

virtual bool SchedulingResource::isAvailable ( const int  cycle) const
pure virtual

◆ isBusResource()

virtual bool SchedulingResource::isBusResource ( ) const
virtual

◆ isExecutionPipelineResource()

virtual bool SchedulingResource::isExecutionPipelineResource ( ) const
virtual

◆ isInputFUResource()

virtual bool SchedulingResource::isInputFUResource ( ) const
virtual

◆ isInputPSocketResource()

virtual bool SchedulingResource::isInputPSocketResource ( ) const
virtual

◆ isInUse()

virtual bool SchedulingResource::isInUse ( const int  cycle) const
pure virtual

◆ isITemplateResource()

virtual bool SchedulingResource::isITemplateResource ( ) const
virtual

Reimplemented in ITemplateResource.

Referenced by IUResource::validateRelatedGroups().

◆ isIUResource()

virtual bool SchedulingResource::isIUResource ( ) const
virtual

◆ isOutputFUResource()

virtual bool SchedulingResource::isOutputFUResource ( ) const
virtual

◆ isOutputPSocketResource()

virtual bool SchedulingResource::isOutputPSocketResource ( ) const
virtual

◆ isSegmentResource()

virtual bool SchedulingResource::isSegmentResource ( ) const
virtual

◆ isShortImmPSocketResource()

virtual bool SchedulingResource::isShortImmPSocketResource ( ) const
virtual

Reimplemented in ShortImmPSocketResource.

Referenced by BusBroker::findImmResource().

◆ name()

virtual const std::string& SchedulingResource::name ( ) const
virtual

◆ operator<()

virtual bool SchedulingResource::operator< ( const SchedulingResource other) const
virtual

◆ operator=()

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

◆ relatedResource()

SchedulingResource & SchedulingResource::relatedResource ( const int  group,
const int  index 
) const
virtual

Return related resource from group with position.

Parameters
groupGroup from which to return resource.
indexIndex of resource in particular group.
Returns
Reference to SchedulingResource [group][index].
Exceptions
OutOfRangeWhen group or index requested does not exist.

Definition at line 120 of file SchedulingResource.cc.

122  {
123 
124  if (group < relatedResourceGroupCount()) {
125  if (index < relatedResourceCount(group)) {
126  return *relatedResourceGroup_.at(group).at(index);
127  } else {
128  std::string msg = "Requested related resource [";
129  msg += Conversion::toString(index);
130  msg += "] does not exists";
131  msg += " in group [";
132  msg += Conversion::toString(group);
133  msg += "] of ";
134  msg += name();
135  msg += ". Group count is: ";
137  msg += ".";
138  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
139  }
140  } else {
141  std::string msg = "Requested related resource group ";
142  msg += Conversion::toString(group);
143  msg += " does not exists in ";
144  msg += name();
145  throw OutOfRange(__FILE__, __LINE__, __func__, msg);
146  }
147 }

References __func__, name(), relatedResourceCount(), relatedResourceGroup_, relatedResourceGroupCount(), and Conversion::toString().

Referenced by IUResource::canAssign(), IUResource::canAssignUse(), BusBroker::findImmResource(), InputPSocketResource::operator<(), OutputPSocketResource::operator<(), InputPSocketResource::validateRelatedGroups(), ShortImmPSocketResource::validateRelatedGroups(), OutputPSocketResource::validateRelatedGroups(), BusResource::validateRelatedGroups(), IUResource::validateRelatedGroups(), and ExecutionPipelineResource::validateRelatedGroups().

Here is the call graph for this function:

◆ relatedResourceCount()

int SchedulingResource::relatedResourceCount ( const int  group) const
inline

◆ relatedResourceGroupCount()

int SchedulingResource::relatedResourceGroupCount ( ) const
virtual

◆ setInitiationInterval()

void SchedulingResource::setInitiationInterval ( unsigned int  ii)

Set initiation interval, if ii = 0 then initiation interval is not used.

Parameters
iiinitiation interval

Definition at line 374 of file SchedulingResource.cc.

375 {
376  initiationInterval_ = ii;
377 }

References initiationInterval_.

◆ setMaxCycle()

virtual void SchedulingResource::setMaxCycle ( unsigned int  )
inlinevirtual

Reimplemented in ExecutionPipelineResource.

Definition at line 122 of file SchedulingResource.hh.

122 {};

◆ unassign()

virtual void SchedulingResource::unassign ( const int  cycle,
MoveNode node 
)
pure virtual

◆ useCount()

int SchedulingResource::useCount ( ) const
virtual

Returns how many times particular scheduling resource was used

Returns
number of times resource was already used

Definition at line 346 of file SchedulingResource.cc.

346  {
347  return useCount_;
348 }

References useCount_.

Referenced by FUResource::operator<().

◆ validateDependentGroups()

virtual bool SchedulingResource::validateDependentGroups ( )
protectedvirtual

◆ validateRelatedGroups()

virtual bool SchedulingResource::validateRelatedGroups ( )
protectedvirtual

Friends And Related Function Documentation

◆ ResourceBroker

friend class ResourceBroker
friend

Definition at line 118 of file SchedulingResource.hh.

Member Data Documentation

◆ dependentResourceGroup_

SchedulingResourceGroup SchedulingResource::dependentResourceGroup_
private

◆ initiationInterval_

int SchedulingResource::initiationInterval_
protected

◆ name_

std::string SchedulingResource::name_
private

Definition at line 149 of file SchedulingResource.hh.

◆ relatedResourceGroup_

SchedulingResourceGroup SchedulingResource::relatedResourceGroup_
private

◆ relatedResourceSet_

SchedulingResourceSet SchedulingResource::relatedResourceSet_
private

Definition at line 152 of file SchedulingResource.hh.

Referenced by addToRelatedGroup(), and hasRelatedResource().

◆ useCount_

int SchedulingResource::useCount_
private

Definition at line 155 of file SchedulingResource.hh.

Referenced by clear(), decreaseUseCount(), increaseUseCount(), and useCount().


The documentation for this class was generated from the following files:
SchedulingResource::relatedResourceGroup_
SchedulingResourceGroup relatedResourceGroup_
Definition: SchedulingResource.hh:145
SchedulingResource::dependentResourceGroupCount
virtual int dependentResourceGroupCount() const
Definition: SchedulingResource.cc:71
OutOfRange
Definition: Exception.hh:320
SchedulingResource::initiationInterval_
int initiationInterval_
Definition: SchedulingResource.hh:132
Conversion::toString
static std::string toString(const T &source)
SchedulingResource::dependentResource
virtual SchedulingResource & dependentResource(const int group, const int index) const
Definition: SchedulingResource.cc:158
SchedulingResource::dependentResourceCount
int dependentResourceCount(const int group) const
SchedulingResource::name_
std::string name_
Definition: SchedulingResource.hh:149
__func__
#define __func__
Definition: Application.hh:67
SchedulingResource::relatedResourceCount
int relatedResourceCount(const int group) const
SchedulingResource::name
virtual const std::string & name() const
SchedulingResource::dependentResourceGroup_
SchedulingResourceGroup dependentResourceGroup_
Definition: SchedulingResource.hh:147
SchedulingResource::relatedResourceGroupCount
virtual int relatedResourceGroupCount() const
Definition: SchedulingResource.cc:61
SchedulingResource::useCount_
int useCount_
Definition: SchedulingResource.hh:155
SchedulingResource::relatedResourceSet_
SchedulingResourceSet relatedResourceSet_
Definition: SchedulingResource.hh:152