OpenASIP  2.0
MachineState.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 MachineState.hh
26  *
27  * Declaration of MachineState class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_MACHINE_STATE_HH
35 #define TTA_MACHINE_STATE_HH
36 
37 #include <string>
38 #include <map>
39 #include <vector>
40 
41 #include "Exception.hh"
42 
43 class GCUState;
44 class BusState;
45 class FUState;
47 class RegisterFileState;
48 class OperationExecutor;
49 class GuardState;
50 class PortState;
51 
52 namespace TTAMachine {
53  class Guard;
54 }
55 
56 /**
57  * Root class of machine state model.
58  *
59  * Owns all state classes.
60  */
61 class MachineState {
62 public:
63  MachineState();
64  virtual ~MachineState();
65 
66  void clear();
67 
68  GCUState& gcuState();
69  BusState& busState(const std::string& name);
70  FUState& fuState(const std::string& name);
71 
72  int FUStateCount() const;
73  FUState& fuState(int index);
75  void endClockOfAllFUStates();
78  void resetAllFUs();
79  void clearBuses();
80 
82  const std::string& portName,
83  const std::string& fuName);
84  LongImmediateUnitState& longImmediateUnitState(const std::string& name);
85  RegisterFileState& registerFileState(const std::string& name);
87 
88  void addGCUState(GCUState* state);
89  void addBusState(BusState* state, const std::string& name);
90  void addFUState(FUState* state, const std::string& name);
91  void addPortState(
92  PortState* state,
93  const std::string& name,
94  const std::string& fuName);
97  const std::string& name);
99  RegisterFileState* state,
100  const std::string& name);
101  void addGuardState(GuardState* state, const TTAMachine::Guard& guard);
102 
103  void addOperationExecutor(OperationExecutor* executor);
104 
105  bool isFinished() const { return finished_; }
106  void setFinished(bool finished=true) { finished_ = finished; }
107 
108 private:
109  /// Copying not allowed.
110  MachineState(const MachineState&);
111  /// Assignment not allowed.
113 
114  /// Contains bus states indexed by names.
115  typedef std::map<std::string, BusState*> BusContainer;
116  /// Contains function unit states indexed by names.
117  typedef std::map<std::string, FUState*> FUContainer;
118  /// Contains port states indexed by names.
119  typedef std::map<std::string, PortState*> PortContainer;
120  /// Contains long immediate unit states indexed by names.
121  typedef std::map<std::string, LongImmediateUnitState*>
123  /// Contains register file states indexed by names.
124  typedef std::map<std::string, RegisterFileState*> RegisterFileContainer;
125  /// Contains guard states indexed by their MOM object.
126  typedef std::map<const TTAMachine::Guard*, GuardState*> GuardContainer;
127  /// Contains operation executors.
128  typedef std::vector<OperationExecutor*> ExecutorContainer;
129 
130  // Contains all states in vectors that are faster to iterate than maps.
131  typedef std::vector<BusState*> BusCache;
132  typedef std::vector<FUState*> FUCache;
133  typedef std::vector<PortState*> PortCache;
134  typedef std::vector<LongImmediateUnitState*> LongImmediateUnitCache;
135  typedef std::vector<RegisterFileState*> RegisterFileCache;
136  typedef std::vector<GuardState*> GuardCache;
137 
138  /// GCU state.
140  /// Contains all bus states.
142  /// Container of function unit states for fast traversal.
144  /// Contains all port states.
146  /// Contains all long immediate unit states.
148  /// Contains all register file states.
150  /// Contains all operation executors.
152  /// Contains all guard states.
154  /// Count of FUStates added in MachineState (optimization).
155  std::size_t fuStateCount_;
156 
157  // Contains all states in vectors that are faster to iterate than maps.
164 
165  // This is set to true when the core has finished execution (reached
166  // a known program exit point).
167  bool finished_;
168 };
169 
170 #include "MachineState.icc"
171 
172 #endif
TTAMachine::Guard
Definition: Guard.hh:55
MachineState::longImmediateUnitState
LongImmediateUnitState & longImmediateUnitState(const std::string &name)
Definition: MachineState.cc:196
MachineState::FUContainer
std::map< std::string, FUState * > FUContainer
Contains function unit states indexed by names.
Definition: MachineState.hh:117
MachineState::MachineState
MachineState()
Definition: MachineState.cc:61
MachineState::addOperationExecutor
void addOperationExecutor(OperationExecutor *executor)
Definition: MachineState.cc:339
GCUState
Definition: GCUState.hh:46
Exception.hh
MachineState::portState
PortState & portState(const std::string &portName, const std::string &fuName)
Definition: MachineState.cc:175
MachineState::gcuState
GCUState & gcuState()
Definition: MachineState.cc:103
MachineState::LongImmediateContainer
std::map< std::string, LongImmediateUnitState * > LongImmediateContainer
Contains long immediate unit states indexed by names.
Definition: MachineState.hh:122
MachineState::RegisterFileContainer
std::map< std::string, RegisterFileState * > RegisterFileContainer
Contains register file states indexed by names.
Definition: MachineState.hh:124
MachineState::clearBuses
void clearBuses()
MachineState::resetAllFUs
void resetAllFUs()
MachineState::RegisterFileCache
std::vector< RegisterFileState * > RegisterFileCache
Definition: MachineState.hh:135
BusState
Definition: BusState.hh:48
MachineState::advanceClockOfAllLongImmediateUnitStates
void advanceClockOfAllLongImmediateUnitStates()
MachineState::rfCache_
RegisterFileCache rfCache_
Definition: MachineState.hh:162
MachineState::setFinished
void setFinished(bool finished=true)
Definition: MachineState.hh:106
MachineState::endClockOfAllFUStates
void endClockOfAllFUStates()
MachineState::portCache_
PortCache portCache_
Definition: MachineState.hh:160
MachineState::FUStateCount
int FUStateCount() const
MachineState::~MachineState
virtual ~MachineState()
Definition: MachineState.cc:68
FUState
Definition: FUState.hh:58
MachineState::advanceClockOfAllFUStates
void advanceClockOfAllFUStates()
MachineState::addPortState
void addPortState(PortState *state, const std::string &name, const std::string &fuName)
Definition: MachineState.cc:280
MachineState
Definition: MachineState.hh:61
MachineState::clear
void clear()
Definition: MachineState.cc:76
MachineState::guardState
GuardState & guardState(const TTAMachine::Guard &guard)
Definition: MachineState.cc:230
MachineState::busState
BusState & busState(const std::string &name)
Definition: MachineState.cc:116
MachineState::FUStates_
FUContainer FUStates_
Container of function unit states for fast traversal.
Definition: MachineState.hh:143
MachineState::addGCUState
void addGCUState(GCUState *state)
Definition: MachineState.cc:244
MachineState::longImmediateCache_
LongImmediateUnitCache longImmediateCache_
Definition: MachineState.hh:161
MachineState::LongImmediateUnitCache
std::vector< LongImmediateUnitState * > LongImmediateUnitCache
Definition: MachineState.hh:134
MachineState::BusContainer
std::map< std::string, BusState * > BusContainer
Contains bus states indexed by names.
Definition: MachineState.hh:115
MachineState::GuardContainer
std::map< const TTAMachine::Guard *, GuardState * > GuardContainer
Contains guard states indexed by their MOM object.
Definition: MachineState.hh:126
MachineState::addLongImmediateUnitState
void addLongImmediateUnitState(LongImmediateUnitState *state, const std::string &name)
Definition: MachineState.cc:295
PortState
Definition: PortState.hh:51
MachineState::addGuardState
void addGuardState(GuardState *state, const TTAMachine::Guard &guard)
Definition: MachineState.cc:325
OperationExecutor
Definition: OperationExecutor.hh:49
MachineState::ExecutorContainer
std::vector< OperationExecutor * > ExecutorContainer
Contains operation executors.
Definition: MachineState.hh:128
MachineState::addRegisterFileState
void addRegisterFileState(RegisterFileState *state, const std::string &name)
Definition: MachineState.cc:310
MachineState::GCUState_
GCUState * GCUState_
GCU state.
Definition: MachineState.hh:139
MachineState::addFUState
void addFUState(FUState *state, const std::string &name)
Definition: MachineState.cc:267
MachineState::longImmediates_
LongImmediateContainer longImmediates_
Contains all long immediate unit states.
Definition: MachineState.hh:147
MachineState::executors_
ExecutorContainer executors_
Contains all operation executors.
Definition: MachineState.hh:151
MachineState::finished_
bool finished_
Definition: MachineState.hh:167
MachineState::ports_
PortContainer ports_
Contains all port states.
Definition: MachineState.hh:145
MachineState::fuStateCount_
std::size_t fuStateCount_
Count of FUStates added in MachineState (optimization).
Definition: MachineState.hh:155
MachineState::fuState
FUState & fuState(const std::string &name)
Definition: MachineState.cc:133
MachineState::registers_
RegisterFileContainer registers_
Contains all register file states.
Definition: MachineState.hh:149
MachineState.icc
RegisterFileState
Definition: RegisterFileState.hh:49
MachineState::GuardCache
std::vector< GuardState * > GuardCache
Definition: MachineState.hh:136
MachineState::busCache_
BusCache busCache_
Definition: MachineState.hh:158
GuardState
Definition: GuardState.hh:60
MachineState::FUCache
std::vector< FUState * > FUCache
Definition: MachineState.hh:132
MachineState::addBusState
void addBusState(BusState *state, const std::string &name)
Definition: MachineState.cc:255
TTAMachine
Definition: Assembler.hh:48
MachineState::fuCache_
FUCache fuCache_
Definition: MachineState.hh:159
MachineState::advanceClockOfAllGuardStates
void advanceClockOfAllGuardStates()
MachineState::operator=
MachineState & operator=(const MachineState &)
Assignment not allowed.
MachineState::PortCache
std::vector< PortState * > PortCache
Definition: MachineState.hh:133
MachineState::busses_
BusContainer busses_
Contains all bus states.
Definition: MachineState.hh:141
MachineState::guards_
GuardContainer guards_
Contains all guard states.
Definition: MachineState.hh:153
MachineState::guardCache_
GuardCache guardCache_
Definition: MachineState.hh:163
LongImmediateUnitState
Definition: LongImmediateUnitState.hh:55
MachineState::BusCache
std::vector< BusState * > BusCache
Definition: MachineState.hh:131
MachineState::PortContainer
std::map< std::string, PortState * > PortContainer
Contains port states indexed by names.
Definition: MachineState.hh:119
MachineState::isFinished
bool isFinished() const
Definition: MachineState.hh:105
MachineState::registerFileState
RegisterFileState & registerFileState(const std::string &name)
Definition: MachineState.cc:213