BaseTrafficGen.py revision 12919
112810Sandreas.sandberg@arm.com# Copyright (c) 2012, 2016, 2018 ARM Limited
212810Sandreas.sandberg@arm.com# All rights reserved.
312810Sandreas.sandberg@arm.com#
412810Sandreas.sandberg@arm.com# The license below extends only to copyright in the software and shall
512810Sandreas.sandberg@arm.com# not be construed as granting a license to any other intellectual
612810Sandreas.sandberg@arm.com# property including but not limited to intellectual property relating
712810Sandreas.sandberg@arm.com# to a hardware implementation of the functionality of the software
812810Sandreas.sandberg@arm.com# licensed hereunder.  You may use the software subject to the license
912810Sandreas.sandberg@arm.com# terms below provided that you ensure that this notice is replicated
1012810Sandreas.sandberg@arm.com# unmodified and in its entirety in all distributions of the software,
1112810Sandreas.sandberg@arm.com# modified or unmodified, in source code or in binary form.
1212810Sandreas.sandberg@arm.com#
1312810Sandreas.sandberg@arm.com# Redistribution and use in source and binary forms, with or without
1412810Sandreas.sandberg@arm.com# modification, are permitted provided that the following conditions are
1512810Sandreas.sandberg@arm.com# met: redistributions of source code must retain the above copyright
1612810Sandreas.sandberg@arm.com# notice, this list of conditions and the following disclaimer;
1712810Sandreas.sandberg@arm.com# redistributions in binary form must reproduce the above copyright
1812810Sandreas.sandberg@arm.com# notice, this list of conditions and the following disclaimer in the
1912810Sandreas.sandberg@arm.com# documentation and/or other materials provided with the distribution;
2012810Sandreas.sandberg@arm.com# neither the name of the copyright holders nor the names of its
2112810Sandreas.sandberg@arm.com# contributors may be used to endorse or promote products derived from
2212810Sandreas.sandberg@arm.com# this software without specific prior written permission.
2312810Sandreas.sandberg@arm.com#
2412810Sandreas.sandberg@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2512810Sandreas.sandberg@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2612810Sandreas.sandberg@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2712810Sandreas.sandberg@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2812810Sandreas.sandberg@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2912810Sandreas.sandberg@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3012810Sandreas.sandberg@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3112810Sandreas.sandberg@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3212810Sandreas.sandberg@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3312810Sandreas.sandberg@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3412810Sandreas.sandberg@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3512810Sandreas.sandberg@arm.com#
3612810Sandreas.sandberg@arm.com# Authors: Thomas Grass
3712810Sandreas.sandberg@arm.com#          Andreas Hansson
3812810Sandreas.sandberg@arm.com#          Sascha Bischoff
3912810Sandreas.sandberg@arm.com
4012810Sandreas.sandberg@arm.comfrom m5.params import *
4112810Sandreas.sandberg@arm.comfrom m5.proxy import *
4212810Sandreas.sandberg@arm.comfrom MemObject import MemObject
4312810Sandreas.sandberg@arm.com
4412919Sgiacomo.travaglini@arm.com# Types of Stream Generators.
4512919Sgiacomo.travaglini@arm.com# Those are orthogonal to the other generators in the TrafficGen
4612919Sgiacomo.travaglini@arm.com# and are meant to initialize the stream and substream IDs for
4712919Sgiacomo.travaglini@arm.com# every memory request, regardless of how the packet has been
4812919Sgiacomo.travaglini@arm.com# generated (Random, Linear, Trace etc)
4912919Sgiacomo.travaglini@arm.comclass StreamGenType(Enum): vals = [ 'none', 'fixed', 'random' ]
5012919Sgiacomo.travaglini@arm.com
5112810Sandreas.sandberg@arm.com# The traffic generator is a master module that generates stimuli for
5212810Sandreas.sandberg@arm.com# the memory system, based on a collection of simple behaviours that
5312810Sandreas.sandberg@arm.com# are either probabilistic or based on traces. It can be used stand
5412810Sandreas.sandberg@arm.com# alone for creating test cases for interconnect and memory
5512810Sandreas.sandberg@arm.com# controllers, or function as a black-box replacement for system
5612810Sandreas.sandberg@arm.com# components that are not yet modelled in detail, e.g. a video engine
5712810Sandreas.sandberg@arm.com# or baseband subsystem in an SoC.
5812810Sandreas.sandberg@arm.comclass BaseTrafficGen(MemObject):
5912810Sandreas.sandberg@arm.com    type = 'BaseTrafficGen'
6012810Sandreas.sandberg@arm.com    abstract = True
6112810Sandreas.sandberg@arm.com    cxx_header = "cpu/testers/traffic_gen/traffic_gen.hh"
6212810Sandreas.sandberg@arm.com
6312810Sandreas.sandberg@arm.com    # Port used for sending requests and receiving responses
6412810Sandreas.sandberg@arm.com    port = MasterPort("Master port")
6512810Sandreas.sandberg@arm.com
6612810Sandreas.sandberg@arm.com    # System used to determine the mode of the memory system
6712810Sandreas.sandberg@arm.com    system = Param.System(Parent.any, "System this generator is part of")
6812810Sandreas.sandberg@arm.com
6912810Sandreas.sandberg@arm.com    # Should requests respond to back-pressure or not, if true, the
7012810Sandreas.sandberg@arm.com    # rate of the traffic generator will be slowed down if requests
7112810Sandreas.sandberg@arm.com    # are not immediately accepted
7212810Sandreas.sandberg@arm.com    elastic_req = Param.Bool(False,
7312810Sandreas.sandberg@arm.com                             "Slow down requests in case of backpressure")
7412810Sandreas.sandberg@arm.com
7512810Sandreas.sandberg@arm.com    # Let the user know if we have waited for a retry and not made any
7612810Sandreas.sandberg@arm.com    # progress for a long period of time. The default value is
7712810Sandreas.sandberg@arm.com    # somewhat arbitrary and may well have to be tuned.
7812810Sandreas.sandberg@arm.com    progress_check = Param.Latency('1ms', "Time before exiting " \
7912810Sandreas.sandberg@arm.com                                   "due to lack of progress")
8012919Sgiacomo.travaglini@arm.com
8112919Sgiacomo.travaglini@arm.com    # Generator type used for applying Stream and/or Substream IDs to requests
8212919Sgiacomo.travaglini@arm.com    stream_gen = Param.StreamGenType('none',
8312919Sgiacomo.travaglini@arm.com        "Generator for adding Stream and/or Substream ID's to requests")
8412919Sgiacomo.travaglini@arm.com
8512919Sgiacomo.travaglini@arm.com    # Sources for Stream/Substream IDs to apply to requests
8612919Sgiacomo.travaglini@arm.com    sids = VectorParam.Unsigned([], "StreamIDs to use")
8712919Sgiacomo.travaglini@arm.com    ssids = VectorParam.Unsigned([], "SubstreamIDs to use")
88