2 Copyright (c) 2002-2009 Tampere University.
4 This file is part of TTA-Based Codesign Environment (TCE).
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:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
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.
27 * Inline definitions of GCUState class.
29 * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
33 #include "SimulatorConstants.hh"
34 #include "SimValue.hh"
35 #include "Exception.hh"
38 * Returns the current program counter value.
40 * @return Program counter value.
42 inline InstructionAddress&
43 GCUState::programCounter() {
44 return programCounter_;
49 * Returns the return address register.
51 * @return Return address register as SimValue.
54 GCUState::returnAddressRegister() {
55 return returnAddressRegister_;
59 * Sets new value to program counter.
61 * The value is updated after the delay set by control stages.
63 * @param value New value.
66 GCUState::setProgramCounter(const InstructionAddress& value) {
67 if (operationPending_ && latency_ != operationPendingTime_) {
69 __FILE__, __LINE__, __func__,
70 "Cannot have jumps in delay slots.");
72 newProgramCounter_ = value;
73 operationPending_ = true;
74 operationPendingTime_ = latency_;
78 * Sets new value to return address.
80 * The value is updated immediately. Takes in account the delay slot
84 GCUState::setReturnAddress() {
85 returnAddressRegister_ =
86 programCounter_ + static_cast<SIntWord>(latency_)
87 * instructionAddressIncrement_;
91 * Sets a wanted value to return address register immediately.
93 * The value is updated immediately. This is basically used to
94 * initialize GCUState return address register to different value
97 * @param value Address to set to return address register.
100 GCUState::setReturnAddress(const InstructionAddress& value) {
101 returnAddressRegister_ = value;