RubyDirectedTester.hh revision 8229
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:
507053SN/A    class CpuPort : public SimpleTimingPort
517053SN/A    {
527053SN/A      private:
537553SN/A        RubyDirectedTester *tester;
546899SN/A
557053SN/A      public:
567553SN/A        CpuPort(const std::string &_name, RubyDirectedTester *_tester, uint _idx)
577053SN/A            : SimpleTimingPort(_name, _tester), tester(_tester), idx(_idx)
587053SN/A        {}
596899SN/A
607553SN/A        uint idx;
616899SN/A
627053SN/A      protected:
637053SN/A        virtual bool recvTiming(PacketPtr pkt);
647053SN/A        virtual Tick recvAtomic(PacketPtr pkt);
657053SN/A    };
666899SN/A
677553SN/A    typedef RubyDirectedTesterParams Params;
687553SN/A    RubyDirectedTester(const Params *p);
697553SN/A    ~RubyDirectedTester();
706899SN/A
717053SN/A    virtual Port *getPort(const std::string &if_name, int idx = -1);
726899SN/A
737053SN/A    Port* getCpuPort(int idx);
746899SN/A
757053SN/A    virtual void init();
766899SN/A
777053SN/A    void wakeup();
786899SN/A
797553SN/A    void incrementCycleCompletions() { m_requests_completed++; }
806899SN/A
817055SN/A    void printStats(std::ostream& out) const {}
827053SN/A    void clearStats() {}
837055SN/A    void printConfig(std::ostream& out) const {}
846899SN/A
857055SN/A    void print(std::ostream& out) const;
866899SN/A
877053SN/A  protected:
887553SN/A    class DirectedStartEvent : public Event
897053SN/A    {
907053SN/A      private:
917553SN/A        RubyDirectedTester *tester;
926899SN/A
937053SN/A      public:
947553SN/A        DirectedStartEvent(RubyDirectedTester *_tester)
957053SN/A            : Event(CPU_Tick_Pri), tester(_tester)
967053SN/A        {}
977053SN/A        void process() { tester->wakeup(); }
987553SN/A        virtual const char *description() const { return "Directed tick"; }
997053SN/A    };
1007053SN/A
1017553SN/A    DirectedStartEvent directedStartEvent;
1027053SN/A
1036899SN/A  private:
1047553SN/A    void hitCallback(NodeID proc, Addr addr);
1056899SN/A
1067053SN/A    void checkForDeadlock();
1076899SN/A
1087053SN/A    // Private copy constructor and assignment operator
1097553SN/A    RubyDirectedTester(const RubyDirectedTester& obj);
1107553SN/A    RubyDirectedTester& operator=(const RubyDirectedTester& obj);
1116899SN/A
1127553SN/A    uint64 m_requests_completed;
1137053SN/A    std::vector<CpuPort*> ports;
1147553SN/A    uint64 m_requests_to_complete;
1157553SN/A    DirectedGenerator* generator;
1166899SN/A};
1176899SN/A
1187553SN/A#endif // __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
119