gem5
[DEVELOP-FOR-23.0]
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
o
p
q
r
s
t
v
x
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
:
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
s
t
v
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Typedefs
a
b
c
d
g
h
i
l
m
r
s
t
u
w
Enumerations
b
h
i
o
p
Enumerator
h
i
o
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
mem
ruby
structures
DirectoryMemory.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017,2019 ARM Limited
3
* All rights reserved.
4
*
5
* The license below extends only to copyright in the software and shall
6
* not be construed as granting a license to any other intellectual
7
* property including but not limited to intellectual property relating
8
* to a hardware implementation of the functionality of the software
9
* licensed hereunder. You may use the software subject to the license
10
* terms below provided that you ensure that this notice is replicated
11
* unmodified and in its entirety in all distributions of the software,
12
* modified or unmodified, in source code or in binary form.
13
*
14
* Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
15
* Copyright (c) 2017 Google Inc.
16
* All rights reserved.
17
*
18
* Redistribution and use in source and binary forms, with or without
19
* modification, are permitted provided that the following conditions are
20
* met: redistributions of source code must retain the above copyright
21
* notice, this list of conditions and the following disclaimer;
22
* redistributions in binary form must reproduce the above copyright
23
* notice, this list of conditions and the following disclaimer in the
24
* documentation and/or other materials provided with the distribution;
25
* neither the name of the copyright holders nor the names of its
26
* contributors may be used to endorse or promote products derived from
27
* this software without specific prior written permission.
28
*
29
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
*/
41
42
#include "
mem/ruby/structures/DirectoryMemory.hh
"
43
44
#include "
base/addr_range.hh
"
45
#include "
base/intmath.hh
"
46
#include "debug/RubyCache.hh"
47
#include "debug/RubyStats.hh"
48
#include "
mem/ruby/slicc_interface/RubySlicc_Util.hh
"
49
#include "
mem/ruby/system/RubySystem.hh
"
50
#include "
sim/system.hh
"
51
52
namespace
gem5
53
{
54
55
namespace
ruby
56
{
57
58
DirectoryMemory::DirectoryMemory
(
const
Params
&
p
)
59
:
SimObject
(
p
), addrRanges(
p
.addr_ranges.begin(),
p
.addr_ranges.end())
60
{
61
m_size_bytes
= 0;
62
for
(
const
auto
&
r
:
addrRanges
) {
63
m_size_bytes
+=
r
.size();
64
}
65
m_size_bits
=
floorLog2
(
m_size_bytes
);
66
m_num_entries
= 0;
67
}
68
69
void
70
DirectoryMemory::init
()
71
{
72
m_num_entries
=
m_size_bytes
/
RubySystem::getBlockSizeBytes
();
73
m_entries
=
new
AbstractCacheEntry
*[
m_num_entries
];
74
for
(
int
i
= 0;
i
<
m_num_entries
;
i
++)
75
m_entries
[
i
] = NULL;
76
}
77
78
DirectoryMemory::~DirectoryMemory
()
79
{
80
// free up all the directory entries
81
for
(uint64_t
i
= 0;
i
<
m_num_entries
;
i
++) {
82
if
(
m_entries
[
i
] != NULL) {
83
delete
m_entries
[
i
];
84
}
85
}
86
delete
[]
m_entries
;
87
}
88
89
bool
90
DirectoryMemory::isPresent
(
Addr
address)
91
{
92
for
(
const
auto
&
r
:
addrRanges
) {
93
if
(
r
.contains(address)) {
94
return
true
;
95
}
96
}
97
return
false
;
98
}
99
100
uint64_t
101
DirectoryMemory::mapAddressToLocalIdx
(
Addr
address)
102
{
103
uint64_t ret = 0;
104
for
(
const
auto
&
r
:
addrRanges
) {
105
if
(
r
.contains(address)) {
106
ret +=
r
.getOffset(address);
107
break
;
108
}
109
ret +=
r
.size();
110
}
111
return
ret >>
RubySystem::getBlockSizeBits
();
112
}
113
114
AbstractCacheEntry
*
115
DirectoryMemory::lookup
(
Addr
address)
116
{
117
assert(
isPresent
(address));
118
DPRINTF
(RubyCache,
"Looking up address: %#x\n"
, address);
119
120
uint64_t idx =
mapAddressToLocalIdx
(address);
121
assert(idx <
m_num_entries
);
122
return
m_entries
[idx];
123
}
124
125
AbstractCacheEntry
*
126
DirectoryMemory::allocate
(
Addr
address,
AbstractCacheEntry
*entry)
127
{
128
assert(
isPresent
(address));
129
uint64_t idx;
130
DPRINTF
(RubyCache,
"Looking up address: %#x\n"
, address);
131
132
idx =
mapAddressToLocalIdx
(address);
133
assert(idx <
m_num_entries
);
134
assert(
m_entries
[idx] == NULL);
135
entry->
changePermission
(AccessPermission_Read_Only);
136
m_entries
[idx] = entry;
137
138
return
entry;
139
}
140
141
void
142
DirectoryMemory::deallocate
(
Addr
address)
143
{
144
assert(
isPresent
(address));
145
uint64_t idx;
146
DPRINTF
(RubyCache,
"Removing entry for address: %#x\n"
, address);
147
148
idx =
mapAddressToLocalIdx
(address);
149
assert(idx <
m_num_entries
);
150
assert(
m_entries
[idx] != NULL);
151
delete
m_entries
[idx];
152
m_entries
[idx] = NULL;
153
}
154
155
void
156
DirectoryMemory::print
(std::ostream& out)
const
157
{
158
}
159
160
void
161
DirectoryMemory::recordRequestType
(DirectoryRequestType requestType) {
162
DPRINTF
(RubyStats,
"Recorded statistic: %s\n"
,
163
DirectoryRequestType_to_string(requestType));
164
}
165
166
}
// namespace ruby
167
}
// namespace gem5
gem5::ruby::DirectoryMemory::addrRanges
const AddrRangeList addrRanges
The address range for which the directory responds.
Definition:
DirectoryMemory.hh:112
gem5::ruby::DirectoryMemory::mapAddressToLocalIdx
uint64_t mapAddressToLocalIdx(Addr address)
Return the index in the directory based on an address.
Definition:
DirectoryMemory.cc:101
system.hh
gem5::ruby::AbstractCacheEntry::changePermission
void changePermission(AccessPermission new_perm)
Definition:
AbstractCacheEntry.cc:74
gem5::ruby::DirectoryMemory::m_size_bits
uint64_t m_size_bits
Definition:
DirectoryMemory.hh:105
gem5::ruby::DirectoryMemory::~DirectoryMemory
~DirectoryMemory()
Definition:
DirectoryMemory.cc:78
gem5::ruby::DirectoryMemory::m_entries
AbstractCacheEntry ** m_entries
Definition:
DirectoryMemory.hh:101
gem5::ruby::AbstractCacheEntry
Definition:
AbstractCacheEntry.hh:62
gem5::floorLog2
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
Definition:
intmath.hh:59
DirectoryMemory.hh
gem5::ruby::RubySystem::getBlockSizeBytes
static uint32_t getBlockSizeBytes()
Definition:
RubySystem.hh:72
gem5::ruby::DirectoryMemory::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition:
DirectoryMemory.cc:70
gem5::ruby::DirectoryMemory::allocate
AbstractCacheEntry * allocate(Addr address, AbstractCacheEntry *new_entry)
Definition:
DirectoryMemory.cc:126
gem5::VegaISA::r
Bitfield< 5 > r
Definition:
pagetable.hh:60
gem5::ArmISA::i
Bitfield< 7 > i
Definition:
misc_types.hh:67
gem5::ruby::DirectoryMemory::recordRequestType
void recordRequestType(DirectoryRequestType requestType)
Definition:
DirectoryMemory.cc:161
gem5::ruby::DirectoryMemory::Params
RubyDirectoryMemoryParams Params
Definition:
DirectoryMemory.hh:63
gem5::ruby::DirectoryMemory::isPresent
bool isPresent(Addr address)
Definition:
DirectoryMemory.cc:90
gem5::ruby::DirectoryMemory::deallocate
void deallocate(Addr address)
Definition:
DirectoryMemory.cc:142
gem5::VegaISA::p
Bitfield< 54 > p
Definition:
pagetable.hh:70
DPRINTF
#define DPRINTF(x,...)
Definition:
trace.hh:210
gem5::ruby::DirectoryMemory::m_num_entries
uint64_t m_num_entries
Definition:
DirectoryMemory.hh:106
gem5::ruby::RubySystem::getBlockSizeBits
static uint32_t getBlockSizeBits()
Definition:
RubySystem.hh:73
gem5::ruby::DirectoryMemory::DirectoryMemory
DirectoryMemory(const Params &p)
Definition:
DirectoryMemory.cc:58
RubySlicc_Util.hh
gem5::SimObject
Abstract superclass for simulation objects.
Definition:
sim_object.hh:146
RubySystem.hh
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition:
types.hh:147
addr_range.hh
gem5::ruby::DirectoryMemory::m_size_bytes
uint64_t m_size_bytes
Definition:
DirectoryMemory.hh:104
intmath.hh
gem5::ruby::DirectoryMemory::lookup
AbstractCacheEntry * lookup(Addr address)
Definition:
DirectoryMemory.cc:115
gem5::ruby::DirectoryMemory::print
void print(std::ostream &out) const
Definition:
DirectoryMemory.cc:156
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition:
gpu_translation_state.hh:37
Generated on Sun Jul 30 2023 01:56:59 for gem5 by
doxygen
1.8.17