base
This commit is contained in:
57
DRAM/src/common/BankStates.cpp
Normal file
57
DRAM/src/common/BankStates.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* BankStates.cpp
|
||||
*
|
||||
* Created on: Feb 24, 2014
|
||||
* Author: robert
|
||||
*/
|
||||
|
||||
#include "BankStates.h"
|
||||
|
||||
namespace common {
|
||||
|
||||
using namespace std;
|
||||
|
||||
BankStates::BankStates(unsigned int numberOfBanks) :
|
||||
rowsInRowBuffers(numberOfBanks)
|
||||
{
|
||||
for (unsigned int i = 0; i < numberOfBanks; ++i)
|
||||
{
|
||||
banks.push_back(Bank(i));
|
||||
}
|
||||
|
||||
closeAllRowBuffers();
|
||||
}
|
||||
|
||||
BankStates::~BankStates()
|
||||
{
|
||||
}
|
||||
|
||||
bool BankStates::rowBufferIsOpen(const Bank &bank) const
|
||||
{
|
||||
return rowsInRowBuffers.at(bank.ID()) != Row::NO_ROW;
|
||||
}
|
||||
|
||||
Row BankStates::getRowInRowBuffer(const Bank &bank) const
|
||||
{
|
||||
return rowsInRowBuffers.at(bank.ID());
|
||||
}
|
||||
|
||||
void BankStates::openRowInRowBuffer(const Bank &bank, const Row &row)
|
||||
{
|
||||
rowsInRowBuffers.at(bank.ID()) = row;
|
||||
}
|
||||
|
||||
void BankStates::closeRowBuffer(const Bank &bank)
|
||||
{
|
||||
rowsInRowBuffers.at(bank.ID()) = Row::NO_ROW;
|
||||
}
|
||||
|
||||
void BankStates::closeAllRowBuffers()
|
||||
{
|
||||
for(vector<Bank>::iterator it = banks.begin(); it != banks.end(); ++it)
|
||||
{
|
||||
closeRowBuffer(*it);
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace scheduler */
|
||||
37
DRAM/src/common/BankStates.h
Normal file
37
DRAM/src/common/BankStates.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* BankStates.h
|
||||
*
|
||||
* Created on: Feb 24, 2014
|
||||
* Author: robert
|
||||
*/
|
||||
|
||||
#ifndef BANKSTATES_H_
|
||||
#define BANKSTATES_H_
|
||||
#include <vector>
|
||||
#include "schedulerextension.h"
|
||||
|
||||
namespace common {
|
||||
|
||||
class BankStates {
|
||||
public:
|
||||
BankStates(unsigned int numberOfBanks);
|
||||
virtual ~BankStates();
|
||||
|
||||
unsigned int getNumberOfBanks() const {return rowsInRowBuffers.size();}
|
||||
const std::vector<Bank>& getBanks() const {return banks;}
|
||||
|
||||
bool rowBufferIsOpen(const Bank &bank) const;
|
||||
Row getRowInRowBuffer(const Bank &bank) const;
|
||||
|
||||
void openRowInRowBuffer(const Bank &bank, const Row &row);
|
||||
void closeRowBuffer(const Bank &bank);
|
||||
void closeAllRowBuffers();
|
||||
|
||||
private:
|
||||
std::vector<Bank> banks;
|
||||
std::vector<Row> rowsInRowBuffers;
|
||||
};
|
||||
|
||||
} /* namespace scheduler */
|
||||
|
||||
#endif /* BANKSTATES_H_ */
|
||||
77
DRAM/src/common/schedulerextension.cpp
Normal file
77
DRAM/src/common/schedulerextension.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "schedulerextension.h"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace tlm;
|
||||
|
||||
namespace common {
|
||||
|
||||
tlm_extension_base* SchedulerExtension::clone() const
|
||||
{
|
||||
return new SchedulerExtension(thread, bank, row, column);
|
||||
}
|
||||
|
||||
void SchedulerExtension::copy_from(const tlm_extension_base &ext)
|
||||
{
|
||||
const SchedulerExtension &cpyFrom = static_cast<const SchedulerExtension&>(ext);
|
||||
thread = cpyFrom.thread;
|
||||
bank = cpyFrom.bank;
|
||||
row = cpyFrom.row;
|
||||
column = cpyFrom.column;
|
||||
}
|
||||
|
||||
/* Static methods
|
||||
*
|
||||
*/
|
||||
const SchedulerExtension& SchedulerExtension::getExtension(const tlm_generic_payload *payload)
|
||||
{
|
||||
SchedulerExtension *result = NULL;
|
||||
payload->get_extension(result);
|
||||
assert(result != NULL);
|
||||
return *result;
|
||||
}
|
||||
|
||||
bool operator ==(const Thread& lhs, const Thread& rhs)
|
||||
{
|
||||
return lhs.ID() == rhs.ID();
|
||||
}
|
||||
|
||||
bool operator !=(const Thread& lhs, const Thread& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator ==(const Bank& lhs, const Bank& rhs)
|
||||
{
|
||||
return lhs.ID() == rhs.ID();
|
||||
}
|
||||
|
||||
bool operator !=(const Bank& lhs, const Bank& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
const Row Row::NO_ROW;
|
||||
|
||||
bool operator ==(const Row& lhs, const Row& rhs)
|
||||
{
|
||||
if(lhs.isNoRow != rhs.isNoRow)
|
||||
return false;
|
||||
return lhs.ID() == rhs.ID();
|
||||
}
|
||||
|
||||
bool operator !=(const Row& lhs, const Row& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator ==(const Column& lhs, const Column& rhs)
|
||||
{
|
||||
return lhs.ID() == rhs.ID();
|
||||
}
|
||||
|
||||
bool operator !=(const Column& lhs, const Column& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
}
|
||||
91
DRAM/src/common/schedulerextension.h
Normal file
91
DRAM/src/common/schedulerextension.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#ifndef SCHEDULEREXTENSION_H
|
||||
#define SCHEDULEREXTENSION_H
|
||||
#include <tlm.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace common{
|
||||
|
||||
class Thread
|
||||
{
|
||||
public :
|
||||
explicit Thread(unsigned int id) : id(id) {}
|
||||
|
||||
unsigned int ID() const { return id;}
|
||||
private:
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
class Bank
|
||||
{
|
||||
public :
|
||||
explicit Bank(unsigned int id) : id(id) {}
|
||||
unsigned int ID() const { return id;}
|
||||
private:
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
|
||||
class Row
|
||||
{
|
||||
public :
|
||||
static const Row NO_ROW;
|
||||
|
||||
Row() : id(0), isNoRow(true) {}
|
||||
explicit Row(unsigned int id) : id(id), isNoRow(false) {}
|
||||
|
||||
unsigned int ID() const { return id;}
|
||||
private:
|
||||
unsigned int id;
|
||||
bool isNoRow;
|
||||
|
||||
friend bool operator==(const Row &lhs, const Row &rhs);
|
||||
};
|
||||
|
||||
class Column
|
||||
{
|
||||
public :
|
||||
explicit Column(unsigned int id) : id(id) {}
|
||||
|
||||
unsigned int ID() const { return id;}
|
||||
private:
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
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 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);
|
||||
|
||||
class SchedulerExtension : public tlm::tlm_extension<SchedulerExtension>
|
||||
{
|
||||
private:
|
||||
Thread thread;
|
||||
Bank bank;
|
||||
Row row;
|
||||
Column column;
|
||||
|
||||
public:
|
||||
|
||||
SchedulerExtension():thread(0),bank(0),row(0),column(0){}
|
||||
SchedulerExtension(const Thread& thread, const Bank& bank, const Row& row, const Column& column) :
|
||||
thread(thread),bank(bank),row(row),column(column){}
|
||||
|
||||
~SchedulerExtension(){}
|
||||
virtual tlm::tlm_extension_base* clone() const;
|
||||
virtual void copy_from(const tlm_extension_base &ext);
|
||||
|
||||
const Thread& getThread() const{return thread;}
|
||||
const Bank& getBank() const{return bank;}
|
||||
const Row& getRow() const{return row;}
|
||||
const Column& getColumn() const{return column;}
|
||||
|
||||
static const SchedulerExtension& getExtension(const tlm::tlm_generic_payload *payload);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
#endif // SCHEDULEREXTENSION_H
|
||||
24
DRAM/src/core/Configuration.h
Normal file
24
DRAM/src/core/Configuration.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Configuration.h
|
||||
*
|
||||
* Created on: Mar 6, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#ifndef CONFIGURATION_H_
|
||||
#define CONFIGURATION_H_
|
||||
|
||||
#include <systemc.h>
|
||||
#include "TimingConfiguration.h"
|
||||
|
||||
namespace controller{
|
||||
|
||||
struct Configuration
|
||||
{
|
||||
TimingConfiguration Timings;
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
|
||||
#endif /* CONFIGURATION_H_ */
|
||||
13
DRAM/src/core/Controller.cpp
Normal file
13
DRAM/src/core/Controller.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* controller.cpp
|
||||
*
|
||||
* Created on: Mar 5, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#include "Controller.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
|
||||
} /* namespace controller */
|
||||
31
DRAM/src/core/Controller.h
Normal file
31
DRAM/src/core/Controller.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* controller.h
|
||||
*
|
||||
* Created on: Mar 5, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#ifndef CONTROLLER_H_
|
||||
#define CONTROLLER_H_
|
||||
|
||||
#include <tlm.h>
|
||||
#include "scheduling/CommandGenerator.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
class Controller {
|
||||
public:
|
||||
Controller();
|
||||
virtual ~Controller();
|
||||
|
||||
bool schedule(tlm::tlm_generic_payload* externalTransaction);//return TLM status??
|
||||
|
||||
private:
|
||||
ControllerState state;
|
||||
CommandGenerator commandGenerator;
|
||||
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
#endif /* CONTROLLER_H_ */
|
||||
21
DRAM/src/core/ControllerState.cpp
Normal file
21
DRAM/src/core/ControllerState.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* controller_state.cpp
|
||||
*
|
||||
* Created on: Mar 5, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#include "ControllerState.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
ControllerState::ControllerState(unsigned int numberOfBanks) : bankStates(numberOfBanks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ControllerState::~ControllerState() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
} /* namespace controller */
|
||||
25
DRAM/src/core/ControllerState.h
Normal file
25
DRAM/src/core/ControllerState.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* controller_state.h
|
||||
*
|
||||
* Created on: Mar 5, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#ifndef CONTROLLER_STATE_H_
|
||||
#define CONTROLLER_STATE_H_
|
||||
|
||||
#include "common/BankStates.h"
|
||||
|
||||
namespace controller {
|
||||
|
||||
class ControllerState {
|
||||
public:
|
||||
ControllerState(unsigned int numberOfBanks);
|
||||
virtual ~ControllerState();
|
||||
|
||||
common::BankStates bankStates;
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
#endif /* CONTROLLER_STATE_H_ */
|
||||
37
DRAM/src/core/TimingConfiguration.h
Normal file
37
DRAM/src/core/TimingConfiguration.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* TimingConfiguration.h
|
||||
*
|
||||
* Created on: Mar 6, 2014
|
||||
* Author: jonny
|
||||
*/
|
||||
|
||||
#ifndef TIMINGS_H_
|
||||
#define TIMINGS_H_
|
||||
|
||||
#include <systemc.h>
|
||||
|
||||
namespace controller{
|
||||
|
||||
struct TimingConfiguration
|
||||
{
|
||||
sc_time clk = sc_time(6.0, SC_NS); // 166MHz
|
||||
|
||||
|
||||
sc_time tRP = 3*clk;
|
||||
sc_time tRAS = 6*clk;
|
||||
sc_time tRC = tRP + tRAS;
|
||||
|
||||
//Refresh
|
||||
sc_time tRFC = 18*clk;
|
||||
sc_time tREF = sc_time(64, SC_MS);
|
||||
sc_time tREFA = tRP + tRFC;
|
||||
sc_time tREFB = tRP + tRC;
|
||||
|
||||
sc_time tREFI = tREFA;
|
||||
|
||||
};
|
||||
|
||||
} /* namespace controller */
|
||||
|
||||
|
||||
#endif /* TimingConfiguration_H_ */
|
||||
47
DRAM/testing/testUtils.cpp
Normal file
47
DRAM/testing/testUtils.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "testUtils.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace tlm;
|
||||
using namespace common;
|
||||
|
||||
/* Scheduler related stuff
|
||||
*
|
||||
*
|
||||
*/
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(SchedulerExtension *extension)
|
||||
{
|
||||
shared_ptr<tlm_generic_payload> result(new tlm_generic_payload());
|
||||
result->set_extension(extension);
|
||||
return result;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
payload.get()->set_command(command);
|
||||
return payload;
|
||||
}
|
||||
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload(const Thread& thread, const Bank& bank,
|
||||
const Row& row)
|
||||
{
|
||||
return createDummyPayload(new SchedulerExtension(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)));
|
||||
}
|
||||
|
||||
shared_ptr<tlm_generic_payload> createDummyPayload()
|
||||
{
|
||||
return createDummyPayload(new SchedulerExtension());
|
||||
}
|
||||
25
DRAM/testing/testUtils.h
Normal file
25
DRAM/testing/testUtils.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef TESTUTILS_H
|
||||
#define TESTUTILS_H
|
||||
|
||||
#include <tlm.h>
|
||||
#include <memory>
|
||||
#include "common/schedulerextension.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(const common::Thread& thread,
|
||||
const common::Bank& bank, const common::Row& row, const common::Column& column);
|
||||
|
||||
std::shared_ptr<tlm::tlm_generic_payload> createDummyPayload(const common::Thread& thread,
|
||||
const common::Bank& bank, const common::Row& row);
|
||||
|
||||
std::shared_ptr<tlm::tlm_generic_payload> createDummyPayload(const common::Thread& thread,
|
||||
const common::Bank& bank);
|
||||
|
||||
std::shared_ptr<tlm::tlm_generic_payload> createDummyPayload(const common::Thread& thread,
|
||||
const common::Bank& bank, const common::Row& row, const common::Column& column,
|
||||
const tlm::tlm_command& command);
|
||||
|
||||
#endif // TESTUTILS_H
|
||||
Reference in New Issue
Block a user