OpenASIP  2.0
MemoryProxy.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 MemoryProxy.hh
26  *
27  * Declaration of MemoryProxy class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2007 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 
34 #ifndef TTA_MEMORY_PROXY_HH
35 #define TTA_MEMORY_PROXY_HH
36 
37 #include "Memory.hh"
38 #include <utility>
39 #include <vector>
40 
41 class SimulatorFrontend;
42 
43 /**
44  * MemoryProxy is a memory access tracker for simulator.
45  *
46  * MemoryProxy tracks calls to reads and writes.
47  * Memory accesses on the last clock cycle can be listed
48  * with readAccessCount(), readAccess(idx), writeAccessCount()
49  * and writeAccess(idx) functions. Memory access information is
50  * stored for only one cycle. Tracks only single memory accesses, not
51  * those made with the block methods.
52  */
53 class MemoryProxy : public Memory {
54 public:
55 
56  typedef std::pair<Word, int> MemoryAccess;
57 
58  MemoryProxy(SimulatorFrontend& frontend, Memory* memory);
59  virtual ~MemoryProxy();
60 
61  virtual void advanceClock();
62  virtual void reset();
63 
64  virtual void write(ULongWord address, MAU data) override;
65  virtual Memory::MAU read(ULongWord address) override;
66 
67  virtual void write(ULongWord address, int size, ULongWord data)
68  { memory_->write(address, size, data); }
69  virtual void read(ULongWord address, int size, ULongWord& data)
70  { memory_->write(address, size, data); }
71 
72  virtual void fillWithZeros() { memory_->fillWithZeros(); }
73 
74  unsigned int readAccessCount() const;
75  unsigned int writeAccessCount() const;
76 
77  MemoryAccess readAccess(unsigned int idx) const;
78 
79  MemoryAccess writeAccess(unsigned int idx) const;
80 
81 private:
83 
84  /// Wrapped memory.
86  /// Copying not allowed.
87  MemoryProxy(const MemoryProxy&);
88  /// Assignment not allowed.
90 
91  /// List of initiated reads on the last cycle.
92  std::vector<MemoryAccess> reads_;
93  /// List of initiated writes on the last cycle.
94  std::vector<MemoryAccess> writes_;
95  /// List of initiated reads.
96  std::vector<MemoryAccess> newReads_;
97  /// List of initiated writes.
98  std::vector<MemoryAccess> newWrites_;
99 
100 };
101 
102 #endif
MemoryProxy::read
virtual void read(ULongWord address, int size, ULongWord &data)
Definition: MemoryProxy.hh:69
MemoryProxy::operator=
MemoryProxy & operator=(const MemoryProxy &)
Assignment not allowed.
MemoryProxy::MemoryProxy
MemoryProxy(SimulatorFrontend &frontend, Memory *memory)
Definition: MemoryProxy.cc:46
Memory.hh
MemoryProxy::newWrites_
std::vector< MemoryAccess > newWrites_
List of initiated writes.
Definition: MemoryProxy.hh:98
MemoryProxy::write
virtual void write(ULongWord address, int size, ULongWord data)
Definition: MemoryProxy.hh:67
Memory::fillWithZeros
virtual void fillWithZeros()
Definition: Memory.cc:704
MemoryProxy::readAccess
MemoryAccess readAccess(unsigned int idx) const
Definition: MemoryProxy.cc:133
MemoryProxy::MemoryAccess
std::pair< Word, int > MemoryAccess
Definition: MemoryProxy.hh:56
MemoryProxy::read
virtual Memory::MAU read(ULongWord address) override
Definition: MemoryProxy.cc:68
MemoryProxy::writeAccessCount
unsigned int writeAccessCount() const
Definition: MemoryProxy.cc:145
MemoryProxy::advanceClock
virtual void advanceClock()
Definition: MemoryProxy.cc:98
MemoryProxy::~MemoryProxy
virtual ~MemoryProxy()
Definition: MemoryProxy.cc:58
MemoryProxy
Definition: MemoryProxy.hh:53
MemoryProxy::reads_
std::vector< MemoryAccess > reads_
List of initiated reads on the last cycle.
Definition: MemoryProxy.hh:92
MemoryProxy::newReads_
std::vector< MemoryAccess > newReads_
List of initiated reads.
Definition: MemoryProxy.hh:96
MemoryProxy::write
virtual void write(ULongWord address, MAU data) override
Definition: MemoryProxy.cc:83
Memory::MAU
MinimumAddressableUnit MAU
Definition: Memory.hh:76
Memory::write
virtual void write(ULongWord address, MAU data)=0
Definition: Memory.cc:95
MemoryProxy::writes_
std::vector< MemoryAccess > writes_
List of initiated writes on the last cycle.
Definition: MemoryProxy.hh:94
MemoryProxy::writeAccess
MemoryAccess writeAccess(unsigned int idx) const
Definition: MemoryProxy.cc:157
MemoryProxy::frontend_
SimulatorFrontend & frontend_
Definition: MemoryProxy.hh:82
MemoryProxy::reset
virtual void reset()
Definition: MemoryProxy.cc:110
ULongWord
unsigned long ULongWord
Definition: BaseType.hh:51
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
MemoryProxy::fillWithZeros
virtual void fillWithZeros()
Definition: MemoryProxy.hh:72
MemoryProxy::readAccessCount
unsigned int readAccessCount() const
Definition: MemoryProxy.cc:122
Memory
Definition: Memory.hh:74
MemoryProxy::memory_
Memory * memory_
Wrapped memory.
Definition: MemoryProxy.hh:85