OpenASIP  2.0
OperationContextPimpl.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 OperationContextPimpl.hh
26  *
27  * Declaration of OperationContextPimpl (private implementation) class.
28  *
29  * @author Viljami Korhonen 2008 (viljami.korhonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef OPERATION_CONTEXT_PIMPL_HH
34 #define OPERATION_CONTEXT_PIMPL_HH
35 
36 #include <string>
37 #include <map>
38 
39 #include "BaseType.hh"
40 #include "TCEString.hh"
41 
42 class OperationState;
43 class SimValue;
44 class Memory;
45 class OperationContext;
46 
48 public:
49  friend class OperationContext;
50 
52 
53  /// Type of state registry.
54  typedef std::map<std::string, OperationState*> StateRegistry;
55 
60 
61 private:
62  OperationContextPimpl(const TCEString& name);
64  const TCEString& name,
65  Memory* memory,
68  int delayCycles);
69 
70  Memory& memory();
71  void setMemory(Memory* memory);
72  int contextId() const;
73  CycleCount cycleCount() const;
76  }
77 
80  void setUpdateProgramCounter(bool value);
81  bool updateProgramCounter() const;
82  void setSaveReturnAddress(bool value);
83  bool saveReturnAddress();
85 
87  bool isEmpty() const;
88  bool hasMemoryModel() const;
89  const TCEString& functionUnitName();
90 
91  int branchDelayCycles();
92 
93  // These methods are only for internal use. Used by the macro definitions
94  // of OSAL.hh.
96  void unregisterState(const char* name);
97  OperationState& state(const char* name) const;
98 
99  bool hasState(const char* name) const;
100  void initializeContextId();
101 
102  /// The Memory model instance.
104  /// Unique number that identifies a context instance.
106  /// Context id for the next created context instance.
107  static int nextContextId_;
108  /// Simulates the program counter value.
110  /// Simulates the procedure return address.
112  /// The state registry.
114  /// Should the return address be saved?
116  /// Should program counter be updated?
118  /// Number of times advanceClock() has been called since
119  /// the creation.
121  /// The external variable that contains the current simulation
122  /// cycle count.
124  /// Name of the FU instance -- passed down from MachineStateBuilder
126  /// Amount of delay cycles caused by pipeline
128 };
129 
130 #endif
OperationContextPimpl::unregisterState
void unregisterState(const char *name)
Definition: OperationContextPimpl.cc:197
OperationContextPimpl::registerState
void registerState(OperationState *state)
Definition: OperationContextPimpl.cc:178
OperationState
Definition: OperationState.hh:46
OperationContextPimpl::irfBlockStart
InstructionAddress & irfBlockStart()
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
BaseType.hh
OperationContextPimpl::returnAddress_
SimValue & returnAddress_
Simulates the procedure return address.
Definition: OperationContextPimpl.hh:111
OperationContextPimpl::stateRegistry
StateRegistry & stateRegistry()
Definition: OperationContextPimpl.hh:59
OperationContext
Definition: OperationContext.hh:56
OperationContextPimpl::StateRegistry
std::map< std::string, OperationState * > StateRegistry
Type of state registry.
Definition: OperationContextPimpl.hh:54
OperationContextPimpl::setUpdateProgramCounter
void setUpdateProgramCounter(bool value)
Definition: OperationContextPimpl.cc:269
OperationContextPimpl::contextId_
int contextId_
Unique number that identifies a context instance.
Definition: OperationContextPimpl.hh:105
OperationContextPimpl::saveReturnAddress_
bool saveReturnAddress_
Should the return address be saved?
Definition: OperationContextPimpl.hh:115
OperationContextPimpl::advanceClock
void advanceClock(OperationContext &)
Definition: OperationContextPimpl.cc:155
OperationContextPimpl::cycleCountVar_
CycleCount * cycleCountVar_
The external variable that contains the current simulation cycle count.
Definition: OperationContextPimpl.hh:123
OperationContextPimpl::state
OperationState & state(const char *name) const
Definition: OperationContextPimpl.cc:139
SimValue
Definition: SimValue.hh:96
TCEString.hh
OperationContextPimpl::cycleCount_
CycleCount cycleCount_
Number of times advanceClock() has been called since the creation.
Definition: OperationContextPimpl.hh:120
OperationContextPimpl::hasMemoryModel
bool hasMemoryModel() const
Definition: OperationContextPimpl.cc:336
OperationContextPimpl::setMemory
void setMemory(Memory *memory)
Definition: OperationContextPimpl.cc:227
OperationContextPimpl::memory_
Memory * memory_
The Memory model instance.
Definition: OperationContextPimpl.hh:103
OperationContextPimpl::branchDelayCycles
int branchDelayCycles()
Definition: OperationContextPimpl.cc:360
OperationContextPimpl::OperationContextPimpl
OperationContextPimpl(const TCEString &name)
Definition: OperationContextPimpl.cc:54
OperationContextPimpl::returnAddress
SimValue & returnAddress()
Definition: OperationContextPimpl.cc:290
OperationContextPimpl::FUName_
const TCEString FUName_
Name of the FU instance – passed down from MachineStateBuilder.
Definition: OperationContextPimpl.hh:125
OperationContextPimpl::updateProgramCounter_
bool updateProgramCounter_
Should program counter be updated?
Definition: OperationContextPimpl.hh:117
OperationContextPimpl::setStateRegistry
void setStateRegistry(StateRegistry &stateRegistry)
Definition: OperationContextPimpl.hh:56
OperationContextPimpl::memory
Memory & memory()
Definition: OperationContextPimpl.cc:214
OperationContextPimpl::programCounter
InstructionAddress & programCounter()
Definition: OperationContextPimpl.cc:261
OperationContextPimpl::contextId
int contextId() const
Definition: OperationContextPimpl.cc:237
OperationContextPimpl::setCycleCountVariable
void setCycleCountVariable(CycleCount &cycleCount)
Definition: OperationContextPimpl.hh:74
OperationContextPimpl::cycleCount
CycleCount cycleCount() const
Definition: OperationContextPimpl.cc:348
OperationContextPimpl::initializeContextId
void initializeContextId()
Definition: OperationContextPimpl.cc:126
OperationContextPimpl::~OperationContextPimpl
~OperationContextPimpl()
Definition: OperationContextPimpl.cc:101
OperationContextPimpl::updateProgramCounter
bool updateProgramCounter() const
Definition: OperationContextPimpl.cc:277
OperationContextPimpl::nextContextId_
static int nextContextId_
Context id for the next created context instance.
Definition: OperationContextPimpl.hh:107
CycleCount
long long CycleCount
Type for storing simulation cycle counts.
Definition: BaseType.hh:187
TCEString
Definition: TCEString.hh:53
OperationContextPimpl::saveReturnAddress
bool saveReturnAddress()
Definition: OperationContextPimpl.cc:314
OperationContextPimpl::setSaveReturnAddress
void setSaveReturnAddress(bool value)
Definition: OperationContextPimpl.cc:303
OperationContextPimpl::unsetStateRegistry
void unsetStateRegistry()
Definition: OperationContextPimpl.hh:58
OperationContextPimpl
Definition: OperationContextPimpl.hh:47
OperationContextPimpl::branchDelayCycles_
int branchDelayCycles_
Amount of delay cycles caused by pipeline.
Definition: OperationContextPimpl.hh:127
OperationContextPimpl::functionUnitName
const TCEString & functionUnitName()
Definition: OperationContextPimpl.cc:247
OperationContextPimpl::hasState
bool hasState(const char *name) const
Definition: OperationContextPimpl.cc:113
OperationContextPimpl::programCounter_
InstructionAddress & programCounter_
Simulates the program counter value.
Definition: OperationContextPimpl.hh:109
OperationContextPimpl::stateRegistry_
StateRegistry * stateRegistry_
The state registry.
Definition: OperationContextPimpl.hh:113
Memory
Definition: Memory.hh:74
OperationContextPimpl::isEmpty
bool isEmpty() const
Definition: OperationContextPimpl.cc:326