RubyDirectedTester.hh revision 9031
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,
579031Sandreas.hansson@arm.com                PortID _id)
588965Sandreas.hansson@arm.com            : MasterPort(_name, _tester, _id), tester(_tester)
597053SN/A        {}
606899SN/A
617053SN/A      protected:
628975Sandreas.hansson@arm.com        virtual bool recvTimingResp(PacketPtr pkt);
638922Swilliam.wang@arm.com        virtual void recvRetry()
648922Swilliam.wang@arm.com        { panic("%s does not expect a retry\n", name()); }
657053SN/A    };
666899SN/A
677553SN/A    typedef RubyDirectedTesterParams Params;
687553SN/A    RubyDirectedTester(const Params *p);
697553SN/A    ~RubyDirectedTester();
706899SN/A
718922Swilliam.wang@arm.com    virtual MasterPort &getMasterPort(const std::string &if_name,
728922Swilliam.wang@arm.com                                      int idx = -1);
736899SN/A
748922Swilliam.wang@arm.com    MasterPort* getCpuPort(int idx);
756899SN/A
767053SN/A    virtual void init();
776899SN/A
787053SN/A    void wakeup();
796899SN/A
807553SN/A    void incrementCycleCompletions() { m_requests_completed++; }
816899SN/A
827055SN/A    void printStats(std::ostream& out) const {}
837053SN/A    void clearStats() {}
847055SN/A    void printConfig(std::ostream& out) const {}
856899SN/A
867055SN/A    void print(std::ostream& out) const;
876899SN/A
887053SN/A  protected:
897553SN/A    class DirectedStartEvent : public Event
907053SN/A    {
917053SN/A      private:
927553SN/A        RubyDirectedTester *tester;
936899SN/A
947053SN/A      public:
957553SN/A        DirectedStartEvent(RubyDirectedTester *_tester)
967053SN/A            : Event(CPU_Tick_Pri), tester(_tester)
977053SN/A        {}
987053SN/A        void process() { tester->wakeup(); }
997553SN/A        virtual const char *description() const { return "Directed tick"; }
1007053SN/A    };
1017053SN/A
1027553SN/A    DirectedStartEvent directedStartEvent;
1037053SN/A
1046899SN/A  private:
1057553SN/A    void hitCallback(NodeID proc, Addr addr);
1066899SN/A
1077053SN/A    void checkForDeadlock();
1086899SN/A
1097053SN/A    // Private copy constructor and assignment operator
1107553SN/A    RubyDirectedTester(const RubyDirectedTester& obj);
1117553SN/A    RubyDirectedTester& operator=(const RubyDirectedTester& obj);
1126899SN/A
1137553SN/A    uint64 m_requests_completed;
1148950Sandreas.hansson@arm.com    std::vector<MasterPort*> ports;
1157553SN/A    uint64 m_requests_to_complete;
1167553SN/A    DirectedGenerator* generator;
1176899SN/A};
1186899SN/A
1197553SN/A#endif // __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
120