gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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/mem_object.hh"
53 #include "params/MemTest.hh"
54 #include "sim/eventq.hh"
55 #include "sim/stats.hh"
56 
70 class MemTest : public MemObject
71 {
72 
73  public:
74 
75  typedef MemTestParams Params;
76  MemTest(const Params *p);
77 
78  virtual void regStats();
79 
80  virtual BaseMasterPort &getMasterPort(const std::string &if_name,
81  PortID idx = InvalidPortID);
82 
83  protected:
84 
85  void tick();
86 
88 
89  void noRequest();
90 
92 
93  void noResponse();
94 
96 
97  class CpuPort : public MasterPort
98  {
100 
101  public:
102 
103  CpuPort(const std::string &_name, MemTest &_memtest)
104  : MasterPort(_name, &_memtest), memtest(_memtest)
105  { }
106 
107  protected:
108 
109  bool recvTimingResp(PacketPtr pkt);
110 
112 
114 
115  Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
116 
117  void recvReqRetry();
118  };
119 
121 
123 
124  const unsigned size;
125 
127 
128  const unsigned percentReads;
129  const unsigned percentFunctional;
130  const unsigned percentUncacheable;
131 
134 
135  unsigned int id;
136 
137  std::set<Addr> outstandingAddrs;
138 
139  // store the expected value for the addresses we have touched
140  std::unordered_map<Addr, uint8_t> referenceData;
141 
142  const unsigned blockSize;
143 
145 
153  {
154  return (addr & ~blockAddrMask);
155  }
156 
160 
161  const unsigned progressInterval; // frequency of progress reports
163  Tick nextProgressMessage; // access # for next progress report
164 
165  uint64_t numReads;
166  uint64_t numWrites;
167  const uint64_t maxLoads;
168 
169  const bool atomic;
170 
172 
175 
182  void completeRequest(PacketPtr pkt, bool functional = false);
183 
184  bool sendPkt(PacketPtr pkt);
185 
186  void recvRetry();
187 
188 };
189 
190 #endif // __CPU_MEMTEST_MEMTEST_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
EventWrapper< MemTest,&MemTest::tick > tickEvent
Definition: memtest.hh:87
const Cycles interval
Definition: memtest.hh:126
void recvRetry()
Definition: memtest.cc:324
bool sendPkt(PacketPtr pkt)
Definition: memtest.cc:74
void noResponse()
Definition: memtest.cc:318
const unsigned size
Definition: memtest.hh:124
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
virtual BaseMasterPort & getMasterPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a master port with a given name and index.
Definition: memtest.cc:128
const PortID InvalidPortID
Definition: types.hh:182
const unsigned percentFunctional
Definition: memtest.hh:129
void recvReqRetry()
Called by the slave port if sendTimingReq was called on this master port (causing recvTimingReq to be...
Definition: memtest.cc:68
const unsigned progressInterval
Definition: memtest.hh:161
ip6_addr_t addr
Definition: inet.hh:335
MemObject declaration.
const Addr blockAddrMask
Definition: memtest.hh:144
std::unordered_map< Addr, uint8_t > referenceData
Definition: memtest.hh:140
EventWrapper< MemTest,&MemTest::noResponse > noResponseEvent
Definition: memtest.hh:95
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
const bool atomic
Definition: memtest.hh:169
Addr blockAlign(Addr addr) const
Get the block aligned address.
Definition: memtest.hh:152
CpuPort port
Definition: memtest.hh:120
MasterID masterId
Request id for all generated traffic.
Definition: memtest.hh:133
const unsigned blockSize
Definition: memtest.hh:142
void tick()
Definition: memtest.cc:218
PacketPtr retryPkt
Definition: memtest.hh:122
uint64_t Tick
Tick count type.
Definition: types.hh:63
unsigned int id
Definition: memtest.hh:135
The MemTest class tests a cache coherent memory system by generating false sharing and verifying the ...
Definition: memtest.hh:70
EventWrapper< MemTest,&MemTest::noRequest > noRequestEvent
Definition: memtest.hh:91
MemTest(const Params *p)
Definition: memtest.cc:87
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the slave port.
Definition: memtest.cc:61
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the slave port.
Definition: memtest.hh:113
CpuPort(const std::string &_name, MemTest &_memtest)
Definition: memtest.hh:103
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:85
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
void noRequest()
Definition: memtest.cc:312
Tick nextProgressMessage
Definition: memtest.hh:163
Stats::Scalar numReadsStat
Definition: memtest.hh:173
Addr baseAddr2
Definition: memtest.hh:158
uint64_t numReads
Definition: memtest.hh:165
std::set< Addr > outstandingAddrs
Definition: memtest.hh:137
Addr uncacheAddr
Definition: memtest.hh:159
const unsigned percentUncacheable
Definition: memtest.hh:130
MemTest & memtest
Definition: memtest.hh:99
const bool suppressFuncWarnings
Definition: memtest.hh:171
const Cycles progressCheck
Definition: memtest.hh:162
The MemObject class extends the ClockedObject with accessor functions to get its master and slave por...
Definition: mem_object.hh:60
A BaseMasterPort is a protocol-agnostic master port, responsible only for the structural connection t...
Definition: port.hh:115
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the slave port.
Definition: memtest.hh:111
const unsigned percentReads
Definition: memtest.hh:128
uint64_t numWrites
Definition: memtest.hh:166
virtual void regStats()
Register statistics for this object.
Definition: memtest.cc:200
Stats::Scalar numWritesStat
Definition: memtest.hh:174
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
void completeRequest(PacketPtr pkt, bool functional=false)
Complete a request by checking the response.
Definition: memtest.cc:137
const uint64_t maxLoads
Definition: memtest.hh:167
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from the slave port.
Definition: memtest.hh:115
Addr baseAddr1
Definition: memtest.hh:157
Bitfield< 0 > p
MemTestParams Params
Definition: memtest.hh:75

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6