OpenASIP  2.0
GCUState.icc
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 GCUState.icc
26  *
27  * Inline definitions of GCUState class.
28  *
29  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "SimulatorConstants.hh"
34 #include "SimValue.hh"
35 #include "Exception.hh"
36 
37 /**
38  * Returns the current program counter value.
39  *
40  * @return Program counter value.
41  */
42 inline InstructionAddress&
43 GCUState::programCounter() {
44  return programCounter_;
45 }
46 
47 
48 /**
49  * Returns the return address register.
50  *
51  * @return Return address register as SimValue.
52  */
53 inline SimValue&
54 GCUState::returnAddressRegister() {
55  return returnAddressRegister_;
56 }
57 
58 /**
59  * Sets new value to program counter.
60  *
61  * The value is updated after the delay set by control stages.
62  *
63  * @param value New value.
64  */
65 inline void
66 GCUState::setProgramCounter(const InstructionAddress& value) {
67  if (operationPending_ && latency_ != operationPendingTime_) {
68  throw Exception(
69  __FILE__, __LINE__, __func__,
70  "Cannot have jumps in delay slots.");
71  }
72  newProgramCounter_ = value;
73  operationPending_ = true;
74  operationPendingTime_ = latency_;
75 }
76 
77 /**
78  * Sets new value to return address.
79  *
80  * The value is updated immediately. Takes in account the delay slot
81  * length.
82  */
83 inline void
84 GCUState::setReturnAddress() {
85  returnAddressRegister_ =
86  programCounter_ + static_cast<SIntWord>(latency_)
87  * instructionAddressIncrement_;
88 }
89 
90 /**
91  * Sets a wanted value to return address register immediately.
92  *
93  * The value is updated immediately. This is basically used to
94  * initialize GCUState return address register to different value
95  * than 0.
96  *
97  * @param value Address to set to return address register.
98  */
99 inline void
100 GCUState::setReturnAddress(const InstructionAddress& value) {
101  returnAddressRegister_ = value;
102 }