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

#include <PSocketResource.hh>

Inheritance diagram for PSocketResource:
Inheritance graph
Collaboration diagram for PSocketResource:
Collaboration graph

Public Member Functions

virtual ~PSocketResource ()
 
 PSocketResource (const std::string &name, 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 void assign (const int cycle, MoveNode &node) override
 
virtual void unassign (const int cycle, MoveNode &node) override
 
void clear () 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
 
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 setMaxCycle (unsigned int)
 

Protected Types

typedef std::map< int, std::set< MoveNode * > > ResourceRecordType
 

Protected Attributes

ResourceRecordType resourceRecord_
 
- Protected Attributes inherited from SchedulingResource
int initiationInterval_
 

Private Member Functions

 PSocketResource (const PSocketResource &)
 
PSocketResourceoperator= (const PSocketResource &)
 

Additional Inherited Members

- Protected Member Functions inherited from SchedulingResource
virtual bool validateDependentGroups ()
 
virtual bool validateRelatedGroups ()
 

Detailed Description

An interface for scheduling resources of Resource Model.

The derived class PSocketResource represents a combined resource of a FU/RF port and a socket that connects it to a bus.

Definition at line 48 of file PSocketResource.hh.

Member Typedef Documentation

◆ ResourceRecordType

typedef std::map<int, std::set<MoveNode*> > PSocketResource::ResourceRecordType
protected

Definition at line 61 of file PSocketResource.hh.

Constructor & Destructor Documentation

◆ ~PSocketResource()

PSocketResource::~PSocketResource ( )
virtual

Empty constructor

Definition at line 52 of file PSocketResource.cc.

52 {}

◆ PSocketResource() [1/2]

PSocketResource::PSocketResource ( const std::string &  name,
unsigned int  initiationInterval = 0 
)

Constructor defining name of resource

Parameters
nameName of resource

Definition at line 46 of file PSocketResource.cc.

◆ PSocketResource() [2/2]

PSocketResource::PSocketResource ( const PSocketResource )
private

Member Function Documentation

◆ assign()

void PSocketResource::assign ( const int  cycle,
MoveNode mn 
)
overridevirtual

Assign resource to given node for given cycle.

Parameters
cycleCycle to assign
nodeMoveNode to assign
Exceptions
Incase PSocket can not be assigned
Note
Exception is internal error, resource should be tested with canAssign() before assign() is called.

Implements SchedulingResource.

Reimplemented in OutputPSocketResource.

Definition at line 105 of file PSocketResource.cc.

106 {
107  resourceRecord_[instructionIndex(cycle)].insert(&mn);
109  return;
110 }

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

Referenced by OutputPSocketResource::assign().

Here is the call graph for this function:

◆ canAssign()

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

Return true if resource can be assigned for given resource in given cycle.

Parameters
cycleCycle to test
nodeMoveNode to test
Returns
true if node can be assigned to cycle

Implements SchedulingResource.

Reimplemented in OutputPSocketResource, and InputPSocketResource.

Definition at line 139 of file PSocketResource.cc.

139  {
140 
141  ResourceRecordType::const_iterator iter = resourceRecord_.find(cycle);
142  if (iter != resourceRecord_.end()) {
143  const std::set<MoveNode*>& movesInCycle = iter->second;
144  for (std::set<MoveNode*>::const_iterator i = movesInCycle.begin();
145  i != movesInCycle.end(); i++) {
146  MoveNode* mn = *i;
147 #ifdef NO_OVERCOMMIT
148  return false;
149 #else
150  if (node.move().isUnconditional() ||
151  mn->move().isUnconditional()) {
152  return false;
153  }
154  if (!node.move().guard().guard().isOpposite(
155  mn->move().guard().guard())) {
156  return false;
157  }
158 #endif
159  }
160  }
161  return true;
162 }

References TTAProgram::MoveGuard::guard(), TTAProgram::Move::guard(), TTAMachine::Guard::isOpposite(), TTAProgram::Move::isUnconditional(), MoveNode::move(), and resourceRecord_.

Here is the call graph for this function:

◆ clear()

void PSocketResource::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 171 of file PSocketResource.cc.

171  {
173  resourceRecord_.clear();
174 }

References SchedulingResource::clear(), and resourceRecord_.

Referenced by OutputPSocketResource::clear().

Here is the call graph for this function:

◆ isAvailable()

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

Test if resource PSocketResource is available

Parameters
cycleCycle which to test
Returns
True if p-socket is available in cycle

Implements SchedulingResource.

Reimplemented in OutputPSocketResource.

Definition at line 80 of file PSocketResource.cc.

80  {
81  ResourceRecordType::const_iterator iter =
82  resourceRecord_.find(instructionIndex(cycle));
83  if (iter != resourceRecord_.end() && iter->second.size() > 0) {
84  const std::set<MoveNode*>& movesInCycle = iter->second;
85  for (std::set<MoveNode*>::const_iterator i = movesInCycle.begin();
86  i != movesInCycle.end(); i++) {
87  if ((*i)->move().isUnconditional()) {
88  return false;
89  }
90  }
91  }
92  return true;
93 }

References SchedulingResource::instructionIndex(), and resourceRecord_.

Here is the call graph for this function:

◆ isInUse()

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

Test if resource PSocketResource is used in given cycle

The PSocket is inUse if it is read from or written to at least once.

Parameters
cycleCycle which to test
Returns
True if p-socket is already used in cycle

Implements SchedulingResource.

Definition at line 64 of file PSocketResource.cc.

64  {
65  ResourceRecordType::const_iterator iter =
66  resourceRecord_.find(instructionIndex(cycle));
67  if (iter != resourceRecord_.end() && iter->second.size() > 0) {
68  return true;
69  }
70  return false;
71 }

References SchedulingResource::instructionIndex(), and resourceRecord_.

Referenced by unassign().

Here is the call graph for this function:

◆ operator=()

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

◆ unassign()

void PSocketResource::unassign ( const int  cycle,
MoveNode mn 
)
overridevirtual

Unassign resource from given node for given cycle.

Parameters
cycleCycle to remove assignment from
nodeMoveNode to remove assignment from
Exceptions
Incase the PSocket was not assigned before.

Implements SchedulingResource.

Reimplemented in OutputPSocketResource.

Definition at line 120 of file PSocketResource.cc.

121 {
122  if (isInUse(cycle)) {
123  resourceRecord_[instructionIndex(cycle)].erase(&mn);
125  return;
126  }
127  std::string msg = "PSocket was not assigned so it can not be unassigned!";
128  throw InvalidData(__FILE__, __LINE__, __func__, msg);
129 }

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

Referenced by OutputPSocketResource::unassign().

Here is the call graph for this function:

Member Data Documentation

◆ resourceRecord_

ResourceRecordType PSocketResource::resourceRecord_
protected

The documentation for this class was generated from the following files:
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
TTAProgram::Move::isUnconditional
bool isUnconditional() const
Definition: Move.cc:154
MoveNode
Definition: MoveNode.hh:65
InvalidData
Definition: Exception.hh:149
TTAProgram::Move::guard
MoveGuard & guard() const
Definition: Move.cc:345
__func__
#define __func__
Definition: Application.hh:67
SchedulingResource::instructionIndex
int instructionIndex(int cycle) const
PSocketResource::isInUse
virtual bool isInUse(const int cycle) const override
Definition: PSocketResource.cc:64
SchedulingResource::initiationInterval
int initiationInterval() const
Definition: SchedulingResource.cc:385
TTAMachine::Guard::isOpposite
virtual bool isOpposite(const Guard &guard) const =0
MoveNode::move
TTAProgram::Move & move()
SchedulingResource::decreaseUseCount
virtual void decreaseUseCount()
Definition: SchedulingResource.cc:364
SchedulingResource::name
virtual const std::string & name() const
TTAProgram::MoveGuard::guard
const TTAMachine::Guard & guard() const
Definition: MoveGuard.cc:86
PSocketResource::resourceRecord_
ResourceRecordType resourceRecord_
Definition: PSocketResource.hh:63
SchedulingResource::increaseUseCount
virtual void increaseUseCount()
Definition: SchedulingResource.cc:355