BankedArray.hh revision 9184
1767SN/A/* 21762SN/A * Copyright (c) 2012 Advanced Micro Devices, Inc. 3767SN/A * All rights reserved. 4767SN/A * 5767SN/A * Redistribution and use in source and binary forms, with or without 6767SN/A * modification, are permitted provided that the following conditions are 7767SN/A * met: redistributions of source code must retain the above copyright 8767SN/A * notice, this list of conditions and the following disclaimer; 9767SN/A * redistributions in binary form must reproduce the above copyright 10767SN/A * notice, this list of conditions and the following disclaimer in the 11767SN/A * documentation and/or other materials provided with the distribution; 12767SN/A * neither the name of the copyright holders nor the names of its 13767SN/A * contributors may be used to endorse or promote products derived from 14767SN/A * this software without specific prior written permission. 15767SN/A * 16767SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17767SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18767SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19767SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20767SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21767SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22767SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23767SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24767SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25767SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26767SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A * 282665SN/A * Author: Brad Beckmann 29767SN/A * 30767SN/A */ 31779SN/A 32779SN/A#ifndef __MEM_RUBY_SYSTEM_BANKEDARRAY_HH__ 33798SN/A#define __MEM_RUBY_SYSTEM_BANKEDARRAY_HH__ 34798SN/A 35779SN/A#include <vector> 36779SN/A 371401SN/A#include "mem/ruby/common/TypeDefines.hh" 381401SN/A#include "sim/eventq.hh" 39767SN/A 40806SN/A 415034Smilesck@eecs.umich.edu 42767SN/Aclass BankedArray : public EventManager 43848SN/A{ 44767SN/Aprivate: 45768SN/A unsigned int banks; 46806SN/A Cycles accessLatency; 47806SN/A unsigned int bankBits; 48779SN/A unsigned int startIndexBit; 49779SN/A 50779SN/A //std::vector<bool> busyBanks; 51779SN/A 52779SN/A class TickEvent : public Event 53779SN/A { 54779SN/A public: 55767SN/A TickEvent() : Event() {} 56806SN/A void process() {} 57767SN/A Index idx; 58767SN/A Tick startAccess; 59779SN/A }; 601290SN/A friend class TickEvent; 61767SN/A 62806SN/A // If the tick event is scheduled then the bank is busy 63806SN/A // otherwise, schedule the event and wait for it to complete 641113SN/A std::vector<TickEvent> busyBanks; 65806SN/A 66806SN/A unsigned int mapIndexToBank(Index idx); 67767SN/A 68779SN/Apublic: 691401SN/A BankedArray(unsigned int banks, Cycles accessLatency, unsigned int startIndexBit); 701401SN/A 711401SN/A // Note: We try the access based on the cache index, not the address 72767SN/A // This is so we don't get aliasing on blocks being replaced 73779SN/A bool tryAccess(Index idx); 74779SN/A 751401SN/A}; 761401SN/A 771401SN/A#endif 78768SN/A