1# Copyright (c) 2005 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 16 unchanged lines hidden (view full) --- 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# 27# Authors: Nathan Binkert 28# Steve Reinhardt 29 30import sys, os, time, atexit, optparse 31 32# import the SWIG-wrapped main C++ functions |
33import cc_main |
34# import a few SWIG-wrapped items (those that are likely to be used 35# directly by user scripts) completely into this module for 36# convenience |
37from cc_main import simulate, SimLoopExitEvent |
38 39# import the m5 compile options 40import defines 41 42# define this here so we can use it right away if necessary 43def panic(string): 44 print >>sys.stderr, 'panic:', string 45 sys.exit(1) --- 19 unchanged lines hidden (view full) --- 65# User should call this function after calling parse_args() to pass 66# parsed standard option values back into the m5 module for 67# processing. 68def setStandardOptions(_options): 69 # Set module global var 70 global options 71 options = _options 72 # tell C++ about output directory |
73 cc_main.setOutputDir(options.outdir) |
74 75# Callback to set trace flags. Not necessarily the best way to do 76# things in the long run (particularly if we change how these global 77# options are handled). 78def setTraceFlags(option, opt_str, value, parser): 79 objects.Trace.flags = value 80 81def setTraceStart(option, opt_str, value, parser): --- 119 unchanged lines hidden (view full) --- 201# once the config is built. 202def instantiate(root): 203 config.ticks_per_sec = float(root.clock.frequency) 204 # ugly temporary hack to get output to config.ini 205 sys.stdout = file(os.path.join(options.outdir, 'config.ini'), 'w') 206 root.print_ini() 207 sys.stdout.close() # close config.ini 208 sys.stdout = sys.__stdout__ # restore to original |
209 cc_main.loadIniFile(resolveSimObject) # load config.ini into C++ |
210 root.createCCObject() 211 root.connectPorts() |
212 cc_main.finalInit() |
213 noDot = True # temporary until we fix dot 214 if not noDot: 215 dot = pydot.Dot() 216 instance.outputDot(dot) 217 dot.orientation = "portrait" 218 dot.size = "8.5,11" 219 dot.ranksep="equally" 220 dot.rank="samerank" 221 dot.write("config.dot") 222 dot.write_ps("config.ps") 223 224# Export curTick to user script. 225def curTick(): |
226 return cc_main.cvar.curTick |
227 228# register our C++ exit callback function with Python |
229atexit.register(cc_main.doExitCleanup) |
230 231# This import allows user scripts to reference 'm5.objects.Foo' after 232# just doing an 'import m5' (without an 'import m5.objects'). May not 233# matter since most scripts will probably 'from m5.objects import *'. 234import objects |