Controllers and drams objects creation based base on the number of channels.

This commit is contained in:
Éder Ferreira Zulian
2015-06-12 18:08:32 +02:00
parent 97a50dff9f
commit fbde607efd
2 changed files with 40 additions and 30 deletions

View File

@@ -100,46 +100,53 @@ void Simulation::setupTlmRecorder(const string &traceName, const string &pathToR
void Simulation::instantiateModules(const string &pathToResources, const std::vector<Device>& devices)
{
// TODO: the number of Drams objects or the number of target sockets in a Dram object should be proportional to the number of controllers/channles (info from config)
dram = new Dram<>("dram");
arbiter = new Arbiter<NumberOfTracePlayers, 128, NumberOfMemChannels>("arbiter");
// TODO: the number of controllers should be the number of channesl, right?!
// each of the arbiter's initiators sockets should bind to a controller...
// The number of channels is equal the number of controllers and comes from config.
controller = new Controller<>("controller");
for (size_t i = 0; i < NumberOfTracePlayers; i++) {
std::string playerStr = "player" + std::to_string(i);
TracePlayer<> *player = new StlPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this);
players.push_back(player);
}
arbiter = new Arbiter<NumberOfTracePlayers, 128, NumberOfMemChannels>("arbiter");
for (size_t i = 0; i < NumberOfMemChannels; i++) {
std::string str = "controller" + std::to_string(i);
Controller<> *controller = new Controller<>(str.c_str());
controllers.push_back(controller);
str = "dram" + std::to_string(i);
Dram<> *dram = new Dram<>(str.c_str());
drams.push_back(dram);
}
}
void Simulation::bindSockets()
{
int i = 0;
size_t i = 0;
for (auto player : players) {
player->iSocket.bind(arbiter->tSockets[i++]);
}
// TODO: the number of controllers should be the number of channesl, right?!
// each of the arbiter's initiators sockets should bind to a controller...
arbiter->iSocket[0].bind(controller->tSocket);
controller->iSocket.bind(dram->tSocket);
for (i = 0; i < NumberOfMemChannels; i++) {
arbiter->iSocket[i].bind(controllers[i]->tSocket);
controllers[i]->iSocket.bind(drams[i]->tSocket);
}
}
Simulation::~Simulation()
{
delete dram;
delete arbiter;
// TODO: the number of components should come from config
delete controller;
for (auto player : players) {
delete player;
}
delete arbiter;
for (auto controller : controllers) {
delete controller;
}
for (auto dram : drams) {
delete dram;
}
}
void Simulation::start()
@@ -173,7 +180,9 @@ void Simulation::stop()
{
wait(terminateSimulation);
report("\nTerminating simulation");
controller->terminateSimulation();
for (auto controller : controllers) {
controller->terminateSimulation();
}
wait(sc_time(200, SC_NS));
TlmRecorder::getInstance().closeConnection();
sc_stop();

View File

@@ -78,7 +78,6 @@ class Simulation: public sc_module, public TracePlayerListener
{
public:
SC_HAS_PROCESS(Simulation);
//Simulation(sc_module_name name, string pathToResources, string traceName, std::vector<Device> devices);
Simulation(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
std::vector<Device> devices);
~Simulation();
@@ -98,15 +97,17 @@ private:
sc_event terminateSimulation;
// TODO: here should be a vector or some other abstract data type and elements should be dynamically allocated based on configuration
Dram<> *dram;
Arbiter<NumberOfTracePlayers, 128, NumberOfMemChannels> *arbiter;
// TODO: here should be a vector or some other abstract data type and elements should be dynamically allocated based on configuration
Controller<> *controller;
ReorderBuffer<> *reorder;
// A vector of pointers to all trace player (that represent devices which acquire the bus and generate transactions targeting the memory)
// A vector of pointers to all trace player (devices which acquire the bus
// and initiate transactions targeting the memory)
std::vector<TracePlayer<>*> players;
// All transactions pass through the same arbiter
Arbiter<NumberOfTracePlayers, 128, NumberOfMemChannels> *arbiter;
// Each DRAM unit has a controller
std::vector<Controller<>*> controllers;
// TODO: Each DRAM has a reorder buffer (check this!)
ReorderBuffer<> *reorder;
// DRAM units
std::vector<Dram<>*> drams;
clock_t simulationStartTime;
void report(std::string message);