linear_gen.hh revision 12811
112396SRiken.Gohil@arm.com/*
212811Sandreas.sandberg@arm.com * Copyright (c) 2012-2013, 2017-2018 ARM Limited
312396SRiken.Gohil@arm.com * All rights reserved
412396SRiken.Gohil@arm.com *
512396SRiken.Gohil@arm.com * The license below extends only to copyright in the software and shall
612396SRiken.Gohil@arm.com * not be construed as granting a license to any other intellectual
712396SRiken.Gohil@arm.com * property including but not limited to intellectual property relating
812396SRiken.Gohil@arm.com * to a hardware implementation of the functionality of the software
912396SRiken.Gohil@arm.com * licensed here under.  You may use the software subject to the license
1012396SRiken.Gohil@arm.com * terms below provided that you ensure that this notice is replicated
1112396SRiken.Gohil@arm.com * unmodified and in its entirety in all distributions of the software,
1212396SRiken.Gohil@arm.com * modified or unmodified, in source code or in binary form.
1312396SRiken.Gohil@arm.com *
1412396SRiken.Gohil@arm.com * Redistribution and use in source and binary forms, with or without
1512396SRiken.Gohil@arm.com * modification, are permitted provided that the following conditions are
1612396SRiken.Gohil@arm.com * met: redistributions of source code must retain the above copyright
1712396SRiken.Gohil@arm.com * notice, this list of conditions and the following disclaimer;
1812396SRiken.Gohil@arm.com * redistributions in binary form must reproduce the above copyright
1912396SRiken.Gohil@arm.com * notice, this list of conditions and the following disclaimer in the
2012396SRiken.Gohil@arm.com * documentation and/or other materials provided with the distribution;
2112396SRiken.Gohil@arm.com * neither the name of the copyright holders nor the names of its
2212396SRiken.Gohil@arm.com * contributors may be used to endorse or promote products derived from
2312396SRiken.Gohil@arm.com * this software without specific prior written permission.
2412396SRiken.Gohil@arm.com *
2512396SRiken.Gohil@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2612396SRiken.Gohil@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2712396SRiken.Gohil@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2812396SRiken.Gohil@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2912396SRiken.Gohil@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3012396SRiken.Gohil@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3112396SRiken.Gohil@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3212396SRiken.Gohil@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3312396SRiken.Gohil@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3412396SRiken.Gohil@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3512396SRiken.Gohil@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3612396SRiken.Gohil@arm.com *
3712396SRiken.Gohil@arm.com * Authors: Thomas Grass
3812396SRiken.Gohil@arm.com *          Andreas Hansson
3912396SRiken.Gohil@arm.com *          Sascha Bischoff
4012396SRiken.Gohil@arm.com *          Neha Agarwal
4112396SRiken.Gohil@arm.com */
4212396SRiken.Gohil@arm.com
4312396SRiken.Gohil@arm.com/**
4412396SRiken.Gohil@arm.com * @file
4512396SRiken.Gohil@arm.com * Declaration of the linear generator that generates sequential
4612396SRiken.Gohil@arm.com * requests.
4712396SRiken.Gohil@arm.com */
4812396SRiken.Gohil@arm.com
4912396SRiken.Gohil@arm.com#ifndef __CPU_TRAFFIC_GEN_LINEAR_GEN_HH__
5012396SRiken.Gohil@arm.com#define __CPU_TRAFFIC_GEN_LINEAR_GEN_HH__
5112396SRiken.Gohil@arm.com
5212396SRiken.Gohil@arm.com#include "base/bitfield.hh"
5312396SRiken.Gohil@arm.com#include "base/intmath.hh"
5412396SRiken.Gohil@arm.com#include "base_gen.hh"
5512396SRiken.Gohil@arm.com#include "mem/packet.hh"
5612396SRiken.Gohil@arm.com
5712396SRiken.Gohil@arm.com/**
5812396SRiken.Gohil@arm.com * The linear generator generates sequential requests from a
5912396SRiken.Gohil@arm.com * start to an end address, with a fixed block size. A
6012396SRiken.Gohil@arm.com * fraction of the requests are reads, as determined by the
6112396SRiken.Gohil@arm.com * read percent. There is an optional data limit for when to
6212396SRiken.Gohil@arm.com * stop generating new requests.
6312396SRiken.Gohil@arm.com */
6412811Sandreas.sandberg@arm.comclass LinearGen : public StochasticGen
6512396SRiken.Gohil@arm.com{
6612396SRiken.Gohil@arm.com
6712396SRiken.Gohil@arm.com  public:
6812396SRiken.Gohil@arm.com
6912396SRiken.Gohil@arm.com    /**
7012396SRiken.Gohil@arm.com     * Create a linear address sequence generator. Set
7112396SRiken.Gohil@arm.com     * min_period == max_period for a fixed inter-transaction
7212396SRiken.Gohil@arm.com     * time.
7312396SRiken.Gohil@arm.com     *
7412811Sandreas.sandberg@arm.com     * @param gen Traffic generator owning this sequence generator
7512396SRiken.Gohil@arm.com     * @param _duration duration of this state before transitioning
7612396SRiken.Gohil@arm.com     * @param start_addr Start address
7712396SRiken.Gohil@arm.com     * @param end_addr End address
7812396SRiken.Gohil@arm.com     * @param _blocksize Size used for transactions injected
7912396SRiken.Gohil@arm.com     * @param min_period Lower limit of random inter-transaction time
8012396SRiken.Gohil@arm.com     * @param max_period Upper limit of random inter-transaction time
8112396SRiken.Gohil@arm.com     * @param read_percent Percent of transactions that are reads
8212396SRiken.Gohil@arm.com     * @param data_limit Upper limit on how much data to read/write
8312396SRiken.Gohil@arm.com     */
8412811Sandreas.sandberg@arm.com    LinearGen(BaseTrafficGen &gen, Tick _duration,
8512396SRiken.Gohil@arm.com              Addr start_addr, Addr end_addr, Addr _blocksize,
8612396SRiken.Gohil@arm.com              Tick min_period, Tick max_period,
8712396SRiken.Gohil@arm.com              uint8_t read_percent, Addr data_limit)
8812811Sandreas.sandberg@arm.com        : StochasticGen(gen, _duration, start_addr, end_addr,
8912811Sandreas.sandberg@arm.com                        _blocksize, min_period, max_period, read_percent,
9012811Sandreas.sandberg@arm.com                        data_limit),
9112811Sandreas.sandberg@arm.com          nextAddr(0),
9212811Sandreas.sandberg@arm.com          dataManipulated(0)
9312396SRiken.Gohil@arm.com    { }
9412396SRiken.Gohil@arm.com
9512396SRiken.Gohil@arm.com    void enter();
9612396SRiken.Gohil@arm.com
9712396SRiken.Gohil@arm.com    PacketPtr getNextPacket();
9812396SRiken.Gohil@arm.com
9912396SRiken.Gohil@arm.com    Tick nextPacketTick(bool elastic, Tick delay) const;
10012396SRiken.Gohil@arm.com
10112396SRiken.Gohil@arm.com  private:
10212396SRiken.Gohil@arm.com    /** Address of next request */
10312396SRiken.Gohil@arm.com    Addr nextAddr;
10412396SRiken.Gohil@arm.com
10512396SRiken.Gohil@arm.com    /**
10612396SRiken.Gohil@arm.com     * Counter to determine the amount of data
10712396SRiken.Gohil@arm.com     * manipulated. Used to determine if we should continue
10812396SRiken.Gohil@arm.com     * generating requests.
10912396SRiken.Gohil@arm.com     */
11012396SRiken.Gohil@arm.com    Addr dataManipulated;
11112396SRiken.Gohil@arm.com};
11212396SRiken.Gohil@arm.com
11312396SRiken.Gohil@arm.com#endif
114