OpenASIP  2.0
BuslessExecutableMove.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 BuslessExecutableMove.cc
26  *
27  * Definition of BuslessExecutableMove class.
28  *
29  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "BuslessExecutableMove.hh"
34 #include "ReadableState.hh"
35 #include "WritableState.hh"
36 #include "BusState.hh"
37 #include "SimValue.hh"
38 
39 /**
40  * Constructor.
41  *
42  * @param src Source of the move.
43  * @param dst Destination of the move.
44  */
46  const ReadableState& src,
47  WritableState& dst) :
48  ExecutableMove(src, NullBusState::instance(), dst) {
49 }
50 
51 /**
52  * Constructor.
53  *
54  * @param src Source of the move.
55  * @param bus Bus of the move.
56  * @param dst Destination of the move.
57  * @param guardReg Guard register.
58  * @param negated True if guard is reversed.
59  */
61  const ReadableState& src,
62  WritableState& dst,
63  const ReadableState& guardReg,
64  bool negated) :
65  ExecutableMove(src, NullBusState::instance(), dst, guardReg, negated) {
66 }
67 
68 /**
69  * Constructor.
70  *
71  * Used to construct a move that has an inline immediate as the source.
72  * The inline immediate becomes property of the created BuslessExecutableMove
73  * and is deleted by it.
74  *
75  * @param immediateSource The inline immediate source of the move.
76  * @param bus Bus of the move.
77  * @param dst Destination of the move.
78  * @param guardReg Guard register.
79  * @param negated True if guard is reversed.
80  */
82  InlineImmediateValue* immediateSource,
83  WritableState& dst,
84  const ReadableState& guardReg,
85  bool negated) :
87  immediateSource, NullBusState::instance(), dst, guardReg, negated) {
88 }
89 
90 /**
91  * Constructor.
92  *
93  * Used to construct a move that has an inline immediate as the source.
94  * The inline immediate becomes property of the created BuslessExecutableMove
95  * and is deleted by it.
96  *
97  * @param immediateSource The inline immediate source of the move.
98  * @param bus Bus of the move.
99  * @param dst Destination of the move.
100  * @param guardReg Guard register.
101  * @param negated True if guard is reversed.
102  */
104  InlineImmediateValue* immediateSource,
105  WritableState& dst) :
106  ExecutableMove(immediateSource, NullBusState::instance(), dst) {
107 }
108 
109 
110 /**
111  * Destructor.
112  */
114 }
115 
116 /**
117  * Does not do anything because value is transferred directly from source to
118  * destination without writing to a bus first.
119  *
120  */
121 void
123 }
124 
125 /**
126  * Writes the value from source to the destination.
127  *
128  * If the move is guarded, the value is written to destination only if guard
129  * expression is true.
130  */
131 void
133 
134  if (guarded_) {
135  const SimValue& regValue = guardReg_->value();
136  const bool guardTerm = (regValue.sLongWordValue() & 1l) == 1;
137  if (!(( guardTerm && !negated_) ||
138  (!guardTerm && negated_))) {
139  // guard expression evaluated to false
140  squashed_ = true;
141  return;
142  }
143  }
144 
145  squashed_ = false;
146  dst_->setValue(src_->value());
147  executionCount_++;
148 }
NullBusState
Definition: BusState.hh:85
SimValue::sLongWordValue
SLongWord sLongWordValue() const
Definition: SimValue.cc:997
BuslessExecutableMove::executeWrite
virtual void executeWrite()
Definition: BuslessExecutableMove.cc:132
ReadableState
Definition: ReadableState.hh:41
BuslessExecutableMove::~BuslessExecutableMove
virtual ~BuslessExecutableMove()
Definition: BuslessExecutableMove.cc:113
ExecutableMove::dst_
WritableState * dst_
Destination of the move.
Definition: ExecutableMove.hh:96
WritableState.hh
WritableState
Definition: WritableState.hh:41
ExecutableMove::guarded_
const bool guarded_
True if this is a guarded move.
Definition: ExecutableMove.hh:100
ExecutableMove::guardReg_
const ReadableState * guardReg_
Guard of the move.
Definition: ExecutableMove.hh:98
SimValue
Definition: SimValue.hh:96
BuslessExecutableMove::BuslessExecutableMove
BuslessExecutableMove(const ReadableState &src, WritableState &dst)
Definition: BuslessExecutableMove.cc:45
ExecutableMove::negated_
const bool negated_
True if guard is inverted.
Definition: ExecutableMove.hh:102
BusState.hh
ExecutableMove
Definition: ExecutableMove.hh:52
ReadableState.hh
BuslessExecutableMove.hh
BuslessExecutableMove::executeRead
virtual void executeRead()
Definition: BuslessExecutableMove.cc:122
SimValue.hh
RegisterState
Definition: RegisterState.hh:50
ReadableState::value
virtual const SimValue & value() const =0
ExecutableMove::src_
const ReadableState * src_
Source of the move.
Definition: ExecutableMove.hh:92
ExecutableMove::executionCount_
ClockCycleCount executionCount_
The count of times this move has been fully executed (without squash).
Definition: ExecutableMove.hh:104
ExecutableMove::squashed_
bool squashed_
True in case this move was squashed last time it was executed.
Definition: ExecutableMove.hh:106
WritableState::setValue
virtual void setValue(const SimValue &value)=0