OpenASIP
2.0
|
#include <FUFiniteStateAutomaton.hh>
Public Types | |
typedef FSAStateTransitionIndex | OperationID |
Public Types inherited from FiniteStateAutomaton | |
typedef int | FSAStateTransitionIndex |
Type used for indexing the transitions. More... | |
typedef int | FSAStateIndex |
Type used for indexing the states. More... | |
typedef std::set< FSAStateIndex > | FSAStateIndexSet |
Type for a set of state indices. More... | |
Private Types | |
typedef std::map< FSAStateIndex, CollisionMatrix * > | StateCollisionMatrixIndex |
Index for collision matrices of states (key is the state index). More... | |
typedef std::map< CollisionMatrix, FSAStateIndex > | CollisionMatrixStateIndex |
Index for finding the state for a collision matrix. More... | |
Private Member Functions | |
void | addCollisionMatrixForState (FSAStateIndex state, CollisionMatrix *matrix) |
FiniteStateAutomaton::FSAStateIndex | resolveState (FiniteStateAutomaton::FSAStateIndex source, FiniteStateAutomaton::FSAStateTransitionIndex transition) |
Private Attributes | |
FUCollisionMatrixIndex | operationCollisionMatrices_ |
Collision matrices of operations are stored here. More... | |
StateCollisionMatrixIndex | stateCollisionMatrices_ |
The collision matrices of each state. More... | |
CollisionMatrixStateIndex | collisionMatrixStates_ |
An index for quickly finding the state of a collision matrix. More... | |
FSAStateTransitionIndex | nopTransition_ |
The number of the NOP transition. More... | |
Friends | |
class | FSAFUResourceConflictDetector |
Friend due to highly optimized compiled simulation versions of the conflict detection functions. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from FiniteStateAutomaton | |
static const FSAStateIndex | ILLEGAL_STATE = -1 |
A state id which denotes an illegal state. More... | |
static const FSAStateIndex | UNKNOWN_STATE = -2 |
A state id which denotes an unknown (unresolved) state. Used for lazy construction of states. More... | |
Protected Types inherited from FiniteStateAutomaton | |
typedef std::vector< FSAStateIndex > | TransitionVector |
Vector which stores the target states of for each transition type. More... | |
typedef std::vector< TransitionVector > | TransitionMap |
Type for storing the transitions of each state. The vector stores for each state (indexed from 0) a vector with elements as many there are transitions. The value of the element is the target state to which the transition leads to, or ILLEGAL_STATE_INDEX if there is no transition for that transition type from that state. Using this structure it's possible to find the target state using two table (vector) lookups. More... | |
Protected Attributes inherited from FiniteStateAutomaton | |
TransitionMap | transitions_ |
The state transitions. In protected to allow fast access from derived classes. More... | |
Finite state automaton (FSA) used to model function unit pipeline resources.
Includes support for lazily initializing the states when needed.
Definition at line 55 of file FUFiniteStateAutomaton.hh.
|
private |
Index for finding the state for a collision matrix.
Definition at line 104 of file FUFiniteStateAutomaton.hh.
Definition at line 61 of file FUFiniteStateAutomaton.hh.
|
private |
Index for collision matrices of states (key is the state index).
Definition at line 100 of file FUFiniteStateAutomaton.hh.
FUFiniteStateAutomaton::FUFiniteStateAutomaton | ( | const TTAMachine::FunctionUnit & | fu, |
bool | lazyBuilding = true |
||
) |
Initializes the FSA from the given FU.
This version is to be used in fast compiled simulation that needs to minimize all function call overheads. To allow figuring out the state ids statically, they are assigned according to the operation's order in the FU when fetched with FunctionUnit::operation().
The last state id (id FunctionUnit::operationCount()) is reserved for NOP. This way compiled simulator may access the state array with a constant index when issuing an operation or checking for a conflict without runtime overhead for figuring out the state id first for each operation.
fu | The function unit to build the FSA from. |
lazyBuilding | True in case states should be built lazily the first time they are visited. Should improve startup time for larger FSAs. |
Definition at line 61 of file FUFiniteStateAutomaton.cc.
References addCollisionMatrixForState(), FiniteStateAutomaton::addState(), FUCollisionMatrixIndex::at(), buildStateMachine(), TTAMachine::HWOperation::name(), nopTransition_, TTAMachine::FunctionUnit::operation(), operationCollisionMatrices_, TTAMachine::FunctionUnit::operationCount(), FiniteStateAutomaton::setTransitionName(), and StringTools::stringToUpper().
|
virtual |
Destructor.
Definition at line 93 of file FUFiniteStateAutomaton.cc.
References AssocTools::deleteAllValues(), and stateCollisionMatrices_.
|
private |
Connects a state and a collision matrix.
state | The state index. |
matrix | The collision matrix (becomes owned by the index). |
Definition at line 162 of file FUFiniteStateAutomaton.cc.
References collisionMatrixStates_, and stateCollisionMatrices_.
Referenced by FUFiniteStateAutomaton(), and resolveState().
void FUFiniteStateAutomaton::advanceCycle | ( | ) |
void FUFiniteStateAutomaton::buildStateMachine | ( | ) |
Builds all states and state transitions.
This might take very long time if there are lots of states to build. That is, if the FU pipeline resource usage patterns are long and complicated.
Definition at line 176 of file FUFiniteStateAutomaton.cc.
References FiniteStateAutomaton::ILLEGAL_STATE, operationCollisionMatrices_, resolveState(), and FUCollisionMatrixIndex::size().
Referenced by FUFiniteStateAutomaton(), and FSAFUResourceConflictDetector::initializeAllStates().
bool FUFiniteStateAutomaton::conflictsWith | ( | OperationID | operation | ) | const |
Inline functions for fast access in the compiled simulator.
|
virtual |
Returns the index of the state resulting from the given transition from the given source state.
This method is called often, thus should be as fast as possible. Therefore, all range checking etc. is disabled. This implementation supports lazy initialization, i.e., it is capable of building missing states when requested.
source | The source state. |
transition | The transition. |
Reimplemented from FiniteStateAutomaton.
Definition at line 225 of file FUFiniteStateAutomaton.cc.
References resolveState(), FiniteStateAutomaton::transitions_, and FiniteStateAutomaton::UNKNOWN_STATE.
Referenced by isLegalTransition().
|
virtual |
Returns true in case the given transition is legal (accepted by the state machine) from the given state.
This method is called often, thus should be as fast as possible. Therefore, all range checking etc. is disabled. This implementation supports lazy initialization, i.e., it is capable of building missing states when requested.
source | The source state. |
transition | The transition. |
Reimplemented from FiniteStateAutomaton.
Definition at line 246 of file FUFiniteStateAutomaton.cc.
References destinationState(), and FiniteStateAutomaton::ILLEGAL_STATE.
void FUFiniteStateAutomaton::issueOperation | ( | OperationID | operation | ) |
FiniteStateAutomaton::FSAStateIndex FUFiniteStateAutomaton::joinState | ( | FSAStateIndexSet | sourceStates | ) |
Returns a join state which is created by ORin the conflict vectors of the given source states.
If the state already exists, returns it, creates a new state otherwise.
sourceStates | The set of source states which are joined. |
Definition at line 262 of file FUFiniteStateAutomaton.cc.
References abortWithError.
CollisionMatrix & FUFiniteStateAutomaton::operationCollisionMatrix | ( | const std::string | operationName | ) |
Returns the collision matrix for the given operation.
operationName | Name of the operation. |
Definition at line 205 of file FUFiniteStateAutomaton.cc.
References FUCollisionMatrixIndex::at(), operationCollisionMatrices_, StringTools::stringToUpper(), and FiniteStateAutomaton::transitionIndex().
Referenced by resolveState().
|
private |
Initializes the given state transition entry.
The transition target state is resolved and built if necessary.
Definition at line 105 of file FUFiniteStateAutomaton.cc.
References addCollisionMatrixForState(), FiniteStateAutomaton::addState(), FUCollisionMatrixIndex::at(), collisionMatrixStates_, FiniteStateAutomaton::ILLEGAL_STATE, CollisionMatrix::isCollision(), nopTransition_, operationCollisionMatrices_, operationCollisionMatrix(), BitMatrix::orWith(), FiniteStateAutomaton::setTransition(), BitMatrix::shiftLeft(), and stateCollisionMatrices_.
Referenced by FSAFUResourceConflictDetector::advanceCycleLazyInline(), buildStateMachine(), destinationState(), and FSAFUResourceConflictDetector::issueOperationLazyInline().
|
virtual |
Returns the textual description of the state at the given index.
state | The index of the state of which name to return. |
Reimplemented from FiniteStateAutomaton.
Definition at line 274 of file FUFiniteStateAutomaton.cc.
References __func__, and stateCollisionMatrices_.
|
friend |
Friend due to highly optimized compiled simulation versions of the conflict detection functions.
Definition at line 59 of file FUFiniteStateAutomaton.hh.
|
private |
An index for quickly finding the state of a collision matrix.
Definition at line 111 of file FUFiniteStateAutomaton.hh.
Referenced by addCollisionMatrixForState(), and resolveState().
|
private |
The number of the NOP transition.
Definition at line 113 of file FUFiniteStateAutomaton.hh.
Referenced by FUFiniteStateAutomaton(), and resolveState().
|
private |
Collision matrices of operations are stored here.
Definition at line 107 of file FUFiniteStateAutomaton.hh.
Referenced by buildStateMachine(), FUFiniteStateAutomaton(), operationCollisionMatrix(), and resolveState().
|
private |
The collision matrices of each state.
Definition at line 109 of file FUFiniteStateAutomaton.hh.
Referenced by addCollisionMatrixForState(), resolveState(), stateName(), and ~FUFiniteStateAutomaton().