OpenASIP  2.0
MemorySystem.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 MemorySystem.hh
26  *
27  * Declaration of MemorySystem class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005,2009 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_MEMORY_SYSTEM_HH
35 #define TTA_MEMORY_SYSTEM_HH
36 
37 #include <map>
38 #include <vector>
39 #include <string>
40 #include <boost/shared_ptr.hpp>
41 
42 #include "Exception.hh"
43 
44 class Memory;
45 class TCEString;
46 
47 namespace TTAMachine {
48  class Machine;
49  class AddressSpace;
50 }
51 
52 /**
53  * The collection of memory simulation models seen by a single core.
54  */
55 class MemorySystem {
56 public:
57  typedef boost::shared_ptr<Memory> MemoryPtr;
58 
59  explicit MemorySystem(const TTAMachine::Machine& machine);
60  virtual ~MemorySystem();
61 
62  void addAddressSpace(
63  const TTAMachine::AddressSpace& as, MemoryPtr mem, bool shared = true);
64 
66  const MemoryPtr memoryConst(const TTAMachine::AddressSpace& as) const;
67 
68  MemoryPtr memory(const std::string& addressSpaceName);
69 
70  unsigned int memoryCount() const;
71  MemoryPtr memory(unsigned int i);
72  const TTAMachine::AddressSpace& addressSpace(unsigned int i);
73  const TTAMachine::AddressSpace& addressSpace(const std::string& name);
74 
75  void shareMemoriesWith(MemorySystem& other);
76 
79  void resetAllMemories();
81  void deleteSharedMemories();
82 
83  bool hasMemory(const TCEString& aSpaceName) const;
84 
85 private:
86  /// Copying not allowed.
87  MemorySystem(const MemorySystem&);
88  /// Assignment not allowed.
90 
91  /// Maps address spaces to memory instances.
92  typedef std::map<const TTAMachine::AddressSpace*, MemoryPtr> MemoryMap;
93 
94  /// Container for memory instances for faster traversal.
95  typedef std::vector<MemoryPtr> MemoryContainer;
96 
97  /// Machine in which MemorySystem belongs to.
99  /// Contains all memories indexed by AddressSpaces.
101  /// List of all the memories for faster traversal.
103  /// All memories shared between multiple cores.
105  /// All private/local memories used by a single core only.
107  /// Shared memories which have been replaced with a shared memory
108  /// from another core. Just for garbage removal.
110 };
111 #include "MemorySystem.icc"
112 
113 #endif
MemorySystem::sharedMemories_
MemoryContainer sharedMemories_
All memories shared between multiple cores.
Definition: MemorySystem.hh:104
MemorySystem::resetAllMemories
void resetAllMemories()
MemorySystem::addAddressSpace
void addAddressSpace(const TTAMachine::AddressSpace &as, MemoryPtr mem, bool shared=true)
Definition: MemorySystem.cc:90
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
Exception.hh
MemorySystem::fillAllMemoriesWithZero
void fillAllMemoriesWithZero()
MemorySystem::machine_
const TTAMachine::Machine * machine_
Machine in which MemorySystem belongs to.
Definition: MemorySystem.hh:98
MemorySystem::MemorySystem
MemorySystem(const TTAMachine::Machine &machine)
Definition: MemorySystem.cc:54
MemorySystem::~MemorySystem
virtual ~MemorySystem()
Definition: MemorySystem.cc:73
MemorySystem::memoryConst
const MemoryPtr memoryConst(const TTAMachine::AddressSpace &as) const
Definition: MemorySystem.cc:211
MemorySystem::MemoryPtr
boost::shared_ptr< Memory > MemoryPtr
Definition: MemorySystem.hh:57
MemorySystem::advanceClockOfLocalMemories
void advanceClockOfLocalMemories()
MemorySystem::memoryCount
unsigned int memoryCount() const
Definition: MemorySystem.cc:226
MemorySystem::advanceClockOfSharedMemories
void advanceClockOfSharedMemories()
MemorySystem::deleteSharedMemories
void deleteSharedMemories()
Definition: MemorySystem.cc:64
MemorySystem::localMemories_
MemoryContainer localMemories_
All private/local memories used by a single core only.
Definition: MemorySystem.hh:106
MemorySystem::shareMemoriesWith
void shareMemoriesWith(MemorySystem &other)
Definition: MemorySystem.cc:133
MemorySystem.icc
MemorySystem
Definition: MemorySystem.hh:55
MemorySystem::hasMemory
bool hasMemory(const TCEString &aSpaceName) const
Definition: MemorySystem.cc:109
MemorySystem::MemoryContainer
std::vector< MemoryPtr > MemoryContainer
Container for memory instances for faster traversal.
Definition: MemorySystem.hh:95
MemorySystem::replacedSharedMemories_
MemoryContainer replacedSharedMemories_
Shared memories which have been replaced with a shared memory from another core. Just for garbage rem...
Definition: MemorySystem.hh:109
MemorySystem::memoryList_
MemoryContainer memoryList_
List of all the memories for faster traversal.
Definition: MemorySystem.hh:102
MemorySystem::MemoryMap
std::map< const TTAMachine::AddressSpace *, MemoryPtr > MemoryMap
Maps address spaces to memory instances.
Definition: MemorySystem.hh:92
TCEString
Definition: TCEString.hh:53
MemorySystem::memory
MemoryPtr memory(const TTAMachine::AddressSpace &as)
Definition: MemorySystem.cc:170
MemorySystem::memories_
MemoryMap memories_
Contains all memories indexed by AddressSpaces.
Definition: MemorySystem.hh:100
MemorySystem::operator=
MemorySystem & operator=(const MemorySystem &)
Assignment not allowed.
TTAMachine
Definition: Assembler.hh:48
MemorySystem::addressSpace
const TTAMachine::AddressSpace & addressSpace(unsigned int i)
Definition: MemorySystem.cc:261
Memory
Definition: Memory.hh:74
TTAMachine::Machine
Definition: Machine.hh:73