gem5  v22.1.0.0
memtest.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 2021 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) 2002-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef __CPU_MEMTEST_MEMTEST_HH__
42 #define __CPU_MEMTEST_MEMTEST_HH__
43 
44 #include <unordered_map>
45 #include <unordered_set>
46 
47 #include "base/statistics.hh"
48 #include "mem/port.hh"
49 #include "params/MemTest.hh"
50 #include "sim/clocked_object.hh"
51 #include "sim/eventq.hh"
52 #include "sim/stats.hh"
53 
54 namespace gem5
55 {
56 
70 class MemTest : public ClockedObject
71 {
72 
73  public:
74 
75  typedef MemTestParams Params;
76  MemTest(const Params &p);
77 
78 
79  Port &getPort(const std::string &if_name,
80  PortID idx=InvalidPortID) override;
81 
82  protected:
83 
84  void tick();
85 
87 
88  void noRequest();
89 
91 
92  void noResponse();
93 
95 
96  class CpuPort : public RequestPort
97  {
99 
100  public:
101 
102  CpuPort(const std::string &_name, MemTest &_memtest)
103  : RequestPort(_name, &_memtest), memtest(_memtest)
104  { }
105 
106  protected:
107 
108  bool recvTimingResp(PacketPtr pkt);
109 
111 
113 
114  Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
115 
116  void recvReqRetry();
117  };
118 
120 
122 
123  // Set if reached the maximum number of outstanding requests.
124  // Won't tick until a response is received.
126 
127  const unsigned size;
128 
130 
131  const unsigned percentReads;
132  const unsigned percentFunctional;
133  const unsigned percentUncacheable;
134 
137 
138  unsigned int id;
139 
140  std::unordered_set<Addr> outstandingAddrs;
141 
142  // store the expected value for the addresses we have touched
143  std::unordered_map<Addr, uint8_t> referenceData;
144 
145  const unsigned blockSize;
146 
148 
149  const unsigned sizeBlocks;
150 
158  {
159  return (addr & ~blockAddrMask);
160  }
161 
165 
166  const unsigned progressInterval; // frequency of progress reports
168  Tick nextProgressMessage; // access # for next progress report
169 
170  uint64_t numReads;
171  uint64_t numWrites;
172  const uint64_t maxLoads;
173 
174  const bool atomic;
175 
176  const bool suppressFuncErrors;
177  protected:
179  {
183  } stats;
184 
191  void completeRequest(PacketPtr pkt, bool functional = false);
192 
193  bool sendPkt(PacketPtr pkt);
194 
195  void recvRetry();
196 
197 };
198 
199 } // namespace gem5
200 
201 #endif // __CPU_MEMTEST_MEMTEST_HH__
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition: memtest.hh:112
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition: memtest.hh:114
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition: memtest.hh:110
CpuPort(const std::string &_name, MemTest &_memtest)
Definition: memtest.hh:102
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: memtest.cc:65
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: memtest.cc:58
The MemTest class tests a cache coherent memory system by generating false sharing and verifying the ...
Definition: memtest.hh:71
EventFunctionWrapper tickEvent
Definition: memtest.hh:86
MemTest(const Params &p)
Definition: memtest.cc:84
void noResponse()
Definition: memtest.cc:326
const bool suppressFuncErrors
Definition: memtest.hh:176
std::unordered_set< Addr > outstandingAddrs
Definition: memtest.hh:140
const uint64_t maxLoads
Definition: memtest.hh:172
void tick()
Definition: memtest.cc:214
const Addr baseAddr1
Definition: memtest.hh:162
gem5::MemTest::MemTestStats stats
const Cycles interval
Definition: memtest.hh:129
const Cycles progressCheck
Definition: memtest.hh:167
void recvRetry()
Definition: memtest.cc:332
const Addr baseAddr2
Definition: memtest.hh:163
const unsigned blockSize
Definition: memtest.hh:145
const unsigned percentFunctional
Definition: memtest.hh:132
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: memtest.cc:125
Addr blockAlign(Addr addr) const
Get the block aligned address.
Definition: memtest.hh:157
uint64_t numWrites
Definition: memtest.hh:171
const unsigned size
Definition: memtest.hh:127
const unsigned percentReads
Definition: memtest.hh:131
void completeRequest(PacketPtr pkt, bool functional=false)
Complete a request by checking the response.
Definition: memtest.cc:134
const Addr uncacheAddr
Definition: memtest.hh:164
const unsigned progressInterval
Definition: memtest.hh:166
std::unordered_map< Addr, uint8_t > referenceData
Definition: memtest.hh:143
MemTestParams Params
Definition: memtest.hh:75
unsigned int id
Definition: memtest.hh:138
PacketPtr retryPkt
Definition: memtest.hh:121
uint64_t numReads
Definition: memtest.hh:170
Tick nextProgressMessage
Definition: memtest.hh:168
const unsigned sizeBlocks
Definition: memtest.hh:149
EventFunctionWrapper noRequestEvent
Definition: memtest.hh:90
const bool atomic
Definition: memtest.hh:174
EventFunctionWrapper noResponseEvent
Definition: memtest.hh:94
const Addr blockAddrMask
Definition: memtest.hh:147
RequestorID requestorId
Request id for all generated traffic.
Definition: memtest.hh:136
bool sendPkt(PacketPtr pkt)
Definition: memtest.cc:71
bool waitResponse
Definition: memtest.hh:125
const unsigned percentUncacheable
Definition: memtest.hh:133
CpuPort port
Definition: memtest.hh:119
void noRequest()
Definition: memtest.cc:320
const std::string _name
Definition: named.hh:41
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
ClockedObject declaration and implementation.
Port Object Declaration.
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58
uint16_t RequestorID
Definition: request.hh:95
Declaration of Statistics objects.
statistics::Scalar numWrites
Definition: memtest.hh:182
statistics::Scalar numReads
Definition: memtest.hh:181
MemTestStats(statistics::Group *parent)
Definition: memtest.cc:203

Generated on Wed Dec 21 2022 10:22:32 for gem5 by doxygen 1.9.1