OpenASIP
2.0
src
base
memory
IdealSRAM.cc
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 IdealSRAM.cc
26
*
27
* Definition of IdealSRAM 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
#include <string>
35
#include <utility>
36
37
#include "
IdealSRAM.hh
"
38
#include "
MemoryContents.hh
"
39
#include "
Conversion.hh
"
40
#include "
Application.hh
"
41
42
using
std::string;
43
44
45
/**
46
* Constructor. Create a model for a given memory.
47
*
48
* The created memory model is empty. No data is allocated for its contents.
49
*
50
* @param start First address of the memory.
51
* @param end Last address of the memory.
52
* @param MAUSize Bit width of the minimum addressable unit of the memory.
53
* @param wordSize Number of MAUs that make up a natural word.
54
* @param align Alignment of natural words, expressed in number of MAUs.
55
*/
56
IdealSRAM::IdealSRAM
(
ULongWord
start,
ULongWord
end, Word MAUSize,
bool
littleEndian) :
57
Memory
(start, end, MAUSize, littleEndian), start_(start), end_(end),
58
MAUSize_(MAUSize) {
59
data_
=
new
MemoryContents
(
end_
-
start_
);
60
}
61
62
63
/**
64
* Destructor.
65
*
66
* The storage reserved for the memory contents is deallocated. Any data
67
* about pending access requests is freed, too.
68
*/
69
IdealSRAM::~IdealSRAM
() {
70
delete
data_
;
71
data_
= NULL;
72
}
73
74
/**
75
* Writes a single memory location.
76
*
77
* The fastest way to write to the memory.
78
*
79
* @param address The target address.
80
* @param data The data to write.
81
*/
82
void
83
IdealSRAM::write
(
ULongWord
address,
MAU
data) {
84
data_
->
writeData
(address -
start_
, data);
85
}
86
87
/**
88
* Reads a single memory location.
89
*
90
* The fastest way to read the memory.
91
*
92
* @param address The address to read.
93
* @return The data read.
94
*/
95
Memory::MAU
96
IdealSRAM::read
(
ULongWord
address) {
97
return
data_
->
readData
(address -
start_
);
98
}
99
100
/**
101
* Fills the whole memory with zeros.
102
*
103
* This is needed due to some buggy simulated programs which expect
104
* uninitialized data to be zero.
105
*/
106
void
107
IdealSRAM::fillWithZeros
() {
108
data_
->
clear
();
109
}
110
111
IdealSRAM::~IdealSRAM
virtual ~IdealSRAM()
Definition:
IdealSRAM.cc:69
MemoryContents.hh
IdealSRAM::start_
UIntWord start_
Starting point of the address space.
Definition:
IdealSRAM.hh:75
IdealSRAM::fillWithZeros
virtual void fillWithZeros()
Definition:
IdealSRAM.cc:107
IdealSRAM::read
virtual Memory::MAU read(ULongWord address) override
Definition:
IdealSRAM.cc:96
PagedArray::readData
ValueType readData(IndexType index)
MemoryContents
Definition:
MemoryContents.hh:48
PagedArray::clear
void clear()
IdealSRAM::end_
UIntWord end_
End point of the address space.
Definition:
IdealSRAM.hh:77
IdealSRAM::write
virtual void write(ULongWord address, MAU data) override
Definition:
IdealSRAM.cc:83
Conversion.hh
Application.hh
IdealSRAM::IdealSRAM
IdealSRAM(ULongWord start, ULongWord end, Word MAUSize, bool littleEndian)
Definition:
IdealSRAM.cc:56
Memory::MAU
MinimumAddressableUnit MAU
Definition:
Memory.hh:76
PagedArray::writeData
void writeData(IndexType index, const ValueType &data)
IdealSRAM.hh
ULongWord
unsigned long ULongWord
Definition:
BaseType.hh:51
IdealSRAM::data_
MemoryContents * data_
Container for holding read/write requests.
Definition:
IdealSRAM.hh:81
Memory
Definition:
Memory.hh:74
Generated by
1.8.17