gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
memtest.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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  * Authors: Erik Hallnor
41  * Steve Reinhardt
42  * Andreas Hansson
43  */
44 
45 #ifndef __CPU_MEMTEST_MEMTEST_HH__
46 #define __CPU_MEMTEST_MEMTEST_HH__
47 
48 #include <set>
49 #include <unordered_map>
50 
51 #include "base/statistics.hh"
52 #include "mem/port.hh"
53 #include "params/MemTest.hh"
54 #include "sim/clocked_object.hh"
55 #include "sim/eventq.hh"
56 #include "sim/stats.hh"
57 
71 class MemTest : public ClockedObject
72 {
73 
74  public:
75 
76  typedef MemTestParams Params;
77  MemTest(const Params *p);
78 
79  void regStats() override;
80 
81  Port &getPort(const std::string &if_name,
82  PortID idx=InvalidPortID) override;
83 
84  protected:
85 
86  void tick();
87 
89 
90  void noRequest();
91 
93 
94  void noResponse();
95 
97 
98  class CpuPort : public MasterPort
99  {
101 
102  public:
103 
104  CpuPort(const std::string &_name, MemTest &_memtest)
105  : MasterPort(_name, &_memtest), memtest(_memtest)
106  { }
107 
108  protected:
109 
110  bool recvTimingResp(PacketPtr pkt);
111 
113 
115 
116  Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
117 
118  void recvReqRetry();
119  };
120 
122 
124 
125  const unsigned size;
126 
128 
129  const unsigned percentReads;
130  const unsigned percentFunctional;
131  const unsigned percentUncacheable;
132 
135 
136  unsigned int id;
137 
138  std::set<Addr> outstandingAddrs;
139 
140  // store the expected value for the addresses we have touched
141  std::unordered_map<Addr, uint8_t> referenceData;
142 
143  const unsigned blockSize;
144 
146 
154  {
155  return (addr & ~blockAddrMask);
156  }
157 
161 
162  const unsigned progressInterval; // frequency of progress reports
164  Tick nextProgressMessage; // access # for next progress report
165 
166  uint64_t numReads;
167  uint64_t numWrites;
168  const uint64_t maxLoads;
169 
170  const bool atomic;
171 
173 
176 
183  void completeRequest(PacketPtr pkt, bool functional = false);
184 
185  bool sendPkt(PacketPtr pkt);
186 
187  void recvRetry();
188 
189 };
190 
191 #endif // __CPU_MEMTEST_MEMTEST_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
const Cycles interval
Definition: memtest.hh:127
void recvRetry()
Definition: memtest.cc:328
bool sendPkt(PacketPtr pkt)
Definition: memtest.cc:73
Ports are used to interface objects to each other.
Definition: port.hh:60
EventFunctionWrapper noResponseEvent
Definition: memtest.hh:96
void noResponse()
Definition: memtest.cc:322
const unsigned size
Definition: memtest.hh:125
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
EventFunctionWrapper tickEvent
Definition: memtest.hh:88
const PortID InvalidPortID
Definition: types.hh:238
const unsigned percentFunctional
Definition: memtest.hh:130
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: memtest.cc:67
const unsigned progressInterval
Definition: memtest.hh:162
Addr blockAlign(Addr addr) const
Get the block aligned address.
Definition: memtest.hh:153
ip6_addr_t addr
Definition: inet.hh:335
const Addr blockAddrMask
Definition: memtest.hh:145
std::unordered_map< Addr, uint8_t > referenceData
Definition: memtest.hh:141
void regStats() override
Callback to set stat parameters.
Definition: memtest.cc:200
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: memtest.cc:126
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
EventFunctionWrapper noRequestEvent
Definition: memtest.hh:92
const bool atomic
Definition: memtest.hh:170
CpuPort port
Definition: memtest.hh:121
MasterID masterId
Request id for all generated traffic.
Definition: memtest.hh:134
const unsigned blockSize
Definition: memtest.hh:143
void tick()
Definition: memtest.cc:218
PacketPtr retryPkt
Definition: memtest.hh:123
uint64_t Tick
Tick count type.
Definition: types.hh:63
unsigned int id
Definition: memtest.hh:136
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
ClockedObject declaration and implementation.
The MemTest class tests a cache coherent memory system by generating false sharing and verifying the ...
Definition: memtest.hh:71
Port Object Declaration.
MemTest(const Params *p)
Definition: memtest.cc:86
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: memtest.cc:60
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition: memtest.hh:114
CpuPort(const std::string &_name, MemTest &_memtest)
Definition: memtest.hh:104
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
uint16_t MasterID
Definition: request.hh:86
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
void noRequest()
Definition: memtest.cc:316
Tick nextProgressMessage
Definition: memtest.hh:164
Stats::Scalar numReadsStat
Definition: memtest.hh:174
Addr baseAddr2
Definition: memtest.hh:159
uint64_t numReads
Definition: memtest.hh:166
std::set< Addr > outstandingAddrs
Definition: memtest.hh:138
Addr uncacheAddr
Definition: memtest.hh:160
const unsigned percentUncacheable
Definition: memtest.hh:131
MemTest & memtest
Definition: memtest.hh:100
const bool suppressFuncWarnings
Definition: memtest.hh:172
const Cycles progressCheck
Definition: memtest.hh:163
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition: memtest.hh:112
const unsigned percentReads
Definition: memtest.hh:129
uint64_t numWrites
Definition: memtest.hh:167
Stats::Scalar numWritesStat
Definition: memtest.hh:175
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
void completeRequest(PacketPtr pkt, bool functional=false)
Complete a request by checking the response.
Definition: memtest.cc:135
const uint64_t maxLoads
Definition: memtest.hh:168
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition: memtest.hh:116
Addr baseAddr1
Definition: memtest.hh:158
Bitfield< 0 > p
MemTestParams Params
Definition: memtest.hh:76

Generated on Fri Feb 28 2020 16:27:00 for gem5 by doxygen 1.8.13