OpenASIP  2.0
FUState.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2017 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 FUState.hh
26  *
27  * Declaration of FUState class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005,2017 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_FU_STATE_HH
35 #define TTA_FU_STATE_HH
36 
37 #include <vector>
38 #include <string>
39 #include <map>
40 #include <set>
41 
42 #include "ClockedState.hh"
43 #include "PortState.hh"
44 #include "OperationContext.hh"
45 
46 class Operation;
47 class OperationExecutor;
48 class OperationContext;
50 
51 //////////////////////////////////////////////////////////////////////////////
52 // FUState
53 //////////////////////////////////////////////////////////////////////////////
54 
55 /**
56  * Models the state of the function unit of a TTA processor.
57  */
58 class FUState : public ClockedState {
59 public:
60  FUState();
61  FUState(const TCEString& name);
62  virtual ~FUState();
63 
64  void setTriggered();
65  void setOperation(Operation& operation);
67  bool isIdle();
68 
69  virtual void endClock();
70  virtual void advanceClock();
71 
72  virtual void addInputPortState(PortState& port);
73  virtual void addOutputPortState(PortState& port);
74 
75  virtual void addOperationExecutor(
76  OperationExecutor& opExec,
77  Operation& op);
78 
80 
81  virtual void replaceOperationExecutor(
82  Operation& op,
83  OperationExecutor* newExecutor);
84 
85  virtual OperationExecutor* executor(Operation& op);
86 
87  virtual OperationContext& context();
88 
89  virtual void reset();
90 
91 protected:
92  /// The idle status of the FU. The derived classes should
93  /// alway set this to true when possible to avoid unnecessary
94  /// advanceClock() and endClock() calls.
95  bool idle_;
96 
97 private:
98  /// Copying not allowed.
99  FUState(const FUState&);
100  /// Assignment not allowed.
101  FUState& operator=(const FUState&);
102 
103  void clearPorts();
104  bool sameBindings(
105  OperationExecutor& exec1,
106  OperationExecutor& exec2,
107  Operation& op);
108 
109  virtual void setOperationSimulator(
110  Operation& op,
112 
113  /// Maps operations to executors.
114  typedef std::map<Operation*, OperationExecutor*> ExecutorContainer;
115  /// Contains all the different instances of executors.
116  typedef std::vector<OperationExecutor*> ExecutorList;
117 
118  /// True if operation is triggered in current clock cycle.
119  bool trigger_;
120  /// Operation to be triggered next.
122  /// OperationExecutor to be used for the next operation (an optimization).
124  /// The operation context for this FU.
126  /// All operation executors.
128  /// All the different instances of OperationExecutors.
130  /// Input ports of the function unit.
131  std::vector<PortState*> inputPorts_;
132  /// Output ports of the function unit.
133  std::vector<PortState*> outputPorts_;
134  /// Count of active executors (to allow returning instantly
135  /// from advanceClock())
136  std::size_t activeExecutors_;
137  /// Optional detailed operation simulation model. Assume there's one
138  /// such model per FU or none at all for now (could be possible to
139  /// be one model per Operation).
141 };
142 
143 #include "FUState.icc"
144 
145 //////////////////////////////////////////////////////////////////////////////
146 // NullFUState
147 //////////////////////////////////////////////////////////////////////////////
148 
149 /**
150  * Models non-existing FUState.
151  */
152 class NullFUState : public FUState {
153 public:
154  static NullFUState& instance();
155 
156  virtual ~NullFUState();
157 
158  virtual void endClock();
159  virtual void advanceClock();
160 
161  virtual void addInputPortState(PortState& port);
162  virtual void addOutputPortState(PortState& port);
163 
164  virtual void addOperationExecutor(
165  OperationExecutor& opExec,
166  Operation& op);
167 
168  virtual OperationExecutor* executor(Operation& op);
169 
170 private:
171  NullFUState();
172  /// Copying not allowed.
173  NullFUState(const NullFUState&);
174  /// Assignment not allowed.
176  /// Unique instance of NullFUState.
178 };
179 
180 #endif
FUState::inputPorts_
std::vector< PortState * > inputPorts_
Input ports of the function unit.
Definition: FUState.hh:131
FUState::nextExecutor_
OperationExecutor * nextExecutor_
OperationExecutor to be used for the next operation (an optimization).
Definition: FUState.hh:123
FUState::advanceClock
virtual void advanceClock()
Definition: FUState.cc:152
NullFUState::operator=
NullFUState & operator=(const NullFUState &)
Assignment not allowed.
FUState::sameBindings
bool sameBindings(OperationExecutor &exec1, OperationExecutor &exec2, Operation &op)
Definition: FUState.cc:324
FUState::operationContext_
OperationContext operationContext_
The operation context for this FU.
Definition: FUState.hh:125
FUState::trigger_
bool trigger_
True if operation is triggered in current clock cycle.
Definition: FUState.hh:119
ClockedState
Definition: ClockedState.hh:40
FUState::endClock
virtual void endClock()
Definition: FUState.cc:122
OperationContext
Definition: OperationContext.hh:56
FUState::operator=
FUState & operator=(const FUState &)
Assignment not allowed.
FUState::addOperationExecutor
virtual void addOperationExecutor(OperationExecutor &opExec, Operation &op)
Definition: FUState.cc:232
FUState.icc
FUState::outputPorts_
std::vector< PortState * > outputPorts_
Output ports of the function unit.
Definition: FUState.hh:133
FUState::addInputPortState
virtual void addInputPortState(PortState &port)
Definition: FUState.cc:211
DetailedOperationSimulator
Definition: DetailedOperationSimulator.hh:49
FUState::detailedModel_
DetailedOperationSimulator * detailedModel_
Optional detailed operation simulation model. Assume there's one such model per FU or none at all for...
Definition: FUState.hh:140
FUState::nextOperation_
Operation * nextOperation_
Operation to be triggered next.
Definition: FUState.hh:121
NullFUState::addInputPortState
virtual void addInputPortState(PortState &port)
Definition: FUState.cc:428
NullFUState::advanceClock
virtual void advanceClock()
Definition: FUState.cc:420
FUState
Definition: FUState.hh:58
NullFUState::addOperationExecutor
virtual void addOperationExecutor(OperationExecutor &opExec, Operation &op)
Definition: FUState.cc:444
FUState::~FUState
virtual ~FUState()
Definition: FUState.cc:88
FUState::FUState
FUState()
Definition: FUState.cc:67
FUState::executors_
ExecutorContainer executors_
All operation executors.
Definition: FUState.hh:127
FUState::replaceOperationExecutor
virtual void replaceOperationExecutor(Operation &op, OperationExecutor *newExecutor)
Definition: FUState.cc:257
FUState::execList_
ExecutorList execList_
All the different instances of OperationExecutors.
Definition: FUState.hh:129
NullFUState::instance
static NullFUState & instance()
Definition: FUState.cc:392
NullFUState::~NullFUState
virtual ~NullFUState()
Definition: FUState.cc:405
FUState::setOperationSimulator
virtual void setOperationSimulator(DetailedOperationSimulator &sim)
Definition: FUState.cc:304
FUState::setTriggered
void setTriggered()
FUState::isIdle
bool isIdle()
PortState
Definition: PortState.hh:51
FUState::activeExecutors_
std::size_t activeExecutors_
Count of active executors (to allow returning instantly from advanceClock())
Definition: FUState.hh:136
NullFUState
Definition: FUState.hh:152
OperationExecutor
Definition: OperationExecutor.hh:49
Operation
Definition: Operation.hh:59
NullFUState::NullFUState
NullFUState()
Definition: FUState.cc:399
FUState::reset
virtual void reset()
this is called at (re)initialization of the simulation
Definition: FUState.cc:103
NullFUState::executor
virtual OperationExecutor * executor(Operation &op)
Definition: FUState.cc:454
FUState::idle_
bool idle_
The idle status of the FU. The derived classes should alway set this to true when possible to avoid u...
Definition: FUState.hh:95
FUState::ExecutorContainer
std::map< Operation *, OperationExecutor * > ExecutorContainer
Maps operations to executors.
Definition: FUState.hh:114
FUState::ExecutorList
std::vector< OperationExecutor * > ExecutorList
Contains all the different instances of executors.
Definition: FUState.hh:116
TCEString
Definition: TCEString.hh:53
FUState::clearPorts
void clearPorts()
Definition: FUState.cc:97
FUState::addOutputPortState
virtual void addOutputPortState(PortState &port)
Definition: FUState.cc:221
NullFUState::instance_
static NullFUState instance_
Unique instance of NullFUState.
Definition: FUState.hh:177
FUState::setOperation
void setOperation(Operation &operation)
FUState::executor
virtual OperationExecutor * executor(Operation &op)
Definition: FUState.cc:358
ClockedState.hh
NullFUState::addOutputPortState
virtual void addOutputPortState(PortState &port)
Definition: FUState.cc:436
OperationContext.hh
PortState.hh
NullFUState::endClock
virtual void endClock()
Definition: FUState.cc:412
FUState::context
virtual OperationContext & context()
Definition: FUState.cc:376