Fixed "PREA if all banks are precharged" issue.

This commit is contained in:
Lukas Steiner (2)
2019-08-09 10:35:17 +02:00
parent 88f57dd88f
commit 1bd322e576
5 changed files with 89 additions and 7 deletions

View File

@@ -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()

View File

@@ -62,7 +62,7 @@ public:
sc_time startBankMachine();
std::pair<Command, tlm_generic_payload *> getNextCommand();
void updateState(Command);
void forcePrecharge();
bool forcePrecharge();
Row getOpenRow();
BmState getState();

View File

@@ -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<sc_time, tlm_generic_payload *> 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<Command, tlm_generic_payload *> 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<std::pair<Command, tlm_generic_payload *>> readyCommands;

View File

@@ -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"

View File

@@ -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