sim_object.hh revision 265
113954Sgiacomo.gabrielli@arm.com/*
213954Sgiacomo.gabrielli@arm.com * Copyright (c) 2003 The Regents of The University of Michigan
313954Sgiacomo.gabrielli@arm.com * All rights reserved.
413954Sgiacomo.gabrielli@arm.com *
513954Sgiacomo.gabrielli@arm.com * Redistribution and use in source and binary forms, with or without
613954Sgiacomo.gabrielli@arm.com * modification, are permitted provided that the following conditions are
713954Sgiacomo.gabrielli@arm.com * met: redistributions of source code must retain the above copyright
813954Sgiacomo.gabrielli@arm.com * notice, this list of conditions and the following disclaimer;
913954Sgiacomo.gabrielli@arm.com * redistributions in binary form must reproduce the above copyright
1013954Sgiacomo.gabrielli@arm.com * notice, this list of conditions and the following disclaimer in the
1113954Sgiacomo.gabrielli@arm.com * documentation and/or other materials provided with the distribution;
1213954Sgiacomo.gabrielli@arm.com * neither the name of the copyright holders nor the names of its
1313954Sgiacomo.gabrielli@arm.com * contributors may be used to endorse or promote products derived from
1413954Sgiacomo.gabrielli@arm.com * this software without specific prior written permission.
1513954Sgiacomo.gabrielli@arm.com *
1613954Sgiacomo.gabrielli@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1713954Sgiacomo.gabrielli@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1813954Sgiacomo.gabrielli@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1913954Sgiacomo.gabrielli@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2013954Sgiacomo.gabrielli@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2113954Sgiacomo.gabrielli@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2213954Sgiacomo.gabrielli@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2313954Sgiacomo.gabrielli@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2413954Sgiacomo.gabrielli@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2513954Sgiacomo.gabrielli@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2613954Sgiacomo.gabrielli@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2713954Sgiacomo.gabrielli@arm.com */
2813954Sgiacomo.gabrielli@arm.com
2913954Sgiacomo.gabrielli@arm.com/* @file
3013954Sgiacomo.gabrielli@arm.com * User Console Definitions
3113954Sgiacomo.gabrielli@arm.com */
3213954Sgiacomo.gabrielli@arm.com
3313954Sgiacomo.gabrielli@arm.com#ifndef __SIM_OBJECT_HH__
3413954Sgiacomo.gabrielli@arm.com#define __SIM_OBJECT_HH__
3513954Sgiacomo.gabrielli@arm.com
3613954Sgiacomo.gabrielli@arm.com#include <map>
3713954Sgiacomo.gabrielli@arm.com#include <list>
3813954Sgiacomo.gabrielli@arm.com#include <vector>
3913954Sgiacomo.gabrielli@arm.com#include <iostream>
4013954Sgiacomo.gabrielli@arm.com
4113954Sgiacomo.gabrielli@arm.com#include "sim/serialize.hh"
4213954Sgiacomo.gabrielli@arm.com
4313954Sgiacomo.gabrielli@arm.com/*
4413954Sgiacomo.gabrielli@arm.com * Abstract superclass for simulation objects.  Represents things that
4513954Sgiacomo.gabrielli@arm.com * correspond to physical components and can be specified via the
4613954Sgiacomo.gabrielli@arm.com * config file (CPUs, caches, etc.).
4713954Sgiacomo.gabrielli@arm.com */
4813954Sgiacomo.gabrielli@arm.comclass SimObject : public Serializeable
4913954Sgiacomo.gabrielli@arm.com{
5013954Sgiacomo.gabrielli@arm.com  protected:
5113954Sgiacomo.gabrielli@arm.com    std::string objName;
5213954Sgiacomo.gabrielli@arm.com
5313954Sgiacomo.gabrielli@arm.com  private:
5413954Sgiacomo.gabrielli@arm.com    friend class Serializer;
5513954Sgiacomo.gabrielli@arm.com
5613954Sgiacomo.gabrielli@arm.com    typedef std::vector<SimObject *> SimObjectList;
5713954Sgiacomo.gabrielli@arm.com
5813954Sgiacomo.gabrielli@arm.com    // list of all instantiated simulation objects
5913954Sgiacomo.gabrielli@arm.com    static SimObjectList simObjectList;
6013954Sgiacomo.gabrielli@arm.com
6113954Sgiacomo.gabrielli@arm.com  public:
6213954Sgiacomo.gabrielli@arm.com    SimObject(const std::string &_name);
6313954Sgiacomo.gabrielli@arm.com
6413954Sgiacomo.gabrielli@arm.com    virtual ~SimObject() {}
6513954Sgiacomo.gabrielli@arm.com
6613954Sgiacomo.gabrielli@arm.com    virtual std::string name() const { return objName; }
6713954Sgiacomo.gabrielli@arm.com
6813954Sgiacomo.gabrielli@arm.com    // register statistics for this object
6913954Sgiacomo.gabrielli@arm.com    virtual void regStats();
7013954Sgiacomo.gabrielli@arm.com    virtual void regFormulas();
7113954Sgiacomo.gabrielli@arm.com
7213954Sgiacomo.gabrielli@arm.com    // print extra results for this object not covered by registered
7313954Sgiacomo.gabrielli@arm.com    // statistics (called at end of simulation)
7413954Sgiacomo.gabrielli@arm.com    virtual void printExtraOutput(std::ostream&);
7513954Sgiacomo.gabrielli@arm.com
7613954Sgiacomo.gabrielli@arm.com    // static: call reg_stats on all SimObjects
7713954Sgiacomo.gabrielli@arm.com    static void regAllStats();
7813954Sgiacomo.gabrielli@arm.com
7913954Sgiacomo.gabrielli@arm.com    // static: call printExtraOutput on all SimObjects
8013954Sgiacomo.gabrielli@arm.com    static void printAllExtraOutput(std::ostream&);
8113954Sgiacomo.gabrielli@arm.com};
8213954Sgiacomo.gabrielli@arm.com
8313954Sgiacomo.gabrielli@arm.com#endif // __SIM_OBJECT_HH__
8413954Sgiacomo.gabrielli@arm.com