RubyDirectedTester.hh revision 8975
16657Snate@binkert.org/*
26657Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
310972Sdavid.hashe@amd.com * Copyright (c) 2009-2010 Advanced Micro Devices, Inc.
46657Snate@binkert.org * All rights reserved.
56657Snate@binkert.org *
66657Snate@binkert.org * Redistribution and use in source and binary forms, with or without
76657Snate@binkert.org * modification, are permitted provided that the following conditions are
86657Snate@binkert.org * met: redistributions of source code must retain the above copyright
96657Snate@binkert.org * notice, this list of conditions and the following disclaimer;
106657Snate@binkert.org * redistributions in binary form must reproduce the above copyright
116657Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
126657Snate@binkert.org * documentation and/or other materials provided with the distribution;
136657Snate@binkert.org * neither the name of the copyright holders nor the names of its
146657Snate@binkert.org * contributors may be used to endorse or promote products derived from
156657Snate@binkert.org * this software without specific prior written permission.
166657Snate@binkert.org *
176657Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186657Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196657Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206657Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216657Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226657Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236657Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246657Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256657Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266657Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276657Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286657Snate@binkert.org */
2913672Sandreas.sandberg@arm.com
306657Snate@binkert.org#ifndef __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
316657Snate@binkert.org#define __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
326657Snate@binkert.org
336657Snate@binkert.org#include <iostream>
348189SLisa.Hsu@amd.com#include <string>
356657Snate@binkert.org#include <vector>
369499Snilay@cs.wisc.edu
379499Snilay@cs.wisc.edu#include "mem/ruby/common/DataBlock.hh"
3811308Santhony.gutierrez@amd.com#include "mem/ruby/common/Global.hh"
399364Snilay@cs.wisc.edu#include "mem/ruby/common/SubBlock.hh"
407055Snate@binkert.org#include "mem/ruby/system/RubyPort.hh"
416882SBrad.Beckmann@amd.com#include "mem/mem_object.hh"
426882SBrad.Beckmann@amd.com#include "mem/packet.hh"
438191SLisa.Hsu@amd.com#include "params/RubyDirectedTester.hh"
446882SBrad.Beckmann@amd.com
4511308Santhony.gutierrez@amd.comclass DirectedGenerator;
4611308Santhony.gutierrez@amd.com
476882SBrad.Beckmann@amd.comclass RubyDirectedTester : public MemObject
4811308Santhony.gutierrez@amd.com{
499102SNuwan.Jayasena@amd.com  public:
5011084Snilay@cs.wisc.edu    class CpuPort : public MasterPort
519366Snilay@cs.wisc.edu    {
529499Snilay@cs.wisc.edu      private:
539499Snilay@cs.wisc.edu        RubyDirectedTester *tester;
549499Snilay@cs.wisc.edu
556882SBrad.Beckmann@amd.com      public:
566657Snate@binkert.org        CpuPort(const std::string &_name, RubyDirectedTester *_tester,
576657Snate@binkert.org                Port::PortId _id)
586657Snate@binkert.org            : MasterPort(_name, _tester, _id), tester(_tester)
596657Snate@binkert.org        {}
6010311Snilay@cs.wisc.edu
6110311Snilay@cs.wisc.edu      protected:
6210311Snilay@cs.wisc.edu        virtual bool recvTimingResp(PacketPtr pkt);
6310311Snilay@cs.wisc.edu        virtual void recvRetry()
646657Snate@binkert.org        { panic("%s does not expect a retry\n", name()); }
6510311Snilay@cs.wisc.edu    };
669366Snilay@cs.wisc.edu
677839Snilay@cs.wisc.edu    typedef RubyDirectedTesterParams Params;
686657Snate@binkert.org    RubyDirectedTester(const Params *p);
696882SBrad.Beckmann@amd.com    ~RubyDirectedTester();
7010308Snilay@cs.wisc.edu
7110308Snilay@cs.wisc.edu    virtual MasterPort &getMasterPort(const std::string &if_name,
726882SBrad.Beckmann@amd.com                                      int idx = -1);
7310308Snilay@cs.wisc.edu
7410308Snilay@cs.wisc.edu    MasterPort* getCpuPort(int idx);
7510308Snilay@cs.wisc.edu
7610308Snilay@cs.wisc.edu    virtual void init();
7710308Snilay@cs.wisc.edu
789366Snilay@cs.wisc.edu    void wakeup();
799366Snilay@cs.wisc.edu
806657Snate@binkert.org    void incrementCycleCompletions() { m_requests_completed++; }
8113672Sandreas.sandberg@arm.com
8213672Sandreas.sandberg@arm.com    void printStats(std::ostream& out) const {}
8313672Sandreas.sandberg@arm.com    void clearStats() {}
8413672Sandreas.sandberg@arm.com    void printConfig(std::ostream& out) const {}
856657Snate@binkert.org
866657Snate@binkert.org    void print(std::ostream& out) const;
876657Snate@binkert.org
8810311Snilay@cs.wisc.edu  protected:
8910311Snilay@cs.wisc.edu    class DirectedStartEvent : public Event
9010311Snilay@cs.wisc.edu    {
9110311Snilay@cs.wisc.edu      private:
926657Snate@binkert.org        RubyDirectedTester *tester;
937839Snilay@cs.wisc.edu
947839Snilay@cs.wisc.edu      public:
9510972Sdavid.hashe@amd.com        DirectedStartEvent(RubyDirectedTester *_tester)
9610972Sdavid.hashe@amd.com            : Event(CPU_Tick_Pri), tester(_tester)
9710972Sdavid.hashe@amd.com        {}
986657Snate@binkert.org        void process() { tester->wakeup(); }
996657Snate@binkert.org        virtual const char *description() const { return "Directed tick"; }
1006657Snate@binkert.org    };
1016657Snate@binkert.org
1026657Snate@binkert.org    DirectedStartEvent directedStartEvent;
1036657Snate@binkert.org
1046657Snate@binkert.org  private:
1056657Snate@binkert.org    void hitCallback(NodeID proc, Addr addr);
1066657Snate@binkert.org
1076657Snate@binkert.org    void checkForDeadlock();
1086657Snate@binkert.org
1096657Snate@binkert.org    // Private copy constructor and assignment operator
1106657Snate@binkert.org    RubyDirectedTester(const RubyDirectedTester& obj);
1116657Snate@binkert.org    RubyDirectedTester& operator=(const RubyDirectedTester& obj);
1126657Snate@binkert.org
1136657Snate@binkert.org    uint64 m_requests_completed;
1146657Snate@binkert.org    std::vector<MasterPort*> ports;
1156657Snate@binkert.org    uint64 m_requests_to_complete;
1166779SBrad.Beckmann@amd.com    DirectedGenerator* generator;
1176657Snate@binkert.org};
1186657Snate@binkert.org
1196657Snate@binkert.org#endif // __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
1206657Snate@binkert.org