OpenASIP 2.2
Loading...
Searching...
No Matches
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>
38#include "Exception.hh"
40
41namespace TTAMachine {
42 class FunctionUnit;
43}
44
45class ResourceVectorSet;
46class CollisionMatrix;
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 */
56public:
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);
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);
87
88 void buildStateMachine();
89
90private:
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
virtual FSAStateIndex destinationState(FSAStateIndex source, FSAStateTransitionIndex transition)
StateCollisionMatrixIndex stateCollisionMatrices_
The collision matrices of each state.
virtual bool isLegalTransition(FSAStateIndex source, FSAStateTransitionIndex transition)
std::map< CollisionMatrix, FSAStateIndex > CollisionMatrixStateIndex
Index for finding the state for a collision matrix.
std::map< FSAStateIndex, CollisionMatrix * > StateCollisionMatrixIndex
Index for collision matrices of states (key is the state index).
FiniteStateAutomaton::FSAStateIndex resolveState(FiniteStateAutomaton::FSAStateIndex source, FiniteStateAutomaton::FSAStateTransitionIndex transition)
FSAStateTransitionIndex OperationID
FSAStateIndex joinState(FSAStateIndexSet sourceStates)
CollisionMatrixStateIndex collisionMatrixStates_
An index for quickly finding the state of a collision matrix.
virtual std::string stateName(FSAStateIndex state) const
FSAStateTransitionIndex nopTransition_
The number of the NOP transition.
bool conflictsWith(OperationID operation) const
Inline functions for fast access in the compiled simulator.
FUCollisionMatrixIndex operationCollisionMatrices_
Collision matrices of operations are stored here.
CollisionMatrix & operationCollisionMatrix(const std::string operationName)
void addCollisionMatrixForState(FSAStateIndex state, CollisionMatrix *matrix)
void issueOperation(OperationID operation)
std::set< FSAStateIndex > FSAStateIndexSet
Type for a set of state indices.
int FSAStateIndex
Type used for indexing the states.
int FSAStateTransitionIndex
Type used for indexing the transitions.