OpenASIP 2.2
Loading...
Searching...
No Matches
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
43class GCUState;
44class BusState;
45class FUState;
49class GuardState;
50class PortState;
51
52namespace TTAMachine {
53 class Guard;
54}
55
56/**
57 * Root class of machine state model.
58 *
59 * Owns all state classes.
60 */
62public:
64 virtual ~MachineState();
65
66 void clear();
67
69 BusState& busState(const std::string& name);
70 FUState& fuState(const std::string& name);
71
72 int FUStateCount() const;
73 FUState& fuState(int index);
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
104
105 bool isFinished() const { return finished_; }
106 void setFinished(bool finished=true) { finished_ = finished; }
107
108private:
109 /// Copying not allowed.
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).
168};
169
170#include "MachineState.icc"
171
172#endif
void advanceClockOfAllLongImmediateUnitStates()
BusCache busCache_
ExecutorContainer executors_
Contains all operation executors.
bool isFinished() const
std::map< std::string, LongImmediateUnitState * > LongImmediateContainer
Contains long immediate unit states indexed by names.
LongImmediateContainer longImmediates_
Contains all long immediate unit states.
void addRegisterFileState(RegisterFileState *state, const std::string &name)
std::map< std::string, RegisterFileState * > RegisterFileContainer
Contains register file states indexed by names.
GCUState * GCUState_
GCU state.
PortState & portState(const std::string &portName, const std::string &fuName)
RegisterFileCache rfCache_
void addBusState(BusState *state, const std::string &name)
LongImmediateUnitState & longImmediateUnitState(const std::string &name)
GuardState & guardState(const TTAMachine::Guard &guard)
FUState & fuState(const std::string &name)
std::vector< GuardState * > GuardCache
std::vector< FUState * > FUCache
RegisterFileContainer registers_
Contains all register file states.
std::vector< RegisterFileState * > RegisterFileCache
void addFUState(FUState *state, const std::string &name)
void addGuardState(GuardState *state, const TTAMachine::Guard &guard)
void endClockOfAllFUStates()
int FUStateCount() const
FUContainer FUStates_
Container of function unit states for fast traversal.
RegisterFileState & registerFileState(const std::string &name)
void addOperationExecutor(OperationExecutor *executor)
LongImmediateUnitCache longImmediateCache_
void addPortState(PortState *state, const std::string &name, const std::string &fuName)
std::vector< OperationExecutor * > ExecutorContainer
Contains operation executors.
std::map< std::string, PortState * > PortContainer
Contains port states indexed by names.
std::vector< LongImmediateUnitState * > LongImmediateUnitCache
void advanceClockOfAllFUStates()
std::map< const TTAMachine::Guard *, GuardState * > GuardContainer
Contains guard states indexed by their MOM object.
std::vector< PortState * > PortCache
void addGCUState(GCUState *state)
void advanceClockOfAllGuardStates()
MachineState & operator=(const MachineState &)
Assignment not allowed.
PortContainer ports_
Contains all port states.
std::map< std::string, BusState * > BusContainer
Contains bus states indexed by names.
PortCache portCache_
std::size_t fuStateCount_
Count of FUStates added in MachineState (optimization).
std::map< std::string, FUState * > FUContainer
Contains function unit states indexed by names.
GuardContainer guards_
Contains all guard states.
BusState & busState(const std::string &name)
MachineState(const MachineState &)
Copying not allowed.
void clearBuses()
void resetAllFUs()
std::vector< BusState * > BusCache
GCUState & gcuState()
virtual ~MachineState()
GuardCache guardCache_
BusContainer busses_
Contains all bus states.
void addLongImmediateUnitState(LongImmediateUnitState *state, const std::string &name)
void setFinished(bool finished=true)