etrace_replay.py revision 13774
1# Copyright (c) 2015 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder.  You may use the software subject to the license
9# terms below provided that you ensure that this notice is replicated
10# unmodified and in its entirety in all distributions of the software,
11# modified or unmodified, in source code or in binary form.
12#
13# Redistribution and use in source and binary forms, with or without
14# modification, are permitted provided that the following conditions are
15# met: redistributions of source code must retain the above copyright
16# notice, this list of conditions and the following disclaimer;
17# redistributions in binary form must reproduce the above copyright
18# notice, this list of conditions and the following disclaimer in the
19# documentation and/or other materials provided with the distribution;
20# neither the name of the copyright holders nor the names of its
21# contributors may be used to endorse or promote products derived from
22# this software without specific prior written permission.
23#
24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35#
36# Authors: Radhika Jagtap
37
38# Basic elastic traces replay script that configures a Trace CPU
39
40from __future__ import print_function
41from __future__ import absolute_import
42
43import optparse
44
45from m5.util import addToPath, fatal
46
47addToPath('../')
48
49from common import Options
50from common import Simulation
51from common import CacheConfig
52from common import MemConfig
53from common.Caches import *
54
55parser = optparse.OptionParser()
56Options.addCommonOptions(parser)
57
58if '--ruby' in sys.argv:
59    print("This script does not support Ruby configuration, mainly"
60    " because Trace CPU has been tested only with classic memory system")
61    sys.exit(1)
62
63(options, args) = parser.parse_args()
64
65if args:
66    print("Error: script doesn't take any positional arguments")
67    sys.exit(1)
68
69numThreads = 1
70
71if options.cpu_type != "TraceCPU":
72    fatal("This is a script for elastic trace replay simulation, use "\
73            "--cpu-type=TraceCPU\n");
74
75if options.num_cpus > 1:
76    fatal("This script does not support multi-processor trace replay.\n")
77
78# In this case FutureClass will be None as there is not fast forwarding or
79# switching
80(CPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
81CPUClass.numThreads = numThreads
82
83system = System(cpu = CPUClass(cpu_id=0),
84                mem_mode = test_mem_mode,
85                mem_ranges = [AddrRange(options.mem_size)],
86                cache_line_size = options.cacheline_size)
87
88# Create a top-level voltage domain
89system.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
90
91# Create a source clock for the system. This is used as the clock period for
92# xbar and memory
93system.clk_domain = SrcClockDomain(clock =  options.sys_clock,
94                                   voltage_domain = system.voltage_domain)
95
96# Create a CPU voltage domain
97system.cpu_voltage_domain = VoltageDomain()
98
99# Create a separate clock domain for the CPUs. In case of Trace CPUs this clock
100# is actually used only by the caches connected to the CPU.
101system.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock,
102                                       voltage_domain =
103                                       system.cpu_voltage_domain)
104
105# All cpus belong to a common cpu_clk_domain, therefore running at a common
106# frequency.
107for cpu in system.cpu:
108    cpu.clk_domain = system.cpu_clk_domain
109
110# BaseCPU no longer has default values for the BaseCPU.isa
111# createThreads() is needed to fill in the cpu.isa
112for cpu in system.cpu:
113    cpu.createThreads()
114
115# Assign input trace files to the Trace CPU
116system.cpu.instTraceFile=options.inst_trace_file
117system.cpu.dataTraceFile=options.data_trace_file
118
119# Configure the classic memory system options
120MemClass = Simulation.setMemClass(options)
121system.membus = SystemXBar()
122system.system_port = system.membus.slave
123CacheConfig.config_cache(options, system)
124MemConfig.config_mem(options, system)
125
126root = Root(full_system = False, system = system)
127Simulation.run(options, root, system, FutureClass)
128