OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MemoryProxy Class Reference

#include <MemoryProxy.hh>

Inheritance diagram for MemoryProxy:
Inheritance graph
Collaboration diagram for MemoryProxy:
Collaboration graph

Public Types

typedef std::pair< Word, int > MemoryAccess
 
- Public Types inherited from Memory
typedef MinimumAddressableUnit MAU
 
typedef MAUMAUTable
 

Public Member Functions

 MemoryProxy (SimulatorFrontend &frontend, Memory *memory)
 
virtual ~MemoryProxy ()
 
virtual void advanceClock ()
 
virtual void reset ()
 
virtual void write (ULongWord address, MAU data) override
 
virtual Memory::MAU read (ULongWord address) override
 
virtual void write (ULongWord address, int size, ULongWord data)
 
virtual void read (ULongWord address, int size, ULongWord &data)
 
virtual void fillWithZeros ()
 
unsigned int readAccessCount () const
 
unsigned int writeAccessCount () const
 
MemoryAccess readAccess (unsigned int idx) const
 
MemoryAccess writeAccess (unsigned int idx) const
 
- Public Member Functions inherited from Memory
 Memory (ULongWord start, ULongWord end, ULongWord MAUSize, bool littleEndian_)
 
virtual ~Memory ()
 
virtual void writeBE (ULongWord address, int size, ULongWord data)
 
virtual void writeLE (ULongWord address, int size, ULongWord data)
 
void write (ULongWord address, int size, ULongWord data)
 
virtual void writeDirectlyBE (ULongWord address, int size, ULongWord data)
 
virtual void writeDirectlyLE (ULongWord address, int size, ULongWord data)
 
void write (ULongWord address, FloatWord data)
 
void write (ULongWord address, DoubleWord data)
 
void read (ULongWord address, int size, ULongWord &data)
 
void read (ULongWord address, DoubleWord &data)
 
void read (ULongWord address, FloatWord &data)
 
virtual void writeBE (ULongWord address, FloatWord data)
 
virtual void writeBE (ULongWord address, DoubleWord data)
 
virtual void writeLE (ULongWord address, FloatWord data)
 
virtual void writeLE (ULongWord address, DoubleWord data)
 
virtual void readBE (ULongWord address, int size, ULongWord &data)
 
virtual void readLE (ULongWord address, int size, ULongWord &data)
 
virtual void readBE (ULongWord address, FloatWord &data)
 
virtual void readBE (ULongWord address, DoubleWord &data)
 
virtual void readLE (ULongWord address, FloatWord &data)
 
virtual void readLE (ULongWord address, DoubleWord &data)
 
virtual ULongWord start ()
 
virtual ULongWord end ()
 
virtual ULongWord MAUSize ()
 
bool isLittleEndian ()
 

Private Member Functions

 MemoryProxy (const MemoryProxy &)
 Copying not allowed.
 
MemoryProxyoperator= (const MemoryProxy &)
 Assignment not allowed.
 

Private Attributes

SimulatorFrontendfrontend_
 
Memorymemory_
 Wrapped memory.
 
std::vector< MemoryAccessreads_
 List of initiated reads on the last cycle.
 
std::vector< MemoryAccesswrites_
 List of initiated writes on the last cycle.
 
std::vector< MemoryAccessnewReads_
 List of initiated reads.
 
std::vector< MemoryAccessnewWrites_
 List of initiated writes.
 

Additional Inherited Members

- Protected Member Functions inherited from Memory
void packBE (const Memory::MAUTable data, int size, ULongWord &value)
 
void unpackBE (const ULongWord &value, int size, Memory::MAUTable data)
 
void packLE (const Memory::MAUTable data, int size, ULongWord &value)
 
void unpackLE (const ULongWord &value, int size, Memory::MAUTable data)
 
- Protected Attributes inherited from Memory
bool littleEndian_
 

Detailed Description

MemoryProxy is a memory access tracker for simulator.

MemoryProxy tracks calls to reads and writes. Memory accesses on the last clock cycle can be listed with readAccessCount(), readAccess(idx), writeAccessCount() and writeAccess(idx) functions. Memory access information is stored for only one cycle. Tracks only single memory accesses, not those made with the block methods.

Definition at line 53 of file MemoryProxy.hh.

Member Typedef Documentation

◆ MemoryAccess

typedef std::pair<Word, int> MemoryProxy::MemoryAccess

Definition at line 56 of file MemoryProxy.hh.

Constructor & Destructor Documentation

◆ MemoryProxy() [1/2]

MemoryProxy::MemoryProxy ( SimulatorFrontend frontend,
Memory memory 
)

The Constructor.

MemoryProxy takes ownership of the wrapped Memory instance.

Parameters
memoryTracked memory.

Definition at line 46 of file MemoryProxy.cc.

46 :
47 Memory(memory->start(), memory->end(), memory->MAUSize(),
48 memory->isLittleEndian()),
49 frontend_(frontend), memory_(memory) {
50}
Memory * memory_
Wrapped memory.
SimulatorFrontend & frontend_
virtual ULongWord end()
Definition Memory.hh:117
bool isLittleEndian()
Definition Memory.hh:120
virtual ULongWord MAUSize()
Definition Memory.hh:118
virtual ULongWord start()
Definition Memory.hh:116

◆ ~MemoryProxy()

MemoryProxy::~MemoryProxy ( )
virtual

The Destructor.

Deletes the tracked memory instance.

Definition at line 58 of file MemoryProxy.cc.

58 {
59 delete memory_;
60}

References memory_.

◆ MemoryProxy() [2/2]

MemoryProxy::MemoryProxy ( const MemoryProxy )
private

Copying not allowed.

Member Function Documentation

◆ advanceClock()

void MemoryProxy::advanceClock ( )
virtual

Resets the memory access information for the last cycle when wrapped memory clock is advanced.

Reimplemented from Memory.

Definition at line 98 of file MemoryProxy.cc.

98 {
101 newWrites_.clear();
102 newReads_.clear();
104}
std::vector< MemoryAccess > newReads_
List of initiated reads.
std::vector< MemoryAccess > writes_
List of initiated writes on the last cycle.
std::vector< MemoryAccess > reads_
List of initiated reads on the last cycle.
std::vector< MemoryAccess > newWrites_
List of initiated writes.
virtual void advanceClock()
Definition Memory.cc:819

References Memory::advanceClock(), memory_, newReads_, newWrites_, reads_, and writes_.

Here is the call graph for this function:

◆ fillWithZeros()

virtual void MemoryProxy::fillWithZeros ( )
inlinevirtual

Fills the whole memory with zeros.

This is needed due to some buggy simulated programs which expect uninitialized data to be zero. The default implementation is a slow for-loop which can be overridden with a faster one depending on the storage used.

Reimplemented from Memory.

Definition at line 72 of file MemoryProxy.hh.

virtual void fillWithZeros()
Definition Memory.cc:704

References Memory::fillWithZeros(), and memory_.

Here is the call graph for this function:

◆ operator=()

MemoryProxy & MemoryProxy::operator= ( const MemoryProxy )
private

Assignment not allowed.

◆ read() [1/2]

Memory::MAU MemoryProxy::read ( ULongWord  address)
overridevirtual

Tracks read calls.

Passes the call to the wrapped memory.

Implements Memory.

Definition at line 68 of file MemoryProxy.cc.

68 {
69
72
73 newReads_.push_back(std::make_pair(address, 1));
74 return memory_->read(address);
75}
void handleEvent(int event)
virtual Memory::MAU read(ULongWord address)=0
Definition Memory.cc:160
@ SE_MEMORY_ACCESS
Genereated when memory read or write is initiated.
SimulationEventHandler & eventHandler()

References SimulatorFrontend::eventHandler(), frontend_, Informer::handleEvent(), memory_, newReads_, Memory::read(), and SimulationEventHandler::SE_MEMORY_ACCESS.

Here is the call graph for this function:

◆ read() [2/2]

virtual void MemoryProxy::read ( ULongWord  address,
int  size,
ULongWord data 
)
inlinevirtual

Definition at line 69 of file MemoryProxy.hh.

70 { memory_->write(address, size, data); }
virtual void write(ULongWord address, MAU data)=0
Definition Memory.cc:95

References memory_, and Memory::write().

Here is the call graph for this function:

◆ readAccess()

MemoryProxy::MemoryAccess MemoryProxy::readAccess ( unsigned int  idx) const

Returns information of the given memory read access.

Parameters
idxIndex of the read access.
Exceptions
OutOfRangeIf the index is invalid.

Definition at line 133 of file MemoryProxy.cc.

133 {
134
135 if (idx > reads_.size()) {
136 throw OutOfRange(__FILE__, __LINE__, __func__);
137 }
138 return reads_[idx];
139}
#define __func__

References __func__, and reads_.

Referenced by ProximMemoryWindow::onSimulationStop().

◆ readAccessCount()

unsigned int MemoryProxy::readAccessCount ( ) const

Returns number of read accesses on the last cycle.

Definition at line 122 of file MemoryProxy.cc.

122 {
123 return reads_.size();
124}

References reads_.

Referenced by ProximMemoryWindow::onSimulationStop().

◆ reset()

void MemoryProxy::reset ( )
virtual

Resets all memory access information when the wrapped memory is reset.

Reimplemented from Memory.

Definition at line 110 of file MemoryProxy.cc.

110 {
111 reads_.clear();
112 writes_.clear();
113 newReads_.clear();
114 newWrites_.clear();
115 memory_->reset();
116}
virtual void reset()
Definition Memory.cc:716

References memory_, newReads_, newWrites_, reads_, Memory::reset(), and writes_.

Here is the call graph for this function:

◆ write() [1/2]

virtual void MemoryProxy::write ( ULongWord  address,
int  size,
ULongWord  data 
)
inlinevirtual

Definition at line 67 of file MemoryProxy.hh.

68 { memory_->write(address, size, data); }

References memory_, and Memory::write().

Here is the call graph for this function:

◆ write() [2/2]

void MemoryProxy::write ( ULongWord  address,
MAU  data 
)
overridevirtual

Tracks write calls.

Passes the call to the wrapped memory.

Implements Memory.

Definition at line 83 of file MemoryProxy.cc.

84 {
85
88
89 newWrites_.push_back(std::make_pair(address, 1));
90 memory_->write(address, data);
91}

References SimulatorFrontend::eventHandler(), frontend_, Informer::handleEvent(), memory_, newWrites_, SimulationEventHandler::SE_MEMORY_ACCESS, and Memory::write().

Here is the call graph for this function:

◆ writeAccess()

MemoryProxy::MemoryAccess MemoryProxy::writeAccess ( unsigned int  idx) const

Returns information of the given memory write access.

Parameters
idxIndex of the write access.
Exceptions
OutOfRangeIf the index is invalid.

Definition at line 157 of file MemoryProxy.cc.

157 {
158
159 if (idx > writes_.size()) {
160 throw OutOfRange(__FILE__, __LINE__, __func__);
161 }
162 return writes_[idx];
163}

References __func__, and writes_.

Referenced by ProximMemoryWindow::onSimulationStop().

◆ writeAccessCount()

unsigned int MemoryProxy::writeAccessCount ( ) const

Returns number of write accesses on the last cycle.

Definition at line 145 of file MemoryProxy.cc.

145 {
146 return writes_.size();
147}

References writes_.

Referenced by ProximMemoryWindow::onSimulationStop().

Member Data Documentation

◆ frontend_

SimulatorFrontend& MemoryProxy::frontend_
private

Definition at line 82 of file MemoryProxy.hh.

Referenced by read(), and write().

◆ memory_

Memory* MemoryProxy::memory_
private

Wrapped memory.

Definition at line 85 of file MemoryProxy.hh.

Referenced by advanceClock(), fillWithZeros(), read(), read(), reset(), write(), write(), and ~MemoryProxy().

◆ newReads_

std::vector<MemoryAccess> MemoryProxy::newReads_
private

List of initiated reads.

Definition at line 96 of file MemoryProxy.hh.

Referenced by advanceClock(), read(), and reset().

◆ newWrites_

std::vector<MemoryAccess> MemoryProxy::newWrites_
private

List of initiated writes.

Definition at line 98 of file MemoryProxy.hh.

Referenced by advanceClock(), reset(), and write().

◆ reads_

std::vector<MemoryAccess> MemoryProxy::reads_
private

List of initiated reads on the last cycle.

Definition at line 92 of file MemoryProxy.hh.

Referenced by advanceClock(), readAccess(), readAccessCount(), and reset().

◆ writes_

std::vector<MemoryAccess> MemoryProxy::writes_
private

List of initiated writes on the last cycle.

Definition at line 94 of file MemoryProxy.hh.

Referenced by advanceClock(), reset(), writeAccess(), and writeAccessCount().


The documentation for this class was generated from the following files: