SystemC.py revision 13729:8c67a3050a07
11049Sbinkertn@umich.edu# Copyright 2018 Google, Inc. 21049Sbinkertn@umich.edu# 31049Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without 41049Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are 51049Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright 61049Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer; 71049Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright 81049Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the 91049Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution; 101049Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its 111049Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from 121049Sbinkertn@umich.edu# this software without specific prior written permission. 131049Sbinkertn@umich.edu# 141049Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 151049Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 161049Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 171049Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 181049Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 191049Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 201049Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 211049Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 221049Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 231049Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 241049Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 251049Sbinkertn@umich.edu# 261049Sbinkertn@umich.edu# Authors: Gabe Black 271049Sbinkertn@umich.edu 281049Sbinkertn@umich.edufrom m5.SimObject import SimObject 291049Sbinkertn@umich.edu 301049Sbinkertn@umich.edu# This class represents the systemc kernel. There should be exactly one in the 311049Sbinkertn@umich.edu# simulation. It receives gem5 SimObject lifecycle callbacks (init, regStats, 321049Sbinkertn@umich.edu# etc.) and manages the lifecycle of the systemc simulation accordingly. 331049Sbinkertn@umich.educlass SystemC_Kernel(SimObject): 341049Sbinkertn@umich.edu type = 'SystemC_Kernel' 351049Sbinkertn@umich.edu cxx_class = 'sc_gem5::Kernel' 361049Sbinkertn@umich.edu cxx_header = 'systemc/core/kernel.hh' 371049Sbinkertn@umich.edu 381049Sbinkertn@umich.edu# This class represents systemc sc_object instances in python config files. It 391049Sbinkertn@umich.edu# inherits from SimObject in python, but the c++ version, sc_core::sc_object, 401049Sbinkertn@umich.edu# doesn't inherit from gem5's c++ SimObject class. 411049Sbinkertn@umich.educlass SystemC_ScObject(SimObject): 421049Sbinkertn@umich.edu type = 'SystemC_ScObject' 431049Sbinkertn@umich.edu abstract = True 441049Sbinkertn@umich.edu cxx_class = 'sc_core::sc_object' 451049Sbinkertn@umich.edu cxx_header = 'systemc/ext/core/sc_object.hh' 461049Sbinkertn@umich.edu 471049Sbinkertn@umich.edu # Clear cxx_base to stop the c++ binding code from assuming 481049Sbinkertn@umich.edu # sc_core::sc_object inherits from SimObject, even though SystemC_ScObject 491049Sbinkertn@umich.edu # does on the python side. 501049Sbinkertn@umich.edu cxx_base = None 511049Sbinkertn@umich.edu 521049Sbinkertn@umich.edu # Hide the cxx_exports from SimObject since we don't inherit from 531049Sbinkertn@umich.edu # SimObject on the c++ side and so don't have those methods to call down 541049Sbinkertn@umich.edu # into. 551049Sbinkertn@umich.edu locals().update({ 561049Sbinkertn@umich.edu method.name: (lambda *a, **k: None) for method in SimObject.cxx_exports 571049Sbinkertn@umich.edu }) 581049Sbinkertn@umich.edu 591049Sbinkertn@umich.educlass SystemC_ScModule(SystemC_ScObject): 601049Sbinkertn@umich.edu type = 'SystemC_ScModule' 611049Sbinkertn@umich.edu abstract = True 621049Sbinkertn@umich.edu cxx_class = 'sc_core::sc_module' 631049Sbinkertn@umich.edu cxx_header = 'systemc/ext/core/sc_module.hh' 641049Sbinkertn@umich.edu 651049Sbinkertn@umich.edutry: 661049Sbinkertn@umich.edu import _m5 671049Sbinkertn@umich.eduexcept: 681049Sbinkertn@umich.edu pass 691049Sbinkertn@umich.eduelse: 701049Sbinkertn@umich.edu import _m5.systemc 711049Sbinkertn@umich.edu _m5.systemc.python_ready() 721049Sbinkertn@umich.edu