OpenASIP  2.0
InstructionMemory.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 InstructionMemory.hh
26  *
27  * Declaration of InstructionMemory class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_INSTRUCTION_MEMORY_HH
35 #define TTA_INSTRUCTION_MEMORY_HH
36 
37 #include <vector>
38 #if __cplusplus < 201103L
39 #include <map>
40 #else
41 #include <unordered_map>
42 #endif
43 
44 #include "SimulatorConstants.hh"
45 #include "Exception.hh"
46 #include "BaseType.hh"
47 
49 
50 /**
51  * Container for ExecutableInstructions which represent the actions performed
52  * by the simulated program's instructions to the machine's state.
53  */
55 public:
56  /// Container for instructions.
57  typedef std::vector<ExecutableInstruction*> InstructionContainer;
58 
60  virtual ~InstructionMemory();
61 
63  InstructionAddress addr, ExecutableInstruction* instruction);
65  InstructionAddress addr, ExecutableInstruction* instruction);
68  InstructionAddress address) const;
69 
70  void resetExecutionCounts();
71 
72  bool hasInstructionAt(InstructionAddress addr) const;
73 
76  InstructionAddress addr) const;
77 
78 private:
79  /// Copying not allowed.
81  /// Assignment not allowed.
83 
84  /// The starting address of the instruction memory address space.
86 
87  /// All the instructions of the memory.
89 
91 
92 
93 #if __cplusplus < 201103L
94  /// Stores the explicit instruction addresses.
95  std::map<InstructionAddress, ExecutableInstruction*> instructionMap_;
96  /// Stores implicit instructions that should be executed after the explicit
97  /// one in the same address.
98  std::map<InstructionAddress, InstructionContainer*> implicitInstructions_;
99 #else
100  /// Stores the explicit instruction addresses.
101  std::unordered_map<InstructionAddress, ExecutableInstruction*> instructionMap_;
102  /// Stores implicit instructions that should be executed after the explicit
103  /// one in the same address.
104  std::unordered_map<InstructionAddress, InstructionContainer*> implicitInstructions_;
105 #endif
106 
107 
108 };
109 
110 #include "InstructionMemory.icc"
111 
112 #endif
InstructionMemory::instructionAtConst
const ExecutableInstruction & instructionAtConst(InstructionAddress address) const
ExecutableInstruction
Definition: ExecutableInstruction.hh:49
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
BaseType.hh
InstructionMemory::hasInstructionAt
bool hasInstructionAt(InstructionAddress addr) const
Definition: InstructionMemory.cc:117
InstructionMemory::addImplicitExecutableInstruction
void addImplicitExecutableInstruction(InstructionAddress addr, ExecutableInstruction *instruction)
Definition: InstructionMemory.cc:92
InstructionMemory::emptyInstructions_
InstructionContainer emptyInstructions_
Definition: InstructionMemory.hh:90
Exception.hh
InstructionMemory::implicitInstructionsAt
const InstructionContainer & implicitInstructionsAt(InstructionAddress addr) const
Definition: InstructionMemory.cc:128
InstructionMemory::resetExecutionCounts
void resetExecutionCounts()
Definition: InstructionMemory.cc:105
InstructionMemory
Definition: InstructionMemory.hh:54
InstructionMemory.icc
SimulatorConstants.hh
InstructionMemory::InstructionContainer
std::vector< ExecutableInstruction * > InstructionContainer
Container for instructions.
Definition: InstructionMemory.hh:57
InstructionMemory::instructionAt
ExecutableInstruction & instructionAt(InstructionAddress address)
InstructionMemory::startAddress_
InstructionAddress startAddress_
The starting address of the instruction memory address space.
Definition: InstructionMemory.hh:85
InstructionMemory::instructionMap_
std::map< InstructionAddress, ExecutableInstruction * > instructionMap_
Stores the explicit instruction addresses.
Definition: InstructionMemory.hh:95
InstructionMemory::hasImplicitInstructionsAt
bool hasImplicitInstructionsAt(InstructionAddress addr) const
Definition: InstructionMemory.cc:123
InstructionMemory::instructions_
InstructionContainer instructions_
All the instructions of the memory.
Definition: InstructionMemory.hh:88
InstructionMemory::~InstructionMemory
virtual ~InstructionMemory()
Definition: InstructionMemory.cc:55
InstructionMemory::InstructionMemory
InstructionMemory(InstructionAddress startAddress)
Definition: InstructionMemory.cc:47
InstructionMemory::operator=
InstructionMemory & operator=(const InstructionMemory &)
Assignment not allowed.
InstructionMemory::addExecutableInstruction
void addExecutableInstruction(InstructionAddress addr, ExecutableInstruction *instruction)
Definition: InstructionMemory.cc:76
InstructionMemory::implicitInstructions_
std::map< InstructionAddress, InstructionContainer * > implicitInstructions_
Stores implicit instructions that should be executed after the explicit one in the same address.
Definition: InstructionMemory.hh:98