1 # Copyright (c) 2015 ARM Limited
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.
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.
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.
36 # Authors: Radhika Jagtap
38 # Basic elastic traces replay script that configures a Trace CPU
40 from __future__
import print_function
41 from __future__
import absolute_import
45 from m5
.util
import addToPath
, fatal
49 from common
import Options
50 from common
import Simulation
51 from common
import CacheConfig
52 from common
import MemConfig
53 from common
.Caches
import *
55 parser
= optparse
.OptionParser()
56 Options
.addCommonOptions(parser
)
58 if '--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")
63 (options
, args
) = parser
.parse_args()
66 print("Error: script doesn't take any positional arguments")
71 if options
.cpu_type
!= "TraceCPU":
72 fatal("This is a script for elastic trace replay simulation, use "\
73 "--cpu-type=TraceCPU\n");
75 if options
.num_cpus
> 1:
76 fatal("This script does not support multi-processor trace replay.\n")
78 # In this case FutureClass will be None as there is not fast forwarding or
80 (CPUClass
, test_mem_mode
, FutureClass
) = Simulation
.setCPUClass(options
)
81 CPUClass
.numThreads
= numThreads
83 system
= 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
)
88 # Create a top-level voltage domain
89 system
.voltage_domain
= VoltageDomain(voltage
= options
.sys_voltage
)
91 # Create a source clock for the system. This is used as the clock period for
93 system
.clk_domain
= SrcClockDomain(clock
= options
.sys_clock
,
94 voltage_domain
= system
.voltage_domain
)
96 # Create a CPU voltage domain
97 system
.cpu_voltage_domain
= VoltageDomain()
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.
101 system
.cpu_clk_domain
= SrcClockDomain(clock
= options
.cpu_clock
,
103 system
.cpu_voltage_domain
)
105 # All cpus belong to a common cpu_clk_domain, therefore running at a common
107 for cpu
in system
.cpu
:
108 cpu
.clk_domain
= system
.cpu_clk_domain
110 # BaseCPU no longer has default values for the BaseCPU.isa
111 # createThreads() is needed to fill in the cpu.isa
112 for cpu
in system
.cpu
:
115 # Assign input trace files to the Trace CPU
116 system
.cpu
.instTraceFile
=options
.inst_trace_file
117 system
.cpu
.dataTraceFile
=options
.data_trace_file
119 # Configure the classic memory system options
120 MemClass
= Simulation
.setMemClass(options
)
121 system
.membus
= SystemXBar()
122 system
.system_port
= system
.membus
.slave
123 CacheConfig
.config_cache(options
, system
)
124 MemConfig
.config_mem(options
, system
)
126 root
= Root(full_system
= False, system
= system
)
127 Simulation
.run(options
, root
, system
, FutureClass
)