changed build structure
This commit is contained in:
72
DRAM/dram/core/Controller.cpp
Normal file
72
DRAM/dram/core/Controller.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* controller.cpp
|
||||
*
|
||||
* Created on: Mar 5, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#include "Controller.h"
|
||||
#include "systemc.h"
|
||||
#include "core/scheduling/checker/ActivateChecker.h"
|
||||
#include "core/scheduling/checker/PrechargeChecker.h"
|
||||
#include "core/scheduling/checker/ReadChecker.h"
|
||||
#include "core/scheduling/checker/WriteChecker.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
Controller::Controller() :
|
||||
config(), state(config.numberOfBanks), commandSequenceGenerator(state), commandChecker(), commandSequenceScheduler(
|
||||
*this), refreshManager(config.Timings.refreshTimings[0], bus), bus(config, state,
|
||||
allCommandChecker)
|
||||
{
|
||||
addCommandChecker(Activate, new ActivateChecker(config, bus));
|
||||
addCommandChecker(Precharge, new PrechargeChecker(config, bus));
|
||||
addCommandChecker(Read, new ReadChecker(config, bus));
|
||||
addCommandChecker(Write, new WriteChecker(config, bus));
|
||||
}
|
||||
|
||||
void Controller::addCommandChecker(Command command, ICommandChecker* checker)
|
||||
{
|
||||
commandChecker[command] = checker;
|
||||
allCommandChecker.push_back(checker);
|
||||
}
|
||||
|
||||
Controller::~Controller()
|
||||
{
|
||||
std::map<Command, ICommandChecker*>::iterator it = commandChecker.begin();
|
||||
while (it != commandChecker.end())
|
||||
{
|
||||
delete it->second;
|
||||
}
|
||||
commandChecker.clear();
|
||||
}
|
||||
|
||||
bool Controller::schedule(sc_time currentTime, tlm::tlm_generic_payload& externalTransaction)
|
||||
{
|
||||
bus.cleanUpBus(currentTime);
|
||||
|
||||
CommandSequence sequence = commandSequenceGenerator.generateCommandSequence(externalTransaction);
|
||||
CommandSchedule schedule = commandSequenceScheduler.prepareSchedule(currentTime, externalTransaction, sequence);
|
||||
|
||||
while(refreshManager.hasCollision(schedule))
|
||||
{
|
||||
refreshManager.scheduleRefresh(currentTime);
|
||||
sequence = commandSequenceGenerator.generateCommandSequence(externalTransaction);
|
||||
schedule = commandSequenceScheduler.prepareSchedule(currentTime, externalTransaction, sequence);
|
||||
assert(schedule.getExecutionTime() < config.Timings.refreshTimings[0].tREFI);//TODO make nice
|
||||
}
|
||||
|
||||
bus.schedule(schedule);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const ICommandChecker& Controller::getChecker(Command command) const
|
||||
{
|
||||
std::map<Command, ICommandChecker*>::const_iterator result = commandChecker.find(command);
|
||||
assert(result != commandChecker.end());
|
||||
return *(result->second);
|
||||
}
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
Reference in New Issue
Block a user