memtest.hh revision 1298
113821Sgabeblack@google.com/* 213821Sgabeblack@google.com * Copyright (c) 2002-2004 The Regents of The University of Michigan 313821Sgabeblack@google.com * All rights reserved. 413821Sgabeblack@google.com * 513821Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 613821Sgabeblack@google.com * modification, are permitted provided that the following conditions are 713821Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 813821Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 913821Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1013821Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1113821Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1213821Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1313821Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1413821Sgabeblack@google.com * this software without specific prior written permission. 1513821Sgabeblack@google.com * 1613821Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1713821Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1813821Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1913821Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2013821Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2113821Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2213821Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2313821Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2413821Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2513821Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2613821Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2713821Sgabeblack@google.com */ 2813821Sgabeblack@google.com 2913821Sgabeblack@google.com#ifndef __MEMTEST_HH__ 3013821Sgabeblack@google.com#define __MEMTEST_HH__ 3113821Sgabeblack@google.com 3213821Sgabeblack@google.com#include <set> 3313821Sgabeblack@google.com 3413821Sgabeblack@google.com#include "base/statistics.hh" 3513821Sgabeblack@google.com#include "cpu/base_cpu.hh" 3613821Sgabeblack@google.com#include "cpu/exec_context.hh" 3713821Sgabeblack@google.com#include "mem/functional_mem/functional_memory.hh" 3813821Sgabeblack@google.com#include "mem/mem_interface.hh" 3913821Sgabeblack@google.com#include "sim/sim_object.hh" 4013821Sgabeblack@google.com#include "sim/stats.hh" 4113821Sgabeblack@google.com 4213821Sgabeblack@google.comclass MemTest : public BaseCPU 4313821Sgabeblack@google.com{ 4413821Sgabeblack@google.com public: 4513821Sgabeblack@google.com 4613821Sgabeblack@google.com MemTest(const std::string &name, 4713821Sgabeblack@google.com MemInterface *_cache_interface, 4813821Sgabeblack@google.com FunctionalMemory *main_mem, 4913821Sgabeblack@google.com FunctionalMemory *check_mem, 5013821Sgabeblack@google.com unsigned _memorySize, 5113821Sgabeblack@google.com unsigned _percentReads, 5213821Sgabeblack@google.com unsigned _percentCopies, 5313821Sgabeblack@google.com unsigned _percentUncacheable, 5413821Sgabeblack@google.com unsigned _progressInterval, 5513821Sgabeblack@google.com unsigned _percentSourceUnaligned, 5613821Sgabeblack@google.com unsigned _percentDestUnaligned, 5713821Sgabeblack@google.com Addr _traceAddr, 5813821Sgabeblack@google.com Counter max_loads_any_thread, 5913821Sgabeblack@google.com Counter max_loads_all_threads); 6013821Sgabeblack@google.com 6113821Sgabeblack@google.com // register statistics 6213821Sgabeblack@google.com virtual void regStats(); 6313821Sgabeblack@google.com // main simulation loop (one cycle) 6413821Sgabeblack@google.com void tick(); 6513821Sgabeblack@google.com 6613823Sgabeblack@google.com protected: 6713823Sgabeblack@google.com class TickEvent : public Event 6813821Sgabeblack@google.com { 6913821Sgabeblack@google.com private: 7013821Sgabeblack@google.com MemTest *cpu; 7113821Sgabeblack@google.com public: 7213821Sgabeblack@google.com TickEvent(MemTest *c) 7313821Sgabeblack@google.com : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c) {} 7413821Sgabeblack@google.com void process() {cpu->tick();} 7513821Sgabeblack@google.com virtual const char *description() { return "tick event"; } 7613821Sgabeblack@google.com }; 7713821Sgabeblack@google.com 7813821Sgabeblack@google.com TickEvent tickEvent; 7913821Sgabeblack@google.com 8013821Sgabeblack@google.com MemInterface *cacheInterface; 8113821Sgabeblack@google.com FunctionalMemory *mainMem; 8213821Sgabeblack@google.com FunctionalMemory *checkMem; 8313821Sgabeblack@google.com ExecContext *xc; 8413821Sgabeblack@google.com 8513821Sgabeblack@google.com unsigned size; // size of testing memory region 8613821Sgabeblack@google.com 8713821Sgabeblack@google.com unsigned percentReads; // target percentage of read accesses 8813821Sgabeblack@google.com unsigned percentCopies; // target percentage of copy accesses 8913821Sgabeblack@google.com unsigned percentUncacheable; 9013821Sgabeblack@google.com 9113821Sgabeblack@google.com int id; 9213821Sgabeblack@google.com 9313821Sgabeblack@google.com std::set<unsigned> outstandingAddrs; 9413821Sgabeblack@google.com 9513821Sgabeblack@google.com unsigned blockSize; 9613821Sgabeblack@google.com 9713821Sgabeblack@google.com Addr blockAddrMask; 9813821Sgabeblack@google.com 9913821Sgabeblack@google.com Addr blockAddr(Addr addr) 10013821Sgabeblack@google.com { 10113821Sgabeblack@google.com return (addr & ~blockAddrMask); 10213821Sgabeblack@google.com } 10313821Sgabeblack@google.com 10413821Sgabeblack@google.com Addr traceBlockAddr; 10513821Sgabeblack@google.com 10613821Sgabeblack@google.com Addr baseAddr1; // fix this to option 10713821Sgabeblack@google.com Addr baseAddr2; // fix this to option 10813821Sgabeblack@google.com Addr uncacheAddr; 10913821Sgabeblack@google.com 11013821Sgabeblack@google.com unsigned progressInterval; // frequency of progress reports 11113823Sgabeblack@google.com Tick nextProgressMessage; // access # for next progress report 11213821Sgabeblack@google.com 11313823Sgabeblack@google.com unsigned percentSourceUnaligned; 11413823Sgabeblack@google.com unsigned percentDestUnaligned; 11513821Sgabeblack@google.com 11613821Sgabeblack@google.com Tick noResponseCycles; 11713821Sgabeblack@google.com 11813821Sgabeblack@google.com uint64_t numReads; 11913821Sgabeblack@google.com Stats::Scalar<> numReadsStat; 12013821Sgabeblack@google.com Stats::Scalar<> numWritesStat; 12113821Sgabeblack@google.com Stats::Scalar<> numCopiesStat; 12213821Sgabeblack@google.com 12313821Sgabeblack@google.com // called by MemCompleteEvent::process() 12413821Sgabeblack@google.com void completeRequest(MemReqPtr &req, uint8_t *data); 12513821Sgabeblack@google.com 12613821Sgabeblack@google.com friend class MemCompleteEvent; 12713821Sgabeblack@google.com}; 12813821Sgabeblack@google.com 12913821Sgabeblack@google.com 13013821Sgabeblack@google.comclass MemCompleteEvent : public Event 13113821Sgabeblack@google.com{ 13213821Sgabeblack@google.com MemReqPtr req; 13313821Sgabeblack@google.com uint8_t *data; 13413821Sgabeblack@google.com MemTest *tester; 13513821Sgabeblack@google.com 13613821Sgabeblack@google.com public: 13713821Sgabeblack@google.com 13813821Sgabeblack@google.com MemCompleteEvent(MemReqPtr &_req, uint8_t *_data, MemTest *_tester) 13913821Sgabeblack@google.com : Event(&mainEventQueue), 14013821Sgabeblack@google.com req(_req), data(_data), tester(_tester) 14113821Sgabeblack@google.com { 14213821Sgabeblack@google.com } 14313821Sgabeblack@google.com 14413821Sgabeblack@google.com void process(); 14513821Sgabeblack@google.com 14613821Sgabeblack@google.com virtual const char *description(); 14713821Sgabeblack@google.com}; 14813821Sgabeblack@google.com 14913821Sgabeblack@google.com#endif // __MEMTEST_HH__ 15013821Sgabeblack@google.com 15113821Sgabeblack@google.com 15213821Sgabeblack@google.com 15313821Sgabeblack@google.com