diff --git a/DRAMSys/library/src/controller/BankMachine.cpp b/DRAMSys/library/src/controller/BankMachine.cpp index 229d32e9..0264d2b0 100644 --- a/DRAMSys/library/src/controller/BankMachine.cpp +++ b/DRAMSys/library/src/controller/BankMachine.cpp @@ -107,9 +107,15 @@ void BankMachine::updateState(Command command) SC_REPORT_FATAL("BankMachine", "Unknown phase"); } -void BankMachine::forcePrecharge() +bool BankMachine::forcePrecharge() { - currentState = BmState::Precharged; + if (currentState != BmState::Precharged) + { + currentState = BmState::Precharged; + return true; + } + else + return false; } Row BankMachine::getOpenRow() diff --git a/DRAMSys/library/src/controller/BankMachine.h b/DRAMSys/library/src/controller/BankMachine.h index faa50fc0..57e7aa5b 100644 --- a/DRAMSys/library/src/controller/BankMachine.h +++ b/DRAMSys/library/src/controller/BankMachine.h @@ -62,7 +62,7 @@ public: sc_time startBankMachine(); std::pair getNextCommand(); void updateState(Command); - void forcePrecharge(); + bool forcePrecharge(); Row getOpenRow(); BmState getState(); diff --git a/DRAMSys/library/src/controller/ControllerNew.cpp b/DRAMSys/library/src/controller/ControllerNew.cpp index 0f657741..d6e9bba1 100644 --- a/DRAMSys/library/src/controller/ControllerNew.cpp +++ b/DRAMSys/library/src/controller/ControllerNew.cpp @@ -141,11 +141,12 @@ tlm_sync_enum ControllerNew::nb_transport_bw(tlm_generic_payload &trans, { PRINTDEBUGMESSAGE(name(), "[bw] " + phaseNameToString(phase) + " notification in " + delay.to_string()); - triggerEventQueueAfterDelay(delay); // TODO: Why do we always trigger the queue? + //triggerEventQueueAfterDelay(delay); // TODO: Why do we always trigger the queue? if (phase == END_RD || phase == END_WR) { std::pair element((sc_time_stamp() + delay), &trans); responseQueue.push(element); + triggerEventQueueAfterDelay(delay); } return TLM_ACCEPTED; } @@ -206,18 +207,25 @@ void ControllerNew::controllerMethod() // (5) Choose one request and send it to DRAM std::pair result; + // (5.1) Check for refresh command (PREA or REFA) result = refreshManager->getNextCommand(); - if (result.second != nullptr) // do PREA or REFA + if (result.second != nullptr) { sc_time delay = refreshManager->updateState(); triggerEventQueueAfterDelay(delay); if (result.first == Command::PREA) { + bool forcedPrecharges = false; for (auto it : bankMachines) - it.second->forcePrecharge(); + forcedPrecharges |= it.second->forcePrecharge(); + // Send the PREA only if at least one bank was precharged + if (forcedPrecharges) + sendToDram(result.first, result.second); } - sendToDram(result.first, result.second); + else + sendToDram(result.first, result.second); } + // (5.2) Check for other commands (PRE, ACT, RD or WR) else { std::vector> readyCommands; diff --git a/DRAMSys/library/src/controller/RefreshManager.cpp b/DRAMSys/library/src/controller/RefreshManager.cpp index 5c7a79ec..6e616556 100644 --- a/DRAMSys/library/src/controller/RefreshManager.cpp +++ b/DRAMSys/library/src/controller/RefreshManager.cpp @@ -1,3 +1,37 @@ +/* + * Copyright (c) 2019, University of Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Lukas Steiner + */ + #include "RefreshManager.h" #include "../common/dramExtensions.h" #include "core/configuration/Configuration.h" diff --git a/DRAMSys/library/src/controller/RefreshManager.h b/DRAMSys/library/src/controller/RefreshManager.h index 2246b4e5..dc150e80 100644 --- a/DRAMSys/library/src/controller/RefreshManager.h +++ b/DRAMSys/library/src/controller/RefreshManager.h @@ -1,3 +1,37 @@ +/* + * Copyright (c) 2019, University of Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Lukas Steiner + */ + #ifndef REFRESHMANAGER_H #define REFRESHMANAGER_H