OpenASIP  2.0
FUFiniteStateAutomaton.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file FUFiniteStateAutomaton.hh
26  *
27  * Declaration of FUFiniteStateAutomaton class.
28  *
29  * @author Pekka Jääskeläinen 2006 (pekka.jaaskelainen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_FU_FINITE_STATE_AUTOMATON_HH
34 #define TTA_FU_FINITE_STATE_AUTOMATON_HH
35 
36 #include <string>
37 #include "FiniteStateAutomaton.hh"
38 #include "Exception.hh"
40 
41 namespace TTAMachine {
42  class FunctionUnit;
43 }
44 
45 class ResourceVectorSet;
46 class CollisionMatrix;
47 class ReservationTable;
48 
49 /**
50  * Finite state automaton (FSA) used to model function unit pipeline
51  * resources.
52  *
53  * Includes support for lazily initializing the states when needed.
54  */
56 public:
57  /// Friend due to highly optimized compiled simulation versions of
58  /// the conflict detection functions.
60 
62 
64  const TTAMachine::FunctionUnit& fu,
65  bool lazyBuilding = true);
66  virtual ~FUFiniteStateAutomaton();
67 
69 
71  const std::string operationName);
72 
74  FSAStateIndex source,
75  FSAStateTransitionIndex transition);
76 
77  virtual bool isLegalTransition(
78  FSAStateIndex source,
79  FSAStateTransitionIndex transition);
80 
81  virtual std::string stateName(FSAStateIndex state) const;
82 
83  /// Inline functions for fast access in the compiled simulator.
84  bool conflictsWith(OperationID operation) const;
85  void issueOperation(OperationID operation);
86  void advanceCycle();
87 
88  void buildStateMachine();
89 
90 private:
92  FSAStateIndex state, CollisionMatrix* matrix);
93 
97 
98  /// Index for collision matrices of states (key is the state index).
99  typedef std::map<FSAStateIndex, CollisionMatrix*>
101 
102  /// Index for finding the state for a collision matrix.
103  typedef std::map<CollisionMatrix, FSAStateIndex>
105 
106  /// Collision matrices of operations are stored here.
108  /// The collision matrices of each state.
110  /// An index for quickly finding the state of a collision matrix.
112  /// The number of the NOP transition.
114 };
115 
116 #endif
FiniteStateAutomaton::FSAStateIndex
int FSAStateIndex
Type used for indexing the states.
Definition: FiniteStateAutomaton.hh:57
FUFiniteStateAutomaton::isLegalTransition
virtual bool isLegalTransition(FSAStateIndex source, FSAStateTransitionIndex transition)
Definition: FUFiniteStateAutomaton.cc:246
Exception.hh
FUFiniteStateAutomaton::FUFiniteStateAutomaton
FUFiniteStateAutomaton(const TTAMachine::FunctionUnit &fu, bool lazyBuilding=true)
Definition: FUFiniteStateAutomaton.cc:61
FUFiniteStateAutomaton::addCollisionMatrixForState
void addCollisionMatrixForState(FSAStateIndex state, CollisionMatrix *matrix)
Definition: FUFiniteStateAutomaton.cc:162
FUFiniteStateAutomaton::operationCollisionMatrix
CollisionMatrix & operationCollisionMatrix(const std::string operationName)
Definition: FUFiniteStateAutomaton.cc:205
FUFiniteStateAutomaton::issueOperation
void issueOperation(OperationID operation)
FUFiniteStateAutomaton::~FUFiniteStateAutomaton
virtual ~FUFiniteStateAutomaton()
Definition: FUFiniteStateAutomaton.cc:93
FiniteStateAutomaton.hh
FUFiniteStateAutomaton::advanceCycle
void advanceCycle()
FUFiniteStateAutomaton::buildStateMachine
void buildStateMachine()
Definition: FUFiniteStateAutomaton.cc:176
FUFiniteStateAutomaton::stateName
virtual std::string stateName(FSAStateIndex state) const
Definition: FUFiniteStateAutomaton.cc:274
FUFiniteStateAutomaton::StateCollisionMatrixIndex
std::map< FSAStateIndex, CollisionMatrix * > StateCollisionMatrixIndex
Index for collision matrices of states (key is the state index).
Definition: FUFiniteStateAutomaton.hh:100
FUFiniteStateAutomaton::stateCollisionMatrices_
StateCollisionMatrixIndex stateCollisionMatrices_
The collision matrices of each state.
Definition: FUFiniteStateAutomaton.hh:109
FUFiniteStateAutomaton::resolveState
FiniteStateAutomaton::FSAStateIndex resolveState(FiniteStateAutomaton::FSAStateIndex source, FiniteStateAutomaton::FSAStateTransitionIndex transition)
Definition: FUFiniteStateAutomaton.cc:105
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
FUFiniteStateAutomaton::joinState
FSAStateIndex joinState(FSAStateIndexSet sourceStates)
Definition: FUFiniteStateAutomaton.cc:262
FUFiniteStateAutomaton::OperationID
FSAStateTransitionIndex OperationID
Definition: FUFiniteStateAutomaton.hh:61
FUFiniteStateAutomaton::destinationState
virtual FSAStateIndex destinationState(FSAStateIndex source, FSAStateTransitionIndex transition)
Definition: FUFiniteStateAutomaton.cc:225
FUFiniteStateAutomaton::nopTransition_
FSAStateTransitionIndex nopTransition_
The number of the NOP transition.
Definition: FUFiniteStateAutomaton.hh:113
FUFiniteStateAutomaton::operationCollisionMatrices_
FUCollisionMatrixIndex operationCollisionMatrices_
Collision matrices of operations are stored here.
Definition: FUFiniteStateAutomaton.hh:107
FiniteStateAutomaton
Definition: FiniteStateAutomaton.hh:49
FUCollisionMatrixIndex
Definition: FUCollisionMatrixIndex.hh:47
FSAFUResourceConflictDetector::operationName
const char * operationName(OperationID id) const
Definition: FSAFUResourceConflictDetector.cc:110
FiniteStateAutomaton::FSAStateTransitionIndex
int FSAStateTransitionIndex
Type used for indexing the transitions.
Definition: FiniteStateAutomaton.hh:55
FUFiniteStateAutomaton::conflictsWith
bool conflictsWith(OperationID operation) const
Inline functions for fast access in the compiled simulator.
FUFiniteStateAutomaton::CollisionMatrixStateIndex
std::map< CollisionMatrix, FSAStateIndex > CollisionMatrixStateIndex
Index for finding the state for a collision matrix.
Definition: FUFiniteStateAutomaton.hh:104
FSAFUResourceConflictDetector
Definition: FSAFUResourceConflictDetector.hh:49
ReservationTable
Definition: ReservationTable.hh:49
FUCollisionMatrixIndex.hh
FUFiniteStateAutomaton::collisionMatrixStates_
CollisionMatrixStateIndex collisionMatrixStates_
An index for quickly finding the state of a collision matrix.
Definition: FUFiniteStateAutomaton.hh:111
FUFiniteStateAutomaton
Definition: FUFiniteStateAutomaton.hh:55
TTAMachine
Definition: Assembler.hh:48
FiniteStateAutomaton::FSAStateIndexSet
std::set< FSAStateIndex > FSAStateIndexSet
Type for a set of state indices.
Definition: FiniteStateAutomaton.hh:59
CollisionMatrix
Definition: CollisionMatrix.hh:49