RubyDirectedTester.hh revision 8950
16899SN/A/* 26899SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 37553SN/A * Copyright (c) 2009-2010 Advanced Micro Devices, Inc. 46899SN/A * All rights reserved. 56899SN/A * 66899SN/A * Redistribution and use in source and binary forms, with or without 76899SN/A * modification, are permitted provided that the following conditions are 86899SN/A * met: redistributions of source code must retain the above copyright 96899SN/A * notice, this list of conditions and the following disclaimer; 106899SN/A * redistributions in binary form must reproduce the above copyright 116899SN/A * notice, this list of conditions and the following disclaimer in the 126899SN/A * documentation and/or other materials provided with the distribution; 136899SN/A * neither the name of the copyright holders nor the names of its 146899SN/A * contributors may be used to endorse or promote products derived from 156899SN/A * this software without specific prior written permission. 166899SN/A * 176899SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186899SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196899SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206899SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216899SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226899SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236899SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246899SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256899SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266899SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276899SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286899SN/A */ 296899SN/A 307553SN/A#ifndef __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__ 317553SN/A#define __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__ 326899SN/A 337055SN/A#include <iostream> 348229Snate@binkert.org#include <string> 357454SN/A#include <vector> 367055SN/A 377053SN/A#include "mem/ruby/common/DataBlock.hh" 386899SN/A#include "mem/ruby/common/Global.hh" 397053SN/A#include "mem/ruby/common/SubBlock.hh" 406899SN/A#include "mem/ruby/system/RubyPort.hh" 418229Snate@binkert.org#include "mem/mem_object.hh" 428229Snate@binkert.org#include "mem/packet.hh" 437553SN/A#include "params/RubyDirectedTester.hh" 446899SN/A 457553SN/Aclass DirectedGenerator; 467553SN/A 477553SN/Aclass RubyDirectedTester : public MemObject 486899SN/A{ 497053SN/A public: 508922Swilliam.wang@arm.com class CpuPort : public MasterPort 517053SN/A { 527053SN/A private: 537553SN/A RubyDirectedTester *tester; 546899SN/A 557053SN/A public: 568854Sandreas.hansson@arm.com CpuPort(const std::string &_name, RubyDirectedTester *_tester, 578854Sandreas.hansson@arm.com uint32_t _idx) 588922Swilliam.wang@arm.com : MasterPort(_name, _tester), tester(_tester), idx(_idx) 597053SN/A {} 606899SN/A 618655Sandreas.hansson@arm.com uint32_t idx; 626899SN/A 637053SN/A protected: 647053SN/A virtual bool recvTiming(PacketPtr pkt); 658922Swilliam.wang@arm.com virtual void recvRetry() 668922Swilliam.wang@arm.com { panic("%s does not expect a retry\n", name()); } 677053SN/A }; 686899SN/A 697553SN/A typedef RubyDirectedTesterParams Params; 707553SN/A RubyDirectedTester(const Params *p); 717553SN/A ~RubyDirectedTester(); 726899SN/A 738922Swilliam.wang@arm.com virtual MasterPort &getMasterPort(const std::string &if_name, 748922Swilliam.wang@arm.com int idx = -1); 756899SN/A 768922Swilliam.wang@arm.com MasterPort* getCpuPort(int idx); 776899SN/A 787053SN/A virtual void init(); 796899SN/A 807053SN/A void wakeup(); 816899SN/A 827553SN/A void incrementCycleCompletions() { m_requests_completed++; } 836899SN/A 847055SN/A void printStats(std::ostream& out) const {} 857053SN/A void clearStats() {} 867055SN/A void printConfig(std::ostream& out) const {} 876899SN/A 887055SN/A void print(std::ostream& out) const; 896899SN/A 907053SN/A protected: 917553SN/A class DirectedStartEvent : public Event 927053SN/A { 937053SN/A private: 947553SN/A RubyDirectedTester *tester; 956899SN/A 967053SN/A public: 977553SN/A DirectedStartEvent(RubyDirectedTester *_tester) 987053SN/A : Event(CPU_Tick_Pri), tester(_tester) 997053SN/A {} 1007053SN/A void process() { tester->wakeup(); } 1017553SN/A virtual const char *description() const { return "Directed tick"; } 1027053SN/A }; 1037053SN/A 1047553SN/A DirectedStartEvent directedStartEvent; 1057053SN/A 1066899SN/A private: 1077553SN/A void hitCallback(NodeID proc, Addr addr); 1086899SN/A 1097053SN/A void checkForDeadlock(); 1106899SN/A 1117053SN/A // Private copy constructor and assignment operator 1127553SN/A RubyDirectedTester(const RubyDirectedTester& obj); 1137553SN/A RubyDirectedTester& operator=(const RubyDirectedTester& obj); 1146899SN/A 1157553SN/A uint64 m_requests_completed; 1168950Sandreas.hansson@arm.com std::vector<MasterPort*> ports; 1177553SN/A uint64 m_requests_to_complete; 1187553SN/A DirectedGenerator* generator; 1196899SN/A}; 1206899SN/A 1217553SN/A#endif // __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__ 122