if fullname == 'm5.objects':
return self
- if fullname.startswith('m5.internal'):
+ if fullname.startswith('_m5'):
return None
source = self.modules.get(fullname, None)
code = code_formatter()
code("""
-import m5.internal
+import _m5.core
import m5.util
buildEnv = m5.util.SmartDict($build_env)
-compileDate = m5.internal.core.compileDate
+compileDate = _m5.core.compileDate
_globals = globals()
-for key,val in m5.internal.core.__dict__.iteritems():
+for key,val in _m5.core.__dict__.iteritems():
if key.startswith('flag_'):
flag = key[5:]
_globals[flag] = val
# Generate any needed param SWIG wrapper files
params_i_files = []
for name,param in sorted(params_to_swig.iteritems()):
- i_file = File('python/m5/internal/%s.i' % (param.swig_module_name()))
+ i_file = File('python/_m5/%s.i' % (param.swig_module_name()))
params_i_files.append(i_file)
env.Command(i_file, Value(name),
MakeAction(createParamSwigWrapper, Transform("SW PARAM")))
env.Depends(i_file, depends)
env.Depends(SWIG, i_file)
- SwigSource('m5.internal', i_file)
+ SwigSource('_m5', i_file)
# Generate all enum header files
for name,enum in sorted(all_enums.iteritems()):
env.Depends(hh_file, depends + extra_deps)
env.Depends(SWIG, hh_file)
- i_file = File('python/m5/internal/enum_%s.i' % name)
+ i_file = File('python/_m5/enum_%s.i' % name)
env.Command(i_file, Value(name),
MakeAction(createEnumSwigWrapper, Transform("ENUMSWIG")))
env.Depends(i_file, depends + extra_deps)
env.Depends(SWIG, i_file)
- SwigSource('m5.internal', i_file)
+ SwigSource('_m5', i_file)
# Generate SimObject SWIG wrapper files
for name,simobj in sorted(sim_objects.iteritems()):
py_source = PySource.modules[simobj.__module__]
extra_deps = [ py_source.tnode ]
- i_file = File('python/m5/internal/param_%s.i' % name)
+ i_file = File('python/_m5/param_%s.i' % name)
env.Command(i_file, Value(name),
MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG")))
env.Depends(i_file, depends + extra_deps)
- SwigSource('m5.internal', i_file)
+ SwigSource('_m5', i_file)
# Generate the main swig init file
def makeEmbeddedSwigInit(package):
PySource('m5.util', 'm5/util/sorteddict.py')
PySource('m5.util', 'm5/util/terminal.py')
-SwigSource('m5.internal', 'swig/core.i')
-SwigSource('m5.internal', 'swig/debug.i')
-SwigSource('m5.internal', 'swig/drain.i')
-SwigSource('m5.internal', 'swig/event.i')
-SwigSource('m5.internal', 'swig/pyobject.i')
-SwigSource('m5.internal', 'swig/range.i')
-SwigSource('m5.internal', 'swig/serialize.i')
-SwigSource('m5.internal', 'swig/stats.i')
-SwigSource('m5.internal', 'swig/trace.i')
+PySource('_m5', '_m5/__init__.py')
+SwigSource('_m5', 'swig/core.i')
+SwigSource('_m5', 'swig/debug.i')
+SwigSource('_m5', 'swig/drain.i')
+SwigSource('_m5', 'swig/event.i')
+SwigSource('_m5', 'swig/pyobject.i')
+SwigSource('_m5', 'swig/range.i')
+SwigSource('_m5', 'swig/serialize.i')
+SwigSource('_m5', 'swig/stats.i')
+SwigSource('_m5', 'swig/trace.i')
PySource('m5.internal', 'm5/internal/__init__.py')
PySource('m5.internal', 'm5/internal/params.py')
--- /dev/null
+# Copyright (c) 2016 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder. You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Andreas Sandberg
+
+# This is a place holder to create a package for generated code. Don't
+# add any Python code in this name space.
# See ParamValue.swig_predecls for description.
def swig_predecls(cls, code):
- code('%import "python/m5/internal/param_$cls.i"')
+ code('%import "python/_m5/param_$cls.i"')
# Hook for exporting additional C++ methods to Python via SWIG.
# Default is none, override using @classmethod in class definition.
params = map(lambda (k, v): v, sorted(cls._params.local.items()))
ports = cls._ports.local
- code('%module(package="m5.internal") param_$cls')
+ code('%module(package="_m5") param_$cls')
code()
code('%{')
code('#include "sim/sim_object.hh"')
code()
if cls._base:
- code('%import "python/m5/internal/param_${{cls._base}}.i"')
+ code('%import "python/_m5/param_${{cls._base}}.i"')
code()
for ns in namespaces:
try:
# Try to import something that's generated by swig
- import internal.core
+ import _m5.core
# Try to grab something from it in case demandimport is being used
- internal.core.curTick
+ _m5.core.curTick
+ in_gem5 = True
except ImportError:
- # The import failed
- internal = None
+ # The import failed, we're being called from the build system
+ in_gem5 = False
-if internal:
+if in_gem5:
import SimObject
import core
import objects
#
# Authors: Nathan Binkert
-import internal
-
-def setOutputDir(dir):
- internal.core.setOutputDir(dir)
+from _m5.core import setOutputDir
from UserDict import DictMixin
-import internal
-
-from internal.debug import SimpleFlag, CompoundFlag
-from internal.debug import schedBreak, setRemoteGDBPort
+import _m5.debug
+from _m5.debug import SimpleFlag, CompoundFlag
+from _m5.debug import schedBreak, setRemoteGDBPort
from m5.util import printList
def help():
self._dict = {}
def _update(self):
- current_version = internal.debug.getAllFlagsVersion()
+ current_version = _m5.debug.getAllFlagsVersion()
if self._version == current_version:
return
self._dict.clear()
- for flag in internal.debug.getAllFlags():
+ for flag in _m5.debug.getAllFlags():
self._dict[flag.name()] = flag
self._version = current_version
# Authors: Nathan Binkert
import m5
-import internal.event
+import _m5.event
-from internal.event import PythonEvent, GlobalSimLoopExitEvent as SimExit
+from _m5.event import PythonEvent, GlobalSimLoopExitEvent as SimExit
mainq = None
self.eventq.schedule(self, m5.curTick() + self.period)
def getEventQueue(index):
- return internal.event.getEventQueue(index)
+ return _m5.event.getEventQueue(index)
def setEventQueue(eventq):
- internal.event.curEventQueue(eventq)
+ _m5.event.curEventQueue(eventq)
__all__ = [ 'create', 'Event', 'ProgressEvent', 'SimExit', 'mainq' ]
modules = { }
for module in modules.iterkeys():
- if module.startswith('m5.internal.param_') or \
- module.startswith('m5.internal.enum_'):
+ if module.startswith('_m5.param_') or \
+ module.startswith('_m5.enum_'):
exec "from %s import *" % module
code('%import "${{self.swig_module_name()}}.i"')
def swig_decl(self, code):
- code('%module(package="m5.internal") ${{self.swig_module_name()}}')
+ code('%module(package="_m5") ${{self.swig_module_name()}}')
code('%{')
self.ptype.cxx_predecls(code)
code('%}')
unsigned = True
def getValue(self):
- from m5.internal.core import Cycles
+ from _m5.core import Cycles
return Cycles(self.value)
@classmethod
def getValue(self):
# Go from the Python class to the wrapped C++ class generated
# by swig
- from m5.internal.range import AddrRange
+ from _m5.range import AddrRange
return AddrRange(long(self.start), long(self.end),
int(self.intlvHighBit), int(self.xorHighBit),
def swig_decl(cls, code):
name = cls.__name__
code('''\
-%module(package="m5.internal") enum_$name
+%module(package="_m5") enum_$name
%{
#include "enums/$name.hh"
@classmethod
def swig_predecls(cls, code):
- code('%import "python/m5/internal/enum_$0.i"', cls.__name__)
+ code('%import "python/_m5/enum_$0.i"', cls.__name__)
@classmethod
def cxx_ini_parse(cls, code, src, dest, ret):
# Call C++ to create corresponding port connection between C++ objects
def ccConnect(self):
- from m5.internal.pyobject import connectPorts
+ from _m5.pyobject import connectPorts
if self.role == 'SLAVE':
# do nothing and let the master take care of it
import sys
# import the SWIG-wrapped main C++ functions
-import internal
-import core
+import _m5.drain
+import _m5.core
+from _m5.stats import updateEvents as updateStatEvents
+
import stats
import SimObject
import ticks
import objects
from m5.util.dot_writer import do_dot, do_dvfs_dot
-from m5.internal.stats import updateEvents as updateStatEvents
from util import fatal
from util import attrdict
"atomic_noncaching" : objects.params.atomic_noncaching,
}
-_drain_manager = internal.drain.DrainManager.instance()
+_drain_manager = _m5.drain.DrainManager.instance()
# The final hook to generate .ini files. Called from the user script
# once the config is built.
# Restore checkpoint (if any)
if ckpt_dir:
_drain_manager.preCheckpointRestore()
- ckpt = internal.core.getCheckpoint(ckpt_dir)
- internal.core.unserializeGlobals(ckpt);
+ ckpt = _m5.core.getCheckpoint(ckpt_dir)
+ _m5.core.unserializeGlobals(ckpt);
for obj in root.descendants(): obj.loadState(ckpt)
else:
for obj in root.descendants(): obj.initState()
atexit.register(stats.dump)
# register our C++ exit callback function with Python
- atexit.register(internal.core.doExitCleanup)
+ atexit.register(_m5.core.doExitCleanup)
# Reset to put the stats in a consistent state.
stats.reset()
if _drain_manager.isDrained():
_drain_manager.resume()
- return internal.event.simulate(*args, **kwargs)
-
-# Export curTick to user script.
-def curTick():
- return internal.core.curTick()
+ return _m5.event.simulate(*args, **kwargs)
def drain():
"""Drain the simulator in preparation of a checkpoint or memory mode
# WARNING: if a valid exit event occurs while draining, it
# will not get returned to the user script
- exit_event = internal.event.simulate()
+ exit_event = _m5.event.simulate()
while exit_event.getCause() != 'Finished drain':
exit_event = simulate()
drain()
memWriteback(root)
print "Writing checkpoint"
- internal.core.serializeAll(dir)
+ _m5.core.serializeAll(dir)
def _changeMemoryMode(system, mode):
if not isinstance(system, (objects.Root, objects.System)):
from m5 import options
global fork_count
- if not internal.core.listenersDisabled():
+ if not _m5.core.listenersDisabled():
raise RuntimeError, "Can not fork a simulator with listeners enabled"
drain()
"fork_seq" : fork_count,
"pid" : os.getpid(),
}
- core.setOutputDir(options.outdir)
+ _m5.core.setOutputDir(options.outdir)
else:
fork_count += 1
return pid
-from internal.core import disableAllListeners
-from internal.core import listenersDisabled
+from _m5.core import disableAllListeners, listenersDisabled
+from _m5.core import curTick
import m5
-from m5 import internal
+import _m5.stats
from m5.objects import Root
from m5.util import attrdict, fatal
# Stat exports
-from m5.internal.stats import schedStatEvent as schedEvent
-from m5.internal.stats import periodicStatDump
+from _m5.stats import schedStatEvent as schedEvent
+from _m5.stats import periodicStatDump
outputList = []
def initText(filename, desc=True):
- output = internal.stats.initText(filename, desc)
+ output = _m5.stats.initText(filename, desc)
outputList.append(output)
def initSimStats():
- internal.stats.initSimStats()
- internal.stats.registerPythonStatsHandlers()
+ _m5.stats.initSimStats()
+ _m5.stats.registerPythonStatsHandlers()
names = []
stats_dict = {}
the package is enabled, no more statistics can be created.'''
global stats_list
- stats_list = list(internal.stats.statsList())
+ stats_list = list(_m5.stats.statsList())
for stat in stats_list:
if not stat.check() or not stat.baseCheck():
stats_dict[stat.name] = stat
stat.enable()
- internal.stats.enable();
+ _m5.stats.enable();
def prepare():
'''Prepare all stats for data access. This must be done before
return
lastDump = curTick
- internal.stats.processDumpQueue()
+ _m5.stats.processDumpQueue()
prepare()
for stat in stats_list:
stat.reset()
- internal.stats.processResetQueue()
+ _m5.stats.processResetQueue()
flags = attrdict({
'none' : 0x0000,
# fix the global frequency and tell C++ about it
def fixGlobalFrequency():
- import internal
+ import _m5.core
global tps, tps_fixed
if not tps_fixed:
tps_fixed = True
- internal.core.setClockFrequency(int(tps))
+ _m5.core.setClockFrequency(int(tps))
print "Global frequency set at %d ticks per second" % int(tps)
def setGlobalFrequency(ticksPerSecond):
#
# Authors: Nathan Binkert
-import internal
-import util
-
-from internal.trace import output, ignore
-
-def disable():
- internal.trace.disable()
-
-def enable():
- internal.trace.enable()
+# Export native methods to Python
+from _m5.trace import output, ignore, disable, enable
* Steve Reinhardt
*/
-%module(package="m5.internal") core
+%module(package="_m5") core
%{
#include "base/misc.hh"
* Authors: Nathan Binkert
*/
-%module(package="m5.internal") debug
+%module(package="_m5") debug
%{
#include <cassert>
* Authors: Andreas Sandberg
*/
-%module(package="m5.internal") drain
+%module(package="_m5") drain
%{
#include "sim/drain.hh"
* Authors: Nathan Binkert
*/
-%module(package="m5.internal") event
+%module(package="_m5") event
%{
#include "base/types.hh"
* Authors: Nathan Binkert
*/
-%module(package="m5.internal") pyobject
+%module(package="_m5") pyobject
%{
#include "python/swig/pyobject.hh"
* Authors: Nathan Binkert
*/
-%module(package="m5.internal") range
+%module(package="_m5") range
%{
#include "base/types.hh"
* Authors: Andreas Sandberg
*/
-%module(package="m5.internal") serialize
+%module(package="_m5") serialize
%{
#include "sim/serialize.hh"
* Authors: Nathan Binkert
*/
-%module(package="m5.internal") stats
+%module(package="_m5") stats
%include <std_list.i>
%include <std_string.i>
* Authors: Nathan Binkert
*/
-%module(package="m5.internal") trace
+%module(package="_m5") trace
%{
#include "base/trace.hh"
UnitTest('trietest', 'trietest.cc')
stattest_py = PySource('m5', 'stattestmain.py', skip_lib=True)
-stattest_swig = SwigSource('m5.internal', 'stattest.i', skip_lib=True)
+stattest_swig = SwigSource('_m5', 'stattest.i', skip_lib=True)
UnitTest('stattest', 'stattest.cc', stattest_py, stattest_swig, main=True)
UnitTest('symtest', 'symtest.cc')
* Authors: Nathan Binkert
*/
-%module(package="m5.internal") stattest
+%module(package="_m5") stattest
%inline %{
extern void stattest_init();
def main():
- from m5.internal.stattest import stattest_init, stattest_run
+ from _m5.stattest import stattest_init, stattest_run
import m5.stats
stattest_init()
# Authors: Andreas Sandberg
import m5
+import _m5
from m5.objects import *
m5.util.addToPath('../configs/')
from common.Caches import *
# Suppress "Entering event queue" messages since we get tons of them.
# Worse yet, they include the timestamp, which makes them highly
# variable and unsuitable for comparing as test outputs.
- m5.internal.core.cvar.want_info = verbose
+ _m5.core.cvar.want_info = verbose
# instantiate configuration
m5.instantiate()