1/* 2 * Copyright (c) 2012-2014, TU Delft 3 * Copyright (c) 2012-2014, TU Eindhoven 4 * Copyright (c) 2012-2016, TU Kaiserslautern 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * 3. Neither the name of the copyright holder nor the names of its 19 * contributors may be used to endorse or promote products derived from 20 * this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 23 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * Authors: Subash Kannoth, Matthias Jung, Éder F. Zulian 35 * 36 */ 37 38#include "MemBankWiseParams.h" 39 40using namespace Data; 41/** 42 * Sets the default bankwise configurations. 43 */ 44MemBankWiseParams::MemBankWiseParams(): 45 bwPowerFactRho(100), 46 bwPowerFactSigma(100), 47 bwMode(false), 48 flgPASR(false) 49{ 50} 51/** 52 * Sets all the bankwise parameters required in bankwise mode 53 */ 54MemBankWiseParams::MemBankWiseParams(int64_t factRho, int64_t factSigma, 55 bool hasPASR, int64_t pasrMode, 56 bool opMode, unsigned nbrofBanks) 57{ 58 59 bwPowerFactRho = factRho; 60 bwPowerFactSigma = factSigma; 61 bwMode = opMode; 62 flgPASR = hasPASR; 63 /////////////////////////////////////////////////////////// 64 // Activate banks for self refresh based on the PASR mode 65 // ACTIVE - X 66 // NOT ACTIVE - 0 67 /////////////////////////////////////////////////////////// 68 switch(pasrMode){ 69 70 case(PASR_0):{ 71 // PASR MODE 0 72 // FULL ARRAY 73 // |X X X X | 74 // |X X X X | 75 activeBanks.resize(nbrofBanks); 76 std::iota(activeBanks.begin(), activeBanks.end(), 0); 77 break; 78 } 79 case(PASR_1):{ 80 // PASR MODE 1 81 // (1/2) ARRAY 82 // |X X X X | 83 // |0 0 0 0 | 84 activeBanks.resize(nbrofBanks - 4); 85 std::iota(activeBanks.begin(), activeBanks.end(), 0); 86 break; 87 } 88 case(PASR_2):{ 89 // PASR MODE 2 90 // (1/4) ARRAY 91 // |X X 0 0 | 92 // |0 0 0 0 | 93 activeBanks.resize(nbrofBanks - 6); 94 std::iota(activeBanks.begin(), activeBanks.end(), 0); 95 break; 96 } 97 case(PASR_3):{ 98 // PASR MODE 3 99 // (1/8) ARRAY 100 // |X 0 0 0 | 101 // |0 0 0 0 | 102 activeBanks.resize(nbrofBanks - 7); 103 std::iota(activeBanks.begin(), activeBanks.end(), 0); 104 break; 105 } 106 case(PASR_4):{ 107 // PASR MODE 4 108 // (3/4) ARRAY 109 // |0 0 X X | 110 // |X X X X | 111 activeBanks.resize(nbrofBanks - 2); 112 std::iota(activeBanks.begin(), activeBanks.end(), 2); 113 break; 114 } 115 case(PASR_5):{ 116 // PASR MODE 5 117 // (1/2) ARRAY 118 // |0 0 0 0 | 119 // |X X X X | 120 activeBanks.resize(nbrofBanks - 4); 121 std::iota(activeBanks.begin(), activeBanks.end(), 4); 122 break; 123 } 124 case(PASR_6):{ 125 // PASR MODE 6 126 // (1/4) ARRAY 127 // |0 0 0 0 | 128 // |0 0 X X | 129 activeBanks.resize(nbrofBanks - 6); 130 std::iota(activeBanks.begin(), activeBanks.end(), 6); 131 break; 132 } 133 case(PASR_7):{ 134 // PASR MODE 7 135 // (1/8) ARRAY 136 // |0 0 0 0 | 137 // |0 0 0 X | 138 activeBanks.resize(nbrofBanks - 7); 139 std::iota(activeBanks.begin(), activeBanks.end(), 7); 140 break; 141 } 142 default:{ 143 // PASR MODE 0 144 // FULL ARRAY 145 // |X X X X | 146 // |X X X X | 147 activeBanks.resize(nbrofBanks); 148 std::iota(activeBanks.begin(), activeBanks.end(), 0); 149 break; 150 } 151 } 152} 153 154/** 155 * Returns true if the given bank is active under the current PASR mode. 156 */ 157bool MemBankWiseParams::isBankActiveInPasr(const unsigned bankIdx) const 158{ 159 return (std::find(activeBanks.begin(), activeBanks.end(), bankIdx) 160 != activeBanks.end()); 161} 162