Get BankGroup, Get Banks
This commit is contained in:
@@ -49,6 +49,16 @@ bool operator !=(const Bank& lhs, const Bank& rhs)
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator ==(const BankGroup& lhs, const BankGroup& rhs)
|
||||
{
|
||||
return lhs.ID() == rhs.ID();
|
||||
}
|
||||
|
||||
bool operator !=(const BankGroup& lhs, const BankGroup& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator <(const Bank& lhs, const Bank& rhs)
|
||||
{
|
||||
return lhs.ID() < rhs.ID();
|
||||
|
||||
@@ -31,6 +31,14 @@ private:
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
class BankGroup
|
||||
{
|
||||
public :
|
||||
explicit BankGroup(unsigned int id) : id(id) {}
|
||||
unsigned int ID() const { return id;}
|
||||
private:
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
class Bank
|
||||
{
|
||||
@@ -70,13 +78,20 @@ private:
|
||||
|
||||
bool operator==(const Thread &lhs, const Thread &rhs);
|
||||
bool operator!=(const Thread &lhs, const Thread &rhs);
|
||||
|
||||
bool operator==(const Channel &lhs, const Channel &rhs);
|
||||
bool operator!=(const Channel &lhs, const Channel &rhs);
|
||||
|
||||
bool operator==(const BankGroup &lhs, const BankGroup &rhs);
|
||||
bool operator!=(const BankGroup &lhs, const BankGroup &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 Column &lhs, const Column &rhs);
|
||||
bool operator!=(const Column &lhs, const Column &rhs);
|
||||
|
||||
|
||||
@@ -15,11 +15,6 @@ namespace core
|
||||
BankStates::BankStates(unsigned int numberOfBanks) :
|
||||
rowsInRowBuffers(numberOfBanks)
|
||||
{
|
||||
for (unsigned int i = 0; i < numberOfBanks; ++i)
|
||||
{
|
||||
banks.push_back(Bank(i));
|
||||
}
|
||||
|
||||
closeAllRowBuffers();
|
||||
}
|
||||
|
||||
@@ -59,9 +54,9 @@ bool BankStates::allRowBuffersAreClosed() const
|
||||
|
||||
void BankStates::closeAllRowBuffers()
|
||||
{
|
||||
for(vector<Bank>::iterator it = banks.begin(); it != banks.end(); ++it)
|
||||
for(Row& row : rowsInRowBuffers)
|
||||
{
|
||||
closeRowBuffer(*it);
|
||||
row = Row::NO_ROW;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ public:
|
||||
virtual ~BankStates();
|
||||
|
||||
unsigned int getNumberOfBanks() const {return rowsInRowBuffers.size();}
|
||||
const std::vector<Bank>& getBanks() const {return banks;}
|
||||
|
||||
bool rowBufferIsOpen(const Bank &bank) const;
|
||||
bool allRowBuffersAreClosed() const;
|
||||
@@ -29,10 +28,7 @@ public:
|
||||
void closeRowBuffer(const Bank &bank);
|
||||
void closeAllRowBuffers();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::vector<Bank> banks;
|
||||
std::vector<Row> rowsInRowBuffers;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,17 +15,17 @@ namespace core{
|
||||
|
||||
struct Configuration
|
||||
{
|
||||
Configuration(): numberOfBanks(8), burstlength(2), Timings(numberOfBanks), RefreshBankwise(false),PowerDownBankwise(false),
|
||||
Configuration(): NumberOfBanks(8), NumberOfBankGroups(4), Burstlength(2), Timings(NumberOfBanks), BankwiseRefresh(false),BankwisePowerDown(false),
|
||||
nActivate(2)
|
||||
{}
|
||||
unsigned int numberOfBanks;
|
||||
unsigned int burstlength;
|
||||
unsigned int NumberOfBanks;
|
||||
unsigned int NumberOfBankGroups;
|
||||
unsigned int Burstlength;
|
||||
TimingConfiguration Timings;
|
||||
|
||||
bool RefreshBankwise;
|
||||
bool PowerDownBankwise;
|
||||
bool BankwiseRefresh;
|
||||
bool BankwisePowerDown;
|
||||
unsigned int nActivate;
|
||||
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
@@ -29,23 +29,15 @@ Controller::Controller(IWrapperConnector& wrapperConnector, TlmRecorder& recorde
|
||||
commandChecker[Command::Read] = new ReadChecker(config, state);
|
||||
commandChecker[Command::Write] = new WriteChecker(config, state);
|
||||
|
||||
if (config.RefreshBankwise)
|
||||
{
|
||||
if (config.BankwiseRefresh)
|
||||
refreshManager = new RefreshManagerBankwise(*this);
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshManager = new RefreshManager(*this);
|
||||
}
|
||||
|
||||
if (config.PowerDownBankwise)
|
||||
{
|
||||
if (config.BankwisePowerDown)
|
||||
powerDownManager = new PowerDownManagerBankwise(*this);
|
||||
}
|
||||
else
|
||||
{
|
||||
powerDownManager = new PowerDownManager(*this);
|
||||
}
|
||||
}
|
||||
|
||||
Controller::~Controller()
|
||||
@@ -72,12 +64,6 @@ void Controller::scheduleRefresh(tlm::tlm_generic_payload& payload, sc_time time
|
||||
{
|
||||
state.cleanUp(time);
|
||||
|
||||
if (time > sc_time(16933400, SC_NS))
|
||||
{
|
||||
int i;
|
||||
i = 5;
|
||||
}
|
||||
|
||||
if (refreshManager->isInvalidated(payload, time))
|
||||
return;
|
||||
|
||||
@@ -93,7 +79,7 @@ bool Controller::scheduleRequest(sc_time start, tlm::tlm_generic_payload& payloa
|
||||
{
|
||||
start = clkAlign(start, config.Timings.clk);
|
||||
state.cleanUp(start);
|
||||
payload.set_streaming_width(config.burstlength);
|
||||
payload.set_streaming_width(config.Burstlength);
|
||||
|
||||
saveState();
|
||||
|
||||
@@ -114,11 +100,11 @@ bool Controller::scheduleRequest(sc_time start, tlm::tlm_generic_payload& payloa
|
||||
|
||||
bool Controller::isBusy(sc_time time, Bank bank)
|
||||
{
|
||||
if(powerDownManager->isActive(bank))
|
||||
{
|
||||
powerDownManager->wakeUp(bank, time);
|
||||
return true;
|
||||
}
|
||||
if (powerDownManager->isActive(bank))
|
||||
{
|
||||
powerDownManager->wakeUp(bank, time);
|
||||
return true;
|
||||
}
|
||||
powerDownManager->wakeUp(bank, time);
|
||||
|
||||
ScheduledCommand lastScheduledCommand = state.getLastScheduledCommand(bank);
|
||||
@@ -134,7 +120,6 @@ bool Controller::isBusy(sc_time time, Bank bank)
|
||||
}
|
||||
else if (lastScheduledCommand.isIn( { Command::SREF, Command::PDNP, Command::PDNA }))
|
||||
{
|
||||
//powerDownManager->wakeUp(bank, time);
|
||||
return true;
|
||||
}
|
||||
else if (lastScheduledCommand.isIn( { Command::SREFX, Command::PDNPX, Command::PDNAX }))
|
||||
@@ -149,6 +134,35 @@ bool Controller::isBusy(sc_time time, Bank bank)
|
||||
|
||||
}
|
||||
|
||||
BankGroup Controller::getBankGroup(Bank bank) const
|
||||
{
|
||||
static std::map<Bank, BankGroup> bankgroups;
|
||||
if (bankgroups.size() == 0)
|
||||
{
|
||||
SC_ASSERT_(config.NumberOfBanks % config.NumberOfBankGroups == 0, "Number of banks must be a multiple of number of bankgroups");
|
||||
|
||||
for (unsigned int bank = 0; bank < config.NumberOfBanks; bank++)
|
||||
{
|
||||
unsigned int group = bank / config.NumberOfBankGroups;
|
||||
bankgroups.insert(std::pair<Bank, BankGroup>(Bank(bank), BankGroup(group)));
|
||||
}
|
||||
}
|
||||
return bankgroups.at(bank);
|
||||
}
|
||||
|
||||
std::vector<Bank> Controller::getBanks() const
|
||||
{
|
||||
static std::vector<Bank> banks;
|
||||
if (banks.size() == 0)
|
||||
{
|
||||
for (unsigned int i = 0; i < config.NumberOfBanks; i++)
|
||||
{
|
||||
banks.push_back(Bank(i));
|
||||
}
|
||||
}
|
||||
return banks;
|
||||
}
|
||||
|
||||
void Controller::send(const CommandSchedule& schedule, tlm::tlm_generic_payload& payload) const
|
||||
{
|
||||
for (const ScheduledCommand& cmd : schedule.getScheduledCommands())
|
||||
|
||||
@@ -38,6 +38,9 @@ public:
|
||||
void saveState();
|
||||
void resetState();
|
||||
|
||||
BankGroup getBankGroup(Bank bank) const;
|
||||
std::vector<Bank> getBanks() const;
|
||||
|
||||
void send(const CommandSchedule& schedule, tlm::tlm_generic_payload& payload) const;
|
||||
|
||||
Configuration config;
|
||||
|
||||
@@ -24,7 +24,7 @@ class ControllerState
|
||||
{
|
||||
public:
|
||||
ControllerState(Configuration* config) :
|
||||
bankStates(config->numberOfBanks), nActivateWindow(config->nActivate), bus(
|
||||
bankStates(config->NumberOfBanks), nActivateWindow(config->nActivate), bus(
|
||||
config->Timings.clk), activates(config->Timings.clk), config(config)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ PowerDownManager::~PowerDownManager()
|
||||
*/
|
||||
void PowerDownManager::init()
|
||||
{
|
||||
for (Bank bank : controller.state.bankStates.getBanks())
|
||||
for (Bank bank : controller.getBanks())
|
||||
{
|
||||
ScheduledCommand pdn(Command::PDNP, SC_ZERO_TIME, SC_ZERO_TIME,
|
||||
DramExtension::getExtension(powerDownPayloads.at(bank.ID())));
|
||||
@@ -194,7 +194,7 @@ void PowerDownManager::sendEnd(sc_time time)
|
||||
|
||||
void PowerDownManager::setupPayloads()
|
||||
{
|
||||
for (Bank bank : controller.state.bankStates.getBanks())
|
||||
for (Bank bank : controller.getBanks())
|
||||
{
|
||||
tlm_generic_payload& payload = powerDownPayloads.at(bank.ID());
|
||||
payload.set_address(getStartAddress(bank));
|
||||
|
||||
@@ -31,7 +31,7 @@ PowerDownManagerBankwise::~PowerDownManagerBankwise()
|
||||
*/
|
||||
void PowerDownManagerBankwise::init()
|
||||
{
|
||||
for (Bank bank : controller.state.bankStates.getBanks())
|
||||
for (Bank bank : controller.getBanks())
|
||||
{
|
||||
ScheduledCommand pdn(Command::PDNP, SC_ZERO_TIME, SC_ZERO_TIME,
|
||||
DramExtension::getExtension(powerDownPayloads.at(bank.ID())));
|
||||
@@ -149,7 +149,7 @@ void PowerDownManagerBankwise::sendEnd(Bank bank, sc_time time)
|
||||
|
||||
void PowerDownManagerBankwise::setupPayloads()
|
||||
{
|
||||
for (Bank bank : controller.state.bankStates.getBanks())
|
||||
for (Bank bank : controller.getBanks())
|
||||
{
|
||||
tlm_generic_payload& payload = powerDownPayloads.at(bank.ID());
|
||||
payload.set_address(getStartAddress(bank));
|
||||
|
||||
@@ -78,7 +78,7 @@ void RefreshManager::reInitialize(tlm::tlm_generic_payload& payload, sc_time tim
|
||||
|
||||
void RefreshManager::setupTransactions()
|
||||
{
|
||||
for (Bank bank : controller.state.bankStates.getBanks())
|
||||
for (Bank bank : controller.getBanks())
|
||||
{
|
||||
tlm_generic_payload& payload = refreshPayloads.at(bank.ID());
|
||||
payload.set_address(getStartAddress(bank));
|
||||
|
||||
@@ -18,7 +18,7 @@ RefreshManagerBankwise::RefreshManagerBankwise(Controller& controller) :
|
||||
{
|
||||
assert(!controller.config.Timings.refreshTimings.empty());
|
||||
|
||||
for (Bank bank : controller.state.bankStates.getBanks())
|
||||
for (Bank bank : controller.getBanks())
|
||||
{
|
||||
refreshManagerForBanks.push_back(new RefreshManagerForBank(controller, bank));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
iSocket.register_nb_transport_bw(this, &ControllerWrapper::nb_transport_bw);
|
||||
tSocket.register_nb_transport_fw(this, &ControllerWrapper::nb_transport_fw);
|
||||
|
||||
payloadsInSystem = std::vector<int>(controller->config.numberOfBanks);
|
||||
payloadsInSystem = std::vector<int>(controller->config.NumberOfBanks);
|
||||
}
|
||||
|
||||
~ControllerWrapper()
|
||||
@@ -310,7 +310,7 @@ private:
|
||||
|
||||
void stop()
|
||||
{
|
||||
for (Bank bank : controller->state.bankStates.getBanks())
|
||||
for (Bank bank : controller->getBanks())
|
||||
{
|
||||
controller->powerDownManager->wakeUp(bank, sc_time_stamp());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user