112207Sjungma@eit.uni-kl.de# Copyright (c) 2016, University of Kaiserslautern
212207Sjungma@eit.uni-kl.de# All rights reserved.
312207Sjungma@eit.uni-kl.de#
412207Sjungma@eit.uni-kl.de# Redistribution and use in source and binary forms, with or without
512207Sjungma@eit.uni-kl.de# modification, are permitted provided that the following conditions are
612207Sjungma@eit.uni-kl.de# met:
712207Sjungma@eit.uni-kl.de#
812207Sjungma@eit.uni-kl.de# 1. Redistributions of source code must retain the above copyright notice,
912207Sjungma@eit.uni-kl.de#    this list of conditions and the following disclaimer.
1012207Sjungma@eit.uni-kl.de#
1112207Sjungma@eit.uni-kl.de# 2. Redistributions in binary form must reproduce the above copyright
1212207Sjungma@eit.uni-kl.de#    notice, this list of conditions and the following disclaimer in the
1312207Sjungma@eit.uni-kl.de#    documentation and/or other materials provided with the distribution.
1412207Sjungma@eit.uni-kl.de#
1512207Sjungma@eit.uni-kl.de# 3. Neither the name of the copyright holder nor the names of its
1612207Sjungma@eit.uni-kl.de#    contributors may be used to endorse or promote products derived from
1712207Sjungma@eit.uni-kl.de#    this software without specific prior written permission.
1812207Sjungma@eit.uni-kl.de#
1912207Sjungma@eit.uni-kl.de# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2012207Sjungma@eit.uni-kl.de# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2112207Sjungma@eit.uni-kl.de# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2212207Sjungma@eit.uni-kl.de# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
2312207Sjungma@eit.uni-kl.de# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2412207Sjungma@eit.uni-kl.de# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2512207Sjungma@eit.uni-kl.de# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2612207Sjungma@eit.uni-kl.de# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2712207Sjungma@eit.uni-kl.de# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2812207Sjungma@eit.uni-kl.de# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2912207Sjungma@eit.uni-kl.de# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3012207Sjungma@eit.uni-kl.de#
3112207Sjungma@eit.uni-kl.de# Authors: Matthias Jung
3212207Sjungma@eit.uni-kl.de
3312207Sjungma@eit.uni-kl.deimport m5
3412207Sjungma@eit.uni-kl.deimport optparse
3512207Sjungma@eit.uni-kl.de
3612207Sjungma@eit.uni-kl.defrom m5.objects import *
3712207Sjungma@eit.uni-kl.defrom m5.util import addToPath, fatal
3812207Sjungma@eit.uni-kl.de
3912207Sjungma@eit.uni-kl.deaddToPath('../../../configs/common/')
4012207Sjungma@eit.uni-kl.de
4112207Sjungma@eit.uni-kl.defrom Caches import *
4212207Sjungma@eit.uni-kl.de
4312207Sjungma@eit.uni-kl.de# This configuration shows a simple setup of a Elastic Trace Player (eTraceCPU)
4412207Sjungma@eit.uni-kl.de# and an external TLM port for SystemC co-simulation.
4512207Sjungma@eit.uni-kl.de#
4612207Sjungma@eit.uni-kl.de# We assume a DRAM size of 512MB and L1 cache sizes of 32KB and an L2 cache
4712207Sjungma@eit.uni-kl.de# size of 1MB.
4812207Sjungma@eit.uni-kl.de#
4912207Sjungma@eit.uni-kl.de# Base System Architecture:
5012207Sjungma@eit.uni-kl.de#
5112207Sjungma@eit.uni-kl.de#                  +-----------+       ^
5212207Sjungma@eit.uni-kl.de# +-------------+  | eTraceCPU |       |
5312207Sjungma@eit.uni-kl.de# | System Port |  +-----+-----+       |
5412207Sjungma@eit.uni-kl.de# +------+------+  | $D1 | $I1 |       |
5512207Sjungma@eit.uni-kl.de#        |         +--+--+--+--+       |
5612207Sjungma@eit.uni-kl.de#        |            |     |          | gem5 World (see this file)
5712207Sjungma@eit.uni-kl.de#        |         +--v-----v--+       |
5812207Sjungma@eit.uni-kl.de#        |         | toL2Bus   |       |
5912207Sjungma@eit.uni-kl.de#        |         +-----+-----+       |
6012207Sjungma@eit.uni-kl.de#        |               |             |
6112207Sjungma@eit.uni-kl.de#        |         +-----v-----+       |
6212207Sjungma@eit.uni-kl.de#        |         |    L2     |       |
6312207Sjungma@eit.uni-kl.de#        |         +-----+-----+       |
6412207Sjungma@eit.uni-kl.de#        |               |             |
6512207Sjungma@eit.uni-kl.de# +------v---------------v-----+       |
6612207Sjungma@eit.uni-kl.de# |           Membus           |       v
6712207Sjungma@eit.uni-kl.de# +----------------+-----------+       External Port (see sc_port.*)
6812207Sjungma@eit.uni-kl.de#                  |                   ^
6912207Sjungma@eit.uni-kl.de#              +---v---+               | TLM World
7012207Sjungma@eit.uni-kl.de#              |  TLM  |               | (see sc_target.*)
7112207Sjungma@eit.uni-kl.de#              +-------+               v
7212207Sjungma@eit.uni-kl.de#
7312207Sjungma@eit.uni-kl.de#
7412207Sjungma@eit.uni-kl.de# Create a system with a Crossbar and an Elastic Trace Player as CPU:
7512207Sjungma@eit.uni-kl.de
7612207Sjungma@eit.uni-kl.de# Setup System:
7712207Sjungma@eit.uni-kl.desystem = System(cpu=TraceCPU(cpu_id=0),
7812207Sjungma@eit.uni-kl.de                mem_mode='timing',
7912207Sjungma@eit.uni-kl.de                mem_ranges = [AddrRange('1024MB')],
8012207Sjungma@eit.uni-kl.de                cache_line_size = 64)
8112207Sjungma@eit.uni-kl.de
8212207Sjungma@eit.uni-kl.de# Create a top-level voltage domain:
8312207Sjungma@eit.uni-kl.desystem.voltage_domain = VoltageDomain()
8412207Sjungma@eit.uni-kl.de
8512207Sjungma@eit.uni-kl.de# Create a source clock for the system. This is used as the clock period for
8612207Sjungma@eit.uni-kl.de# xbar and memory:
8712207Sjungma@eit.uni-kl.desystem.clk_domain = SrcClockDomain(clock =  '1GHz',
8812207Sjungma@eit.uni-kl.de        voltage_domain = system.voltage_domain)
8912207Sjungma@eit.uni-kl.de
9012207Sjungma@eit.uni-kl.de# Create a CPU voltage domain:
9112207Sjungma@eit.uni-kl.desystem.cpu_voltage_domain = VoltageDomain()
9212207Sjungma@eit.uni-kl.de
9312207Sjungma@eit.uni-kl.de# Create a separate clock domain for the CPUs. In case of Trace CPUs this clock
9412207Sjungma@eit.uni-kl.de# is actually used only by the caches connected to the CPU:
9512207Sjungma@eit.uni-kl.desystem.cpu_clk_domain = SrcClockDomain(clock = '1GHz',
9612207Sjungma@eit.uni-kl.de        voltage_domain = system.cpu_voltage_domain)
9712207Sjungma@eit.uni-kl.de
9812207Sjungma@eit.uni-kl.de# Setup CPU and its L1 caches:
9912207Sjungma@eit.uni-kl.desystem.cpu.createInterruptController()
10012207Sjungma@eit.uni-kl.desystem.cpu.icache = L1_ICache(size="32kB")
10112207Sjungma@eit.uni-kl.desystem.cpu.dcache = L1_DCache(size="32kB")
10212207Sjungma@eit.uni-kl.desystem.cpu.icache.cpu_side = system.cpu.icache_port
10312207Sjungma@eit.uni-kl.desystem.cpu.dcache.cpu_side = system.cpu.dcache_port
10412207Sjungma@eit.uni-kl.de
10512207Sjungma@eit.uni-kl.de# Assign input trace files to the eTraceCPU:
10612207Sjungma@eit.uni-kl.desystem.cpu.instTraceFile="system.cpu.traceListener.inst.gz"
10712207Sjungma@eit.uni-kl.desystem.cpu.dataTraceFile="system.cpu.traceListener.data.gz"
10812207Sjungma@eit.uni-kl.de
10912207Sjungma@eit.uni-kl.de# Setting up L1 BUS:
11012207Sjungma@eit.uni-kl.desystem.tol2bus = L2XBar()
11112207Sjungma@eit.uni-kl.desystem.l2cache = L2Cache(size="1MB")
11212207Sjungma@eit.uni-kl.desystem.physmem = SimpleMemory() # This must be instantiated, even if not needed
11312207Sjungma@eit.uni-kl.de
11412207Sjungma@eit.uni-kl.de# Create a external TLM port:
11512207Sjungma@eit.uni-kl.desystem.tlm = ExternalSlave()
11612207Sjungma@eit.uni-kl.desystem.tlm.addr_ranges = [AddrRange('4096MB')]
11712207Sjungma@eit.uni-kl.desystem.tlm.port_type = "tlm_slave"
11812207Sjungma@eit.uni-kl.desystem.tlm.port_data = "transactor1"
11912207Sjungma@eit.uni-kl.de
12012207Sjungma@eit.uni-kl.de# Connect everything:
12112207Sjungma@eit.uni-kl.desystem.membus = SystemXBar()
12212207Sjungma@eit.uni-kl.desystem.system_port = system.membus.slave
12312207Sjungma@eit.uni-kl.desystem.cpu.icache.mem_side = system.tol2bus.slave
12412207Sjungma@eit.uni-kl.desystem.cpu.dcache.mem_side = system.tol2bus.slave
12512207Sjungma@eit.uni-kl.desystem.tol2bus.master = system.l2cache.cpu_side
12612207Sjungma@eit.uni-kl.desystem.l2cache.mem_side = system.membus.slave
12712207Sjungma@eit.uni-kl.desystem.membus.master = system.tlm.port
12812207Sjungma@eit.uni-kl.de
12912207Sjungma@eit.uni-kl.de# Start the simulation:
13012207Sjungma@eit.uni-kl.deroot = Root(full_system = False, system = system)
13112207Sjungma@eit.uni-kl.deroot.system.mem_mode = 'timing'
13212207Sjungma@eit.uni-kl.dem5.instantiate()
13312207Sjungma@eit.uni-kl.dem5.simulate() # Simulation time specified later on commandline
134