BankwiseScheduler Part
-- and minor refactoring
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#ifndef BANKSTATES_H_
|
||||
#define BANKSTATES_H_
|
||||
#include <vector>
|
||||
#include "schedulerextension.h"
|
||||
#include "dramextension.h"
|
||||
|
||||
namespace common {
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include "schedulerextension.h"
|
||||
#include "dramextension.h"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace tlm;
|
||||
|
||||
namespace common {
|
||||
|
||||
tlm_extension_base* SchedulerExtension::clone() const
|
||||
tlm_extension_base* DramExtension::clone() const
|
||||
{
|
||||
return new SchedulerExtension(thread, bank, row, column);
|
||||
return new DramExtension(thread, bank, row, column);
|
||||
}
|
||||
|
||||
void SchedulerExtension::copy_from(const tlm_extension_base &ext)
|
||||
void DramExtension::copy_from(const tlm_extension_base &ext)
|
||||
{
|
||||
const SchedulerExtension &cpyFrom = static_cast<const SchedulerExtension&>(ext);
|
||||
const DramExtension &cpyFrom = static_cast<const DramExtension&>(ext);
|
||||
thread = cpyFrom.thread;
|
||||
bank = cpyFrom.bank;
|
||||
row = cpyFrom.row;
|
||||
@@ -22,9 +22,9 @@ void SchedulerExtension::copy_from(const tlm_extension_base &ext)
|
||||
/* Static methods
|
||||
*
|
||||
*/
|
||||
const SchedulerExtension& SchedulerExtension::getExtension(const tlm_generic_payload *payload)
|
||||
const DramExtension& DramExtension::getExtension(const tlm_generic_payload *payload)
|
||||
{
|
||||
SchedulerExtension *result = NULL;
|
||||
DramExtension *result = NULL;
|
||||
payload->get_extension(result);
|
||||
assert(result != NULL);
|
||||
return *result;
|
||||
@@ -60,7 +60,7 @@ bool operator!=(const Row &lhs, const Row &rhs);
|
||||
bool operator==(const Column &lhs, const Column &rhs);
|
||||
bool operator!=(const Column &lhs, const Column &rhs);
|
||||
|
||||
class SchedulerExtension : public tlm::tlm_extension<SchedulerExtension>
|
||||
class DramExtension : public tlm::tlm_extension<DramExtension>
|
||||
{
|
||||
private:
|
||||
Thread thread;
|
||||
@@ -70,11 +70,11 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
SchedulerExtension():thread(0),bank(0),row(0),column(0){}
|
||||
SchedulerExtension(const Thread& thread, const Bank& bank, const Row& row, const Column& column) :
|
||||
DramExtension():thread(0),bank(0),row(0),column(0){}
|
||||
DramExtension(const Thread& thread, const Bank& bank, const Row& row, const Column& column) :
|
||||
thread(thread),bank(bank),row(row),column(column){}
|
||||
|
||||
~SchedulerExtension(){}
|
||||
~DramExtension(){}
|
||||
virtual tlm::tlm_extension_base* clone() const;
|
||||
virtual void copy_from(const tlm_extension_base &ext);
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
const Row& getRow() const{return row;}
|
||||
const Column& getColumn() const{return column;}
|
||||
|
||||
static const SchedulerExtension& getExtension(const tlm::tlm_generic_payload *payload);
|
||||
static const DramExtension& getExtension(const tlm::tlm_generic_payload *payload);
|
||||
};
|
||||
|
||||
|
||||
@@ -16,8 +16,15 @@ namespace controller{
|
||||
struct Configuration
|
||||
{
|
||||
unsigned int numberOfBanks;
|
||||
bool RefreshBankwise = false;
|
||||
TimingConfiguration Timings;
|
||||
|
||||
bool RefreshBankwise = false;
|
||||
|
||||
unsigned int getStartAddress(int bank)//TODO utils??
|
||||
{
|
||||
//return ColumnSize * BytesSize;???
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#include <core/PowerDownManager.h>
|
||||
#include <core/powerdown/PowerDownManager.h>
|
||||
|
||||
namespace controller {
|
||||
|
||||
|
||||
62
DRAM/src/core/refresh/BankwiseRefreshManager.cpp
Normal file
62
DRAM/src/core/refresh/BankwiseRefreshManager.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* BankwiseRefreshManager.cpp
|
||||
*
|
||||
* Created on: Mar 9, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#include <core/refresh/BankwiseRefreshManager.h>
|
||||
|
||||
namespace controller {
|
||||
|
||||
BankwiseRefreshManager::BankwiseRefreshManager(Configuration& configuration, IInternalScheduler& internalScheduler) : controllerConfiguration(configuration), internalScheduler(internalScheduler), refreshTransactions(configuration.numberOfBanks), lastRefreshs()
|
||||
{
|
||||
lastRefreshs.reserve(configuration.numberOfBanks);
|
||||
for (unsigned int i = 0; i < configuration.numberOfBanks; ++i)
|
||||
{
|
||||
tlm::tlm_generic_payload& transaction = refreshTransactions[i];
|
||||
//setup
|
||||
lastRefreshs.push_back(ScheduledCommand(transaction, Command::Refresh, SC_ZERO_TIME));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
BankwiseRefreshManager::~BankwiseRefreshManager()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
bool BankwiseRefreshManager::hasCollision(const CommandSchedule& schedule)
|
||||
{
|
||||
}
|
||||
|
||||
sc_time BankwiseRefreshManager::getEarliestStartTime(const CommandSchedule& schedule)
|
||||
{
|
||||
}
|
||||
|
||||
void BankwiseRefreshManager::cb_refreshFinished(tlm::tlm_generic_payload& transaction,
|
||||
sc_time currentTime)
|
||||
{
|
||||
}
|
||||
|
||||
void BankwiseRefreshManager::planNextRefresh(ScheduledCommand& refresh)
|
||||
{
|
||||
}
|
||||
|
||||
void BankwiseRefreshManager::scheduleRefresh(const ScheduledCommand& refresh) const
|
||||
{
|
||||
}
|
||||
|
||||
void BankwiseRefreshManager::setupTransaction(unsigned int i)
|
||||
{
|
||||
refreshTransactions[i].set_address(controllerConfiguration.getStartAddress(i));
|
||||
refreshTransactions[i].set_command(tlm::TLM_READ_COMMAND);
|
||||
refreshTransactions[i].set_data_length(0);
|
||||
refreshTransactions[i].set_response_status(tlm::TLM_OK_RESPONSE);
|
||||
refreshTransactions[i].set_dmi_allowed(false);
|
||||
refreshTransactions[i].set_byte_enable_length(0);
|
||||
refreshTransactions[i].set_streaming_width(0);
|
||||
}
|
||||
|
||||
} /* namespace controller */
|
||||
43
DRAM/src/core/refresh/BankwiseRefreshManager.h
Normal file
43
DRAM/src/core/refresh/BankwiseRefreshManager.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* BankwiseRefreshManager.h
|
||||
*
|
||||
* Created on: Mar 9, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#ifndef BANKWISEREFRESHMANAGER_H_
|
||||
#define BANKWISEREFRESHMANAGER_H_
|
||||
|
||||
#include "IRefreshManager.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
class BankwiseRefreshManager : public IRefreshManager
|
||||
{
|
||||
public:
|
||||
BankwiseRefreshManager(Configuration& configuration, IInternalScheduler& internalScheduler);
|
||||
virtual ~BankwiseRefreshManager();
|
||||
|
||||
//internal:
|
||||
virtual bool hasCollision(const CommandSchedule& schedule);
|
||||
virtual sc_time getEarliestStartTime(const CommandSchedule& schedule);
|
||||
|
||||
//external:
|
||||
virtual void cb_refreshFinished(tlm::tlm_generic_payload& transaction, sc_time currentTime);
|
||||
|
||||
private:
|
||||
Configuration& controllerConfiguration;
|
||||
IInternalScheduler& internalScheduler;
|
||||
|
||||
std::vector<tlm::tlm_generic_payload> refreshTransactions;
|
||||
std::vector<ScheduledCommand> lastRefreshs;
|
||||
|
||||
void planNextRefresh(ScheduledCommand& refresh);
|
||||
void scheduleRefresh(const ScheduledCommand& refresh) const;
|
||||
|
||||
void setupTransaction(unsigned int i);
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
#endif /* BANKWISEREFRESHMANAGER_H_ */
|
||||
@@ -9,6 +9,10 @@
|
||||
#define IREFRESHMANAGER_H_
|
||||
|
||||
#include <systemc.h>
|
||||
#include <vector>
|
||||
#include "core/scheduling/InternalScheduler.h"
|
||||
#include "core/Configuration.h"
|
||||
#include "core/scheduling/ScheduledCommand.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
@@ -22,7 +26,7 @@ public:
|
||||
virtual sc_time getEarliestStartTime(const CommandSchedule& schedule) = 0;
|
||||
|
||||
//external:
|
||||
virtual void cb_refreshFinished(sc_time currentTime) = 0;
|
||||
virtual void cb_refreshFinished(tlm::tlm_generic_payload& transaction, sc_time currentTime) = 0;
|
||||
|
||||
private:
|
||||
virtual void scheduleRefresh(const ScheduledCommand& refresh) const = 0;
|
||||
|
||||
@@ -9,15 +9,16 @@
|
||||
|
||||
namespace controller {
|
||||
|
||||
RefreshManager::RefreshManager(Configuration& configuration, IInternalScheduler& internalScheduler) : controllerConfiguration(configuration), internalScheduler(internalScheduler), lastRefresh(refreshTransaction, Command::Refresh, SC_ZERO_TIME)
|
||||
RefreshManager::RefreshManager(const Configuration& configuration, IInternalScheduler& internalScheduler) : controllerConfiguration(configuration), internalScheduler(internalScheduler), lastRefresh(refreshTransaction, Command::Refresh, SC_ZERO_TIME)
|
||||
{
|
||||
cb_refreshFinished(SC_ZERO_TIME);
|
||||
setupTransaction();
|
||||
cb_refreshFinished(refreshTransaction, SC_ZERO_TIME);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is called from TLM Wrapper when end_refresh is sent from DRAM.
|
||||
*/
|
||||
void RefreshManager::cb_refreshFinished(sc_time currentTime)
|
||||
void RefreshManager::cb_refreshFinished(tlm::tlm_generic_payload& transaction, sc_time currentTime)
|
||||
{
|
||||
planNextRefresh(lastRefresh);
|
||||
assert(currentTime < lastRefresh.time);
|
||||
@@ -53,4 +54,15 @@ void RefreshManager::planNextRefresh(ScheduledCommand& refresh)
|
||||
refresh.time += controllerConfiguration.Timings.tREF;
|
||||
}
|
||||
|
||||
void RefreshManager::setupTransaction()
|
||||
{
|
||||
refreshTransaction.set_address(0);
|
||||
refreshTransaction.set_command(tlm::TLM_READ_COMMAND);
|
||||
refreshTransaction.set_data_length(0);
|
||||
refreshTransaction.set_response_status(tlm::TLM_OK_RESPONSE);
|
||||
refreshTransaction.set_dmi_allowed(false);
|
||||
refreshTransaction.set_byte_enable_length(0);
|
||||
refreshTransaction.set_streaming_width(0);
|
||||
}
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
#ifndef REFRESHMANAGER_H_
|
||||
#define REFRESHMANAGER_H_
|
||||
|
||||
#include <vector>
|
||||
#include "core/scheduling/InternalScheduler.h"
|
||||
#include "core/Configuration.h"
|
||||
#include "IRefreshManager.h"
|
||||
|
||||
namespace controller {
|
||||
@@ -18,7 +15,7 @@ namespace controller {
|
||||
class RefreshManager : public IRefreshManager
|
||||
{
|
||||
public:
|
||||
RefreshManager(Configuration& configuration, IInternalScheduler& internalScheduler);
|
||||
RefreshManager(const Configuration& configuration, IInternalScheduler& internalScheduler);
|
||||
virtual ~RefreshManager() {}
|
||||
|
||||
//internal:
|
||||
@@ -26,17 +23,19 @@ public:
|
||||
virtual sc_time getEarliestStartTime(const CommandSchedule& schedule);
|
||||
|
||||
//external:
|
||||
virtual void cb_refreshFinished(sc_time currentTime);
|
||||
virtual void cb_refreshFinished(tlm::tlm_generic_payload& transaction, sc_time currentTime);
|
||||
|
||||
private:
|
||||
const Configuration& controllerConfiguration;
|
||||
IInternalScheduler& internalScheduler;
|
||||
Configuration& controllerConfiguration;
|
||||
|
||||
tlm::tlm_generic_payload refreshTransaction;
|
||||
ScheduledCommand lastRefresh;
|
||||
|
||||
void planNextRefresh(ScheduledCommand& refresh);
|
||||
void scheduleRefresh(const ScheduledCommand& refresh) const;
|
||||
|
||||
void setupTransaction();
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "CommandGenerator.h"
|
||||
#include "common/schedulerextension.h"
|
||||
#include "common/dramextension.h"
|
||||
|
||||
using namespace common;
|
||||
using namespace std;
|
||||
@@ -15,7 +15,7 @@ namespace controller {
|
||||
|
||||
CommandSequence CommandGenerator::generateCommandSequence(tlm::tlm_generic_payload& transaction)
|
||||
{
|
||||
const SchedulerExtension& extension = SchedulerExtension::getExtension(&transaction);
|
||||
const DramExtension& extension = DramExtension::getExtension(&transaction);
|
||||
Bank bank = extension.getBank();
|
||||
Row row = extension.getRow();
|
||||
|
||||
|
||||
@@ -9,26 +9,11 @@
|
||||
#define COMMANDSCHEDULE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <systemc.h>
|
||||
#include "Command.h"
|
||||
#include "common/schedulerextension.h"
|
||||
|
||||
#include "common/dramextension.h"
|
||||
#include "ScheduledCommand.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
struct ScheduledCommand{
|
||||
ScheduledCommand(const tlm::tlm_generic_payload& transaction, Command command, sc_time time) : transaction(transaction), command(command), time(time){};
|
||||
|
||||
const tlm::tlm_generic_payload& transaction;
|
||||
Command command;
|
||||
sc_time time;
|
||||
|
||||
inline bool operator==(const ScheduledCommand& b) const
|
||||
{
|
||||
return b.command == command && b.time == time;
|
||||
}
|
||||
};
|
||||
|
||||
class CommandSchedule {
|
||||
public:
|
||||
CommandSchedule();
|
||||
|
||||
32
DRAM/src/core/scheduling/ScheduledCommand.h
Normal file
32
DRAM/src/core/scheduling/ScheduledCommand.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* ScheduledCommand.h
|
||||
*
|
||||
* Created on: Mar 10, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#ifndef SCHEDULEDCOMMAND_H_
|
||||
#define SCHEDULEDCOMMAND_H_
|
||||
|
||||
#include "Command.h"
|
||||
#include <systemc.h>
|
||||
|
||||
namespace controller{
|
||||
|
||||
struct ScheduledCommand{
|
||||
ScheduledCommand(const tlm::tlm_generic_payload& transaction, Command command, sc_time time) : transaction(transaction), command(command), time(time){};
|
||||
|
||||
const tlm::tlm_generic_payload& transaction;
|
||||
Command command;
|
||||
sc_time time;
|
||||
|
||||
inline bool operator==(const ScheduledCommand& b) const
|
||||
{
|
||||
return b.command == command && b.time == time;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
#endif /* SCHEDULEDCOMMAND_H_ */
|
||||
12
DRAM/testing/BankwiseRefreshManager_test.cpp
Normal file
12
DRAM/testing/BankwiseRefreshManager_test.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* BankwiseRefreshManager_test.cpp
|
||||
*
|
||||
* Created on: Mar 9, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#include <core/refresh/BankwiseRefreshManager.h>
|
||||
|
||||
namespace controller {
|
||||
|
||||
} /* namespace controller */
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#include <core/PowerDownManager.h>
|
||||
#include <core/powerdown/PowerDownManager.h>
|
||||
|
||||
namespace controller {
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ TEST(RefreshManager, FinishedRefreshTriggersNewRefresh)
|
||||
//schedule first refresh in constructor
|
||||
RefreshManager manager(config, internalScheduler);
|
||||
//schedule second refresh in callback (end_refresh)
|
||||
manager.cb_refreshFinished(config.Timings.tREF + config.Timings.tREFA);
|
||||
tlm::tlm_generic_payload trans;
|
||||
manager.cb_refreshFinished(trans, config.Timings.tREF + config.Timings.tREFA);
|
||||
}
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
@@ -9,7 +9,7 @@ using namespace common;
|
||||
*
|
||||
*
|
||||
*/
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(SchedulerExtension *extension)
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(DramExtension *extension)
|
||||
{
|
||||
shared_ptr<tlm_generic_payload> result(new tlm_generic_payload());
|
||||
result->set_extension(extension);
|
||||
@@ -19,13 +19,13 @@ shared_ptr<tlm_generic_payload> createDummyPayload(SchedulerExtension *extension
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(const Thread& thread, const Bank& bank,
|
||||
const Row& row, const Column& column)
|
||||
{
|
||||
return createDummyPayload(new SchedulerExtension(thread, bank, row, column));
|
||||
return createDummyPayload(new DramExtension(thread, bank, row, column));
|
||||
}
|
||||
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(const Thread& thread, const Bank& bank,
|
||||
const Row& row, const Column& column, const tlm::tlm_command& command)
|
||||
{
|
||||
auto payload = createDummyPayload(new SchedulerExtension(thread, bank, row, column));
|
||||
auto payload = createDummyPayload(new DramExtension(thread, bank, row, column));
|
||||
payload.get()->set_command(command);
|
||||
return payload;
|
||||
}
|
||||
@@ -33,15 +33,15 @@ shared_ptr<tlm_generic_payload> createDummyPayload(const Thread& thread, const B
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(const Thread& thread, const Bank& bank,
|
||||
const Row& row)
|
||||
{
|
||||
return createDummyPayload(new SchedulerExtension(thread, bank, row, Column(0)));
|
||||
return createDummyPayload(new DramExtension(thread, bank, row, Column(0)));
|
||||
}
|
||||
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(const Thread& thread, const Bank& bank)
|
||||
{
|
||||
return createDummyPayload(new SchedulerExtension(thread, bank, Row(0), Column(0)));
|
||||
return createDummyPayload(new DramExtension(thread, bank, Row(0), Column(0)));
|
||||
}
|
||||
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload()
|
||||
{
|
||||
return createDummyPayload(new SchedulerExtension());
|
||||
return createDummyPayload(new DramExtension());
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
#include <tlm.h>
|
||||
#include <memory>
|
||||
#include "common/schedulerextension.h"
|
||||
#include "common/dramextension.h"
|
||||
|
||||
std::shared_ptr<tlm::tlm_generic_payload> createDummyPayload();
|
||||
|
||||
std::shared_ptr<tlm::tlm_generic_payload> createDummyPayload(common::SchedulerExtension* extension);
|
||||
std::shared_ptr<tlm::tlm_generic_payload> createDummyPayload(common::DramExtension* extension);
|
||||
|
||||
std::shared_ptr<tlm::tlm_generic_payload> createDummyPayload(const common::Thread& thread,
|
||||
const common::Bank& bank, const common::Row& row, const common::Column& column);
|
||||
|
||||
Reference in New Issue
Block a user