TimerTable.hh revision 7455
16112SN/A/*
26112SN/A * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36112SN/A * All rights reserved.
49988Snilay@cs.wisc.edu *
58835SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without
69988Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are
77935SN/A * met: redistributions of source code must retain the above copyright
87935SN/A * notice, this list of conditions and the following disclaimer;
97935SN/A * redistributions in binary form must reproduce the above copyright
106112SN/A * notice, this list of conditions and the following disclaimer in the
116112SN/A * documentation and/or other materials provided with the distribution;
126112SN/A * neither the name of the copyright holders nor the names of its
1310315Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from
148835SAli.Saidi@ARM.com * this software without specific prior written permission.
159885Sstever@gmail.com *
169885Sstever@gmail.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1711570SCurtis.Dunham@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
189988Snilay@cs.wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1911312Santhony.gutierrez@amd.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
208835SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
218835SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2210315Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
238835SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2410063Snilay@cs.wisc.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256112SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
269481Snilay@cs.wisc.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278721SN/A */
2810736Snilay@cs.wisc.edu
2911219Snilay@cs.wisc.edu#ifndef __MEM_RUBY_SYSTEM_TIMERTABLE_HH__
308721SN/A#define __MEM_RUBY_SYSTEM_TIMERTABLE_HH__
3111570SCurtis.Dunham@arm.com
3211570SCurtis.Dunham@arm.com#include <cassert>
3311570SCurtis.Dunham@arm.com#include <iostream>
3411570SCurtis.Dunham@arm.com#include <string>
358835SAli.Saidi@ARM.com
368835SAli.Saidi@ARM.com#include "base/hashmap.hh"
3711440SCurtis.Dunham@arm.com#include "mem/ruby/common/Address.hh"
3811440SCurtis.Dunham@arm.com#include "mem/ruby/common/Global.hh"
397935SN/A
407935SN/Aclass Consumer;
417935SN/A
427935SN/Aclass TimerTable
437935SN/A{
447935SN/A  public:
457935SN/A    TimerTable();
469885Sstever@gmail.com
479885Sstever@gmail.com    static void printConfig(std::ostream& out) {}
489885Sstever@gmail.com
499885Sstever@gmail.com    void
509885Sstever@gmail.com    setConsumer(Consumer* consumer_ptr)
5110315Snilay@cs.wisc.edu    {
529988Snilay@cs.wisc.edu        assert(m_consumer_ptr == NULL);
5310315Snilay@cs.wisc.edu        m_consumer_ptr = consumer_ptr;
549885Sstever@gmail.com    }
556112SN/A
566112SN/A    void
576112SN/A    setDescription(const std::string& name)
589481Snilay@cs.wisc.edu    {
5910063Snilay@cs.wisc.edu        m_name = name;
606112SN/A    }
619885Sstever@gmail.com
626112SN/A    bool isReady() const;
6311570SCurtis.Dunham@arm.com    const Address& readyAddress() const;
646112SN/A    bool isSet(const Address& address) const { return !!m_map.count(address); }
658835SAli.Saidi@ARM.com    void set(const Address& address, Time relative_latency);
666112SN/A    void unset(const Address& address);
676112SN/A    void print(std::ostream& out) const;
689988Snilay@cs.wisc.edu
696112SN/A  private:
706112SN/A    void updateNext() const;
718835SAli.Saidi@ARM.com
729481Snilay@cs.wisc.edu    // Private copy constructor and assignment operator
736112SN/A    TimerTable(const TimerTable& obj);
746112SN/A    TimerTable& operator=(const TimerTable& obj);
756112SN/A
766112SN/A    // Data Members (m_prefix)
776112SN/A    typedef m5::hash_map<Address, Time> AddressMap;
786112SN/A    AddressMap m_map;
7911570SCurtis.Dunham@arm.com    mutable bool m_next_valid;
8011570SCurtis.Dunham@arm.com    mutable Time m_next_time; // Only valid if m_next_valid is true
8111570SCurtis.Dunham@arm.com    mutable Address m_next_address;  // Only valid if m_next_valid is true
8211570SCurtis.Dunham@arm.com    Consumer* m_consumer_ptr;  // Consumer to signal a wakeup()
838835SAli.Saidi@ARM.com    std::string m_name;
846112SN/A};
859885Sstever@gmail.com
8610315Snilay@cs.wisc.eduinline std::ostream&
879481Snilay@cs.wisc.eduoperator<<(std::ostream& out, const TimerTable& obj)
8811960Sgabeblack@google.com{
896112SN/A    obj.print(out);
906112SN/A    out << std::flush;
916112SN/A    return out;
926112SN/A}
936112SN/A
946112SN/A#endif // __MEM_RUBY_SYSTEM_TIMERTABLE_HH__
956112SN/A