OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ITemplateResource Class Reference

#include <ITemplateResource.hh>

Inheritance diagram for ITemplateResource:
Inheritance graph
Collaboration diagram for ITemplateResource:
Collaboration graph

Public Member Functions

virtual ~ITemplateResource ()
 
 ITemplateResource (TTAMachine::InstructionTemplate &templ, unsigned int initiationInterval=0)
 
virtual bool isInUse (const int cycle) const override
 
virtual bool isAvailable (const int cycle) const override
 
virtual bool canAssign (const int cycle, const MoveNode &node) const override
 
virtual bool canAssign (const int cycle) const
 
virtual void assign (const int cycle, MoveNode &node) override
 
virtual void assign (const int cycle)
 
virtual void unassign (const int cycle, MoveNode &node) override
 
virtual void unassign (const int cycle)
 
virtual bool isITemplateResource () const override
 
void clear () override
 
virtual bool operator< (const SchedulingResource &other) const override
 
- Public Member Functions inherited from SchedulingResource
virtual ~SchedulingResource ()
 
 SchedulingResource (const std::string &name, const unsigned int ii=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
 
int instructionIndex (int cycle) const
 
void setInitiationInterval (unsigned int ii)
 
int initiationInterval () const
 
virtual void setMaxCycle (unsigned int)
 

Protected Member Functions

virtual bool validateDependentGroups () override
 
virtual bool validateRelatedGroups () override
 

Private Types

typedef std::map< int, int > ResourceRecordType
 

Private Member Functions

 ITemplateResource (const ITemplateResource &)
 
ITemplateResourceoperator= (const ITemplateResource &)
 

Private Attributes

ResourceRecordType resourceRecord_
 
TTAMachine::InstructionTemplatetemplate_
 

Additional Inherited Members

- Protected Attributes inherited from SchedulingResource
int initiationInterval_
 

Detailed Description

An interface for scheduling resources of Resource Model The derived class ITemplateResource

Definition at line 51 of file ITemplateResource.hh.

Member Typedef Documentation

◆ ResourceRecordType

typedef std::map<int, int> ITemplateResource::ResourceRecordType
private

Definition at line 76 of file ITemplateResource.hh.

Constructor & Destructor Documentation

◆ ~ITemplateResource()

ITemplateResource::~ITemplateResource ( )
virtual

Destructor.

Definition at line 53 of file ITemplateResource.cc.

53  {
54 }

◆ ITemplateResource() [1/2]

ITemplateResource::ITemplateResource ( TTAMachine::InstructionTemplate templ,
unsigned int  initiationInterval = 0 
)

Constructor.

Parameters
nameName of template.

Definition at line 43 of file ITemplateResource.cc.

45  :
47  template_(&templ){
48 }

◆ ITemplateResource() [2/2]

ITemplateResource::ITemplateResource ( const ITemplateResource )
private

Member Function Documentation

◆ assign() [1/2]

void ITemplateResource::assign ( const int  cycle)
virtual

Assign instruction template resource to given cycle.

Parameters
cycleCycle to assign.

Definition at line 97 of file ITemplateResource.cc.

97  {
98 
99  if (canAssign(cycle)) {
102  } else {
103  resourceRecord_[instructionIndex(cycle)] = 1;
104  }
105  }
106 }

References canAssign(), MapTools::containsKey(), SchedulingResource::instructionIndex(), and resourceRecord_.

Here is the call graph for this function:

◆ assign() [2/2]

void ITemplateResource::assign ( const int  cycle,
MoveNode node 
)
overridevirtual

The overridden method should be used instead.

Implements SchedulingResource.

Definition at line 87 of file ITemplateResource.cc.

87  {
88  abortWithError("Not implemented!");
89 }

References abortWithError.

Referenced by ITemplateBroker::assign(), ITemplateBroker::assignImmediate(), ITemplateBroker::instruction(), and ITemplateBroker::reselectTemplate().

◆ canAssign() [1/2]

bool ITemplateResource::canAssign ( const int  cycle) const
virtual

Return true if instruction template resource can be assigned on given cycle.

Parameters
cycleCycle to test.
Returns
True if template can be assigned to given cycle.

Definition at line 146 of file ITemplateResource.cc.

146  {
147  return !isInUse(cycle);
148 }

References isInUse().

Here is the call graph for this function:

◆ canAssign() [2/2]

bool ITemplateResource::canAssign ( const int  cycle,
const MoveNode node 
) const
overridevirtual

The overridden method should be used instead.

Implements SchedulingResource.

Definition at line 134 of file ITemplateResource.cc.

134  {
135  abortWithError("Not implemented!");
136  return false;
137 }

References abortWithError.

Referenced by assign().

◆ clear()

void ITemplateResource::clear ( )
overridevirtual

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 from SchedulingResource.

Definition at line 204 of file ITemplateResource.cc.

204  {
206  resourceRecord_.clear();
207 }

References SchedulingResource::clear(), and resourceRecord_.

Here is the call graph for this function:

◆ isAvailable()

bool ITemplateResource::isAvailable ( const int  cycle) const
overridevirtual

Test if instruction tempalte resource is available in given cycle.

Parameters
cycleCycle to test.
Returns
True if resource available in given cycle.

Implements SchedulingResource.

Definition at line 79 of file ITemplateResource.cc.

79  {
80  return !isInUse(cycle);
81 }

References isInUse().

Here is the call graph for this function:

◆ isInUse()

bool ITemplateResource::isInUse ( const int  cycle) const
overridevirtual

Test if instruction template resource is used in given cycle.

Parameters
cycleCycle to test.
Returns
True if resource is used in given cycle.

Implements SchedulingResource.

Definition at line 63 of file ITemplateResource.cc.

63  {
65  if (MapTools::valueForKey<int>(resourceRecord_, instructionIndex(cycle)) != 0) {
66  return true;
67  }
68  }
69  return false;
70 }

References MapTools::containsKey(), SchedulingResource::instructionIndex(), and resourceRecord_.

Referenced by canAssign(), isAvailable(), and unassign().

Here is the call graph for this function:

◆ isITemplateResource()

bool ITemplateResource::isITemplateResource ( ) const
overridevirtual

Return true always.

Returns
True always.

Reimplemented from SchedulingResource.

Definition at line 156 of file ITemplateResource.cc.

156  {
157  return true;
158 }

◆ operator<()

bool ITemplateResource::operator< ( const SchedulingResource other) const
overridevirtual

Comparison operator.

Favours itemplates with more nop slots.

Reimplemented from SchedulingResource.

Definition at line 215 of file ITemplateResource.cc.

215  {
216  const ITemplateResource *itr = static_cast<const ITemplateResource*>(&other);
217  if (itr == NULL) {
218  return false;
219  }
220 
221  return SchedulingResource::operator<(other);
222 }

References SchedulingResource::operator<().

Here is the call graph for this function:

◆ operator=()

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

◆ unassign() [1/2]

void ITemplateResource::unassign ( const int  cycle)
virtual

Unassign instruction template from given cycle.

Parameters
cycleCycle to remove assignment from.

Definition at line 123 of file ITemplateResource.cc.

123  {
124 
125  if (isInUse(cycle)) {
127  }
128 }

References SchedulingResource::instructionIndex(), isInUse(), and resourceRecord_.

Here is the call graph for this function:

◆ unassign() [2/2]

void ITemplateResource::unassign ( const int  cycle,
MoveNode node 
)
overridevirtual

The overridden method should be used instead.

Implements SchedulingResource.

Definition at line 112 of file ITemplateResource.cc.

112  {
113 
114  abortWithError("Not implemented!");
115 }

References abortWithError.

Referenced by ITemplateBroker::assign(), ITemplateBroker::assignImmediate(), and ITemplateBroker::unassignImmediate().

◆ validateDependentGroups()

bool ITemplateResource::validateDependentGroups ( )
overrideprotectedvirtual

Tests if all referred resources in dependent groups are of proper types.

Returns
True If all resources in dependent groups are immediate units or buses (move slots).

Reimplemented from SchedulingResource.

Definition at line 168 of file ITemplateResource.cc.

168  {
169  for (int i = 0; i < dependentResourceGroupCount(); i++) {
170  for (int j = 0, count = dependentResourceCount(i); j < count; j++) {
171  if (!(dependentResource(i, j).isIUResource() ||
172  dependentResource(i, j).isBusResource())) {
173  return false;
174  }
175  }
176  }
177  return true;
178 }

References SchedulingResource::dependentResource(), SchedulingResource::dependentResourceCount(), SchedulingResource::dependentResourceGroupCount(), SchedulingResource::isBusResource(), and SchedulingResource::isIUResource().

Here is the call graph for this function:

◆ validateRelatedGroups()

bool ITemplateResource::validateRelatedGroups ( )
overrideprotectedvirtual

Tests if related resource groups are empty.

Returns
True if related resource groups are empty.
Note
This resource type has no related resources.

Reimplemented from SchedulingResource.

Definition at line 187 of file ITemplateResource.cc.

187  {
188  for (int i = 0; i < relatedResourceGroupCount(); i++) {
189  if (relatedResourceCount(i) > 0) {
190  return false;
191  }
192  }
193  return true;
194 }

References SchedulingResource::relatedResourceCount(), and SchedulingResource::relatedResourceGroupCount().

Here is the call graph for this function:

Member Data Documentation

◆ resourceRecord_

ResourceRecordType ITemplateResource::resourceRecord_
private

Definition at line 82 of file ITemplateResource.hh.

Referenced by assign(), clear(), isInUse(), and unassign().

◆ template_

TTAMachine::InstructionTemplate* ITemplateResource::template_
private

Definition at line 83 of file ITemplateResource.hh.


The documentation for this class was generated from the following files:
SchedulingResource::dependentResourceGroupCount
virtual int dependentResourceGroupCount() const
Definition: SchedulingResource.cc:71
SchedulingResource::clear
virtual void clear()
Definition: SchedulingResource.cc:397
SchedulingResource::SchedulingResource
SchedulingResource(const std::string &name, const unsigned int ii=0)
Definition: SchedulingResource.cc:51
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ITemplateResource::resourceRecord_
ResourceRecordType resourceRecord_
Definition: ITemplateResource.hh:82
ITemplateResource::canAssign
virtual bool canAssign(const int cycle, const MoveNode &node) const override
Definition: ITemplateResource.cc:134
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::isBusResource
virtual bool isBusResource() const
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
SchedulingResource::operator<
virtual bool operator<(const SchedulingResource &other) const
SchedulingResource::instructionIndex
int instructionIndex(int cycle) const
SchedulingResource::initiationInterval
int initiationInterval() const
Definition: SchedulingResource.cc:385
SchedulingResource::relatedResourceCount
int relatedResourceCount(const int group) const
SchedulingResource::isIUResource
virtual bool isIUResource() const
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
ITemplateResource::template_
TTAMachine::InstructionTemplate * template_
Definition: ITemplateResource.hh:83
ITemplateResource
Definition: ITemplateResource.hh:51
SchedulingResource::relatedResourceGroupCount
virtual int relatedResourceGroupCount() const
Definition: SchedulingResource.cc:61
ITemplateResource::isInUse
virtual bool isInUse(const int cycle) const override
Definition: ITemplateResource.cc:63