2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Erik Hallnor
32 #ifndef __CPU_MEMTEST_MEMTEST_HH__
33 #define __CPU_MEMTEST_MEMTEST_HH__
37 #include "base/fast_alloc.hh"
38 #include "base/statistics.hh"
39 #include "mem/mem_object.hh"
40 #include "mem/port.hh"
41 #include "mem/port_proxy.hh"
42 #include "params/MemTest.hh"
43 #include "sim/eventq.hh"
44 #include "sim/sim_exit.hh"
45 #include "sim/sim_object.hh"
46 #include "sim/stats.hh"
49 class MemTest : public MemObject
52 typedef MemTestParams Params;
53 MemTest(const Params *p);
57 // register statistics
58 virtual void regStats();
60 inline Tick ticks(int numCycles) const { return numCycles; }
62 // main simulation loop (one cycle)
65 virtual MasterPort &getMasterPort(const std::string &if_name,
69 * Print state of address in memory system via PrintReq (for
72 void printAddr(Addr a);
75 class TickEvent : public Event
81 TickEvent(MemTest *c) : Event(CPU_Tick_Pri), cpu(c) {}
82 void process() { cpu->tick(); }
83 virtual const char *description() const { return "MemTest tick"; }
88 class CpuPort : public MasterPort
94 CpuPort(const std::string &_name, MemTest *_memtest)
95 : MasterPort(_name, _memtest), memtest(_memtest)
100 virtual bool recvTiming(PacketPtr pkt);
102 virtual bool recvTimingSnoop(PacketPtr pkt) { return true; }
104 virtual Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
106 virtual void recvFunctionalSnoop(PacketPtr pkt) { }
108 virtual void recvRetry();
115 class MemTestSenderState : public Packet::SenderState, public FastAlloc
119 MemTestSenderState(uint8_t *_data)
123 // Hold onto data pointer
132 // The dmaOustanding flag enforces only one dma at a time
136 unsigned size; // size of testing memory region
138 unsigned percentReads; // target percentage of read accesses
139 unsigned percentFunctional; // target percentage of functional accesses
140 unsigned percentUncacheable;
144 /** Request id for all generated traffic */
149 std::set<unsigned> outstandingAddrs;
155 Addr blockAddr(Addr addr)
157 return (addr & ~blockAddrMask);
162 Addr baseAddr1; // fix this to option
163 Addr baseAddr2; // fix this to option
166 unsigned progressInterval; // frequency of progress reports
167 Tick nextProgressMessage; // access # for next progress report
169 unsigned percentSourceUnaligned;
170 unsigned percentDestUnaligned;
172 Tick noResponseCycles;
179 bool suppress_func_warnings;
181 Stats::Scalar numReadsStat;
182 Stats::Scalar numWritesStat;
183 Stats::Scalar numCopiesStat;
185 // called by MemCompleteEvent::process()
186 void completeRequest(PacketPtr pkt);
188 void sendPkt(PacketPtr pkt);
192 friend class MemCompleteEvent;
195 #endif // __CPU_MEMTEST_MEMTEST_HH__