OpenASIP 2.2
Loading...
Searching...
No Matches
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}
virtual const std::string & name() const

◆ 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}
SchedulingResourceGroup dependentResourceGroup_
virtual int dependentResourceGroupCount() const

References dependentResourceGroup_, and dependentResourceGroupCount().

Referenced by InputFUBroker::setupResourceLinks(), ITemplateBroker::setupResourceLinks(), and OutputFUBroker::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}
virtual int relatedResourceGroupCount() const
SchedulingResourceGroup relatedResourceGroup_
SchedulingResourceSet relatedResourceSet_

References relatedResourceGroup_, relatedResourceGroupCount(), and relatedResourceSet_.

Referenced by BusBroker::setupResourceLinks(), ExecutionPipelineBroker::setupResourceLinks(), InputPSocketBroker::setupResourceLinks(), IUBroker::setupResourceLinks(), and OutputPSocketBroker::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 BusResource, ExecutionPipelineResource, ITemplateResource, IUResource, OutputPSocketResource, and PSocketResource.

Definition at line 397 of file SchedulingResource.cc.

397 {
398 useCount_ = 0;
399}

References useCount_.

Referenced by BusResource::clear(), ExecutionPipelineResource::clear(), ITemplateResource::clear(), IUResource::clear(), and PSocketResource::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 InputFUResource::unassign(), OutputFUResource::unassign(), and PSocketResource::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}
#define __func__
static std::string toString(const T &source)
int dependentResourceCount(const int group) const

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

Referenced by InputFUResource::assign(), OutputFUResource::assign(), InputFUResource::canAssign(), OutputFUResource::canAssign(), hasDependentResource(), FUResource::isAvailable(), InputFUResource::isAvailable(), FUResource::isInUse(), InputFUResource::isInUse(), FUResource::operator<(), InputFUResource::unassign(), OutputFUResource::unassign(), InputFUResource::validateDependentGroups(), ITemplateResource::validateDependentGroups(), and OutputFUResource::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}
virtual SchedulingResource & dependentResource(const int group, const int index) const

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) !=
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 BusResource::assign(), InputFUResource::assign(), OutputFUResource::assign(), and PSocketResource::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 ITemplateResource::assign(), BusResource::assign(), OutputPSocketResource::assign(), PSocketResource::assign(), ExecutionPipelineResource::assignDestination(), ExecutionPipelineResource::assignSource(), OutputPSocketResource::canAssign(), IUResource::canAssign(), IUResource::canAssignUse(), ExecutionPipelineResource::checkOperandAllowed(), ExecutionPipelineResource::cyclesOverlap(), IUResource::findAvailable(), ExecutionPipelineResource::hasConflictingResultsOnCycle(), ExecutionPipelineResource::isAvailable(), PSocketResource::isAvailable(), IUResource::isAvailable(), BusResource::isInUse(), ExecutionPipelineResource::isInUse(), ITemplateResource::isInUse(), IUResource::isInUse(), PSocketResource::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(), ITemplateResource::unassign(), BusResource::unassign(), OutputPSocketResource::unassign(), PSocketResource::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}
int relatedResourceCount(const int group) const

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

Referenced by IUResource::canAssign(), IUResource::canAssignUse(), BusBroker::findImmResource(), InputPSocketResource::operator<(), OutputPSocketResource::operator<(), ShortImmPSocketResource::validateRelatedGroups(), BusResource::validateRelatedGroups(), ExecutionPipelineResource::validateRelatedGroups(), InputPSocketResource::validateRelatedGroups(), IUResource::validateRelatedGroups(), and OutputPSocketResource::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{
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 Symbol 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: