memtest.hh revision 9294
12SN/A/* 21762SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A * 282665SN/A * Authors: Erik Hallnor 292665SN/A * Steve Reinhardt 302SN/A */ 312SN/A 321400SN/A#ifndef __CPU_MEMTEST_MEMTEST_HH__ 331400SN/A#define __CPU_MEMTEST_MEMTEST_HH__ 342SN/A 351298SN/A#include <set> 361298SN/A 371298SN/A#include "base/statistics.hh" 388229Snate@binkert.org#include "mem/mem_object.hh" 398229Snate@binkert.org#include "mem/port.hh" 408853Sandreas.hansson@arm.com#include "mem/port_proxy.hh" 415034SN/A#include "params/MemTest.hh" 421400SN/A#include "sim/eventq.hh" 431400SN/A#include "sim/sim_exit.hh" 441298SN/A#include "sim/sim_object.hh" 45695SN/A#include "sim/stats.hh" 462SN/A 473187SN/Aclass Packet; 483187SN/Aclass MemTest : public MemObject 492SN/A{ 502SN/A public: 515034SN/A typedef MemTestParams Params; 525034SN/A MemTest(const Params *p); 532SN/A 543187SN/A virtual void init(); 553187SN/A 562SN/A // register statistics 572SN/A virtual void regStats(); 581634SN/A 592SN/A // main simulation loop (one cycle) 602SN/A void tick(); 612SN/A 629294Sandreas.hansson@arm.com virtual BaseMasterPort &getMasterPort(const std::string &if_name, 639294Sandreas.hansson@arm.com PortID idx = InvalidPortID); 643187SN/A 655315SN/A /** 665315SN/A * Print state of address in memory system via PrintReq (for 675315SN/A * debugging). 685315SN/A */ 695314SN/A void printAddr(Addr a); 705314SN/A 712SN/A protected: 722SN/A class TickEvent : public Event 732SN/A { 742SN/A private: 752SN/A MemTest *cpu; 765606SN/A 772SN/A public: 785606SN/A TickEvent(MemTest *c) : Event(CPU_Tick_Pri), cpu(c) {} 795606SN/A void process() { cpu->tick(); } 805336SN/A virtual const char *description() const { return "MemTest tick"; } 812SN/A }; 822SN/A 832SN/A TickEvent tickEvent; 844474SN/A 858922Swilliam.wang@arm.com class CpuPort : public MasterPort 863187SN/A { 873187SN/A MemTest *memtest; 883187SN/A 893187SN/A public: 903187SN/A 913187SN/A CpuPort(const std::string &_name, MemTest *_memtest) 928922Swilliam.wang@arm.com : MasterPort(_name, _memtest), memtest(_memtest) 933187SN/A { } 943187SN/A 953187SN/A protected: 963187SN/A 978975Sandreas.hansson@arm.com virtual bool recvTimingResp(PacketPtr pkt); 983187SN/A 998975Sandreas.hansson@arm.com virtual void recvTimingSnoopReq(PacketPtr pkt) { } 1003187SN/A 1018948Sandreas.hansson@arm.com virtual Tick recvAtomicSnoop(PacketPtr pkt) { return 0; } 1028948Sandreas.hansson@arm.com 1038948Sandreas.hansson@arm.com virtual void recvFunctionalSnoop(PacketPtr pkt) { } 1043187SN/A 1053187SN/A virtual void recvRetry(); 1063187SN/A }; 1073187SN/A 1083187SN/A CpuPort cachePort; 1093187SN/A CpuPort funcPort; 1108853Sandreas.hansson@arm.com PortProxy funcProxy; 1113187SN/A 1129044SAli.Saidi@ARM.com class MemTestSenderState : public Packet::SenderState 1133187SN/A { 1143187SN/A public: 1153187SN/A /** Constructor. */ 1163187SN/A MemTestSenderState(uint8_t *_data) 1173187SN/A : data(_data) 1183187SN/A { } 1193187SN/A 1203187SN/A // Hold onto data pointer 1213187SN/A uint8_t *data; 1223187SN/A }; 1233187SN/A 1243349SN/A PacketPtr retryPkt; 1253187SN/A 1263187SN/A bool accessRetry; 1277544SN/A 1287544SN/A // 1297544SN/A // The dmaOustanding flag enforces only one dma at a time 1307544SN/A // 1317544SN/A bool dmaOutstanding; 1322SN/A 1335543SN/A unsigned size; // size of testing memory region 1342SN/A 1355543SN/A unsigned percentReads; // target percentage of read accesses 1365543SN/A unsigned percentFunctional; // target percentage of functional accesses 1372SN/A unsigned percentUncacheable; 1382SN/A 1397544SN/A bool issueDmas; 1407544SN/A 1418832SAli.Saidi@ARM.com /** Request id for all generated traffic */ 1428832SAli.Saidi@ARM.com MasterID masterId; 1438832SAli.Saidi@ARM.com 1441298SN/A int id; 1451298SN/A 1461298SN/A std::set<unsigned> outstandingAddrs; 1471298SN/A 1482SN/A unsigned blockSize; 1492SN/A 1502SN/A Addr blockAddrMask; 1512SN/A 1522SN/A Addr blockAddr(Addr addr) 1532SN/A { 1542SN/A return (addr & ~blockAddrMask); 1552SN/A } 1562SN/A 1572SN/A Addr traceBlockAddr; 1582SN/A 1595543SN/A Addr baseAddr1; // fix this to option 1605543SN/A Addr baseAddr2; // fix this to option 1612SN/A Addr uncacheAddr; 1622SN/A 1635543SN/A unsigned progressInterval; // frequency of progress reports 1645543SN/A Tick nextProgressMessage; // access # for next progress report 1652SN/A 166548SN/A unsigned percentSourceUnaligned; 167548SN/A unsigned percentDestUnaligned; 168548SN/A 1692SN/A Tick noResponseCycles; 1702SN/A 171695SN/A uint64_t numReads; 1728436SBrad.Beckmann@amd.com uint64_t numWrites; 1731400SN/A uint64_t maxLoads; 1743262SN/A 1753262SN/A bool atomic; 1768436SBrad.Beckmann@amd.com bool suppress_func_warnings; 1773262SN/A 1785999SN/A Stats::Scalar numReadsStat; 1795999SN/A Stats::Scalar numWritesStat; 1805999SN/A Stats::Scalar numCopiesStat; 1812SN/A 1822SN/A // called by MemCompleteEvent::process() 1833349SN/A void completeRequest(PacketPtr pkt); 1843187SN/A 1853349SN/A void sendPkt(PacketPtr pkt); 1863262SN/A 1873187SN/A void doRetry(); 1882SN/A 1892SN/A friend class MemCompleteEvent; 1902SN/A}; 1912SN/A 1921400SN/A#endif // __CPU_MEMTEST_MEMTEST_HH__ 1932SN/A 1942SN/A 1952SN/A 196