112919Sgiacomo.travaglini@arm.com/* 212919Sgiacomo.travaglini@arm.com * Copyright (c) 2018 ARM Limited 312919Sgiacomo.travaglini@arm.com * All rights reserved 412919Sgiacomo.travaglini@arm.com * 512919Sgiacomo.travaglini@arm.com * The license below extends only to copyright in the software and shall 612919Sgiacomo.travaglini@arm.com * not be construed as granting a license to any other intellectual 712919Sgiacomo.travaglini@arm.com * property including but not limited to intellectual property relating 812919Sgiacomo.travaglini@arm.com * to a hardware implementation of the functionality of the software 912919Sgiacomo.travaglini@arm.com * licensed here under. You may use the software subject to the license 1012919Sgiacomo.travaglini@arm.com * terms below provided that you ensure that this notice is replicated 1112919Sgiacomo.travaglini@arm.com * unmodified and in its entirety in all distributions of the software, 1212919Sgiacomo.travaglini@arm.com * modified or unmodified, in source code or in binary form. 1312919Sgiacomo.travaglini@arm.com * 1412919Sgiacomo.travaglini@arm.com * Redistribution and use in source and binary forms, with or without 1512919Sgiacomo.travaglini@arm.com * modification, are permitted provided that the following conditions are 1612919Sgiacomo.travaglini@arm.com * met: redistributions of source code must retain the above copyright 1712919Sgiacomo.travaglini@arm.com * notice, this list of conditions and the following disclaimer; 1812919Sgiacomo.travaglini@arm.com * redistributions in binary form must reproduce the above copyright 1912919Sgiacomo.travaglini@arm.com * notice, this list of conditions and the following disclaimer in the 2012919Sgiacomo.travaglini@arm.com * documentation and/or other materials provided with the distribution; 2112919Sgiacomo.travaglini@arm.com * neither the name of the copyright holders nor the names of its 2212919Sgiacomo.travaglini@arm.com * contributors may be used to endorse or promote products derived from 2312919Sgiacomo.travaglini@arm.com * this software without specific prior written permission. 2412919Sgiacomo.travaglini@arm.com * 2512919Sgiacomo.travaglini@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2612919Sgiacomo.travaglini@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2712919Sgiacomo.travaglini@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2812919Sgiacomo.travaglini@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2912919Sgiacomo.travaglini@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3012919Sgiacomo.travaglini@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3112919Sgiacomo.travaglini@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3212919Sgiacomo.travaglini@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3312919Sgiacomo.travaglini@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3412919Sgiacomo.travaglini@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3512919Sgiacomo.travaglini@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3612919Sgiacomo.travaglini@arm.com * 3712919Sgiacomo.travaglini@arm.com * Authors: Giacomo Travaglini 3812919Sgiacomo.travaglini@arm.com */ 3912919Sgiacomo.travaglini@arm.com 4012919Sgiacomo.travaglini@arm.com#include "stream_gen.hh" 4112919Sgiacomo.travaglini@arm.com 4212919Sgiacomo.travaglini@arm.com#include "base/random.hh" 4312919Sgiacomo.travaglini@arm.com 4412919Sgiacomo.travaglini@arm.comStreamGen* 4512919Sgiacomo.travaglini@arm.comStreamGen::create(const BaseTrafficGenParams *p) 4612919Sgiacomo.travaglini@arm.com{ 4712919Sgiacomo.travaglini@arm.com switch (p->stream_gen) { 4812919Sgiacomo.travaglini@arm.com case Enums::fixed: 4912919Sgiacomo.travaglini@arm.com return new FixedStreamGen(p); 5012919Sgiacomo.travaglini@arm.com case Enums::random: 5112919Sgiacomo.travaglini@arm.com return new RandomStreamGen(p); 5212919Sgiacomo.travaglini@arm.com case Enums::none: 5312919Sgiacomo.travaglini@arm.com default: 5412919Sgiacomo.travaglini@arm.com return nullptr; 5512919Sgiacomo.travaglini@arm.com } 5612919Sgiacomo.travaglini@arm.com} 5712919Sgiacomo.travaglini@arm.com 5812919Sgiacomo.travaglini@arm.comuint32_t 5912919Sgiacomo.travaglini@arm.comRandomStreamGen::randomPick(const std::vector<uint32_t> &svec) 6012919Sgiacomo.travaglini@arm.com{ 6112919Sgiacomo.travaglini@arm.com // Pick a random entry in the vector of IDs 6212919Sgiacomo.travaglini@arm.com return svec[random_mt.random<size_t>(0, svec.size()-1)]; 6312919Sgiacomo.travaglini@arm.com} 64