Included splitting into gem5.
This commit is contained in:
Binary file not shown.
@@ -41,6 +41,10 @@ set(DCMAKE_SH="CMAKE_SH-NOTFOUND")
|
||||
|
||||
find_library(GEM5_LIBRARY gem5_${GEM5_VARIANT} PATH $ENV{GEM5}/build/${GEM5_ARCH}/)
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../library/src/simulation/DRAMSysRecordable.cpp)
|
||||
add_definitions(-DRECORDING)
|
||||
endif()
|
||||
|
||||
add_executable(DRAMSys_gem5
|
||||
main.cpp
|
||||
$ENV{GEM5}/util/systemc/sc_logger.cc
|
||||
|
||||
@@ -41,25 +41,29 @@
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "DRAMSys.h"
|
||||
#include "TraceSetup.h"
|
||||
|
||||
#include "report_handler.hh"
|
||||
#include "sc_target.hh"
|
||||
#include "sim_control.hh"
|
||||
#include "slave_transactor.hh"
|
||||
#include "stats.hh"
|
||||
|
||||
using namespace std;
|
||||
#include "DRAMSys.h"
|
||||
|
||||
#ifdef RECORDING
|
||||
#include "DRAMSysRecordable.h"
|
||||
#include "../common/third_party/nlohmann/single_include/nlohmann/json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
#endif
|
||||
|
||||
using namespace tlm;
|
||||
|
||||
class Gem5SimControlDRAMsys: public Gem5SystemC::Gem5SimControl
|
||||
class Gem5SimControlDRAMsys : public Gem5SystemC::Gem5SimControl
|
||||
{
|
||||
public:
|
||||
Gem5SimControlDRAMsys(string configFile) :
|
||||
Gem5SimControlDRAMsys(std::string configFile) :
|
||||
Gem5SystemC::Gem5SimControl("gem5", configFile, 0, "MemoryAccess")
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void afterSimulate()
|
||||
{
|
||||
@@ -68,7 +72,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
struct AddressOffset: sc_module {
|
||||
class AddressOffset : sc_module
|
||||
{
|
||||
private:
|
||||
unsigned long long int offset;
|
||||
|
||||
@@ -86,7 +91,7 @@ public:
|
||||
}
|
||||
|
||||
//Forward Interface
|
||||
tlm::tlm_sync_enum nb_transport_fw(tlm_generic_payload &trans, tlm_phase &phase,
|
||||
tlm_sync_enum nb_transport_fw(tlm_generic_payload &trans, tlm_phase &phase,
|
||||
sc_time &delay)
|
||||
{
|
||||
//std::cout << "NB "<< this->name() <<": " << trans.get_address() << " -" << offset;
|
||||
@@ -95,7 +100,7 @@ public:
|
||||
return i_socket->nb_transport_fw(trans, phase, delay);
|
||||
}
|
||||
|
||||
unsigned int transport_dbg(tlm::tlm_generic_payload &trans)
|
||||
unsigned int transport_dbg(tlm_generic_payload &trans)
|
||||
{
|
||||
// adjust address offset:
|
||||
//std::cout << "Debug "<< this->name() <<": " << trans.get_address() << " -" << offset;
|
||||
@@ -104,7 +109,7 @@ public:
|
||||
return i_socket->transport_dbg(trans);
|
||||
}
|
||||
|
||||
void b_transport(tlm::tlm_generic_payload &trans, sc_time &delay)
|
||||
void b_transport(tlm_generic_payload &trans, sc_time &delay)
|
||||
{
|
||||
// adjust address offset:
|
||||
//std::cout << "B "<< this->name() <<": " << trans.get_address() << " -" << offset;
|
||||
@@ -114,7 +119,7 @@ public:
|
||||
}
|
||||
|
||||
//Backward Interface
|
||||
tlm::tlm_sync_enum nb_transport_bw(tlm_generic_payload &trans, tlm_phase &phase,
|
||||
tlm_sync_enum nb_transport_bw(tlm_generic_payload &trans, tlm_phase &phase,
|
||||
sc_time &delay)
|
||||
{
|
||||
//trans.set_address(trans.get_address()+offset);
|
||||
@@ -123,7 +128,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
string pathOfFile(string file)
|
||||
std::string pathOfFile(std::string file)
|
||||
{
|
||||
return file.substr(0, file.find_last_of('/'));
|
||||
}
|
||||
@@ -132,9 +137,9 @@ int sc_main(int argc, char **argv)
|
||||
{
|
||||
SC_REPORT_INFO("sc_main", "Simulation Setup");
|
||||
|
||||
string SimulationXML;
|
||||
string gem5ConfigFile;
|
||||
string resources;
|
||||
std::string simulationJson;
|
||||
std::string gem5ConfigFile;
|
||||
std::string resources;
|
||||
unsigned int numTransactors;
|
||||
Gem5SystemC::Gem5SlaveTransactor *t;
|
||||
std::vector<Gem5SystemC::Gem5SlaveTransactor *> transactors;
|
||||
@@ -142,18 +147,28 @@ int sc_main(int argc, char **argv)
|
||||
if (argc == 4) {
|
||||
// Get path of resources:
|
||||
resources = pathOfFile(argv[0])
|
||||
+ string("/../../DRAMSys/library/resources/");
|
||||
+ std::string("/../../DRAMSys/library/resources/");
|
||||
|
||||
SimulationXML = argv[1];
|
||||
simulationJson = argv[1];
|
||||
gem5ConfigFile = argv[2];
|
||||
numTransactors = atoi(argv[3]);
|
||||
numTransactors = std::stoul(argv[3]);
|
||||
|
||||
} else {
|
||||
SC_REPORT_FATAL("sc_main", "Please provide configuration files and number of ports");
|
||||
}
|
||||
|
||||
// Instantiate DRAMSys:
|
||||
DRAMSys dramSys("DRAMSys", SimulationXML, resources);
|
||||
DRAMSys *dramSys;
|
||||
#ifdef RECORDING
|
||||
json simulationdoc = parseJSON(simulationJson);
|
||||
json simulatordoc = parseJSON(resources + "configs/simulator/"
|
||||
+ std::string(simulationdoc["simulation"]["simconfig"]));
|
||||
|
||||
if (simulatordoc["simconfig"]["DatabaseRecording"])
|
||||
dramSys = new DRAMSysRecordable("DRAMSys", simulationJson, resources);
|
||||
else
|
||||
#endif
|
||||
dramSys = new DRAMSys("DRAMSys", simulationJson, resources);
|
||||
|
||||
// Instantiate gem5:
|
||||
Gem5SimControlDRAMsys sim_control(gem5ConfigFile);
|
||||
@@ -164,7 +179,7 @@ int sc_main(int argc, char **argv)
|
||||
// Names generated here must match port names used by the gem5 config file, e.g., config.ini
|
||||
if (numTransactors == 1) {
|
||||
t = new Gem5SystemC::Gem5SlaveTransactor("transactor", "transactor");
|
||||
t->socket.bind(dramSys.tSocket);
|
||||
t->socket.bind(dramSys->tSocket);
|
||||
t->sim_control.bind(sim_control);
|
||||
transactors.push_back(t);
|
||||
} else {
|
||||
@@ -174,7 +189,7 @@ int sc_main(int argc, char **argv)
|
||||
std::string name = "transactor" + std::to_string(index);
|
||||
std::string portName = "transactor" + std::to_string(index);
|
||||
t = new Gem5SystemC::Gem5SlaveTransactor(name.c_str(), portName.c_str());
|
||||
t->socket.bind(dramSys.tSocket);
|
||||
t->socket.bind(dramSys->tSocket);
|
||||
t->sim_control.bind(sim_control);
|
||||
transactors.push_back(t);
|
||||
}
|
||||
@@ -190,9 +205,9 @@ int sc_main(int argc, char **argv)
|
||||
AddressOffset dramOffset("dramOffset", (2147483648 - 67108863)); //+67108863);
|
||||
|
||||
dramInterface.socket.bind(dramOffset.t_socket);
|
||||
dramOffset.i_socket.bind(dramSys.tSocket); // ID0
|
||||
dramOffset.i_socket.bind(dramSys->tSocket); // ID0
|
||||
nvmInterface.socket.bind(nvmOffset.t_socket);
|
||||
nvmOffset.i_socket.bind(dramSys.tSocket);
|
||||
nvmOffset.i_socket.bind(dramSys->tSocket);
|
||||
|
||||
dramInterface.sim_control.bind(sim_control);
|
||||
nvmInterface.sim_control.bind(sim_control);
|
||||
@@ -208,9 +223,10 @@ int sc_main(int argc, char **argv)
|
||||
sc_core::sc_stop();
|
||||
}
|
||||
|
||||
for (auto t : transactors) {
|
||||
for (auto t : transactors)
|
||||
delete t;
|
||||
}
|
||||
|
||||
delete dramSys;
|
||||
|
||||
SC_REPORT_INFO("sc_main", "End of Simulation");
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"simulation": {
|
||||
"addressmapping": "am_wideio.xml",
|
||||
"mcconfig": "sms.xml",
|
||||
"memspec": "wideio.json",
|
||||
"simconfig": "sms.xml",
|
||||
"simulationid": "sms-example",
|
||||
"thermalconfig": "config.xml",
|
||||
"tracesetup": [
|
||||
{
|
||||
"clkMhz": 1000,
|
||||
"name": "random.stl"
|
||||
},
|
||||
{
|
||||
"clkMhz": 1000,
|
||||
"name": "chstone-adpcm_32.stl"
|
||||
},
|
||||
{
|
||||
"clkMhz": 1000,
|
||||
"name": "stream.stl"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -68,24 +68,24 @@ int sc_main(int argc, char **argv)
|
||||
sc_set_time_resolution(1, SC_PS);
|
||||
|
||||
std::string resources;
|
||||
std::string simulationJSON;
|
||||
std::string simulationJson;
|
||||
// Run only with default config (ddr3-example.json):
|
||||
if (argc == 1) {
|
||||
// Get path of resources:
|
||||
resources = pathOfFile(argv[0])
|
||||
+ std::string("/../../DRAMSys/library/resources/");
|
||||
simulationJSON = resources + "simulations/ddr3-example.json";
|
||||
simulationJson = resources + "simulations/ddr3-example.json";
|
||||
}
|
||||
// Run with specific config but default resource folders:
|
||||
else if (argc == 2) {
|
||||
// Get path of resources:
|
||||
resources = pathOfFile(argv[0])
|
||||
+ std::string("/../../DRAMSys/library/resources/");
|
||||
simulationJSON = argv[1];
|
||||
simulationJson = argv[1];
|
||||
}
|
||||
// Run with spefific config and specific resource folder:
|
||||
else if (argc == 3) {
|
||||
simulationJSON = argv[1];
|
||||
simulationJson = argv[1];
|
||||
resources = argv[2];
|
||||
}
|
||||
|
||||
@@ -94,18 +94,18 @@ int sc_main(int argc, char **argv)
|
||||
// Instantiate DRAMSys:
|
||||
DRAMSys *dramSys;
|
||||
#ifdef RECORDING
|
||||
json simulationdoc = parseJSON(simulationJSON);
|
||||
json simulationdoc = parseJSON(simulationJson);
|
||||
json simulatordoc = parseJSON(resources + "configs/simulator/"
|
||||
+ std::string(simulationdoc["simulation"]["simconfig"]));
|
||||
|
||||
if (simulatordoc["simconfig"]["DatabaseRecording"])
|
||||
dramSys = new DRAMSysRecordable("DRAMSys", simulationJSON, resources);
|
||||
dramSys = new DRAMSysRecordable("DRAMSys", simulationJson, resources);
|
||||
else
|
||||
#endif
|
||||
dramSys = new DRAMSys("DRAMSys", simulationJSON, resources);
|
||||
dramSys = new DRAMSys("DRAMSys", simulationJson, resources);
|
||||
|
||||
// Instantiate STL Players:
|
||||
TraceSetup *ts = new TraceSetup(simulationJSON, resources, &players);
|
||||
TraceSetup *ts = new TraceSetup(simulationJson, resources, &players);
|
||||
|
||||
// Bind STL Players with DRAMSys:
|
||||
for (size_t i = 0; i < players.size(); i++)
|
||||
|
||||
Reference in New Issue
Block a user