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

#include <IdealSRAM.hh>

Inheritance diagram for IdealSRAM:
Inheritance graph
Collaboration diagram for IdealSRAM:
Collaboration graph

Public Member Functions

 IdealSRAM (ULongWord start, ULongWord end, Word MAUSize, bool littleEndian)
 
virtual ~IdealSRAM ()
 
virtual void write (ULongWord address, MAU data) override
 
virtual Memory::MAU read (ULongWord address) override
 
virtual void fillWithZeros ()
 
virtual void write (ULongWord address, MAU data)=0
 
void write (ULongWord address, int size, ULongWord data)
 
void write (ULongWord address, FloatWord data)
 
void write (ULongWord address, DoubleWord data)
 
virtual Memory::MAU read (ULongWord address)=0
 
void read (ULongWord address, int size, ULongWord &data)
 
void read (ULongWord address, DoubleWord &data)
 
void read (ULongWord address, FloatWord &data)
 
- Public Member Functions inherited from Memory
 Memory (ULongWord start, ULongWord end, ULongWord MAUSize, bool littleEndian_)
 
virtual ~Memory ()
 
virtual void advanceClock ()
 
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 void reset ()
 
virtual ULongWord start ()
 
virtual ULongWord end ()
 
virtual ULongWord MAUSize ()
 
bool isLittleEndian ()
 

Private Member Functions

 IdealSRAM (const IdealSRAM &)
 Copying not allowed.
 
IdealSRAMoperator= (const IdealSRAM &)
 Assignment not allowed.
 

Private Attributes

UIntWord start_
 Starting point of the address space.
 
UIntWord end_
 End point of the address space.
 
Word MAUSize_
 Size of the minimum adressable unit.
 
MemoryContentsdata_
 Container for holding read/write requests.
 

Additional Inherited Members

- Public Types inherited from Memory
typedef MinimumAddressableUnit MAU
 
typedef MAUMAUTable
 
- 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

Class that models an "ideal" memory.

An ideal memory is defined as a memory with read latency zero. The data is available at the same cycle in which the load is initiated. Also, after a store is initiated, data is written into memory as soon as the clock advances.

This implementation uses a "paged array" as the storage structure which avoids unnecessary allocation while providing O(1) access time. See PagedArray for more details.

Definition at line 55 of file IdealSRAM.hh.

Constructor & Destructor Documentation

◆ IdealSRAM() [1/2]

IdealSRAM::IdealSRAM ( ULongWord  start,
ULongWord  end,
Word  MAUSize,
bool  littleEndian 
)

Constructor. Create a model for a given memory.

The created memory model is empty. No data is allocated for its contents.

Parameters
startFirst address of the memory.
endLast address of the memory.
MAUSizeBit width of the minimum addressable unit of the memory.
wordSizeNumber of MAUs that make up a natural word.
alignAlignment of natural words, expressed in number of MAUs.

Definition at line 56 of file IdealSRAM.cc.

56 :
57 Memory(start, end, MAUSize, littleEndian), start_(start), end_(end),
60}
MemoryContents * data_
Container for holding read/write requests.
Definition IdealSRAM.hh:81
UIntWord end_
End point of the address space.
Definition IdealSRAM.hh:77
Word MAUSize_
Size of the minimum adressable unit.
Definition IdealSRAM.hh:79
UIntWord start_
Starting point of the address space.
Definition IdealSRAM.hh:75
virtual ULongWord end()
Definition Memory.hh:117
virtual ULongWord MAUSize()
Definition Memory.hh:118
virtual ULongWord start()
Definition Memory.hh:116

References data_, end_, and start_.

◆ ~IdealSRAM()

IdealSRAM::~IdealSRAM ( )
virtual

Destructor.

The storage reserved for the memory contents is deallocated. Any data about pending access requests is freed, too.

Definition at line 69 of file IdealSRAM.cc.

69 {
70 delete data_;
71 data_ = NULL;
72}

References data_.

◆ IdealSRAM() [2/2]

IdealSRAM::IdealSRAM ( const IdealSRAM )
private

Copying not allowed.

Member Function Documentation

◆ fillWithZeros()

void IdealSRAM::fillWithZeros ( )
virtual

Fills the whole memory with zeros.

This is needed due to some buggy simulated programs which expect uninitialized data to be zero.

Reimplemented from Memory.

Definition at line 107 of file IdealSRAM.cc.

107 {
108 data_->clear();
109}
void clear()

References PagedArray< ValueType, PageSize, DefaultValue >::clear(), and data_.

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ read() [1/5]

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

Reads a single memory location.

The fastest way to read the memory.

Parameters
addressThe address to read.
Returns
The data read.

Implements Memory.

Definition at line 96 of file IdealSRAM.cc.

96 {
97 return data_->readData(address - start_);
98}
ValueType readData(IndexType index)

References data_, PagedArray< ValueType, PageSize, DefaultValue >::readData(), and start_.

Here is the call graph for this function:

◆ read() [2/5]

Memory::MAU Memory::read ( ULongWord  address)
virtual

Reads a single memory location.

Must be implemented in the derived class. No range checking. The fastest way to read the memory.

Parameters
addressThe address to read.
Returns
The data read.

Implements Memory.

Definition at line 85 of file Memory.cc.

160 {
161 return 0;
162}

◆ read() [3/5]

void Memory::read ( ULongWord  address,
DoubleWord data 
)

A convenience method for reading data from the memory and interpreting it as a DoubleWord in order set by endian bit of memory.

Note
Currently works only if MAU == 8 bits. asserts otherwise.
Parameters
addressThe address to read.
dataThe data to write.
Exceptions
OutOfRangein case the address is out of range of the memory.

Definition at line 97 of file Memory.cc.

513 {
514 if (littleEndian_) {
515 readLE(address, data);
516 } else {
517 readBE(address, data);
518 }
519}
virtual void readLE(ULongWord address, int size, ULongWord &data)
Definition Memory.cc:682
virtual void readBE(ULongWord address, int size, ULongWord &data)
Definition Memory.cc:640
bool littleEndian_
Definition Memory.hh:128

◆ read() [4/5]

void Memory::read ( ULongWord  address,
FloatWord data 
)

A convenience method for reading data from the memory and interpreting it as a FloatWord in order set by the memory.

Note
Currently works only if MAU == 8 bits. asserts otherwise.
Parameters
addressThe address to read.
dataThe data to write.
Exceptions
OutOfRangein case the address is out of range of the memory.

Definition at line 98 of file Memory.cc.

329 {
330 if (littleEndian_) {
331 readLE(address, data);
332 } else {
333 readBE(address, data);
334 }
335}

◆ read() [5/5]

void Memory::read ( ULongWord  address,
int  size,
ULongWord data 
)

A convenience method for reading units of data from the memory.

The data is written to an UIntWord.

Parameters
addressThe address to read.
countNumber of MAUs to read.
dataThe data to write.
Exceptions
OutOfRangein case the address is out of range of the memory.

Definition at line 96 of file Memory.cc.

663 {
664 if (littleEndian_) {
665 readLE(address, size, data);
666 } else {
667 readBE(address, size, data);
668 }
669}

◆ write() [1/5]

void Memory::write ( ULongWord  address,
DoubleWord  data 
)

A convenience method for writing a DoubleWord to the memory.

Note
Currently works only if MAU == 8 bits. asserts otherwise.
Parameters
addressThe address to write.
dataThe data to write.
Exceptions
OutOfRangein case the address is out of range of the memory.

Definition at line 95 of file Memory.cc.

531 {
532 if (littleEndian_) {
533 writeLE(address, data);
534 } else {
535 writeBE(address, data);
536 }
537}
virtual void writeLE(ULongWord address, int size, ULongWord data)
Definition Memory.cc:221
virtual void writeBE(ULongWord address, int size, ULongWord data)
Definition Memory.cc:194

◆ write() [2/5]

void Memory::write ( ULongWord  address,
FloatWord  data 
)

◆ write() [3/5]

void Memory::write ( ULongWord  address,
int  count,
ULongWord  data 
)

A convenience method for writing units of data to the memory.

The data is stored in an UIntWord.

Parameters
addressThe address to write.
countNumber of MAUs to write.
dataThe data to write.
Exceptions
OutOfRangein case the address is out of range of the memory.

Definition at line 89 of file Memory.cc.

175 {
176 if (littleEndian_) {
177 writeLE(address, count, data);
178 } else {
179 writeBE(address, count, data);
180 }
181}

◆ write() [4/5]

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

Writes a single memory location.

The fastest way to write to the memory.

Parameters
addressThe target address.
dataThe data to write.

Implements Memory.

Definition at line 83 of file IdealSRAM.cc.

83 {
84 data_->writeData(address - start_, data);
85}
void writeData(IndexType index, const ValueType &data)

References data_, start_, and PagedArray< ValueType, PageSize, DefaultValue >::writeData().

Here is the call graph for this function:

◆ write() [5/5]

void Memory::write ( ULongWord  address,
MAU  data 
)
virtual

Writes a single memory location.

Must be implemented in the derived class. No range checking. The fastest way to write to the memory.

Parameters
addressThe target address.
dataThe data to write.

Implements Memory.

Definition at line 84 of file Memory.cc.

95 {
96 abortWithError("Must be implemented in the derived class.");
97}
#define abortWithError(message)

Member Data Documentation

◆ data_

MemoryContents* IdealSRAM::data_
private

Container for holding read/write requests.

Definition at line 81 of file IdealSRAM.hh.

Referenced by fillWithZeros(), IdealSRAM(), read(), write(), and ~IdealSRAM().

◆ end_

UIntWord IdealSRAM::end_
private

End point of the address space.

Definition at line 77 of file IdealSRAM.hh.

Referenced by IdealSRAM().

◆ MAUSize_

Word IdealSRAM::MAUSize_
private

Size of the minimum adressable unit.

Definition at line 79 of file IdealSRAM.hh.

◆ start_

UIntWord IdealSRAM::start_
private

Starting point of the address space.

Definition at line 75 of file IdealSRAM.hh.

Referenced by IdealSRAM(), read(), and write().


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