RubyTester.hh revision 7454
16899SN/A/* 26899SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36899SN/A * Copyright (c) 2009 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 307805Snilay@cs.wisc.edu#ifndef __CPU_RUBYTEST_RUBYTESTER_HH__ 317632SBrad.Beckmann@amd.com#define __CPU_RUBYTEST_RUBYTESTER_HH__ 327632SBrad.Beckmann@amd.com 338232Snate@binkert.org#include <iostream> 346899SN/A#include <vector> 357053SN/A#include <string> 367053SN/A 376899SN/A#include "cpu/rubytest/CheckTable.hh" 386899SN/A#include "mem/mem_object.hh" 396899SN/A#include "mem/packet.hh" 406899SN/A#include "mem/ruby/common/DataBlock.hh" 417053SN/A#include "mem/ruby/common/Global.hh" 426899SN/A#include "mem/ruby/common/SubBlock.hh" 436899SN/A#include "mem/ruby/system/RubyPort.hh" 448184Ssomayeh@cs.wisc.edu#include "params/RubyTester.hh" 458184Ssomayeh@cs.wisc.edu 466899SN/Aclass RubyTester : public MemObject 477053SN/A{ 486899SN/A public: 497053SN/A class CpuPort : public SimpleTimingPort 507053SN/A { 516899SN/A private: 526899SN/A RubyTester *tester; 536899SN/A 546899SN/A public: 557053SN/A CpuPort(const std::string &_name, RubyTester *_tester, int _idx) 567053SN/A : SimpleTimingPort(_name, _tester), tester(_tester), idx(_idx) 577053SN/A {} 586899SN/A 596899SN/A int idx; 607053SN/A 617053SN/A protected: 626899SN/A virtual bool recvTiming(PacketPtr pkt); 637053SN/A virtual Tick recvAtomic(PacketPtr pkt); 646899SN/A }; 657454SN/A 667053SN/A struct SenderState : public Packet::SenderState 677053SN/A { 687053SN/A SubBlock* subBlock; 696899SN/A Packet::SenderState *saved; 707053SN/A 716899SN/A SenderState(Address addr, int size, 727053SN/A Packet::SenderState *sender_state = NULL) 736899SN/A : saved(sender_state) 746899SN/A { 756899SN/A subBlock = new SubBlock(addr, size); 766899SN/A } 776899SN/A 786899SN/A ~SenderState() 796899SN/A { 806899SN/A delete subBlock; 816899SN/A } 826899SN/A }; 836899SN/A 846899SN/A typedef RubyTesterParams Params; 856899SN/A RubyTester(const Params *p); 866899SN/A ~RubyTester(); 876899SN/A 886899SN/A virtual Port *getPort(const std::string &if_name, int idx = -1); 896899SN/A 906899SN/A Port* getCpuPort(int idx); 916899SN/A 926899SN/A virtual void init(); 936899SN/A 946899SN/A void wakeup(); 956899SN/A 966899SN/A void incrementCheckCompletions() { m_checks_completed++; } 976899SN/A 986899SN/A void printStats(std::ostream& out) const {} 997053SN/A void clearStats() {} 1007053SN/A void printConfig(std::ostream& out) const {} 1016899SN/A 1026899SN/A void print(std::ostream& out) const; 1036899SN/A 1046899SN/A protected: 1056899SN/A class CheckStartEvent : public Event 1067053SN/A { 1077053SN/A private: 1087053SN/A RubyTester *tester; 1097053SN/A 1107053SN/A public: 1116899SN/A CheckStartEvent(RubyTester *_tester) 1127053SN/A : Event(CPU_Tick_Pri), tester(_tester) 1137053SN/A {} 1146899SN/A void process() { tester->wakeup(); } 1157053SN/A virtual const char *description() const { return "RubyTester tick"; } 1167053SN/A }; 1177053SN/A 1187053SN/A CheckStartEvent checkStartEvent; 1197053SN/A 1207053SN/A private: 1217053SN/A void hitCallback(NodeID proc, SubBlock* data); 1227053SN/A 1236899SN/A void checkForDeadlock(); 1246899SN/A 1257053SN/A // Private copy constructor and assignment operator 1266899SN/A RubyTester(const RubyTester& obj); 1276899SN/A RubyTester& operator=(const RubyTester& obj); 1287053SN/A 1296899SN/A CheckTable* m_checkTable_ptr; 1307053SN/A std::vector<Time> m_last_progress_vector; 1316899SN/A 1326899SN/A uint64 m_checks_completed; 1337053SN/A std::vector<CpuPort*> ports; 1347053SN/A uint64 m_checks_to_complete; 1356899SN/A int m_deadlock_threshold; 1367053SN/A int m_num_cpu_sequencers; 1377053SN/A int m_wakeup_frequency; 1386899SN/A}; 1397053SN/A 1407053SN/Ainline std::ostream& 1417053SN/Aoperator<<(std::ostream& out, const RubyTester& obj) 1427053SN/A{ 1437053SN/A obj.print(out); 1447053SN/A out << std::flush; 1457053SN/A return out; 1466899SN/A} 1477053SN/A 1487053SN/A#endif // __CPU_RUBYTEST_RUBYTESTER_HH__ 1497053SN/A