module.hh revision 12982
112070Snikos.nikoleris@arm.com/* 29380SAndreas.Sandberg@ARM.com * Copyright 2018 Google, Inc. 39380SAndreas.Sandberg@ARM.com * 49380SAndreas.Sandberg@ARM.com * Redistribution and use in source and binary forms, with or without 59380SAndreas.Sandberg@ARM.com * modification, are permitted provided that the following conditions are 69380SAndreas.Sandberg@ARM.com * met: redistributions of source code must retain the above copyright 79380SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer; 89380SAndreas.Sandberg@ARM.com * redistributions in binary form must reproduce the above copyright 99380SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer in the 109380SAndreas.Sandberg@ARM.com * documentation and/or other materials provided with the distribution; 119380SAndreas.Sandberg@ARM.com * neither the name of the copyright holders nor the names of its 129380SAndreas.Sandberg@ARM.com * contributors may be used to endorse or promote products derived from 139380SAndreas.Sandberg@ARM.com * this software without specific prior written permission. 149380SAndreas.Sandberg@ARM.com * 159380SAndreas.Sandberg@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 169380SAndreas.Sandberg@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 179380SAndreas.Sandberg@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 189380SAndreas.Sandberg@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 199380SAndreas.Sandberg@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 209380SAndreas.Sandberg@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 219380SAndreas.Sandberg@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 229380SAndreas.Sandberg@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 239380SAndreas.Sandberg@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 249380SAndreas.Sandberg@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 259380SAndreas.Sandberg@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 269380SAndreas.Sandberg@ARM.com * 279380SAndreas.Sandberg@ARM.com * Authors: Gabe Black 289380SAndreas.Sandberg@ARM.com */ 299380SAndreas.Sandberg@ARM.com 309380SAndreas.Sandberg@ARM.com#ifndef __SYSTEMC_CORE_MODULE_HH__ 319380SAndreas.Sandberg@ARM.com#define __SYSTEMC_CORE_MODULE_HH__ 329380SAndreas.Sandberg@ARM.com 339380SAndreas.Sandberg@ARM.com#include <cassert> 349380SAndreas.Sandberg@ARM.com#include <set> 359380SAndreas.Sandberg@ARM.com 369380SAndreas.Sandberg@ARM.com#include "systemc/core/object.hh" 379792Sandreas.hansson@arm.com#include "systemc/ext/core/sc_module.hh" 389380SAndreas.Sandberg@ARM.com 399380SAndreas.Sandberg@ARM.comnamespace sc_gem5 4012070Snikos.nikoleris@arm.com{ 419380SAndreas.Sandberg@ARM.com 429380SAndreas.Sandberg@ARM.comclass Module 439380SAndreas.Sandberg@ARM.com{ 4411682Sandreas.hansson@arm.com private: 4511682Sandreas.hansson@arm.com const char *_name; 4612070Snikos.nikoleris@arm.com sc_core::sc_module *_sc_mod; 4711682Sandreas.hansson@arm.com Object *_obj; 4812070Snikos.nikoleris@arm.com 499380SAndreas.Sandberg@ARM.com public: 509654SAndreas.Sandberg@ARM.com 519654SAndreas.Sandberg@ARM.com Module(const char *name); 529380SAndreas.Sandberg@ARM.com ~Module(); 539380SAndreas.Sandberg@ARM.com 549380SAndreas.Sandberg@ARM.com void finish(Object *this_obj); 559380SAndreas.Sandberg@ARM.com 569380SAndreas.Sandberg@ARM.com const char *name() const { return _name; } 579380SAndreas.Sandberg@ARM.com 589380SAndreas.Sandberg@ARM.com sc_core::sc_module * 599380SAndreas.Sandberg@ARM.com sc_mod() const 609380SAndreas.Sandberg@ARM.com { 619380SAndreas.Sandberg@ARM.com assert(_sc_mod); 629380SAndreas.Sandberg@ARM.com return _sc_mod; 639792Sandreas.hansson@arm.com } 6411156Sandreas.sandberg@arm.com 6512070Snikos.nikoleris@arm.com void 669792Sandreas.hansson@arm.com sc_mod(sc_core::sc_module *sc_mod) 679380SAndreas.Sandberg@ARM.com { 689380SAndreas.Sandberg@ARM.com assert(!_sc_mod); 699380SAndreas.Sandberg@ARM.com _sc_mod = sc_mod; 709792Sandreas.hansson@arm.com } 719380SAndreas.Sandberg@ARM.com 729380SAndreas.Sandberg@ARM.com Object * 739380SAndreas.Sandberg@ARM.com obj() 7410512SAli.Saidi@ARM.com { 7512070Snikos.nikoleris@arm.com assert(_obj); 769380SAndreas.Sandberg@ARM.com return _obj; 779380SAndreas.Sandberg@ARM.com } 789792Sandreas.hansson@arm.com 799380SAndreas.Sandberg@ARM.com void pop(); 809380SAndreas.Sandberg@ARM.com}; 8111156Sandreas.sandberg@arm.com 829380SAndreas.Sandberg@ARM.comModule *currentModule(); 8312070Snikos.nikoleris@arm.comModule *newModule(); 849380SAndreas.Sandberg@ARM.com 859793Sakash.bagdia@arm.comextern std::set<Module *> allModules; 869380SAndreas.Sandberg@ARM.com 8711156Sandreas.sandberg@arm.com} // namespace sc_gem5 8811156Sandreas.sandberg@arm.com 899793Sakash.bagdia@arm.com#endif //__SYSTEMC_CORE_MODULE_HH__ 909380SAndreas.Sandberg@ARM.com