OpenASIP  2.0
OperationContext.hh
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 OperationContext.hh
26  *
27  * Declaration of OperationContext class.
28  *
29  * @author Pekka Jääskeläinen 2004 (pekka.jaaskelainen-no.spam-tut.fi)
30  * @note This file is used in compiled simulation. Keep dependencies *clean*
31  * @note rating: yellow
32  * @note reviewed 7 September 2004 by pj, jn, jm, ao
33  */
34 
35 #ifndef TTA_OPERATION_CONTEXT_HH
36 #define TTA_OPERATION_CONTEXT_HH
37 
38 #include "BaseType.hh"
39 #include "TCEString.hh"
40 #include <map>
41 
42 class OperationState;
43 class SimValue;
44 class Memory;
46 
47 #define DEFAULT_FU_NAME "unnamed_fu"
48 
49 /**
50  * OperationContext is used to store any implementation and context dependent
51  * data that may affect the result of an operation.
52  *
53  * In typical client applications, operation implementations are related to
54  * a function unit.
55  */
57 public:
58 
60  OperationContext(const TCEString& name);
62  Memory* memory,
65  int delayCycles);
66 
68 
69  OperationState& state(const char* name) const;
70 
71  /// Type of state registry.
72  typedef std::map<std::string, OperationState*> StateRegistry;
73 
75  void unsetStateRegistry();
77 
78  virtual ~OperationContext();
79 
80  Memory& memory();
81  const Memory& memory() const;
82  void setMemory(Memory* memory);
83  int contextId() const;
84 
86  const InstructionAddress& programCounter() const;
87  void setUpdateProgramCounter(bool value);
88  bool updateProgramCounter() const;
89  void setSaveReturnAddress(bool value);
90  bool saveReturnAddress();
92  const SimValue& returnAddress() const;
93 
94  void advanceClock();
95  bool isEmpty() const;
96  bool hasMemoryModel() const;
97  const TCEString& functionUnitName() const;
98 
99  int branchDelayCycles() const;
100 
101  // These methods are only for internal use. Used by the macro definitions
102  // of OSAL.hh.
104  void unregisterState(const char* name);
105 
106  CycleCount cycleCount() const;
108 
109 private:
110  /// Assignment not allowed
112  /// Implementation in separate source file to speed up compiling.
114 };
115 
116 #endif
OperationContext::setSaveReturnAddress
void setSaveReturnAddress(bool value)
Definition: OperationContext.cc:183
OperationContext::setMemory
void setMemory(Memory *memory)
Definition: OperationContext.cc:238
OperationContext::pimpl_
OperationContextPimpl * pimpl_
Implementation in separate source file to speed up compiling.
Definition: OperationContext.hh:113
OperationState
Definition: OperationState.hh:46
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
BaseType.hh
OperationContext::cycleCount
CycleCount cycleCount() const
Definition: OperationContext.cc:288
OperationContext::memory
Memory & memory()
Definition: OperationContext.cc:251
OperationContext
Definition: OperationContext.hh:56
OperationContext::unregisterState
void unregisterState(const char *name)
Definition: OperationContext.cc:138
OperationContext::functionUnitName
const TCEString & functionUnitName() const
Definition: OperationContext.cc:276
OperationContext::setStateRegistry
void setStateRegistry(StateRegistry &stateRegistry)
Definition: OperationContext.cc:313
OperationContext::saveReturnAddress
bool saveReturnAddress()
Definition: OperationContext.cc:194
OperationContext::setCycleCountVariable
void setCycleCountVariable(CycleCount &cycleCount)
Definition: OperationContext.cc:300
OperationContext::~OperationContext
virtual ~OperationContext()
Definition: OperationContext.cc:87
OperationContext::contextId
int contextId() const
Definition: OperationContext.cc:266
SimValue
Definition: SimValue.hh:96
TCEString.hh
OperationContext::registerState
void registerState(OperationState *state)
Definition: OperationContext.cc:124
OperationContext::isEmpty
bool isEmpty() const
Definition: OperationContext.cc:224
OperationContext::branchDelayCycles
int branchDelayCycles() const
Definition: OperationContext.cc:308
OperationContext::stateRegistry
StateRegistry & stateRegistry()
Definition: OperationContext.cc:323
OperationContext::hasMemoryModel
bool hasMemoryModel() const
OperationContext::OperationContext
OperationContext()
Definition: OperationContext.cc:48
OperationContext::programCounter
InstructionAddress & programCounter()
Definition: OperationContext.cc:152
CycleCount
long long CycleCount
Type for storing simulation cycle counts.
Definition: BaseType.hh:187
TCEString
Definition: TCEString.hh:53
OperationContext::StateRegistry
std::map< std::string, OperationState * > StateRegistry
Type of state registry.
Definition: OperationContext.hh:72
OperationContext::setUpdateProgramCounter
void setUpdateProgramCounter(bool value)
Definition: OperationContext.cc:162
OperationContext::operator=
OperationContext & operator=(const OperationContext &)
Assignment not allowed.
OperationContext::state
OperationState & state(const char *name) const
Definition: OperationContext.cc:100
OperationContext::unsetStateRegistry
void unsetStateRegistry()
Definition: OperationContext.cc:318
OperationContextPimpl
Definition: OperationContextPimpl.hh:47
OperationContext::updateProgramCounter
bool updateProgramCounter() const
Definition: OperationContext.cc:169
OperationContext::advanceClock
void advanceClock()
Definition: OperationContext.cc:108
OperationContext::returnAddress
SimValue & returnAddress()
Definition: OperationContext.cc:207
Memory
Definition: Memory.hh:74