RubyDirectedTester.hh revision 8922
111106Spower.jg@gmail.com/*
211106Spower.jg@gmail.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
311680SCurtis.Dunham@arm.com * Copyright (c) 2009-2010 Advanced Micro Devices, Inc.
411680SCurtis.Dunham@arm.com * All rights reserved.
511680SCurtis.Dunham@arm.com *
611106Spower.jg@gmail.com * Redistribution and use in source and binary forms, with or without
711687Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
811687Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
911687Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
1011687Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
1111680SCurtis.Dunham@arm.com * notice, this list of conditions and the following disclaimer in the
1211390Ssteve.reinhardt@amd.com * documentation and/or other materials provided with the distribution;
1311390Ssteve.reinhardt@amd.com * neither the name of the copyright holders nor the names of its
1411106Spower.jg@gmail.com * contributors may be used to endorse or promote products derived from
1511106Spower.jg@gmail.com * this software without specific prior written permission.
1611680SCurtis.Dunham@arm.com *
1711106Spower.jg@gmail.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1811106Spower.jg@gmail.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1911106Spower.jg@gmail.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2011106Spower.jg@gmail.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2111106Spower.jg@gmail.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2211106Spower.jg@gmail.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2311106Spower.jg@gmail.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2411106Spower.jg@gmail.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2511680SCurtis.Dunham@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2611680SCurtis.Dunham@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2711680SCurtis.Dunham@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2811680SCurtis.Dunham@arm.com */
2911680SCurtis.Dunham@arm.com
3011680SCurtis.Dunham@arm.com#ifndef __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
3111680SCurtis.Dunham@arm.com#define __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
3211680SCurtis.Dunham@arm.com
3311106Spower.jg@gmail.com#include <iostream>
3411106Spower.jg@gmail.com#include <string>
3511106Spower.jg@gmail.com#include <vector>
3611106Spower.jg@gmail.com
3711106Spower.jg@gmail.com#include "mem/ruby/common/DataBlock.hh"
3811106Spower.jg@gmail.com#include "mem/ruby/common/Global.hh"
3911106Spower.jg@gmail.com#include "mem/ruby/common/SubBlock.hh"
4011106Spower.jg@gmail.com#include "mem/ruby/system/RubyPort.hh"
4111106Spower.jg@gmail.com#include "mem/mem_object.hh"
4211106Spower.jg@gmail.com#include "mem/packet.hh"
4311106Spower.jg@gmail.com#include "params/RubyDirectedTester.hh"
4411106Spower.jg@gmail.com
4511106Spower.jg@gmail.comclass DirectedGenerator;
4611106Spower.jg@gmail.com
4711106Spower.jg@gmail.comclass RubyDirectedTester : public MemObject
4811106Spower.jg@gmail.com{
4911106Spower.jg@gmail.com  public:
5011106Spower.jg@gmail.com    class CpuPort : public MasterPort
5111106Spower.jg@gmail.com    {
5211106Spower.jg@gmail.com      private:
5311106Spower.jg@gmail.com        RubyDirectedTester *tester;
5411106Spower.jg@gmail.com
5511106Spower.jg@gmail.com      public:
5611106Spower.jg@gmail.com        CpuPort(const std::string &_name, RubyDirectedTester *_tester,
5711106Spower.jg@gmail.com                uint32_t _idx)
5811106Spower.jg@gmail.com            : MasterPort(_name, _tester), tester(_tester), idx(_idx)
5911106Spower.jg@gmail.com        {}
6011106Spower.jg@gmail.com
6111106Spower.jg@gmail.com        uint32_t idx;
6211106Spower.jg@gmail.com
6311106Spower.jg@gmail.com      protected:
6411106Spower.jg@gmail.com        virtual bool recvTiming(PacketPtr pkt);
6511106Spower.jg@gmail.com        virtual void recvRetry()
6611106Spower.jg@gmail.com        { panic("%s does not expect a retry\n", name()); }
6711106Spower.jg@gmail.com        virtual Tick recvAtomic(PacketPtr pkt);
6811106Spower.jg@gmail.com        virtual void recvFunctional(PacketPtr pkt) { }
6911106Spower.jg@gmail.com    };
7011106Spower.jg@gmail.com
7111106Spower.jg@gmail.com    typedef RubyDirectedTesterParams Params;
7211106Spower.jg@gmail.com    RubyDirectedTester(const Params *p);
7311106Spower.jg@gmail.com    ~RubyDirectedTester();
7411106Spower.jg@gmail.com
7511106Spower.jg@gmail.com    virtual MasterPort &getMasterPort(const std::string &if_name,
7611106Spower.jg@gmail.com                                      int idx = -1);
7711106Spower.jg@gmail.com
7811106Spower.jg@gmail.com    MasterPort* getCpuPort(int idx);
7911680SCurtis.Dunham@arm.com
8011106Spower.jg@gmail.com    virtual void init();
8111106Spower.jg@gmail.com
8211106Spower.jg@gmail.com    void wakeup();
8311106Spower.jg@gmail.com
8411106Spower.jg@gmail.com    void incrementCycleCompletions() { m_requests_completed++; }
8511106Spower.jg@gmail.com
8611106Spower.jg@gmail.com    void printStats(std::ostream& out) const {}
8711106Spower.jg@gmail.com    void clearStats() {}
8811106Spower.jg@gmail.com    void printConfig(std::ostream& out) const {}
8911106Spower.jg@gmail.com
9011106Spower.jg@gmail.com    void print(std::ostream& out) const;
9111106Spower.jg@gmail.com
9211106Spower.jg@gmail.com  protected:
9311106Spower.jg@gmail.com    class DirectedStartEvent : public Event
9411106Spower.jg@gmail.com    {
9511106Spower.jg@gmail.com      private:
9611106Spower.jg@gmail.com        RubyDirectedTester *tester;
9711106Spower.jg@gmail.com
9811106Spower.jg@gmail.com      public:
9911106Spower.jg@gmail.com        DirectedStartEvent(RubyDirectedTester *_tester)
10011106Spower.jg@gmail.com            : Event(CPU_Tick_Pri), tester(_tester)
10111106Spower.jg@gmail.com        {}
10211106Spower.jg@gmail.com        void process() { tester->wakeup(); }
10311106Spower.jg@gmail.com        virtual const char *description() const { return "Directed tick"; }
10411106Spower.jg@gmail.com    };
10511106Spower.jg@gmail.com
10611106Spower.jg@gmail.com    DirectedStartEvent directedStartEvent;
10711106Spower.jg@gmail.com
10811106Spower.jg@gmail.com  private:
10911106Spower.jg@gmail.com    void hitCallback(NodeID proc, Addr addr);
11011106Spower.jg@gmail.com
11111106Spower.jg@gmail.com    void checkForDeadlock();
11211106Spower.jg@gmail.com
11311106Spower.jg@gmail.com    // Private copy constructor and assignment operator
11411106Spower.jg@gmail.com    RubyDirectedTester(const RubyDirectedTester& obj);
11511106Spower.jg@gmail.com    RubyDirectedTester& operator=(const RubyDirectedTester& obj);
11611106Spower.jg@gmail.com
11711106Spower.jg@gmail.com    uint64 m_requests_completed;
11811106Spower.jg@gmail.com    std::vector<CpuPort*> ports;
11911106Spower.jg@gmail.com    uint64 m_requests_to_complete;
12011106Spower.jg@gmail.com    DirectedGenerator* generator;
12111106Spower.jg@gmail.com};
12211106Spower.jg@gmail.com
12311106Spower.jg@gmail.com#endif // __CPU_DIRECTEDTEST_RUBYDIRECTEDTESTER_HH__
12411106Spower.jg@gmail.com