OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
FSAFUResourceConflictDetector Class Reference

#include <FSAFUResourceConflictDetector.hh>

Inheritance diagram for FSAFUResourceConflictDetector:
Inheritance graph
Collaboration diagram for FSAFUResourceConflictDetector:
Collaboration graph

Public Member Functions

 FSAFUResourceConflictDetector (const TTAMachine::FunctionUnit &fu)
 
virtual ~FSAFUResourceConflictDetector ()
 
virtual bool issueOperation (OperationID id)
 
virtual bool advanceCycle ()
 
virtual bool isIdle ()
 
bool issueOperationInline (OperationID id)
 
bool issueOperationLazyInline (OperationID id)
 
bool advanceCycleInline ()
 
bool advanceCycleLazyInline ()
 
virtual void reset ()
 
void initializeAllStates ()
 
const char * operationName (OperationID id) const
 
virtual OperationID operationID (const TCEString &operationName) const
 
virtual void writeToDotFile (const TCEString &fileName) const
 
- Public Member Functions inherited from FUResourceConflictDetector
 FUResourceConflictDetector ()
 
virtual ~FUResourceConflictDetector ()
 
virtual void endClock ()
 
virtual void advanceClock ()
 
- Public Member Functions inherited from ClockedState
 ClockedState ()
 
virtual ~ClockedState ()
 

Private Attributes

FSAFUResourceConflictDetectorPimplpimpl_
 Private implementation in a separate source file. More...
 

Additional Inherited Members

- Public Types inherited from FUResourceConflictDetector
typedef int OperationID
 Type for identifying operations in the conflict detector interface. More...
 
- Protected Attributes inherited from FUResourceConflictDetector
OperationIDIndexoperationIndices_
 Map for finding indices for operations quickly. More...
 

Detailed Description

An FSA implementation of a FU resource conflict detector.

Definition at line 49 of file FSAFUResourceConflictDetector.hh.

Constructor & Destructor Documentation

◆ FSAFUResourceConflictDetector()

FSAFUResourceConflictDetector::FSAFUResourceConflictDetector ( const TTAMachine::FunctionUnit fu)

Constructor.

Initializes the FSA to a lazy mode in which the states are built when they are needed the first time. In order to initialize all states, call initializeAllStates().

Parameters
fuThe function unit to detect conflicts for.
Exceptions
InvalidDataIf the model could not be built from the given FU.

Definition at line 52 of file FSAFUResourceConflictDetector.cc.

References issueOperation(), FSAFUResourceConflictDetectorPimpl::NOP, and pimpl_.

Here is the call graph for this function:

◆ ~FSAFUResourceConflictDetector()

FSAFUResourceConflictDetector::~FSAFUResourceConflictDetector ( )
virtual

Destructor.

Definition at line 62 of file FSAFUResourceConflictDetector.cc.

62  {
63  delete pimpl_;
64  pimpl_ = NULL;
65 }

References pimpl_.

Member Function Documentation

◆ advanceCycle()

bool FSAFUResourceConflictDetector::advanceCycle ( )
virtual

Simulates a cycle advance and reports a conflict if detected.

Returns
False in case a conflict is detected, otherwise true.

Reimplemented from FUResourceConflictDetector.

Definition at line 120 of file FSAFUResourceConflictDetector.cc.

120  {
121  return advanceCycleLazyInline();
122 }

References advanceCycleLazyInline().

Here is the call graph for this function:

◆ advanceCycleInline()

bool FSAFUResourceConflictDetector::advanceCycleInline ( )
inline

Simulates a cycle advance and reports a conflict if detected.

Inlineable optimized version for compiled simulation and benchmarking.

Note
Do not call this in case the last operation issue transfered the FSA to the illegal state! That is, returned false. No checking is done to get fastest possible simulation.
Returns
False in case a conflict is detected, otherwise true.

Definition at line 230 of file FSAFUResourceConflictDetector.cc.

230  {
231 
232  // assert(nextState_ != FiniteStateAutomaton::ILLEGAL_STATE);
234  // issue NOP transition at the next cycle in case there are no other
235  // operation issues
237  fsa_.transitions_[pimpl_->currentState_][pimpl_->NOP];
238  return true;
239 }

References FSAFUResourceConflictDetectorPimpl::currentState_, FSAFUResourceConflictDetectorPimpl::nextState_, FSAFUResourceConflictDetectorPimpl::NOP, and pimpl_.

◆ advanceCycleLazyInline()

bool FSAFUResourceConflictDetector::advanceCycleLazyInline ( )
inline

Simulates a cycle advance and reports a conflict if detected.

Inlineable optimized version for compiled simulation and benchmarking.

Note
Do not call this in case the last operation issue transfered the FSA to the illegal state! That is, returned false. No checking is done to get fastest possible simulation.
Returns
False in case a conflict is detected, otherwise true.

Definition at line 253 of file FSAFUResourceConflictDetector.cc.

253  {
254 
255  // assert(nextState_ != FiniteStateAutomaton::ILLEGAL_STATE);
257  // issue NOP transition at the next cycle in case there are no other
258  // operation issues
263  }
264  return true;
265 }

References FSAFUResourceConflictDetectorPimpl::currentState_, FSAFUResourceConflictDetectorPimpl::fsa_, FSAFUResourceConflictDetectorPimpl::nextState_, FSAFUResourceConflictDetectorPimpl::NOP, pimpl_, FUFiniteStateAutomaton::resolveState(), FiniteStateAutomaton::transitions_, and FiniteStateAutomaton::UNKNOWN_STATE.

Referenced by advanceCycle().

Here is the call graph for this function:

◆ initializeAllStates()

void FSAFUResourceConflictDetector::initializeAllStates ( )

Initializes all states in the state machine.

By default, only the initial state is constructed and rest when visited the first time.

Definition at line 74 of file FSAFUResourceConflictDetector.cc.

74  {
76 }

References FUFiniteStateAutomaton::buildStateMachine(), FSAFUResourceConflictDetectorPimpl::fsa_, and pimpl_.

Here is the call graph for this function:

◆ isIdle()

bool FSAFUResourceConflictDetector::isIdle ( )
virtual

The FSA FU model is considered to be idle when the FSA is at start state and there are no new operations issued at that state.

Reimplemented from FUResourceConflictDetector.

Definition at line 157 of file FSAFUResourceConflictDetector.cc.

157  {
158  return pimpl_->currentState_ == pimpl_->fsa_.startState()
160 }

References FSAFUResourceConflictDetectorPimpl::currentState_, FSAFUResourceConflictDetectorPimpl::fsa_, FSAFUResourceConflictDetectorPimpl::nextState_, pimpl_, and FiniteStateAutomaton::startState().

Here is the call graph for this function:

◆ issueOperation()

bool FSAFUResourceConflictDetector::issueOperation ( OperationID  id)
virtual

Issues an operation and reports a conflict if detected.

Parameters
idThe id of the operation to issue.
Returns
False in case a conflict is detected, otherwise true.

Reimplemented from FUResourceConflictDetector.

Definition at line 99 of file FSAFUResourceConflictDetector.cc.

99  {
100  return issueOperationLazyInline(id);
101 }

References issueOperationLazyInline().

Referenced by FSAFUResourceConflictDetector(), and reset().

Here is the call graph for this function:

◆ issueOperationInline()

bool FSAFUResourceConflictDetector::issueOperationInline ( OperationID  id)

Issues an operation and reports a conflict if detected.

Inlineable optimized version for compiled simulation and benchmarking. All states are assumed initialized. For lazily initialized FSA, use issueOperationLazyInline(). This version has about balanced runtime for conflict and no-conflict cases for sensible benchmarking with random operation sequences.

Parameters
idThe id of the operation to issue.
Returns
False in case a conflict is detected, otherwise true.

Definition at line 184 of file FSAFUResourceConflictDetector.cc.

184  {
185 
188  pimpl_->nextState_ = 0;
189  return false;
190  }
191  return true;
192 }

References FSAFUResourceConflictDetectorPimpl::currentState_, FSAFUResourceConflictDetectorPimpl::fsa_, FiniteStateAutomaton::ILLEGAL_STATE, FSAFUResourceConflictDetectorPimpl::nextState_, pimpl_, and FiniteStateAutomaton::transitions_.

◆ issueOperationLazyInline()

bool FSAFUResourceConflictDetector::issueOperationLazyInline ( OperationID  id)

Issues an operation and reports a conflict if detected.

Inlineable optimized version for compiled simulation and benchmarking. For lazily initialized FSA. Checks if a state is missing and constructs it if needed.

Parameters
idThe id of the operation to issue.
Returns
False in case a conflict is detected, otherwise true.

Definition at line 205 of file FSAFUResourceConflictDetector.cc.

205  {
206 
210  }
212  pimpl_->nextState_ = 0;
213  return false;
214  }
215  return true;
216 }

References FSAFUResourceConflictDetectorPimpl::currentState_, FSAFUResourceConflictDetectorPimpl::fsa_, FiniteStateAutomaton::ILLEGAL_STATE, FSAFUResourceConflictDetectorPimpl::nextState_, pimpl_, FUFiniteStateAutomaton::resolveState(), FiniteStateAutomaton::transitions_, and FiniteStateAutomaton::UNKNOWN_STATE.

Referenced by issueOperation().

Here is the call graph for this function:

◆ operationID()

FSAFUResourceConflictDetector::OperationID FSAFUResourceConflictDetector::operationID ( const TCEString operationName) const
virtual

Returns an operation id for the given operation.

Operation IDs are used in the interface for optimizing the access. This method converts OSAL Operations to operation IDs.

Parameters
operationThe OSAL Operation to find ID for.
Returns
The operation ID.

Reimplemented from FUResourceConflictDetector.

Definition at line 134 of file FSAFUResourceConflictDetector.cc.

135  {
136 
137  return pimpl_->fsa_.transitionIndex(
139 }

References FSAFUResourceConflictDetectorPimpl::fsa_, operationName(), pimpl_, StringTools::stringToUpper(), and FiniteStateAutomaton::transitionIndex().

Here is the call graph for this function:

◆ operationName()

const char * FSAFUResourceConflictDetector::operationName ( OperationID  id) const

Returns the name of the operation associated to the given transition id.

Parameters
idThe transition id.
Returns
The name of the operation.

Definition at line 110 of file FSAFUResourceConflictDetector.cc.

110  {
111  return pimpl_->fsa_.transitionName(id).c_str();
112 }

References FSAFUResourceConflictDetectorPimpl::fsa_, pimpl_, and FiniteStateAutomaton::transitionName().

Referenced by operationID().

Here is the call graph for this function:

◆ reset()

void FSAFUResourceConflictDetector::reset ( )
virtual

Sets the state of the detector to its initial state.

This means that the FU state is assumed to be what it is in powerup.

Reimplemented from FUResourceConflictDetector.

Definition at line 147 of file FSAFUResourceConflictDetector.cc.

147  {
150 }

References FSAFUResourceConflictDetectorPimpl::currentState_, FSAFUResourceConflictDetectorPimpl::fsa_, issueOperation(), FSAFUResourceConflictDetectorPimpl::NOP, pimpl_, and FiniteStateAutomaton::startState().

Here is the call graph for this function:

◆ writeToDotFile()

void FSAFUResourceConflictDetector::writeToDotFile ( const TCEString fileName) const
virtual

Writes the state machine to a Graphviz dot file.

Parameters
fileNameThe file name.

Definition at line 84 of file FSAFUResourceConflictDetector.cc.

85  {
86 
87  std::ofstream dot(fileName.c_str());
88  dot << pimpl_->fsa_.toDotString() << std::endl;
89  dot.close();
90 }

References FSAFUResourceConflictDetectorPimpl::fsa_, pimpl_, and FiniteStateAutomaton::toDotString().

Here is the call graph for this function:

Member Data Documentation

◆ pimpl_

FSAFUResourceConflictDetectorPimpl* FSAFUResourceConflictDetector::pimpl_
private

The documentation for this class was generated from the following files:
FSAFUResourceConflictDetector::advanceCycleLazyInline
bool advanceCycleLazyInline()
Definition: FSAFUResourceConflictDetector.cc:253
FiniteStateAutomaton::ILLEGAL_STATE
static const FSAStateIndex ILLEGAL_STATE
A state id which denotes an illegal state.
Definition: FiniteStateAutomaton.hh:61
FiniteStateAutomaton::transitions_
TransitionMap transitions_
The state transitions. In protected to allow fast access from derived classes.
Definition: FiniteStateAutomaton.hh:120
FiniteStateAutomaton::startState
virtual FSAStateIndex startState() const
Definition: FiniteStateAutomaton.cc:282
FiniteStateAutomaton::transitionName
virtual const std::string & transitionName(FSAStateTransitionIndex transition) const
Definition: FiniteStateAutomaton.cc:81
FSAFUResourceConflictDetectorPimpl::currentState_
FiniteStateAutomaton::FSAStateIndex currentState_
Current state of the FSA.
Definition: FSAFUResourceConflictDetectorPimpl.hh:64
FUFiniteStateAutomaton::buildStateMachine
void buildStateMachine()
Definition: FUFiniteStateAutomaton.cc:176
FUFiniteStateAutomaton::resolveState
FiniteStateAutomaton::FSAStateIndex resolveState(FiniteStateAutomaton::FSAStateIndex source, FiniteStateAutomaton::FSAStateTransitionIndex transition)
Definition: FUFiniteStateAutomaton.cc:105
FiniteStateAutomaton::UNKNOWN_STATE
static const FSAStateIndex UNKNOWN_STATE
A state id which denotes an unknown (unresolved) state. Used for lazy construction of states.
Definition: FiniteStateAutomaton.hh:64
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
FSAFUResourceConflictDetector::pimpl_
FSAFUResourceConflictDetectorPimpl * pimpl_
Private implementation in a separate source file.
Definition: FSAFUResourceConflictDetector.hh:77
FSAFUResourceConflictDetectorPimpl
Definition: FSAFUResourceConflictDetectorPimpl.hh:48
FSAFUResourceConflictDetectorPimpl::NOP
const FiniteStateAutomaton::FSAStateTransitionIndex NOP
The transition index of a NOP operation.
Definition: FSAFUResourceConflictDetectorPimpl.hh:70
FiniteStateAutomaton::toDotString
virtual std::string toDotString() const
Definition: FiniteStateAutomaton.cc:235
FSAFUResourceConflictDetectorPimpl::fsa_
FUFiniteStateAutomaton fsa_
The FSA.
Definition: FSAFUResourceConflictDetectorPimpl.hh:62
FSAFUResourceConflictDetector::issueOperationLazyInline
bool issueOperationLazyInline(OperationID id)
Definition: FSAFUResourceConflictDetector.cc:205
FUResourceConflictDetector::FUResourceConflictDetector
FUResourceConflictDetector()
Definition: FUResourceConflictDetector.cc:42
FiniteStateAutomaton::transitionIndex
virtual FSAStateTransitionIndex transitionIndex(const std::string &transitionName) const
Definition: FiniteStateAutomaton.cc:120
FSAFUResourceConflictDetector::operationName
const char * operationName(OperationID id) const
Definition: FSAFUResourceConflictDetector.cc:110
FSAFUResourceConflictDetector::issueOperation
virtual bool issueOperation(OperationID id)
Definition: FSAFUResourceConflictDetector.cc:99
FSAFUResourceConflictDetectorPimpl::nextState_
FiniteStateAutomaton::FSAStateIndex nextState_
The next state of the FSA (move to currentState in cycle advance).
Definition: FSAFUResourceConflictDetectorPimpl.hh:66