dram_gen.hh revision 12396
112396SRiken.Gohil@arm.com/* 212396SRiken.Gohil@arm.com * Copyright (c) 2012-2013, 2017 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 DRAM generator for issuing variable page 4612396SRiken.Gohil@arm.com * hit length requests and bank utilisation. 4712396SRiken.Gohil@arm.com */ 4812396SRiken.Gohil@arm.com 4912396SRiken.Gohil@arm.com#ifndef __CPU_TRAFFIC_GEN_DRAM_GEN_HH__ 5012396SRiken.Gohil@arm.com#define __CPU_TRAFFIC_GEN_DRAM_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 "mem/packet.hh" 5512396SRiken.Gohil@arm.com#include "proto/protoio.hh" 5612396SRiken.Gohil@arm.com#include "random_gen.hh" 5712396SRiken.Gohil@arm.com 5812396SRiken.Gohil@arm.com/** 5912396SRiken.Gohil@arm.com * DRAM specific generator is for issuing request with variable page 6012396SRiken.Gohil@arm.com * hit length and bank utilization. Currently assumes a single 6112396SRiken.Gohil@arm.com * channel configuration. 6212396SRiken.Gohil@arm.com */ 6312396SRiken.Gohil@arm.comclass DramGen : public RandomGen 6412396SRiken.Gohil@arm.com{ 6512396SRiken.Gohil@arm.com 6612396SRiken.Gohil@arm.com public: 6712396SRiken.Gohil@arm.com 6812396SRiken.Gohil@arm.com /** 6912396SRiken.Gohil@arm.com * Create a DRAM address sequence generator. 7012396SRiken.Gohil@arm.com * 7112396SRiken.Gohil@arm.com * @param _name Name to use for status and debug 7212396SRiken.Gohil@arm.com * @param master_id MasterID set on each request 7312396SRiken.Gohil@arm.com * @param _duration duration of this state before transitioning 7412396SRiken.Gohil@arm.com * @param start_addr Start address 7512396SRiken.Gohil@arm.com * @param end_addr End address 7612396SRiken.Gohil@arm.com * @param _blocksize Size used for transactions injected 7712396SRiken.Gohil@arm.com * @param min_period Lower limit of random inter-transaction time 7812396SRiken.Gohil@arm.com * @param max_period Upper limit of random inter-transaction time 7912396SRiken.Gohil@arm.com * @param read_percent Percent of transactions that are reads 8012396SRiken.Gohil@arm.com * @param data_limit Upper limit on how much data to read/write 8112396SRiken.Gohil@arm.com * @param num_seq_pkts Number of packets per stride, each of _blocksize 8212396SRiken.Gohil@arm.com * @param page_size Page size (bytes) used in the DRAM 8312396SRiken.Gohil@arm.com * @param nbr_of_banks_DRAM Total number of banks in DRAM 8412396SRiken.Gohil@arm.com * @param nbr_of_banks_util Number of banks to utilized, 8512396SRiken.Gohil@arm.com * for N banks, we will use banks: 0->(N-1) 8612396SRiken.Gohil@arm.com * @param addr_mapping Address mapping to be used, 8712396SRiken.Gohil@arm.com * 0: RoCoRaBaCh, 1: RoRaBaCoCh/RoRaBaChCo 8812396SRiken.Gohil@arm.com * assumes single channel system 8912396SRiken.Gohil@arm.com */ 9012396SRiken.Gohil@arm.com DramGen(const std::string& _name, MasterID master_id, Tick _duration, 9112396SRiken.Gohil@arm.com Addr start_addr, Addr end_addr, Addr _blocksize, 9212396SRiken.Gohil@arm.com Tick min_period, Tick max_period, 9312396SRiken.Gohil@arm.com uint8_t read_percent, Addr data_limit, 9412396SRiken.Gohil@arm.com unsigned int num_seq_pkts, unsigned int page_size, 9512396SRiken.Gohil@arm.com unsigned int nbr_of_banks_DRAM, unsigned int nbr_of_banks_util, 9612396SRiken.Gohil@arm.com unsigned int addr_mapping, 9712396SRiken.Gohil@arm.com unsigned int nbr_of_ranks) 9812396SRiken.Gohil@arm.com : RandomGen(_name, master_id, _duration, start_addr, end_addr, 9912396SRiken.Gohil@arm.com _blocksize, min_period, max_period, read_percent, data_limit), 10012396SRiken.Gohil@arm.com numSeqPkts(num_seq_pkts), countNumSeqPkts(0), addr(0), 10112396SRiken.Gohil@arm.com isRead(true), pageSize(page_size), 10212396SRiken.Gohil@arm.com pageBits(floorLog2(page_size / _blocksize)), 10312396SRiken.Gohil@arm.com bankBits(floorLog2(nbr_of_banks_DRAM)), 10412396SRiken.Gohil@arm.com blockBits(floorLog2(_blocksize)), 10512396SRiken.Gohil@arm.com nbrOfBanksDRAM(nbr_of_banks_DRAM), 10612396SRiken.Gohil@arm.com nbrOfBanksUtil(nbr_of_banks_util), addrMapping(addr_mapping), 10712396SRiken.Gohil@arm.com rankBits(floorLog2(nbr_of_ranks)), 10812396SRiken.Gohil@arm.com nbrOfRanks(nbr_of_ranks) 10912396SRiken.Gohil@arm.com { 11012396SRiken.Gohil@arm.com if (addrMapping != 1 && addrMapping != 0) { 11112396SRiken.Gohil@arm.com addrMapping = 1; 11212396SRiken.Gohil@arm.com warn("Unknown address mapping specified, using RoRaBaCoCh\n"); 11312396SRiken.Gohil@arm.com } 11412396SRiken.Gohil@arm.com } 11512396SRiken.Gohil@arm.com 11612396SRiken.Gohil@arm.com PacketPtr getNextPacket(); 11712396SRiken.Gohil@arm.com 11812396SRiken.Gohil@arm.com /** Insert bank, rank, and column bits into packed 11912396SRiken.Gohil@arm.com * address to create address for 1st command in a 12012396SRiken.Gohil@arm.com * series 12112396SRiken.Gohil@arm.com * @param new_bank Bank number of next packet series 12212396SRiken.Gohil@arm.com * @param new_rank Rank value of next packet series 12312396SRiken.Gohil@arm.com */ 12412396SRiken.Gohil@arm.com void genStartAddr(unsigned int new_bank , unsigned int new_rank); 12512396SRiken.Gohil@arm.com 12612396SRiken.Gohil@arm.com protected: 12712396SRiken.Gohil@arm.com 12812396SRiken.Gohil@arm.com /** Number of sequential DRAM packets to be generated per cpu request */ 12912396SRiken.Gohil@arm.com const unsigned int numSeqPkts; 13012396SRiken.Gohil@arm.com 13112396SRiken.Gohil@arm.com /** Track number of sequential packets generated for a request */ 13212396SRiken.Gohil@arm.com unsigned int countNumSeqPkts; 13312396SRiken.Gohil@arm.com 13412396SRiken.Gohil@arm.com /** Address of request */ 13512396SRiken.Gohil@arm.com Addr addr; 13612396SRiken.Gohil@arm.com 13712396SRiken.Gohil@arm.com /** Remember type of requests to be generated in series */ 13812396SRiken.Gohil@arm.com bool isRead; 13912396SRiken.Gohil@arm.com 14012396SRiken.Gohil@arm.com /** Page size of DRAM */ 14112396SRiken.Gohil@arm.com const unsigned int pageSize; 14212396SRiken.Gohil@arm.com 14312396SRiken.Gohil@arm.com /** Number of page bits in DRAM address */ 14412396SRiken.Gohil@arm.com const unsigned int pageBits; 14512396SRiken.Gohil@arm.com 14612396SRiken.Gohil@arm.com /** Number of bank bits in DRAM address*/ 14712396SRiken.Gohil@arm.com const unsigned int bankBits; 14812396SRiken.Gohil@arm.com 14912396SRiken.Gohil@arm.com /** Number of block bits in DRAM address */ 15012396SRiken.Gohil@arm.com const unsigned int blockBits; 15112396SRiken.Gohil@arm.com 15212396SRiken.Gohil@arm.com /** Number of banks in DRAM */ 15312396SRiken.Gohil@arm.com const unsigned int nbrOfBanksDRAM; 15412396SRiken.Gohil@arm.com 15512396SRiken.Gohil@arm.com /** Number of banks to be utilized for a given configuration */ 15612396SRiken.Gohil@arm.com const unsigned int nbrOfBanksUtil; 15712396SRiken.Gohil@arm.com 15812396SRiken.Gohil@arm.com /** Address mapping to be used */ 15912396SRiken.Gohil@arm.com unsigned int addrMapping; 16012396SRiken.Gohil@arm.com 16112396SRiken.Gohil@arm.com /** Number of rank bits in DRAM address*/ 16212396SRiken.Gohil@arm.com const unsigned int rankBits; 16312396SRiken.Gohil@arm.com 16412396SRiken.Gohil@arm.com /** Number of ranks to be utilized for a given configuration */ 16512396SRiken.Gohil@arm.com const unsigned int nbrOfRanks; 16612396SRiken.Gohil@arm.com 16712396SRiken.Gohil@arm.com}; 16812396SRiken.Gohil@arm.com 16912396SRiken.Gohil@arm.com#endif 170