Merge zizzer:/bk/newmem
[gem5.git] / configs / example / fs.py
1 # Copyright (c) 2006-2007 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
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution;
11 # neither the name of the copyright holders nor the names of its
12 # contributors may be used to endorse or promote products derived from
13 # this software without specific prior written permission.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27 # Authors: Ali Saidi
28
29 import optparse, os, sys
30
31 import m5
32 from m5.objects import *
33 m5.AddToPath('../common')
34 from FSConfig import *
35 from SysPaths import *
36 from Benchmarks import *
37 import Simulation
38 from Caches import *
39
40 if not m5.build_env['FULL_SYSTEM']:
41 m5.panic("This script requires full-system mode (ALPHA_FS).")
42
43 # Get paths we might need. It's expected this file is in m5/configs/example.
44 config_path = os.path.dirname(os.path.abspath(__file__))
45 config_root = os.path.dirname(config_path)
46
47 parser = optparse.OptionParser()
48
49 # System options
50 parser.add_option("--kernel", action="store", type="string")
51 parser.add_option("--script", action="store", type="string")
52
53 # Benchmark options
54 parser.add_option("--l2cache", action="store_true")
55 parser.add_option("--dual", action="store_true",
56 help="Simulate two systems attached with an ethernet link")
57 parser.add_option("-b", "--benchmark", action="store", type="string",
58 dest="benchmark",
59 help="Specify the benchmark to run. Available benchmarks: %s"\
60 % DefinedBenchmarks)
61
62 # Metafile options
63 parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
64 help="Specify the filename to dump a pcap capture of the" \
65 "ethernet traffic")
66
67 execfile(os.path.join(config_root, "common", "Options.py"))
68
69 (options, args) = parser.parse_args()
70
71 if args:
72 print "Error: script doesn't take any positional arguments"
73 sys.exit(1)
74
75 # driver system CPU is always simple... note this is an assignment of
76 # a class, not an instance.
77 DriveCPUClass = AtomicSimpleCPU
78 drive_mem_mode = 'atomic'
79
80 # system under test can be any CPU
81 (TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
82
83 TestCPUClass.clock = '2GHz'
84 DriveCPUClass.clock = '2GHz'
85
86 if options.benchmark:
87 try:
88 bm = Benchmarks[options.benchmark]
89 except KeyError:
90 print "Error benchmark %s has not been defined." % options.benchmark
91 print "Valid benchmarks are: %s" % DefinedBenchmarks
92 sys.exit(1)
93 else:
94 if options.dual:
95 bm = [SysConfig(), SysConfig()]
96 else:
97 bm = [SysConfig()]
98
99 if m5.build_env['TARGET_ISA'] == "alpha":
100 test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0])
101 elif m5.build_env['TARGET_ISA'] == "sparc":
102 test_sys = makeSparcSystem(test_mem_mode, bm[0])
103 else:
104 m5.panic("incapable of building non-alpha or non-sparc full system!")
105
106 if options.kernel is not None:
107 test_sys.kernel = binary(options.kernel)
108
109 if options.script is not None:
110 test_sys.readfile = options.script
111
112 np = options.num_cpus
113
114 if options.l2cache:
115 test_sys.l2 = L2Cache(size = '2MB')
116 test_sys.tol2bus = Bus()
117 test_sys.l2.cpu_side = test_sys.tol2bus.port
118 test_sys.l2.mem_side = test_sys.membus.port
119
120 test_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)]
121 for i in xrange(np):
122 if options.caches:
123 test_sys.cpu[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'),
124 L1Cache(size = '64kB'))
125
126 if options.l2cache:
127 test_sys.cpu[i].connectMemPorts(test_sys.tol2bus)
128 else:
129 test_sys.cpu[i].connectMemPorts(test_sys.membus)
130
131 if len(bm) == 2:
132 if m5.build_env['TARGET_ISA'] == 'alpha':
133 drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1])
134 elif m5.build_env['TARGET_ISA'] == 'sparc':
135 drive_sys = makeSparcSystem(drive_mem_mode, bm[1])
136 drive_sys.cpu = DriveCPUClass(cpu_id=0)
137 drive_sys.cpu.connectMemPorts(drive_sys.membus)
138 root = makeDualRoot(test_sys, drive_sys, options.etherdump)
139 elif len(bm) == 1:
140 root = Root(clock = '1THz', system = test_sys)
141 else:
142 print "Error I don't know how to create more than 2 systems."
143 sys.exit(1)
144
145 Simulation.run(options, root, test_sys, FutureClass)