memtest.hh revision 1400
113938Sodanrc@yahoo.com.br/* 213938Sodanrc@yahoo.com.br * Copyright (c) 2002-2004 The Regents of The University of Michigan 313938Sodanrc@yahoo.com.br * All rights reserved. 413938Sodanrc@yahoo.com.br * 513938Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without 613938Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are 713938Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright 813938Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer; 913938Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright 1013938Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the 1113938Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution; 1213938Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its 1313938Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from 1413938Sodanrc@yahoo.com.br * this software without specific prior written permission. 1513938Sodanrc@yahoo.com.br * 1613938Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1713938Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1813938Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1913938Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2013938Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2113938Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2213938Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2313938Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2413938Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2513938Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2613938Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2713938Sodanrc@yahoo.com.br */ 2813938Sodanrc@yahoo.com.br 2913938Sodanrc@yahoo.com.br#ifndef __CPU_MEMTEST_MEMTEST_HH__ 3013938Sodanrc@yahoo.com.br#define __CPU_MEMTEST_MEMTEST_HH__ 3113938Sodanrc@yahoo.com.br 3213938Sodanrc@yahoo.com.br#include <set> 3313938Sodanrc@yahoo.com.br 3413938Sodanrc@yahoo.com.br#include "base/statistics.hh" 3513938Sodanrc@yahoo.com.br#include "mem/functional_mem/functional_memory.hh" 3613938Sodanrc@yahoo.com.br#include "mem/mem_interface.hh" 3713938Sodanrc@yahoo.com.br#include "sim/eventq.hh" 3813938Sodanrc@yahoo.com.br#include "sim/sim_exit.hh" 3913938Sodanrc@yahoo.com.br#include "sim/sim_object.hh" 4013938Sodanrc@yahoo.com.br#include "sim/stats.hh" 4113938Sodanrc@yahoo.com.br 4213940Sodanrc@yahoo.com.brclass ExecContext; 4313938Sodanrc@yahoo.com.brclass MemTest : public SimObject 4413938Sodanrc@yahoo.com.br{ 4513940Sodanrc@yahoo.com.br public: 4613940Sodanrc@yahoo.com.br 4713940Sodanrc@yahoo.com.br MemTest(const std::string &name, 4813940Sodanrc@yahoo.com.br MemInterface *_cache_interface, 4913940Sodanrc@yahoo.com.br FunctionalMemory *main_mem, 5013940Sodanrc@yahoo.com.br FunctionalMemory *check_mem, 5113940Sodanrc@yahoo.com.br unsigned _memorySize, 5213940Sodanrc@yahoo.com.br unsigned _percentReads, 5313940Sodanrc@yahoo.com.br unsigned _percentCopies, 5413940Sodanrc@yahoo.com.br unsigned _percentUncacheable, 5513940Sodanrc@yahoo.com.br unsigned _progressInterval, 5613940Sodanrc@yahoo.com.br unsigned _percentSourceUnaligned, 5713940Sodanrc@yahoo.com.br unsigned _percentDestUnaligned, 5813940Sodanrc@yahoo.com.br Addr _traceAddr, 5913940Sodanrc@yahoo.com.br Counter _max_loads); 6013940Sodanrc@yahoo.com.br 6113940Sodanrc@yahoo.com.br // register statistics 6213940Sodanrc@yahoo.com.br virtual void regStats(); 6313940Sodanrc@yahoo.com.br // main simulation loop (one cycle) 6413940Sodanrc@yahoo.com.br void tick(); 6513940Sodanrc@yahoo.com.br 6613940Sodanrc@yahoo.com.br protected: 6713940Sodanrc@yahoo.com.br class TickEvent : public Event 6813940Sodanrc@yahoo.com.br { 6913940Sodanrc@yahoo.com.br private: 7013940Sodanrc@yahoo.com.br MemTest *cpu; 7113940Sodanrc@yahoo.com.br public: 7213940Sodanrc@yahoo.com.br TickEvent(MemTest *c) 7313940Sodanrc@yahoo.com.br : Event(&mainEventQueue, CPU_Tick_Pri), cpu(c) {} 7413940Sodanrc@yahoo.com.br void process() {cpu->tick();} 7513940Sodanrc@yahoo.com.br virtual const char *description() { return "tick event"; } 7613940Sodanrc@yahoo.com.br }; 7713940Sodanrc@yahoo.com.br 7813940Sodanrc@yahoo.com.br TickEvent tickEvent; 7913940Sodanrc@yahoo.com.br 8013940Sodanrc@yahoo.com.br MemInterface *cacheInterface; 8113940Sodanrc@yahoo.com.br FunctionalMemory *mainMem; 8213940Sodanrc@yahoo.com.br FunctionalMemory *checkMem; 8313940Sodanrc@yahoo.com.br ExecContext *xc; 8413940Sodanrc@yahoo.com.br 8513940Sodanrc@yahoo.com.br unsigned size; // size of testing memory region 8613940Sodanrc@yahoo.com.br 8713940Sodanrc@yahoo.com.br unsigned percentReads; // target percentage of read accesses 8813940Sodanrc@yahoo.com.br unsigned percentCopies; // target percentage of copy accesses 8913940Sodanrc@yahoo.com.br unsigned percentUncacheable; 9013940Sodanrc@yahoo.com.br 9113940Sodanrc@yahoo.com.br int id; 9213940Sodanrc@yahoo.com.br 9313940Sodanrc@yahoo.com.br std::set<unsigned> outstandingAddrs; 9413940Sodanrc@yahoo.com.br 9513940Sodanrc@yahoo.com.br unsigned blockSize; 9613940Sodanrc@yahoo.com.br 9713947Sodanrc@yahoo.com.br Addr blockAddrMask; 9813940Sodanrc@yahoo.com.br 9913940Sodanrc@yahoo.com.br Addr blockAddr(Addr addr) 10013947Sodanrc@yahoo.com.br { 10113940Sodanrc@yahoo.com.br return (addr & ~blockAddrMask); 10213940Sodanrc@yahoo.com.br } 10313940Sodanrc@yahoo.com.br 10413940Sodanrc@yahoo.com.br Addr traceBlockAddr; 10513940Sodanrc@yahoo.com.br 10613940Sodanrc@yahoo.com.br Addr baseAddr1; // fix this to option 10713940Sodanrc@yahoo.com.br Addr baseAddr2; // fix this to option 10813947Sodanrc@yahoo.com.br Addr uncacheAddr; 10913947Sodanrc@yahoo.com.br 11013947Sodanrc@yahoo.com.br unsigned progressInterval; // frequency of progress reports 11113947Sodanrc@yahoo.com.br Tick nextProgressMessage; // access # for next progress report 11213947Sodanrc@yahoo.com.br 11313947Sodanrc@yahoo.com.br unsigned percentSourceUnaligned; 11413947Sodanrc@yahoo.com.br unsigned percentDestUnaligned; 11513947Sodanrc@yahoo.com.br 11613947Sodanrc@yahoo.com.br Tick noResponseCycles; 11713947Sodanrc@yahoo.com.br 11813947Sodanrc@yahoo.com.br uint64_t numReads; 11913947Sodanrc@yahoo.com.br uint64_t maxLoads; 12013947Sodanrc@yahoo.com.br Stats::Scalar<> numReadsStat; 12113947Sodanrc@yahoo.com.br Stats::Scalar<> numWritesStat; 12213947Sodanrc@yahoo.com.br Stats::Scalar<> numCopiesStat; 12313947Sodanrc@yahoo.com.br 124 // called by MemCompleteEvent::process() 125 void completeRequest(MemReqPtr &req, uint8_t *data); 126 127 friend class MemCompleteEvent; 128}; 129 130 131class MemCompleteEvent : public Event 132{ 133 MemReqPtr req; 134 uint8_t *data; 135 MemTest *tester; 136 137 public: 138 139 MemCompleteEvent(MemReqPtr &_req, uint8_t *_data, MemTest *_tester) 140 : Event(&mainEventQueue), 141 req(_req), data(_data), tester(_tester) 142 { 143 } 144 145 void process(); 146 147 virtual const char *description(); 148}; 149 150#endif // __CPU_MEMTEST_MEMTEST_HH__ 151 152 153 154