OpenASIP 2.2
Loading...
Searching...
No Matches
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
46class Operation;
50
51//////////////////////////////////////////////////////////////////////////////
52// FUState
53//////////////////////////////////////////////////////////////////////////////
54
55/**
56 * Models the state of the function unit of a TTA processor.
57 */
58class FUState : public ClockedState {
59public:
60 FUState();
61 FUState(const TCEString& name);
62 virtual ~FUState();
63
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
86
87 virtual OperationContext& context();
88
89 virtual void reset();
90
91protected:
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
97private:
98 /// Copying not allowed.
100 /// Assignment not allowed.
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.
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 */
152class NullFUState : public FUState {
153public:
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
169
170private:
171 NullFUState();
172 /// Copying not allowed.
174 /// Assignment not allowed.
176 /// Unique instance of NullFUState.
178};
179
180#endif
bool trigger_
True if operation is triggered in current clock cycle.
Definition FUState.hh:119
virtual OperationContext & context()
Definition FUState.cc:376
OperationContext operationContext_
The operation context for this FU.
Definition FUState.hh:125
std::size_t activeExecutors_
Count of active executors (to allow returning instantly from advanceClock())
Definition FUState.hh:136
void setOperation(Operation &operation, OperationExecutor &executor)
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
Operation * nextOperation_
Operation to be triggered next.
Definition FUState.hh:121
virtual void replaceOperationExecutor(Operation &op, OperationExecutor *newExecutor)
Definition FUState.cc:257
FUState(const FUState &)
Copying not allowed.
virtual void addOutputPortState(PortState &port)
Definition FUState.cc:221
FUState()
Definition FUState.cc:67
virtual void advanceClock()
Definition FUState.cc:152
void setTriggered()
std::vector< OperationExecutor * > ExecutorList
Contains all the different instances of executors.
Definition FUState.hh:116
OperationExecutor * nextExecutor_
OperationExecutor to be used for the next operation (an optimization).
Definition FUState.hh:123
virtual void reset()
this is called at (re)initialization of the simulation
Definition FUState.cc:103
bool sameBindings(OperationExecutor &exec1, OperationExecutor &exec2, Operation &op)
Definition FUState.cc:324
std::map< Operation *, OperationExecutor * > ExecutorContainer
Maps operations to executors.
Definition FUState.hh:114
virtual void addInputPortState(PortState &port)
Definition FUState.cc:211
virtual void addOperationExecutor(OperationExecutor &opExec, Operation &op)
Definition FUState.cc:232
ExecutorList execList_
All the different instances of OperationExecutors.
Definition FUState.hh:129
std::vector< PortState * > inputPorts_
Input ports of the function unit.
Definition FUState.hh:131
virtual OperationExecutor * executor(Operation &op)
Definition FUState.cc:358
void clearPorts()
Definition FUState.cc:97
virtual void endClock()
Definition FUState.cc:122
ExecutorContainer executors_
All operation executors.
Definition FUState.hh:127
bool isIdle()
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 & operator=(const FUState &)
Assignment not allowed.
virtual void setOperationSimulator(DetailedOperationSimulator &sim)
Definition FUState.cc:304
void setOperation(Operation &operation)
virtual ~FUState()
Definition FUState.cc:88
std::vector< PortState * > outputPorts_
Output ports of the function unit.
Definition FUState.hh:133
virtual void addInputPortState(PortState &port)
Definition FUState.cc:428
virtual ~NullFUState()
Definition FUState.cc:405
virtual void addOutputPortState(PortState &port)
Definition FUState.cc:436
static NullFUState instance_
Unique instance of NullFUState.
Definition FUState.hh:177
NullFUState(const NullFUState &)
Copying not allowed.
NullFUState & operator=(const NullFUState &)
Assignment not allowed.
virtual void addOperationExecutor(OperationExecutor &opExec, Operation &op)
Definition FUState.cc:444
virtual void advanceClock()
Definition FUState.cc:420
virtual void endClock()
Definition FUState.cc:412
virtual OperationExecutor * executor(Operation &op)
Definition FUState.cc:454
static NullFUState & instance()
Definition FUState.cc:392