sim_object.hh revision 465
17161Sgblack@eecs.umich.edu/*
27161Sgblack@eecs.umich.edu * Copyright (c) 2003 The Regents of The University of Michigan
37161Sgblack@eecs.umich.edu * All rights reserved.
47161Sgblack@eecs.umich.edu *
57161Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67161Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77161Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87161Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97161Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107161Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117161Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127161Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137161Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
147161Sgblack@eecs.umich.edu * this software without specific prior written permission.
157161Sgblack@eecs.umich.edu *
167161Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177161Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187161Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197161Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207161Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217161Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
227161Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237161Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
247161Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
257161Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
267161Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
277161Sgblack@eecs.umich.edu */
287161Sgblack@eecs.umich.edu
297161Sgblack@eecs.umich.edu/* @file
307161Sgblack@eecs.umich.edu * User Console Definitions
317161Sgblack@eecs.umich.edu */
327161Sgblack@eecs.umich.edu
337161Sgblack@eecs.umich.edu#ifndef __SIM_OBJECT_HH__
347161Sgblack@eecs.umich.edu#define __SIM_OBJECT_HH__
357161Sgblack@eecs.umich.edu
367161Sgblack@eecs.umich.edu#include <map>
377161Sgblack@eecs.umich.edu#include <list>
387161Sgblack@eecs.umich.edu#include <vector>
397161Sgblack@eecs.umich.edu#include <iostream>
407161Sgblack@eecs.umich.edu
417161Sgblack@eecs.umich.edu#include "sim/serialize.hh"
427161Sgblack@eecs.umich.edu
437161Sgblack@eecs.umich.edu/*
447161Sgblack@eecs.umich.edu * Abstract superclass for simulation objects.  Represents things that
457161Sgblack@eecs.umich.edu * correspond to physical components and can be specified via the
467161Sgblack@eecs.umich.edu * config file (CPUs, caches, etc.).
477161Sgblack@eecs.umich.edu */
487161Sgblack@eecs.umich.educlass SimObject : public Serializable
497161Sgblack@eecs.umich.edu{
507161Sgblack@eecs.umich.edu  protected:
517161Sgblack@eecs.umich.edu    std::string objName;
527162Sgblack@eecs.umich.edu
537161Sgblack@eecs.umich.edu  private:
547162Sgblack@eecs.umich.edu    friend class Serializer;
557161Sgblack@eecs.umich.edu
567161Sgblack@eecs.umich.edu    typedef std::vector<SimObject *> SimObjectList;
577161Sgblack@eecs.umich.edu
587162Sgblack@eecs.umich.edu    // list of all instantiated simulation objects
597161Sgblack@eecs.umich.edu    static SimObjectList simObjectList;
607162Sgblack@eecs.umich.edu
617161Sgblack@eecs.umich.edu  public:
627161Sgblack@eecs.umich.edu    SimObject(const std::string &_name);
637162Sgblack@eecs.umich.edu
647161Sgblack@eecs.umich.edu    virtual ~SimObject() {}
657162Sgblack@eecs.umich.edu
667161Sgblack@eecs.umich.edu    virtual std::string name() const { return objName; }
677161Sgblack@eecs.umich.edu
687162Sgblack@eecs.umich.edu    // initialization pass of all objects.  Gets invoked by SimInit()
697161Sgblack@eecs.umich.edu    virtual void init();
707162Sgblack@eecs.umich.edu    static void initAll();
717161Sgblack@eecs.umich.edu
727161Sgblack@eecs.umich.edu    // register statistics for this object
737161Sgblack@eecs.umich.edu    virtual void regStats();
747162Sgblack@eecs.umich.edu    virtual void regFormulas();
757161Sgblack@eecs.umich.edu    virtual void resetStats();
767162Sgblack@eecs.umich.edu
777161Sgblack@eecs.umich.edu    // print extra results for this object not covered by registered
787161Sgblack@eecs.umich.edu    // statistics (called at end of simulation)
797161Sgblack@eecs.umich.edu    virtual void printExtraOutput(std::ostream&);
807162Sgblack@eecs.umich.edu
817161Sgblack@eecs.umich.edu    // static: call reg_stats on all SimObjects
827162Sgblack@eecs.umich.edu    static void regAllStats();
837161Sgblack@eecs.umich.edu
847161Sgblack@eecs.umich.edu    // static: call resetStats on all SimObjects
857161Sgblack@eecs.umich.edu    static void resetAllStats();
867162Sgblack@eecs.umich.edu
877161Sgblack@eecs.umich.edu    // static: call printExtraOutput on all SimObjects
887162Sgblack@eecs.umich.edu    static void printAllExtraOutput(std::ostream&);
897161Sgblack@eecs.umich.edu
907161Sgblack@eecs.umich.edu    // static: call nameOut() & serialize() on all SimObjects
917161Sgblack@eecs.umich.edu    static void serializeAll(std::ostream &);
927161Sgblack@eecs.umich.edu};
937161Sgblack@eecs.umich.edu
947161Sgblack@eecs.umich.edu#endif // __SIM_OBJECT_HH__
957161Sgblack@eecs.umich.edu