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
3713892Sgabeblack@google.com#include "mem/packet.hh"
3813892Sgabeblack@google.com#include "mem/port.hh"
397053SN/A#include "mem/ruby/common/DataBlock.hh"
407053SN/A#include "mem/ruby/common/SubBlock.hh"
4111017Snilay@cs.wisc.edu#include "mem/ruby/common/TypeDefines.hh"
427553SN/A#include "params/RubyDirectedTester.hh"
4313892Sgabeblack@google.com#include "sim/clocked_object.hh"
446899SN/A
457553SN/Aclass DirectedGenerator;
467553SN/A
4713892Sgabeblack@google.comclass RubyDirectedTester : public ClockedObject
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);
6310713Sandreas.hansson@arm.com        virtual void recvReqRetry()
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
7113784Sgabeblack@google.com    Port &getPort(const std::string &if_name,
7213784Sgabeblack@google.com                  PortID idx=InvalidPortID) override;
736899SN/A
748922Swilliam.wang@arm.com    MasterPort* getCpuPort(int idx);
756899SN/A
7613799SAndrea.Mondelli@ucf.edu    void init() override;
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:
8912129Sspwilson2@wisc.edu    EventFunctionWrapper directedStartEvent;
907053SN/A
916899SN/A  private:
927553SN/A    void hitCallback(NodeID proc, Addr addr);
936899SN/A
947053SN/A    void checkForDeadlock();
956899SN/A
967053SN/A    // Private copy constructor and assignment operator
977553SN/A    RubyDirectedTester(const RubyDirectedTester& obj);
987553SN/A    RubyDirectedTester& operator=(const RubyDirectedTester& obj);
996899SN/A
10011061Snilay@cs.wisc.edu    uint64_t m_requests_completed;
1018950Sandreas.hansson@arm.com    std::vector<MasterPort*> ports;
10211061Snilay@cs.wisc.edu    uint64_t m_requests_to_complete;
1037553SN/A    DirectedGenerator* generator;
1046899SN/A};
1056899SN/A
1067553SN/A#endif // __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
107