module.hh revision 12950
112863Sgabeblack@google.com/*
212863Sgabeblack@google.com * Copyright 2018 Google, Inc.
312863Sgabeblack@google.com *
412863Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512863Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612863Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712863Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812863Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912863Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012863Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112863Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212863Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312863Sgabeblack@google.com * this software without specific prior written permission.
1412863Sgabeblack@google.com *
1512863Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612863Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712863Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812863Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912863Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012863Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112863Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212863Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312863Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412863Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512863Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612863Sgabeblack@google.com *
2712863Sgabeblack@google.com * Authors: Gabe Black
2812863Sgabeblack@google.com */
2912863Sgabeblack@google.com
3012863Sgabeblack@google.com#ifndef __SYSTEMC_CORE_MODULE_HH__
3112863Sgabeblack@google.com#define __SYSTEMC_CORE_MODULE_HH__
3212863Sgabeblack@google.com
3312950Sgabeblack@google.com#include <cassert>
3412950Sgabeblack@google.com
3512950Sgabeblack@google.com#include "systemc/core/object.hh"
3612950Sgabeblack@google.com#include "systemc/ext/core/sc_module.hh"
3712950Sgabeblack@google.com
3812950Sgabeblack@google.comnamespace sc_gem5
3912863Sgabeblack@google.com{
4012863Sgabeblack@google.com
4112863Sgabeblack@google.comclass Module
4212863Sgabeblack@google.com{
4312863Sgabeblack@google.com  private:
4412863Sgabeblack@google.com    const char *_name;
4512950Sgabeblack@google.com    sc_core::sc_module *_sc_mod;
4612950Sgabeblack@google.com    Object *_obj;
4712863Sgabeblack@google.com
4812863Sgabeblack@google.com  public:
4912863Sgabeblack@google.com
5012950Sgabeblack@google.com    Module(const char *name);
5112950Sgabeblack@google.com    void finish(Object *this_obj);
5212863Sgabeblack@google.com
5312950Sgabeblack@google.com    const char *name() const { return _name; }
5412950Sgabeblack@google.com
5512950Sgabeblack@google.com    sc_core::sc_module *
5612950Sgabeblack@google.com    sc_mod() const
5712950Sgabeblack@google.com    {
5812950Sgabeblack@google.com        assert(_sc_mod);
5912950Sgabeblack@google.com        return _sc_mod;
6012950Sgabeblack@google.com    }
6112950Sgabeblack@google.com
6212950Sgabeblack@google.com    void
6312950Sgabeblack@google.com    sc_mod(sc_core::sc_module *sc_mod)
6412950Sgabeblack@google.com    {
6512950Sgabeblack@google.com        assert(!_sc_mod);
6612950Sgabeblack@google.com        _sc_mod = sc_mod;
6712950Sgabeblack@google.com    }
6812950Sgabeblack@google.com
6912950Sgabeblack@google.com    Object *
7012950Sgabeblack@google.com    obj()
7112950Sgabeblack@google.com    {
7212950Sgabeblack@google.com        assert(_obj);
7312950Sgabeblack@google.com        return _obj;
7412950Sgabeblack@google.com    }
7512950Sgabeblack@google.com
7612863Sgabeblack@google.com    void pop();
7712863Sgabeblack@google.com};
7812863Sgabeblack@google.com
7912950Sgabeblack@google.comModule *currentModule();
8012950Sgabeblack@google.comModule *newModule();
8112863Sgabeblack@google.com
8212863Sgabeblack@google.com} // namespace sc_gem5
8312863Sgabeblack@google.com
8412863Sgabeblack@google.com#endif  //__SYSTEMC_CORE_MODULE_HH__
85