Added: PrechargeChecker, ActivateChecker, ReadChecker, WriteChecker
Implemented: ActivateChecker Added functionality to Bus (InternalScheduler)
This commit is contained in:
@@ -60,9 +60,7 @@
|
|||||||
</folderInfo>
|
</folderInfo>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings">
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
<externalSettings containerId="scheduler;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier"/>
|
|
||||||
</storageModule>
|
|
||||||
</cconfiguration>
|
</cconfiguration>
|
||||||
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.1948932292">
|
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.1948932292">
|
||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1948932292" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1948932292" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||||
|
|||||||
2
DRAM/.settings/org.eclipse.ltk.core.refactoring.prefs
Normal file
2
DRAM/.settings/org.eclipse.ltk.core.refactoring.prefs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <set>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ bool operator !=(const Bank& lhs, const Bank& rhs)
|
|||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator <(const Bank& lhs, const Bank& rhs)
|
||||||
|
{
|
||||||
|
return lhs.ID() < rhs.ID();
|
||||||
|
}
|
||||||
|
|
||||||
const Row Row::NO_ROW;
|
const Row Row::NO_ROW;
|
||||||
|
|
||||||
bool operator ==(const Row& lhs, const Row& rhs)
|
bool operator ==(const Row& lhs, const Row& rhs)
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ bool operator==(const Thread &lhs, const Thread &rhs);
|
|||||||
bool operator!=(const Thread &lhs, const Thread &rhs);
|
bool operator!=(const Thread &lhs, const Thread &rhs);
|
||||||
bool operator==(const Bank &lhs, const Bank &rhs);
|
bool operator==(const Bank &lhs, const Bank &rhs);
|
||||||
bool operator!=(const Bank &lhs, const Bank &rhs);
|
bool operator!=(const Bank &lhs, const Bank &rhs);
|
||||||
|
bool operator<(const Bank &lhs, const Bank &rhs);
|
||||||
bool operator==(const Row &lhs, const Row &rhs);
|
bool operator==(const Row &lhs, const Row &rhs);
|
||||||
bool operator!=(const Row &lhs, const Row &rhs);
|
bool operator!=(const Row &lhs, const Row &rhs);
|
||||||
bool operator==(const Column &lhs, const Column &rhs);
|
bool operator==(const Column &lhs, const Column &rhs);
|
||||||
|
|||||||
@@ -15,10 +15,13 @@ namespace controller{
|
|||||||
|
|
||||||
struct Configuration
|
struct Configuration
|
||||||
{
|
{
|
||||||
unsigned int numberOfBanks;
|
Configuration():Timings(numberOfBanks){}
|
||||||
|
unsigned int numberOfBanks = 8;
|
||||||
TimingConfiguration Timings;
|
TimingConfiguration Timings;
|
||||||
|
|
||||||
bool RefreshBankwise = false;
|
bool RefreshBankwise = false;
|
||||||
|
|
||||||
|
unsigned int nActivate = 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace controller */
|
} /* namespace controller */
|
||||||
|
|||||||
@@ -9,5 +9,21 @@
|
|||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
|
/*Controller::Controller()
|
||||||
|
{
|
||||||
|
//create command scheduler
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller::~Controller()
|
||||||
|
{
|
||||||
|
//delete command scheduler
|
||||||
|
}*/
|
||||||
|
|
||||||
|
bool Controller::schedule(sc_time currentTime,
|
||||||
|
tlm::tlm_generic_payload* externalTransaction)
|
||||||
|
{
|
||||||
|
bus.cleanUpPendingBusCommands(currentTime);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace controller */
|
} /* namespace controller */
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,13 @@
|
|||||||
|
|
||||||
#include <tlm.h>
|
#include <tlm.h>
|
||||||
#include "scheduling/CommandSequenceGenerator.h"
|
#include "scheduling/CommandSequenceGenerator.h"
|
||||||
#include "scheduling/InternalScheduler.h"
|
#include "scheduling/CommandBus.h"
|
||||||
#include "Configuration.h"
|
#include "Configuration.h"
|
||||||
#include "scheduling/CommandSequenceScheduler.h"
|
#include "scheduling/CommandSequenceScheduler.h"
|
||||||
#include "refresh/RefreshManager.h"
|
#include "refresh/RefreshManager.h"
|
||||||
#include "powerdown/PowerDownManager.h"
|
#include "powerdown/PowerDownManager.h"
|
||||||
|
#include <map>
|
||||||
|
#include "scheduling/checker/ICommandChecker.h"
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
@@ -24,17 +26,18 @@ public:
|
|||||||
Controller();
|
Controller();
|
||||||
virtual ~Controller();
|
virtual ~Controller();
|
||||||
|
|
||||||
bool schedule(tlm::tlm_generic_payload* externalTransaction); //return TLM status??
|
bool schedule( sc_time currentTime, tlm::tlm_generic_payload* externalTransaction); //return TLM status??
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Configuration config;
|
Configuration config;
|
||||||
ControllerState state;
|
ControllerState state;
|
||||||
|
|
||||||
CommandSequenceGenerator commandGenerator;
|
CommandSequenceGenerator commandGenerator;
|
||||||
|
std::map<Command, ICommandChecker*> commandScheduler;
|
||||||
CommandSequenceScheduler commandSequenceScheduler;
|
CommandSequenceScheduler commandSequenceScheduler;
|
||||||
RefreshManager refreshManager;
|
RefreshManager refreshManager;
|
||||||
PowerDownManager powerDownManager;
|
PowerDownManager powerDownManager;
|
||||||
InternalScheduler internalScheduler;
|
CommandBus bus;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace controller */
|
} /* namespace controller */
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#define TIMINGS_H_
|
#define TIMINGS_H_
|
||||||
|
|
||||||
#include <systemc.h>
|
#include <systemc.h>
|
||||||
|
#include "core/utils/Utils.h"
|
||||||
|
|
||||||
namespace controller{
|
namespace controller{
|
||||||
|
|
||||||
@@ -21,9 +22,8 @@ struct RefreshTiming
|
|||||||
|
|
||||||
struct TimingConfiguration
|
struct TimingConfiguration
|
||||||
{
|
{
|
||||||
TimingConfiguration()
|
TimingConfiguration(unsigned int numberOfBanks)
|
||||||
{
|
{
|
||||||
unsigned int numberOfBanks = 8;
|
|
||||||
for (unsigned int i = 0; i < numberOfBanks; ++i)
|
for (unsigned int i = 0; i < numberOfBanks; ++i)
|
||||||
{
|
{
|
||||||
sc_time tRFC = 18*clk;
|
sc_time tRFC = 18*clk;
|
||||||
@@ -35,9 +35,14 @@ struct TimingConfiguration
|
|||||||
sc_time clk = sc_time(6.0, SC_NS); // 166MHz
|
sc_time clk = sc_time(6.0, SC_NS); // 166MHz
|
||||||
|
|
||||||
|
|
||||||
sc_time tRP = 3*clk;
|
sc_time tRP = 3*clk; //precharge-time (pre -> act same bank)
|
||||||
sc_time tRAS = 6*clk;
|
sc_time tRAS = 6*clk; //active-time (act -> pre same bank)
|
||||||
sc_time tRC = tRP + tRAS;
|
|
||||||
|
sc_time tRC = tRP + tRAS; //RAS-cycle-time (min time bw 2 succesive ACT to same bank)
|
||||||
|
sc_time tRRD = 2*clk; //(min time bw 2 succesive ACT to different banks)
|
||||||
|
sc_time tRCD = 5*clk; //act -> read/write
|
||||||
|
|
||||||
|
sc_time tTAW = clkAlign(sc_time(50, SC_NS), clk, Alignment::UP);
|
||||||
|
|
||||||
//Refresh
|
//Refresh
|
||||||
//sc_time tRFC = 18*clk;
|
//sc_time tRFC = 18*clk;
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
/*
|
|
||||||
* Utils.cpp
|
|
||||||
*
|
|
||||||
* Created on: Mar 12, 2014
|
|
||||||
* Author: jonny
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
using namespace common;
|
|
||||||
|
|
||||||
unsigned int getStartAddress(Bank bank)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
* Utils.h
|
|
||||||
*
|
|
||||||
* Created on: Mar 10, 2014
|
|
||||||
* Author: jonny
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef UTILS_H_
|
|
||||||
#define UTILS_H_
|
|
||||||
|
|
||||||
#include "common/dramextension.h"
|
|
||||||
|
|
||||||
unsigned int getStartAddress(common::Bank bank);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* UTILS_H_ */
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <systemc.h>
|
#include <systemc.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "core/scheduling/InternalScheduler.h"
|
#include "core/scheduling/CommandBus.h"
|
||||||
#include "core/Configuration.h"
|
#include "core/Configuration.h"
|
||||||
#include "core/scheduling/ScheduledCommand.h"
|
#include "core/scheduling/ScheduledCommand.h"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/refresh/RefreshManager.h>
|
#include <core/refresh/RefreshManager.h>
|
||||||
#include "core/Utils.h"
|
#include "core/utils/Utils.h"
|
||||||
|
|
||||||
using namespace common;
|
using namespace common;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ RefreshManager::RefreshManager(const RefreshTiming& refreshTiming,
|
|||||||
RefreshManager::RefreshManager(const RefreshTiming& refreshTiming,
|
RefreshManager::RefreshManager(const RefreshTiming& refreshTiming,
|
||||||
IInternalScheduler& internalScheduler, Bank bank) :
|
IInternalScheduler& internalScheduler, Bank bank) :
|
||||||
refreshTiming(refreshTiming), internalScheduler(internalScheduler), nextPlannedRefresh(
|
refreshTiming(refreshTiming), internalScheduler(internalScheduler), nextPlannedRefresh(
|
||||||
refreshTransaction, Command::Refresh, sc_time(65, SC_MS), refreshTiming.tRFC)
|
refreshTransaction, Command::Refresh, SC_ZERO_TIME, refreshTiming.tRFC)
|
||||||
{
|
{
|
||||||
setupTransaction(refreshTransaction, bank);
|
setupTransaction(refreshTransaction, bank);
|
||||||
planNextRefresh(nextPlannedRefresh);
|
planNextRefresh(nextPlannedRefresh);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace controller {
|
|||||||
|
|
||||||
enum class Command {Precharge, PrechargeAll, Activate, Read, Write, ReadA, WriteA, Refresh};
|
enum class Command {Precharge, PrechargeAll, Activate, Read, Write, ReadA, WriteA, Refresh};
|
||||||
|
|
||||||
|
typedef std::vector<Command> CommandSequence;
|
||||||
|
|
||||||
} /* namespace controller */
|
} /* namespace controller */
|
||||||
|
|
||||||
#endif /* COMMAND_H_ */
|
#endif /* COMMAND_H_ */
|
||||||
|
|||||||
76
DRAM/src/core/scheduling/CommandBus.cpp
Normal file
76
DRAM/src/core/scheduling/CommandBus.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* InternalScheduler.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 9, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CommandBus.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
void CommandBus::scheduleCommand(const ScheduledCommand& command)
|
||||||
|
{
|
||||||
|
if(command.getCommand() == Command::Refresh)
|
||||||
|
{
|
||||||
|
scheduleRefresh(command);
|
||||||
|
lastCommandsOnBus.at(Command::Activate).at(command.getBank()) = command.getStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pendingBusCommands.count(command.getStart()) == 0);
|
||||||
|
pendingBusCommands.insert(command.getStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandBus::scheduleTrigger(const Trigger command, sc_time time)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_time CommandBus::getLastCommand(Command command, common::Bank bank)
|
||||||
|
{
|
||||||
|
return lastCommandsOnBus[command][bank];
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_time CommandBus::getLastCommand(Command command)
|
||||||
|
{
|
||||||
|
sc_time max;
|
||||||
|
for(unsigned int i = 0; i < config.numberOfBanks; ++i)
|
||||||
|
{
|
||||||
|
sc_time current = getLastCommand(command, common::Bank(i));
|
||||||
|
if(current > max)
|
||||||
|
max = current;
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CommandBus::notYetScheduled(Command command) const
|
||||||
|
{
|
||||||
|
return (lastCommandsOnBus.count(command) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_time CommandBus::getEarliestStartTime(const ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
sc_time newStart = command.getStart();
|
||||||
|
|
||||||
|
std::set<sc_time>::iterator it = pendingBusCommands.begin();
|
||||||
|
while(it != pendingBusCommands.end() && *it <= newStart)
|
||||||
|
{
|
||||||
|
if(*it == newStart)
|
||||||
|
newStart += config.Timings.clk;
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
return newStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandBus::cleanUpPendingBusCommands(sc_time currentTime)
|
||||||
|
{
|
||||||
|
pendingBusCommands.erase(pendingBusCommands.begin(), pendingBusCommands.lower_bound(currentTime));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandBus::scheduleRefresh(const ScheduledCommand& command)
|
||||||
|
{
|
||||||
|
state.bankStates.closeAllRowBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
45
DRAM/src/core/scheduling/CommandBus.h
Normal file
45
DRAM/src/core/scheduling/CommandBus.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* InternalScheduler.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 6, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INTERNALSCHEDULER_H_
|
||||||
|
#define INTERNALSCHEDULER_H_
|
||||||
|
|
||||||
|
#include "CommandSchedule.h"
|
||||||
|
#include "core/ControllerState.h"
|
||||||
|
#include "core/scheduling/Trigger.h"
|
||||||
|
#include "IInternalScheduler.h"
|
||||||
|
#include "core/Configuration.h"
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
namespace controller{
|
||||||
|
|
||||||
|
class CommandBus : public IInternalScheduler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CommandBus(controller::ControllerState& state, const Configuration& config) : state(state), config(config) {}
|
||||||
|
virtual void scheduleCommand(const ScheduledCommand& command);
|
||||||
|
virtual void scheduleTrigger(const Trigger trigger, sc_time time);
|
||||||
|
|
||||||
|
void cleanUpPendingBusCommands(sc_time currentTime);
|
||||||
|
|
||||||
|
sc_time getLastCommand(Command command, common::Bank bank);//TODO simple way to make it const?
|
||||||
|
sc_time getLastCommand(Command command);
|
||||||
|
bool notYetScheduled(Command command) const;
|
||||||
|
sc_time getEarliestStartTime(const ScheduledCommand& command) const;
|
||||||
|
private:
|
||||||
|
controller::ControllerState& state;
|
||||||
|
const Configuration& config;
|
||||||
|
|
||||||
|
std::map<Command,std::map<common::Bank, sc_time>> lastCommandsOnBus;
|
||||||
|
void scheduleRefresh(const controller::ScheduledCommand& command);
|
||||||
|
|
||||||
|
std::set<sc_time> pendingBusCommands;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* INTERNALSCHEDULER_H_ */
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "common/dramextension.h"
|
#include "common/dramextension.h"
|
||||||
#include "ScheduledCommand.h"
|
#include "ScheduledCommand.h"
|
||||||
|
|
||||||
using namespace common;
|
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
@@ -27,6 +26,12 @@ public:
|
|||||||
scheduledCommands.push_back(ScheduledCommand(transaction, command, time, executionTime));
|
scheduledCommands.push_back(ScheduledCommand(transaction, command, time, executionTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add(ScheduledCommand scheduledCommand)
|
||||||
|
{
|
||||||
|
assert(&scheduledCommand.getTransaction() == &transaction);
|
||||||
|
scheduledCommands.push_back(scheduledCommand);
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<ScheduledCommand>& getScheduledCommands() const
|
const std::vector<ScheduledCommand>& getScheduledCommands() const
|
||||||
{
|
{
|
||||||
return scheduledCommands;
|
return scheduledCommands;
|
||||||
@@ -47,9 +52,9 @@ public:
|
|||||||
return scheduledCommands.back().getEnd() - scheduledCommands.front().getStart();
|
return scheduledCommands.back().getEnd() - scheduledCommands.front().getStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bank getBank() const
|
common::Bank getBank() const
|
||||||
{
|
{
|
||||||
return DramExtension::getExtension(&transaction).getBank();
|
return common::DramExtension::getExtension(&transaction).getBank();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
typedef std::vector<Command> CommandSequence;
|
|
||||||
|
|
||||||
class CommandSequenceGenerator {
|
class CommandSequenceGenerator {
|
||||||
public:
|
public:
|
||||||
CommandSequenceGenerator(const ControllerState& controllerState) : controllerState(controllerState) {}
|
CommandSequenceGenerator(const ControllerState& controllerState) : controllerState(controllerState) {}
|
||||||
|
|||||||
@@ -15,9 +15,17 @@ CommandSequenceScheduler::CommandSequenceScheduler()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandSequenceScheduler::~CommandSequenceScheduler()
|
CommandSchedule CommandSequenceScheduler::prepareSchedule(tlm::tlm_generic_payload& transaction, CommandSequence commands)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated destructor stub
|
CommandSchedule schedule(transaction);
|
||||||
|
for(unsigned int i = 0; i < commands.size(); ++i)
|
||||||
|
{
|
||||||
|
Command command = commands.at(i);
|
||||||
|
sc_time start;
|
||||||
|
sc_time executionTime;
|
||||||
|
schedule.add(command, start, executionTime);
|
||||||
|
}
|
||||||
|
return schedule;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace controller */
|
} /* namespace controller */
|
||||||
|
|||||||
@@ -8,13 +8,18 @@
|
|||||||
#ifndef COMMANDSEQUENCESCHEDULER_H_
|
#ifndef COMMANDSEQUENCESCHEDULER_H_
|
||||||
#define COMMANDSEQUENCESCHEDULER_H_
|
#define COMMANDSEQUENCESCHEDULER_H_
|
||||||
|
|
||||||
|
#include "CommandSchedule.h"
|
||||||
|
#include "Command.h"
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
class CommandSequenceScheduler
|
class CommandSequenceScheduler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CommandSequenceScheduler();
|
CommandSequenceScheduler();
|
||||||
virtual ~CommandSequenceScheduler();
|
virtual ~CommandSequenceScheduler(){}
|
||||||
|
|
||||||
|
CommandSchedule prepareSchedule(tlm::tlm_generic_payload& transaction, CommandSequence commands);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace controller */
|
} /* namespace controller */
|
||||||
|
|||||||
22
DRAM/src/core/scheduling/IInternalScheduler.h
Normal file
22
DRAM/src/core/scheduling/IInternalScheduler.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* IInternalScheduler.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IINTERNALSCHEDULER_H_
|
||||||
|
#define IINTERNALSCHEDULER_H_
|
||||||
|
|
||||||
|
namespace controller
|
||||||
|
{
|
||||||
|
class IInternalScheduler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IInternalScheduler() {}
|
||||||
|
virtual void scheduleCommand(const controller::ScheduledCommand& command) = 0;
|
||||||
|
virtual void scheduleTrigger(const controller::Trigger trigger, sc_time time) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* IINTERNALSCHEDULER_H_ */
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* InternalScheduler.cpp
|
|
||||||
*
|
|
||||||
* Created on: Mar 9, 2014
|
|
||||||
* Author: jonny
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "InternalScheduler.h"
|
|
||||||
|
|
||||||
namespace controller {
|
|
||||||
|
|
||||||
void InternalScheduler::scheduleCommand(const ScheduledCommand& command)
|
|
||||||
{
|
|
||||||
if(command.getCommand() == Command::Refresh)
|
|
||||||
{
|
|
||||||
scheduleRefresh(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InternalScheduler::scheduleTrigger(const Trigger command, sc_time time)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InternalScheduler::scheduleRefresh(const ScheduledCommand& command)
|
|
||||||
{
|
|
||||||
state.bankStates.closeAllRowBuffers();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* namespace controller */
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* InternalScheduler.h
|
|
||||||
*
|
|
||||||
* Created on: Mar 6, 2014
|
|
||||||
* Author: jonny
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INTERNALSCHEDULER_H_
|
|
||||||
#define INTERNALSCHEDULER_H_
|
|
||||||
|
|
||||||
#include "CommandSchedule.h"
|
|
||||||
#include "core/ControllerState.h"
|
|
||||||
#include "core/scheduling/Trigger.h"
|
|
||||||
|
|
||||||
namespace controller{
|
|
||||||
|
|
||||||
class IInternalScheduler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IInternalScheduler() {}
|
|
||||||
virtual void scheduleCommand(const controller::ScheduledCommand& command) = 0;
|
|
||||||
virtual void scheduleTrigger(const controller::Trigger trigger, sc_time time) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class InternalScheduler : public IInternalScheduler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InternalScheduler(controller::ControllerState& state) : state(state) {}
|
|
||||||
virtual void scheduleCommand(const controller::ScheduledCommand& command);
|
|
||||||
virtual void scheduleTrigger(const controller::Trigger trigger, sc_time time);
|
|
||||||
|
|
||||||
private:
|
|
||||||
controller::ControllerState& state;
|
|
||||||
|
|
||||||
void scheduleRefresh(const controller::ScheduledCommand& command);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* INTERNALSCHEDULER_H_ */
|
|
||||||
@@ -8,8 +8,10 @@
|
|||||||
#ifndef SCHEDULEDCOMMAND_H_
|
#ifndef SCHEDULEDCOMMAND_H_
|
||||||
#define SCHEDULEDCOMMAND_H_
|
#define SCHEDULEDCOMMAND_H_
|
||||||
|
|
||||||
#include "Command.h"
|
|
||||||
#include <systemc.h>
|
#include <systemc.h>
|
||||||
|
#include <tlm.h>
|
||||||
|
#include "Command.h"
|
||||||
|
#include "common/dramextension.h"
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
@@ -52,6 +54,11 @@ public:
|
|||||||
return transaction;
|
return transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common::Bank getBank() const
|
||||||
|
{
|
||||||
|
return common::DramExtension::getExtension(&transaction).getBank();
|
||||||
|
}
|
||||||
|
|
||||||
inline bool operator==(const ScheduledCommand& b) const
|
inline bool operator==(const ScheduledCommand& b) const
|
||||||
{
|
{
|
||||||
return b.command == command && b.start == start && b.executionTime == executionTime
|
return b.command == command && b.start == start && b.executionTime == executionTime
|
||||||
@@ -62,7 +69,7 @@ private:
|
|||||||
const tlm::tlm_generic_payload& transaction;
|
const tlm::tlm_generic_payload& transaction;
|
||||||
const Command command;
|
const Command command;
|
||||||
sc_time start;
|
sc_time start;
|
||||||
const sc_time executionTime;
|
sc_time executionTime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
70
DRAM/src/core/scheduling/checker/ActivateChecker.cpp
Normal file
70
DRAM/src/core/scheduling/checker/ActivateChecker.cpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* ActivateScheduler.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 12, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/ActivateChecker.h>
|
||||||
|
#include <map>
|
||||||
|
#include "core/utils/Utils.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace common;
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
void ActivateChecker::check(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
if (command.getCommand() != Command::Activate)
|
||||||
|
return;
|
||||||
|
check_activateToActivate(command);
|
||||||
|
check_nActivateWindow(command);
|
||||||
|
check_bus(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivateChecker::check_activateToActivate(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
if (bus.notYetScheduled(Command::Activate))
|
||||||
|
return;
|
||||||
|
|
||||||
|
sc_time lastActivate = bus.getLastCommand(Command::Activate);
|
||||||
|
sc_time lastActivateOnBank = bus.getLastCommand(Command::Activate, command.getBank());
|
||||||
|
|
||||||
|
command.delayStart(delayByConstraint(lastActivate, command.getStart(), config.Timings.tRRD));
|
||||||
|
command.delayStart(
|
||||||
|
delayByConstraint(lastActivateOnBank, command.getStart(), config.Timings.tRC));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivateChecker::check_prechargeToActivate(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
sc_time lastPrechargeOnBank = std::max(
|
||||||
|
bus.getLastCommand(Command::Precharge, command.getBank()),
|
||||||
|
bus.getLastCommand(Command::PrechargeAll, command.getBank()));
|
||||||
|
command.delayStart(
|
||||||
|
delayByConstraint(lastPrechargeOnBank, command.getStart(), config.Timings.tRC));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivateChecker::check_nActivateWindow(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
if (!nActivateWindow.isFull())
|
||||||
|
return;
|
||||||
|
command.delayStart(
|
||||||
|
delayByConstraint(nActivateWindow.getOldest(), command.getStart(),
|
||||||
|
config.Timings.tTAW));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivateChecker::check_bus(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
command.delayStart(bus.getEarliestStartTime(command) - command.getStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivateChecker::cb_IInternalScheduler(const ScheduledCommand& command)
|
||||||
|
{
|
||||||
|
if (command.getCommand() == Command::Activate)
|
||||||
|
{
|
||||||
|
nActivateWindow.put(command.getStart());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
41
DRAM/src/core/scheduling/checker/ActivateChecker.h
Normal file
41
DRAM/src/core/scheduling/checker/ActivateChecker.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* ActivateScheduler.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 12, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ACTIVATESCHEDULER_H_
|
||||||
|
#define ACTIVATESCHEDULER_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include "core/scheduling/checker/ICommandChecker.h"
|
||||||
|
#include "core/Configuration.h"
|
||||||
|
#include "core/utils/RingBuffer.h"
|
||||||
|
#include "core/scheduling/CommandBus.h"
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
class ActivateChecker: public controller::ICommandChecker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActivateChecker(Configuration& config, CommandBus& commandBus) : config(config), bus(commandBus), nActivateWindow(config.nActivate - 1){}
|
||||||
|
virtual ~ActivateChecker(){}
|
||||||
|
|
||||||
|
virtual void check(ScheduledCommand& command) const;
|
||||||
|
virtual void cb_IInternalScheduler(const ScheduledCommand& command);
|
||||||
|
private:
|
||||||
|
const Configuration& config;
|
||||||
|
CommandBus& bus;//should be const .. but fucking map access operator!!!!
|
||||||
|
|
||||||
|
void check_activateToActivate(ScheduledCommand& command) const;
|
||||||
|
void check_prechargeToActivate(ScheduledCommand& command) const;
|
||||||
|
void check_nActivateWindow(ScheduledCommand& command) const;
|
||||||
|
void check_bus(ScheduledCommand& command) const;
|
||||||
|
|
||||||
|
RingBuffer nActivateWindow;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
|
|
||||||
|
#endif /* ACTIVATESCHEDULER_H_ */
|
||||||
28
DRAM/src/core/scheduling/checker/ICommandChecker.h
Normal file
28
DRAM/src/core/scheduling/checker/ICommandChecker.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* ICommandScheduler.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 12, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ICOMMANDSCHEDULER_H_
|
||||||
|
#define ICOMMANDSCHEDULER_H_
|
||||||
|
|
||||||
|
#include "systemc.h"
|
||||||
|
#include "core/scheduling/ScheduledCommand.h"
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
class ICommandChecker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~ICommandChecker() {}
|
||||||
|
|
||||||
|
virtual void schedule(ScheduledCommand& command) const = 0;
|
||||||
|
virtual void cb_IInternalScheduler(const ScheduledCommand& command) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ICOMMANDSCHEDULER_H_ */
|
||||||
20
DRAM/src/core/scheduling/checker/PrechargeChecker.cpp
Normal file
20
DRAM/src/core/scheduling/checker/PrechargeChecker.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* PrechargeChecker.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/PrechargeChecker.h>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
void controller::PrechargeChecker::check(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void controller::PrechargeChecker::cb_IInternalScheduler(const ScheduledCommand& command)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
32
DRAM/src/core/scheduling/checker/PrechargeChecker.h
Normal file
32
DRAM/src/core/scheduling/checker/PrechargeChecker.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* PrechargeChecker.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PRECHARGECHECKER_H_
|
||||||
|
#define PRECHARGECHECKER_H_
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/ICommandChecker.h>
|
||||||
|
#include "core/Configuration.h"
|
||||||
|
#include "core/scheduling/CommandBus.h"
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
class PrechargeChecker: public controller::ICommandChecker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrechargeChecker(const Configuration& config, const CommandBus& commandBus) : config(config), bus(commandBus) {}
|
||||||
|
virtual ~PrechargeChecker() {}
|
||||||
|
|
||||||
|
virtual void check(ScheduledCommand& command) const;
|
||||||
|
virtual void cb_IInternalScheduler(const ScheduledCommand& command);
|
||||||
|
private:
|
||||||
|
const Configuration& config;
|
||||||
|
const CommandBus& bus;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
|
|
||||||
|
#endif /* PRECHARGECHECKER_H_ */
|
||||||
20
DRAM/src/core/scheduling/checker/ReadChecker.cpp
Normal file
20
DRAM/src/core/scheduling/checker/ReadChecker.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* ReadChecker.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/ReadChecker.h>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
void ReadChecker::check(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadChecker::cb_IInternalScheduler(const ScheduledCommand& command)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
32
DRAM/src/core/scheduling/checker/ReadChecker.h
Normal file
32
DRAM/src/core/scheduling/checker/ReadChecker.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* ReadChecker.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef READCHECKER_H_
|
||||||
|
#define READCHECKER_H_
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/ICommandChecker.h>
|
||||||
|
#include "core/Configuration.h"
|
||||||
|
#include "core/scheduling/CommandBus.h"
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
class ReadChecker: public controller::ICommandChecker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ReadChecker(const Configuration& config, const CommandBus& commandBus) : config(config), bus(commandBus) {}
|
||||||
|
virtual ~ReadChecker() {}
|
||||||
|
|
||||||
|
virtual void check(ScheduledCommand& command) const;
|
||||||
|
virtual void cb_IInternalScheduler(const ScheduledCommand& command);
|
||||||
|
private:
|
||||||
|
const Configuration& config;
|
||||||
|
const CommandBus& bus;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
|
|
||||||
|
#endif /* READCHECKER_H_ */
|
||||||
20
DRAM/src/core/scheduling/checker/WriteChecker.cpp
Normal file
20
DRAM/src/core/scheduling/checker/WriteChecker.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* WriteChecker.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/WriteChecker.h>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
void WriteChecker::check(ScheduledCommand& command) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteChecker::cb_IInternalScheduler(const ScheduledCommand& command)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
32
DRAM/src/core/scheduling/checker/WriteChecker.h
Normal file
32
DRAM/src/core/scheduling/checker/WriteChecker.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* WriteChecker.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WRITECHECKER_H_
|
||||||
|
#define WRITECHECKER_H_
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/ICommandChecker.h>
|
||||||
|
#include "core/Configuration.h"
|
||||||
|
#include "core/scheduling/CommandBus.h"
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
class WriteChecker: public controller::ICommandChecker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WriteChecker(const Configuration& config, const CommandBus& commandBus) : config(config), bus(commandBus) {}
|
||||||
|
virtual ~WriteChecker() {}
|
||||||
|
|
||||||
|
virtual void check(ScheduledCommand& command) const;
|
||||||
|
virtual void cb_IInternalScheduler(const ScheduledCommand& command);
|
||||||
|
private:
|
||||||
|
const Configuration& config;
|
||||||
|
const CommandBus& bus;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
|
|
||||||
|
#endif /* WRITECHECKER_H_ */
|
||||||
61
DRAM/src/core/utils/RingBuffer.h
Normal file
61
DRAM/src/core/utils/RingBuffer.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* RingBuffer.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RINGBUFFER_H_
|
||||||
|
#define RINGBUFFER_H_
|
||||||
|
|
||||||
|
#include <systemc.h>
|
||||||
|
|
||||||
|
class RingBuffer
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
RingBuffer(unsigned int maxSize) : maxSize(maxSize) {}
|
||||||
|
|
||||||
|
void put(sc_time t)
|
||||||
|
{
|
||||||
|
buffer.push_front(t);
|
||||||
|
if(getSize()>maxSize)
|
||||||
|
buffer.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_time getOldest() const
|
||||||
|
{
|
||||||
|
return buffer.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_time getNewest() const
|
||||||
|
{
|
||||||
|
return buffer.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isFull() const
|
||||||
|
{
|
||||||
|
return getSize() == maxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isEmpty() const
|
||||||
|
{
|
||||||
|
return buffer.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int getSize() const
|
||||||
|
{
|
||||||
|
return buffer.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
const sc_time get(unsigned int i) const
|
||||||
|
{
|
||||||
|
return buffer.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::deque<sc_time> buffer;
|
||||||
|
unsigned int maxSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* RINGBUFFER_H_ */
|
||||||
33
DRAM/src/core/utils/Utils.cpp
Normal file
33
DRAM/src/core/utils/Utils.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Utils.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 12, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
using namespace common;
|
||||||
|
|
||||||
|
unsigned int getStartAddress(Bank bank)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_time delayByConstraint(sc_time previous, sc_time start, sc_time constraint)
|
||||||
|
{
|
||||||
|
assert(start > previous);
|
||||||
|
sc_time distance = start - previous;
|
||||||
|
if(distance < constraint)
|
||||||
|
return constraint - distance;
|
||||||
|
else
|
||||||
|
return SC_ZERO_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_time clkAlign(sc_time time, sc_time clk, Alignment alignment)
|
||||||
|
{
|
||||||
|
if(alignment == Alignment::UP)
|
||||||
|
return ceil(time/clk)*clk;
|
||||||
|
else
|
||||||
|
return floor(time/clk)*clk;
|
||||||
|
}
|
||||||
22
DRAM/src/core/utils/Utils.h
Normal file
22
DRAM/src/core/utils/Utils.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Utils.h
|
||||||
|
*
|
||||||
|
* Created on: Mar 10, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UTILS_H_
|
||||||
|
#define UTILS_H_
|
||||||
|
|
||||||
|
#include "common/dramextension.h"
|
||||||
|
#include <systemc.h>
|
||||||
|
|
||||||
|
unsigned int getStartAddress(common::Bank bank);
|
||||||
|
|
||||||
|
sc_time delayByConstraint(sc_time previous, sc_time start, sc_time constraint);
|
||||||
|
|
||||||
|
enum class Alignment {UP, DOWN};
|
||||||
|
|
||||||
|
sc_time clkAlign(sc_time time, sc_time clk, Alignment alignment = Alignment::UP);
|
||||||
|
|
||||||
|
#endif /* UTILS_H_ */
|
||||||
12
DRAM/testing/ActivateChecker_test.cpp
Normal file
12
DRAM/testing/ActivateChecker_test.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* ActivateScheduler_test.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 12, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/ActivateChecker.h>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
@@ -5,8 +5,78 @@
|
|||||||
* Author: jonny
|
* Author: jonny
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <gmock/gmock.h>
|
||||||
#include <core/refresh/BankwiseRefreshManager.h>
|
#include <core/refresh/BankwiseRefreshManager.h>
|
||||||
|
#include "testUtils.h"
|
||||||
|
#include "common/dramextension.h"
|
||||||
|
|
||||||
|
using namespace testing;
|
||||||
|
using namespace common;
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
|
class MockInternalScheduler: public IInternalScheduler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MOCK_METHOD1(scheduleCommand, void (const ScheduledCommand& command));
|
||||||
|
MOCK_METHOD2(scheduleTrigger, void (const Trigger command, sc_time time));
|
||||||
|
};
|
||||||
|
|
||||||
|
class BankwiseRefreshManagerTest: public Test
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BankwiseRefreshManagerTest(){}
|
||||||
|
|
||||||
|
Configuration config;
|
||||||
|
MockInternalScheduler internalScheduler;
|
||||||
|
std::shared_ptr<tlm::tlm_generic_payload> transaction;
|
||||||
|
|
||||||
|
CommandSchedule getCollidingWithFirstRefreshOnBank(unsigned int i)
|
||||||
|
{
|
||||||
|
transaction = createDummyPayload(Thread(0), Bank(i));
|
||||||
|
CommandSchedule colliding(*transaction.get());
|
||||||
|
sc_time tREFI = config.Timings.refreshTimings.at(i).tREFI;
|
||||||
|
sc_time clk = config.Timings.clk;
|
||||||
|
|
||||||
|
colliding.add(Command::Read, tREFI - 1 * clk, 2 * clk);
|
||||||
|
return colliding;
|
||||||
|
};
|
||||||
|
|
||||||
|
CommandSchedule getNonCollidingWithFirstRefreshOnBank(unsigned int i)
|
||||||
|
{
|
||||||
|
transaction = createDummyPayload(Thread(0), Bank(i));
|
||||||
|
CommandSchedule non_colliding(*transaction.get());
|
||||||
|
sc_time tREFI = config.Timings.refreshTimings.at(i).tREFI;
|
||||||
|
sc_time clk = config.Timings.clk;
|
||||||
|
|
||||||
|
non_colliding.add(Command::Read, tREFI - 3 * clk, 2 * clk);
|
||||||
|
return non_colliding;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(BankwiseRefreshManagerTest, RefreshsAreScheduledAfterStartup)
|
||||||
|
{
|
||||||
|
|
||||||
|
EXPECT_CALL(internalScheduler, scheduleTrigger(Trigger::RefreshTrigger, _)).Times(config.numberOfBanks * 2);
|
||||||
|
EXPECT_CALL(internalScheduler, scheduleCommand(_)).Times(config.numberOfBanks);
|
||||||
|
|
||||||
|
//first trigger for each bank is scheduled
|
||||||
|
BankwiseRefreshManager manager(config.Timings.refreshTimings, internalScheduler);
|
||||||
|
|
||||||
|
//first refresh for each bank is scheduled, second trigger is scheduled
|
||||||
|
manager.scheduleRefresh(config.Timings.refreshTimings.at(0).tREFI);//call back from wrapper
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BankwiseRefreshManagerTest, hasCollisionExpectCollisionOnBank2)
|
||||||
|
{
|
||||||
|
BankwiseRefreshManager manager(config.Timings.refreshTimings, internalScheduler);
|
||||||
|
EXPECT_TRUE(manager.hasCollision(getCollidingWithFirstRefreshOnBank(2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BankwiseRefreshManagerTest, hasCollisionExpectNoCollisionOnBank2)
|
||||||
|
{
|
||||||
|
BankwiseRefreshManager manager(config.Timings.refreshTimings, internalScheduler);
|
||||||
|
EXPECT_FALSE(manager.hasCollision(getNonCollidingWithFirstRefreshOnBank(2)));
|
||||||
|
}
|
||||||
} /* namespace controller */
|
} /* namespace controller */
|
||||||
|
|||||||
12
DRAM/testing/PrechargeChecker_test.cpp
Normal file
12
DRAM/testing/PrechargeChecker_test.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* PrechargeChecker_test.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/PrechargeChecker.h>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
12
DRAM/testing/ReadChecker_test.cpp
Normal file
12
DRAM/testing/ReadChecker_test.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* ReadChecker_test.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/ReadChecker.h>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
@@ -8,12 +8,17 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include "core/refresh/RefreshManager.h"
|
#include "core/refresh/RefreshManager.h"
|
||||||
|
#include "testUtils.h"
|
||||||
|
|
||||||
using ::testing::_;
|
using ::testing::_;
|
||||||
using ::testing::AtLeast;
|
using ::testing::AtLeast;
|
||||||
using ::testing::Expectation;
|
using ::testing::Expectation;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
const double lowest_double = -DBL_MAX;
|
||||||
|
|
||||||
constexpr unsigned int numberOfBanks = 8;
|
constexpr unsigned int numberOfBanks = 8;
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
@@ -33,10 +38,12 @@ public:
|
|||||||
Configuration config;
|
Configuration config;
|
||||||
MockInternalScheduler internalScheduler;
|
MockInternalScheduler internalScheduler;
|
||||||
|
|
||||||
|
std::shared_ptr<tlm::tlm_generic_payload> transaction;
|
||||||
|
|
||||||
CommandSchedule getCollidingWithFirstRefresh()
|
CommandSchedule getCollidingWithFirstRefresh()
|
||||||
{
|
{
|
||||||
tlm::tlm_generic_payload transaction;
|
transaction = createDummyPayload();
|
||||||
CommandSchedule colliding(transaction);
|
CommandSchedule colliding(*transaction.get());
|
||||||
sc_time tREFI = config.Timings.refreshTimings.at(0).tREFI;
|
sc_time tREFI = config.Timings.refreshTimings.at(0).tREFI;
|
||||||
sc_time clk = config.Timings.clk;
|
sc_time clk = config.Timings.clk;
|
||||||
|
|
||||||
@@ -46,8 +53,8 @@ public:
|
|||||||
|
|
||||||
CommandSchedule getNonCollidingWithFirstRefresh()
|
CommandSchedule getNonCollidingWithFirstRefresh()
|
||||||
{
|
{
|
||||||
tlm::tlm_generic_payload transaction;
|
transaction = createDummyPayload();
|
||||||
CommandSchedule non_colliding(transaction);
|
CommandSchedule non_colliding(*transaction.get());
|
||||||
sc_time tREFI = config.Timings.refreshTimings.at(0).tREFI;
|
sc_time tREFI = config.Timings.refreshTimings.at(0).tREFI;
|
||||||
sc_time clk = config.Timings.clk;
|
sc_time clk = config.Timings.clk;
|
||||||
|
|
||||||
@@ -59,7 +66,6 @@ public:
|
|||||||
|
|
||||||
TEST_F(RefreshManagerTest, RefreshIsScheduledAfterStartup)
|
TEST_F(RefreshManagerTest, RefreshIsScheduledAfterStartup)
|
||||||
{
|
{
|
||||||
|
|
||||||
EXPECT_CALL(internalScheduler, scheduleTrigger(Trigger::RefreshTrigger, _)).Times(2);
|
EXPECT_CALL(internalScheduler, scheduleTrigger(Trigger::RefreshTrigger, _)).Times(2);
|
||||||
EXPECT_CALL(internalScheduler, scheduleCommand(_));
|
EXPECT_CALL(internalScheduler, scheduleCommand(_));
|
||||||
|
|
||||||
|
|||||||
12
DRAM/testing/WriteChecker_test.cpp
Normal file
12
DRAM/testing/WriteChecker_test.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* WriteChecker_test.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 13, 2014
|
||||||
|
* Author: jonny
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <core/scheduling/checker/WriteChecker.h>
|
||||||
|
|
||||||
|
namespace controller {
|
||||||
|
|
||||||
|
} /* namespace controller */
|
||||||
Reference in New Issue
Block a user