OpenASIP 2.2
Loading...
Searching...
No Matches
ExecutableMove.cc
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 ExecutableMove.cc
26 *
27 * Definition of ExecutableMove class.
28 *
29 * @author Jussi Nykänen 2005 (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#include "ExecutableMove.hh"
35#include "ReadableState.hh"
36#include "WritableState.hh"
37#include "BusState.hh"
38#include "SimValue.hh"
39
40// This should be defined if guards block bus writes, that is, in case
41// guard definition evaluates to false, even the bus is not written.
42// At least this is the case in MOVE, therefore this needs to be defined
43// to be able to compare bus traces between MOVE and TCE easily.
44const bool GUARD_BLOCKS_BUS_WRITE = true;
45
46/**
47 * Constructor.
48 *
49 * @param src Source of the move.
50 * @param bus Bus of the move.
51 * @param dst Destination of the move.
52 */
54 const ReadableState& src,
55 BusState& bus,
56 WritableState& dst) :
57 src_(&src), bus_(&bus), dst_(&dst),
58 guardReg_(NULL), guarded_(false), negated_(false),
59 executionCount_(0), squashed_(false),
60 inlineImmediate_(NULL) {
61}
62
63/**
64 * Constructor.
65 *
66 * @param src Source of the move.
67 * @param bus Bus of the move.
68 * @param dst Destination of the move.
69 * @param guardReg Guard register.
70 * @param negated True if guard is reversed.
71 */
73 const ReadableState& src,
74 BusState& bus,
75 WritableState& dst,
76 const ReadableState& guardReg,
77 bool negated) :
78 src_(&src), bus_(&bus), dst_(&dst), guardReg_(&guardReg),
79 guarded_(true), negated_(negated),
80 executionCount_(0), squashed_(false),
81 inlineImmediate_(NULL) {
82}
83
84/**
85 * Constructor.
86 *
87 * Used to construct a move that has an inline immediate as the source.
88 * The inline immediate becomes property of the created ExecutableMove
89 * and is deleted by it.
90 *
91 * @param immediateSource The inline immediate source of the move.
92 * @param bus Bus of the move.
93 * @param dst Destination of the move.
94 * @param guardReg Guard register.
95 * @param negated True if guard is reversed.
96 */
98 InlineImmediateValue* immediateSource,
99 BusState& bus,
100 WritableState& dst,
101 const ReadableState& guardReg,
102 bool negated) :
103 src_(immediateSource), bus_(&bus), dst_(&dst), guardReg_(&guardReg),
104 guarded_(true), negated_(negated),
105 executionCount_(0), squashed_(false),
106 inlineImmediate_(immediateSource) {
107}
108
109/**
110 * Constructor.
111 *
112 * Used to construct a move that has an inline immediate as the source.
113 * The inline immediate becomes property of the created ExecutableMove
114 * and is deleted by it.
115 *
116 * @param immediateSource The inline immediate source of the move.
117 * @param bus Bus of the move.
118 * @param dst Destination of the move.
119 * @param guardReg Guard register.
120 * @param negated True if guard is reversed.
121 */
123 InlineImmediateValue* immediateSource,
124 BusState& bus,
125 WritableState& dst) :
126 src_(immediateSource), bus_(&bus), dst_(&dst),
127 guardReg_(NULL), guarded_(false), negated_(false),
128 executionCount_(0), squashed_(false),
129 inlineImmediate_(immediateSource) {
130}
131
132
133/**
134 * Destructor.
135 */
140
141/**
142 * Evaluates the possible guard of the move, i.e., decides whether the
143 * move is squashed at the simulated cycle or not.
144 *
145 * This must be called by the ExecutableInstruction before any
146 * executeRead()/executeWrite() is called in order not to overwrite
147 * the old guard value in case of the default 1-latency guards.
148 */
149void
151 if (guarded_) {
152 const SimValue& regValue = guardReg_->value();
153 const bool guardTerm = (regValue.sIntWordValue() & 1) == 1;
154 squashed_ = !((!negated_ && guardTerm) ||
155 ( negated_ && !guardTerm));
157 } else {
158 bus_->setSquashed(false);
159 }
160}
161
162/**
163 * Copies the value of the move source to the transport bus.
164 */
165void
172
173/**
174 * Writes the value of the bus to the destination.
175 *
176 * If the move is guarded, the value is written to destination only if guard
177 * expression is true.
178 *
179 */
180void
182
183 if (guarded_ && squashed_)
184 return;
185
186 dst_->setValue(bus_->value());
188}
189
190/**
191 * Resets the execution counter of this move.
192 */
193void
197
198/**
199 * Returns the count of executions of this move.
200 *
201 * This count does not include squashed executions.
202 *
203 * @return Count of executions of this move.
204 */
209
210/**
211 * Returns true in case move with the move was squashed the last time
212 * the instruction was executed.
213 *
214 * Being squashed means that the move is guarded and the guard expression
215 * evaluated to false.
216 *
217 * @return True in case move was squashed last time its instruction was
218 * executed.
219 */
220inline bool
222 return squashed_;
223}
224
225/**
226 * A dummy constructor for being used with DummyExecutableMove
227 */
229 src_(0),
230 bus_(&NullBusState::instance()),
231 dst_(0),
232 guarded_(false),
233 negated_(false) {
234 inlineImmediate_ = NULL;
235}
236
237
238
239/**
240 * Constructor for SimpleExecutableMove that sets the execution count
241 *
242 * @param executionCount the execution count
243 */
const bool GUARD_BLOCKS_BUS_WRITE
find Finds info of the inner loops in the false
CycleCount ClockCycleCount
Alias for ClockCycleCount.
void setSquashed(bool isSquashed)
Definition BusState.cc:78
void setValueInlined(const SimValue &value)
DummyExecutableMove(ClockCycleCount executionCount)
WritableState * dst_
Destination of the move.
const ReadableState * src_
Source of the move.
const ReadableState * guardReg_
Guard of the move.
ClockCycleCount executionCount() const
const bool negated_
True if guard is inverted.
virtual ~ExecutableMove()
BusState * bus_
Bus of the move.
InlineImmediateValue * inlineImmediate_
If the move source is an inline immediate, the instance is stored here so it can be deleted in the de...
virtual bool squashed() const
virtual void evaluateGuard()
ClockCycleCount executionCount_
The count of times this move has been fully executed (without squash).
virtual void executeRead()
virtual void executeWrite()
bool squashed_
True in case this move was squashed last time it was executed.
const bool guarded_
True if this is a guarded move.
virtual const SimValue & value() const =0
virtual const SimValue & value() const
SIntWord sIntWordValue() const
Definition SimValue.cc:944
virtual void setValue(const SimValue &value)=0