summaryrefslogtreecommitdiff
path: root/src/python/m5
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/m5')
-rw-r--r--src/python/m5/__init__.py122
-rw-r--r--src/python/m5/config.py6
-rw-r--r--src/python/m5/objects/AlphaO3CPU.py (renamed from src/python/m5/objects/AlphaFullCPU.py)4
-rw-r--r--src/python/m5/objects/FuncUnit.py17
4 files changed, 127 insertions, 22 deletions
diff --git a/src/python/m5/__init__.py b/src/python/m5/__init__.py
index f849a899b..ac6904277 100644
--- a/src/python/m5/__init__.py
+++ b/src/python/m5/__init__.py
@@ -30,11 +30,11 @@
import sys, os, time, atexit, optparse
# import the SWIG-wrapped main C++ functions
-import main
+import cc_main
# import a few SWIG-wrapped items (those that are likely to be used
# directly by user scripts) completely into this module for
# convenience
-from main import simulate, SimLoopExitEvent
+from cc_main import simulate, SimLoopExitEvent
# import the m5 compile options
import defines
@@ -58,6 +58,20 @@ def AddToPath(path):
sys.path.insert(1, path)
+# The m5 module's pointer to the parsed options object
+options = None
+
+
+# User should call this function after calling parse_args() to pass
+# parsed standard option values back into the m5 module for
+# processing.
+def setStandardOptions(_options):
+ # Set module global var
+ global options
+ options = _options
+ # tell C++ about output directory
+ cc_main.setOutputDir(options.outdir)
+
# Callback to set trace flags. Not necessarily the best way to do
# things in the long run (particularly if we change how these global
# options are handled).
@@ -67,28 +81,102 @@ def setTraceFlags(option, opt_str, value, parser):
def setTraceStart(option, opt_str, value, parser):
objects.Trace.start = value
-def clearPCSymbol(option, opt_str, value, parser):
- objects.ExecutionTrace.pc_symbol = False
+def setTraceFile(option, opt_str, value, parser):
+ objects.Trace.file = value
+
+def usePCSymbol(option, opt_str, value, parser):
+ objects.ExecutionTrace.pc_symbol = value
+
+def printCycle(option, opt_str, value, parser):
+ objects.ExecutionTrace.print_cycle = value
+
+def printOp(option, opt_str, value, parser):
+ objects.ExecutionTrace.print_opclass = value
+
+def printThread(option, opt_str, value, parser):
+ objects.ExecutionTrace.print_thread = value
-def clearPrintCycle(option, opt_str, value, parser):
- objects.ExecutionTrace.print_cycle = False
+def printEA(option, opt_str, value, parser):
+ objects.ExecutionTrace.print_effaddr = value
+
+def printData(option, opt_str, value, parser):
+ objects.ExecutionTrace.print_data = value
+
+def printFetchseq(option, opt_str, value, parser):
+ objects.ExecutionTrace.print_fetchseq = value
+
+def printCpseq(option, opt_str, value, parser):
+ objects.ExecutionTrace.print_cpseq = value
+
+def dumpOnExit(option, opt_str, value, parser):
+ objects.Trace.dump_on_exit = value
+
+def debugBreak(option, opt_str, value, parser):
+ objects.Debug.break_cycles = value
def statsTextFile(option, opt_str, value, parser):
objects.Statistics.text_file = value
+# Extra list to help for options that are true or false
+TrueOrFalse = ['True', 'False']
+TorF = "True | False"
+
# Standard optparse options. Need to be explicitly included by the
# user script when it calls optparse.OptionParser().
standardOptions = [
+ optparse.make_option("--outdir", type="string", default="."),
optparse.make_option("--traceflags", type="string", action="callback",
callback=setTraceFlags),
optparse.make_option("--tracestart", type="int", action="callback",
callback=setTraceStart),
- optparse.make_option("--nopcsymbol", action="callback",
- callback=clearPCSymbol,
- help="Turn off printing PC symbols in trace output"),
- optparse.make_option("--noprintcycle", action="callback",
- callback=clearPrintCycle,
- help="Turn off printing cycles in trace output"),
+ optparse.make_option("--tracefile", type="string", action="callback",
+ callback=setTraceFile),
+ optparse.make_option("--pcsymbol", type="choice", choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=usePCSymbol,
+ help="Use PC symbols in trace output"),
+ optparse.make_option("--printcycle", type="choice", choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=printCycle,
+ help="Print cycle numbers in trace output"),
+ optparse.make_option("--printopclass", type="choice",
+ choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=printOp,
+ help="Print cycle numbers in trace output"),
+ optparse.make_option("--printthread", type="choice",
+ choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=printThread,
+ help="Print thread number in trace output"),
+ optparse.make_option("--printeffaddr", type="choice",
+ choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=printEA,
+ help="Print effective address in trace output"),
+ optparse.make_option("--printdata", type="choice",
+ choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=printData,
+ help="Print result data in trace output"),
+ optparse.make_option("--printfetchseq", type="choice",
+ choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=printFetchseq,
+ help="Print fetch sequence numbers in trace output"),
+ optparse.make_option("--printcpseq", type="choice",
+ choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=printCpseq,
+ help="Print correct path sequence numbers in trace output"),
+ optparse.make_option("--dumponexit", type="choice",
+ choices=TrueOrFalse,
+ default="True", metavar=TorF,
+ action="callback", callback=dumpOnExit,
+ help="Dump trace buffer on exit"),
+ optparse.make_option("--debugbreak", type="int", metavar="CYCLE",
+ action="callback", callback=debugBreak,
+ help="Cycle to create a breakpoint"),
optparse.make_option("--statsfile", type="string", action="callback",
callback=statsTextFile, metavar="FILE",
help="Sets the output file for the statistics")
@@ -114,14 +202,14 @@ def resolveSimObject(name):
def instantiate(root):
config.ticks_per_sec = float(root.clock.frequency)
# ugly temporary hack to get output to config.ini
- sys.stdout = file('config.ini', 'w')
+ sys.stdout = file(os.path.join(options.outdir, 'config.ini'), 'w')
root.print_ini()
sys.stdout.close() # close config.ini
sys.stdout = sys.__stdout__ # restore to original
- main.loadIniFile(resolveSimObject) # load config.ini into C++
+ cc_main.loadIniFile(resolveSimObject) # load config.ini into C++
root.createCCObject()
root.connectPorts()
- main.finalInit()
+ cc_main.finalInit()
noDot = True # temporary until we fix dot
if not noDot:
dot = pydot.Dot()
@@ -135,10 +223,10 @@ def instantiate(root):
# Export curTick to user script.
def curTick():
- return main.cvar.curTick
+ return cc_main.cvar.curTick
# register our C++ exit callback function with Python
-atexit.register(main.doExitCleanup)
+atexit.register(cc_main.doExitCleanup)
# This import allows user scripts to reference 'm5.objects.Foo' after
# just doing an 'import m5' (without an 'import m5.objects'). May not
diff --git a/src/python/m5/config.py b/src/python/m5/config.py
index 058e72578..c29477465 100644
--- a/src/python/m5/config.py
+++ b/src/python/m5/config.py
@@ -30,7 +30,7 @@
import os, re, sys, types, inspect, copy
import m5
-from m5 import panic
+from m5 import panic, cc_main
from convert import *
from multidict import multidict
@@ -529,7 +529,7 @@ class SimObject(object):
def getCCObject(self):
if not self._ccObject:
self._ccObject = -1 # flag to catch cycles in recursion
- self._ccObject = m5.main.createSimObject(self.path())
+ self._ccObject = cc_main.createSimObject(self.path())
elif self._ccObject == -1:
raise RuntimeError, "%s: recursive call to getCCObject()" \
% self.path()
@@ -1443,7 +1443,7 @@ class PortRef(object):
if self.ccConnected: # already done this
return
peer = self.peer
- m5.main.connectPorts(self.simobj.getCCObject(), self.name, self.index,
+ cc_main.connectPorts(self.simobj.getCCObject(), self.name, self.index,
peer.simobj.getCCObject(), peer.name, peer.index)
self.ccConnected = True
peer.ccConnected = True
diff --git a/src/python/m5/objects/AlphaFullCPU.py b/src/python/m5/objects/AlphaO3CPU.py
index 2988305d3..f14f8c88e 100644
--- a/src/python/m5/objects/AlphaFullCPU.py
+++ b/src/python/m5/objects/AlphaO3CPU.py
@@ -2,8 +2,8 @@ from m5 import build_env
from m5.config import *
from BaseCPU import BaseCPU
-class DerivAlphaFullCPU(BaseCPU):
- type = 'DerivAlphaFullCPU'
+class DerivAlphaO3CPU(BaseCPU):
+ type = 'DerivAlphaO3CPU'
activity = Param.Unsigned("Initial count")
numThreads = Param.Unsigned("number of HW thread contexts")
diff --git a/src/python/m5/objects/FuncUnit.py b/src/python/m5/objects/FuncUnit.py
new file mode 100644
index 000000000..f61590ae9
--- /dev/null
+++ b/src/python/m5/objects/FuncUnit.py
@@ -0,0 +1,17 @@
+from m5.config import *
+
+class OpType(Enum):
+ vals = ['(null)', 'IntAlu', 'IntMult', 'IntDiv', 'FloatAdd',
+ 'FloatCmp', 'FloatCvt', 'FloatMult', 'FloatDiv', 'FloatSqrt',
+ 'MemRead', 'MemWrite', 'IprAccess', 'InstPrefetch']
+
+class OpDesc(SimObject):
+ type = 'OpDesc'
+ issueLat = Param.Int(1, "cycles until another can be issued")
+ opClass = Param.OpType("type of operation")
+ opLat = Param.Int(1, "cycles until result is available")
+
+class FUDesc(SimObject):
+ type = 'FUDesc'
+ count = Param.Int("number of these FU's available")
+ opList = VectorParam.OpDesc("operation classes for this FU type")