This change updates the gem5 SST Bridge to use SST 13.0.0. Changes are made to replace SimpleMem class to StandardMem class as SimpleMem will be deprecated in SST 14 and above. In addition, the translator.hh is updated to translate more types of gem5 packets. A new parameter `ports` was added on SST's side when invoking the gem5 component which does not require recompiling the gem5 component whenever a new outgoing bridge is added in a gem5 config. Change-Id: I45f0013bc35d088df0aa5a71951422cabab4d7f7 Signed-off-by: Kaustav Goswami <kggoswami@ucdavis.edu>
158 lines
5.6 KiB
Python
158 lines
5.6 KiB
Python
# Copyright (c) 2021 Arm Limited
|
|
# All rights reserved.
|
|
#
|
|
# The license below extends only to copyright in the software and shall
|
|
# not be construed as granting a license to any other intellectual
|
|
# property including but not limited to intellectual property relating
|
|
# to a hardware implementation of the functionality of the software
|
|
# licensed hereunder. You may use the software subject to the license
|
|
# terms below provided that you ensure that this notice is replicated
|
|
# unmodified and in its entirety in all distributions of the software,
|
|
# modified or unmodified, in source code or in binary form.
|
|
#
|
|
# Copyright (c) 2021-2023 The Regents of the University of California
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions are
|
|
# met: redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer;
|
|
# redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution;
|
|
# neither the name of the copyright holders nor the names of its
|
|
# contributors may be used to endorse or promote products derived from
|
|
# this software without specific prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
import sst
|
|
import sys
|
|
import os
|
|
|
|
from sst import UnitAlgebra
|
|
|
|
cache_link_latency = "1ps"
|
|
|
|
kernel = "vmlinux_exit.arm64"
|
|
cpu_clock_rate = "3GHz"
|
|
# gem5 will send requests to physical addresses of range [0x80000000, inf) to
|
|
# memory currently, we do not subtract 0x80000000 from the request's address to
|
|
# get the "real" address so, the mem_size would always be 2GiB larger than the
|
|
# desired memory size
|
|
memory_size_gem5 = "4GiB"
|
|
memory_size_sst = "16GiB"
|
|
addr_range_end = UnitAlgebra(memory_size_sst).getRoundedValue()
|
|
|
|
l1_params = {
|
|
"access_latency_cycles" : "1",
|
|
"cache_frequency" : cpu_clock_rate,
|
|
"replacement_policy" : "lru",
|
|
"coherence_protocol" : "MESI",
|
|
"associativity" : "4",
|
|
"cache_line_size" : "64",
|
|
"cache_size" : "4 KiB",
|
|
"L1" : "1",
|
|
}
|
|
|
|
gem5_command = f" ../../configs/example/sst/arm_fs.py \
|
|
--kernel {kernel} \
|
|
--cpu-clock-rate {cpu_clock_rate} \
|
|
--memory-size {memory_size_gem5}"
|
|
|
|
# We keep a track of all the memory ports that we have.
|
|
sst_ports = {
|
|
"system_port" : "system.system_outgoing_bridge",
|
|
"cache_port" : "system.memory_outgoing_bridge"
|
|
}
|
|
|
|
# We need a list of ports.
|
|
port_list = []
|
|
for port in sst_ports:
|
|
port_list.append(port)
|
|
|
|
cpu_params = {
|
|
"frequency": cpu_clock_rate,
|
|
"cmd": gem5_command,
|
|
"ports" : " ".join(port_list),
|
|
"debug_flags" : ""
|
|
}
|
|
|
|
gem5_node = sst.Component("gem5_node", "gem5.gem5Component")
|
|
gem5_node.addParams(cpu_params)
|
|
|
|
cache_bus = sst.Component("cache_bus", "memHierarchy.Bus")
|
|
cache_bus.addParams( { "bus_frequency" : cpu_clock_rate } )
|
|
# for initialization
|
|
system_port = gem5_node.setSubComponent("system_port", "gem5.gem5Bridge", 0)
|
|
system_port.addParams({
|
|
"response_receiver_name": sst_ports["system_port"],
|
|
"mem_size": memory_size_sst
|
|
})
|
|
# SST -> gem5
|
|
cache_port = gem5_node.setSubComponent("cache_port", "gem5.gem5Bridge", 0)
|
|
cache_port.addParams({
|
|
"response_receiver_name": sst_ports["cache_port"],
|
|
"mem_size": memory_size_sst
|
|
})
|
|
|
|
# L1 cache
|
|
l1_cache = sst.Component("l1_cache", "memHierarchy.Cache")
|
|
l1_cache.addParams(l1_params)
|
|
|
|
# Memory
|
|
memctrl = sst.Component("memory", "memHierarchy.MemController")
|
|
# `addr_range_end` should be changed accordingly to memory_size_sst
|
|
memctrl.addParams({
|
|
"debug" : "0",
|
|
"clock" : "1GHz",
|
|
"request_width" : "64",
|
|
"addr_range_end" : addr_range_end,
|
|
})
|
|
memory = memctrl.setSubComponent("backend", "memHierarchy.simpleMem")
|
|
memory.addParams({
|
|
"access_time" : "30ns",
|
|
"mem_size" : memory_size_sst
|
|
})
|
|
|
|
# Connections
|
|
# cpu <-> L1
|
|
cpu_cache_link = sst.Link("cpu_l1_cache_link")
|
|
cpu_cache_link.connect(
|
|
(cache_port, "port", cache_link_latency),
|
|
(cache_bus, "high_network_0", cache_link_latency)
|
|
)
|
|
system_cache_link = sst.Link("system_cache_link")
|
|
system_cache_link.connect(
|
|
(system_port, "port", cache_link_latency),
|
|
(cache_bus, "high_network_1", cache_link_latency)
|
|
)
|
|
cache_bus_cache_link = sst.Link("cache_bus_cache_link")
|
|
cache_bus_cache_link.connect(
|
|
(cache_bus, "low_network_0", cache_link_latency),
|
|
(l1_cache, "high_network_0", cache_link_latency)
|
|
)
|
|
# L1 <-> mem
|
|
cache_mem_link = sst.Link("l1_cache_mem_link")
|
|
cache_mem_link.connect(
|
|
(l1_cache, "low_network_0", cache_link_latency),
|
|
(memctrl, "direct_link", cache_link_latency)
|
|
)
|
|
|
|
# enable Statistics
|
|
stat_params = { "rate" : "0ns" }
|
|
sst.setStatisticLoadLevel(5)
|
|
sst.setStatisticOutput("sst.statOutputTXT", {"filepath" : "./sst-stats.txt"})
|
|
sst.enableAllStatisticsForComponentName("l1_cache", stat_params)
|
|
sst.enableAllStatisticsForComponentName("memory", stat_params)
|