113676Sjason@lowepower.com# Copyright (c) 2012 ARM Limited
213676Sjason@lowepower.com# All rights reserved.
313676Sjason@lowepower.com#
413676Sjason@lowepower.com# The license below extends only to copyright in the software and shall
513676Sjason@lowepower.com# not be construed as granting a license to any other intellectual
613676Sjason@lowepower.com# property including but not limited to intellectual property relating
713676Sjason@lowepower.com# to a hardware implementation of the functionality of the software
813676Sjason@lowepower.com# licensed hereunder.  You may use the software subject to the license
913676Sjason@lowepower.com# terms below provided that you ensure that this notice is replicated
1013676Sjason@lowepower.com# unmodified and in its entirety in all distributions of the software,
1113676Sjason@lowepower.com# modified or unmodified, in source code or in binary form.
1213676Sjason@lowepower.com#
1313676Sjason@lowepower.com# Redistribution and use in source and binary forms, with or without
1413676Sjason@lowepower.com# modification, are permitted provided that the following conditions are
1513676Sjason@lowepower.com# met: redistributions of source code must retain the above copyright
1613676Sjason@lowepower.com# notice, this list of conditions and the following disclaimer;
1713676Sjason@lowepower.com# redistributions in binary form must reproduce the above copyright
1813676Sjason@lowepower.com# notice, this list of conditions and the following disclaimer in the
1913676Sjason@lowepower.com# documentation and/or other materials provided with the distribution;
2013676Sjason@lowepower.com# neither the name of the copyright holders nor the names of its
2113676Sjason@lowepower.com# contributors may be used to endorse or promote products derived from
2213676Sjason@lowepower.com# this software without specific prior written permission.
2313676Sjason@lowepower.com#
2413676Sjason@lowepower.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2513676Sjason@lowepower.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2613676Sjason@lowepower.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2713676Sjason@lowepower.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2813676Sjason@lowepower.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2913676Sjason@lowepower.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3013676Sjason@lowepower.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3113676Sjason@lowepower.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3213676Sjason@lowepower.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3313676Sjason@lowepower.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3413676Sjason@lowepower.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3513676Sjason@lowepower.com#
3613676Sjason@lowepower.com# Authors: Andreas Hansson
3713676Sjason@lowepower.com
3813676Sjason@lowepower.comimport m5
3913676Sjason@lowepower.comfrom m5.objects import *
4013676Sjason@lowepower.com
4113676Sjason@lowepower.comimport argparse
4213676Sjason@lowepower.com
4313676Sjason@lowepower.comparser = argparse.ArgumentParser(description='Simple memory tester')
4413676Sjason@lowepower.comparser.add_argument('--bandwidth', default=None)
4513676Sjason@lowepower.comparser.add_argument('--latency', default=None)
4613676Sjason@lowepower.comparser.add_argument('--latency_var', default=None)
4713676Sjason@lowepower.com
4813676Sjason@lowepower.comargs = parser.parse_args()
4913676Sjason@lowepower.com
5013676Sjason@lowepower.com# even if this is only a traffic generator, call it cpu to make sure
5113676Sjason@lowepower.com# the scripts are happy
5213677Sjason@lowepower.comtry:
5313677Sjason@lowepower.com    cpu = TrafficGen(
5413677Sjason@lowepower.com        config_file=os.path.join(os.path.dirname(os.path.abspath(__file__)),
5513676Sjason@lowepower.com                             "tgen-simple-mem.cfg"))
5613677Sjason@lowepower.comexcept NameError:
5713677Sjason@lowepower.com    m5.fatal("protobuf required for simple memory test")
5813676Sjason@lowepower.com
5913676Sjason@lowepower.comclass MyMem(SimpleMemory):
6013676Sjason@lowepower.com    if args.bandwidth:
6113676Sjason@lowepower.com        bandwidth = args.bandwidth
6213676Sjason@lowepower.com    if args.latency:
6313676Sjason@lowepower.com        latency = args.latency
6413676Sjason@lowepower.com    if args.latency_var:
6513676Sjason@lowepower.com        latency_var = args.latency_var
6613676Sjason@lowepower.com
6713676Sjason@lowepower.com# system simulated
6813676Sjason@lowepower.comsystem = System(cpu = cpu, physmem = MyMem(),
6913676Sjason@lowepower.com                membus = IOXBar(width = 16),
7013676Sjason@lowepower.com                clk_domain = SrcClockDomain(clock = '1GHz',
7113676Sjason@lowepower.com                                            voltage_domain =
7213676Sjason@lowepower.com                                            VoltageDomain()))
7313676Sjason@lowepower.com
7413676Sjason@lowepower.com# add a communication monitor, and also trace all the packets and
7513676Sjason@lowepower.com# calculate and verify stack distance
7613676Sjason@lowepower.comsystem.monitor = CommMonitor()
7713676Sjason@lowepower.comsystem.monitor.trace = MemTraceProbe(trace_file = "monitor.ptrc.gz")
7813676Sjason@lowepower.comsystem.monitor.stackdist = StackDistProbe(verify = True)
7913676Sjason@lowepower.com
8013676Sjason@lowepower.com# connect the traffic generator to the bus via a communication monitor
8113676Sjason@lowepower.comsystem.cpu.port = system.monitor.slave
8213676Sjason@lowepower.comsystem.monitor.master = system.membus.slave
8313676Sjason@lowepower.com
8413676Sjason@lowepower.com# connect the system port even if it is not used in this example
8513676Sjason@lowepower.comsystem.system_port = system.membus.slave
8613676Sjason@lowepower.com
8713676Sjason@lowepower.com# connect memory to the membus
8813676Sjason@lowepower.comsystem.physmem.port = system.membus.master
8913676Sjason@lowepower.com
9013676Sjason@lowepower.com# -----------------------
9113676Sjason@lowepower.com# run simulation
9213676Sjason@lowepower.com# -----------------------
9313676Sjason@lowepower.com
9413676Sjason@lowepower.comroot = Root(full_system = False, system = system)
9513676Sjason@lowepower.comroot.system.mem_mode = 'timing'
9613676Sjason@lowepower.com
9713676Sjason@lowepower.comm5.instantiate()
9813676Sjason@lowepower.comexit_event = m5.simulate(100000000000)
9913677Sjason@lowepower.comif exit_event.getCause() != "simulate() limit reached":
10013677Sjason@lowepower.com    exit(1)
101