From c135d7c31bd3f4847f3e395b0224744227abd73c Mon Sep 17 00:00:00 2001 From: Janik Schlemminger Date: Tue, 15 Jul 2014 00:10:49 +0200 Subject: [PATCH 1/3] Traceplayer has a clock now --- dram/resources/simulations/sim-batch.xml | 2 +- dram/src/controller/core/TimingCalculation.cpp | 5 +++++ dram/src/controller/core/TimingCalculation.h | 1 + dram/src/controller/core/configuration/MemSpecLoader.cpp | 6 +++--- dram/src/simulation/Simulation.cpp | 8 ++++---- dram/src/simulation/Simulation.h | 3 ++- dram/src/simulation/SimulationManager.cpp | 2 +- dram/src/simulation/TracePlayer.h | 9 +++++---- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dram/resources/simulations/sim-batch.xml b/dram/resources/simulations/sim-batch.xml index 6956da22..7b793ec0 100644 --- a/dram/resources/simulations/sim-batch.xml +++ b/dram/resources/simulations/sim-batch.xml @@ -16,7 +16,7 @@ - mediabench-epic_32.stl + mediabench-epic_32.stl diff --git a/dram/src/controller/core/TimingCalculation.cpp b/dram/src/controller/core/TimingCalculation.cpp index b9dafb6a..407a9fbb 100644 --- a/dram/src/controller/core/TimingCalculation.cpp +++ b/dram/src/controller/core/TimingCalculation.cpp @@ -23,6 +23,11 @@ sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, sc_time constr return SC_ZERO_TIME; } +const sc_time FrequencyToClk(double frequencyMhz) +{ + return sc_time(1 / frequencyMhz, SC_US); +} + const sc_time clkAlign(sc_time time, Alignment alignment) { sc_time clk = Configuration::getInstance().Timings.clk; diff --git a/dram/src/controller/core/TimingCalculation.h b/dram/src/controller/core/TimingCalculation.h index 9ba13135..9b513f69 100644 --- a/dram/src/controller/core/TimingCalculation.h +++ b/dram/src/controller/core/TimingCalculation.h @@ -26,6 +26,7 @@ sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, sc_time constr enum Alignment {UP, DOWN}; const sc_time clkAlign(sc_time time, Alignment alignment = UP); bool isClkAligned(sc_time time, sc_time clk); +const sc_time FrequencyToClk(double frequencyMhz); } diff --git a/dram/src/controller/core/configuration/MemSpecLoader.cpp b/dram/src/controller/core/configuration/MemSpecLoader.cpp index 21536582..517ef18d 100644 --- a/dram/src/controller/core/configuration/MemSpecLoader.cpp +++ b/dram/src/controller/core/configuration/MemSpecLoader.cpp @@ -7,6 +7,7 @@ #include "MemSpecLoader.h" #include "TimingConfiguration.h" +#include "../TimingCalculation.h" using namespace tinyxml2; using namespace std; @@ -91,9 +92,8 @@ void MemSpecLoader::loadDDR4(Configuration& config, XMLElement* memspec) //MemTimings XMLElement* timings = memspec->FirstChildElement("memtimingspec"); double clkMhz = queryDoubleParameter(timings, "clkMhz"); - sc_time clk = sc_time(1 / clkMhz, SC_US); - config.Timings.clk = clk; - + config.Timings.clk = FrequencyToClk(clkMhz); + sc_time clk = config.Timings.clk; config.Timings.tRP = clk * queryUIntParameter(timings, "RP"); config.Timings.tRAS = clk * queryUIntParameter(timings, "RAS"); config.Timings.tRC = clk * queryUIntParameter(timings, "RC"); diff --git a/dram/src/simulation/Simulation.cpp b/dram/src/simulation/Simulation.cpp index 80af5417..8d86220b 100644 --- a/dram/src/simulation/Simulation.cpp +++ b/dram/src/simulation/Simulation.cpp @@ -83,10 +83,10 @@ void Simulation::instantiateModules(const string &pathToResources, const std::ve arbiter = new Arbiter("arbiter"); controller = new Controller<>("controller"); - player1 = new TracePlayer<>("player1", pathToResources + string("traces/") + devices[0].trace, devices[0].burstLength, this); - player2 = new TracePlayer<>("player2", pathToResources + string("traces/") + devices[1].trace, devices[1].burstLength, this); - player3 = new TracePlayer<>("player3", pathToResources + string("traces/") + devices[2].trace, devices[2].burstLength, this); - player4 = new TracePlayer<>("player4", pathToResources + string("traces/") + devices[3].trace, devices[3].burstLength, this); + player1 = new TracePlayer<>("player1", pathToResources + string("traces/") + devices[0].trace, devices[0].burstLength, devices[0].clk, this); + player2 = new TracePlayer<>("player2", pathToResources + string("traces/") + devices[1].trace, devices[1].burstLength, devices[1].clk, this); + player3 = new TracePlayer<>("player3", pathToResources + string("traces/") + devices[2].trace, devices[2].burstLength, devices[2].clk, this); + player4 = new TracePlayer<>("player4", pathToResources + string("traces/") + devices[3].trace, devices[3].burstLength, devices[3].clk, this); } void Simulation::bindSockets() diff --git a/dram/src/simulation/Simulation.h b/dram/src/simulation/Simulation.h index 463911e9..c5ca2af2 100644 --- a/dram/src/simulation/Simulation.h +++ b/dram/src/simulation/Simulation.h @@ -30,10 +30,11 @@ struct DramSetup struct Device { Device():trace("empty.stl"), burstLength(0){} - Device(std::string trace, unsigned int burstLength = 8) : trace(trace), burstLength(burstLength) + Device(std::string trace, sc_time clk, unsigned int burstLength = 8) : trace(trace), clk (clk), burstLength(burstLength) { } std::string trace; + sc_time clk; unsigned int burstLength; }; diff --git a/dram/src/simulation/SimulationManager.cpp b/dram/src/simulation/SimulationManager.cpp index fdc9fc4b..e53f8dcc 100644 --- a/dram/src/simulation/SimulationManager.cpp +++ b/dram/src/simulation/SimulationManager.cpp @@ -149,7 +149,7 @@ void SimulationManager::addTraceSetup(SimulationBatch& batch, tinyxml2::XMLEleme vector devices; for (XMLElement* device = element->FirstChildElement("device"); device != NULL; device = device->NextSiblingElement("device")) { - devices.push_back(Device(device->GetText(), device->IntAttribute("bl"))); + devices.push_back(Device(device->GetText(), FrequencyToClk(device->DoubleAttribute("clkMhz")), device->IntAttribute("bl"))); } while (devices.size() < Simulation::NumberOfTracePlayers) { diff --git a/dram/src/simulation/TracePlayer.h b/dram/src/simulation/TracePlayer.h index 1c76277a..8aa2028b 100644 --- a/dram/src/simulation/TracePlayer.h +++ b/dram/src/simulation/TracePlayer.h @@ -31,7 +31,7 @@ struct TracePlayer: public sc_module { public: tlm_utils::simple_initiator_socket iSocket; - TracePlayer(sc_module_name /*name*/, string pathToTrace, unsigned int burstLength, + TracePlayer(sc_module_name /*name*/, string pathToTrace, unsigned int burstLength, sc_time clk, simulation::ISimulation* simulationManager); void start(); @@ -46,6 +46,7 @@ private: MemoryManager memoryManager; ifstream file; unsigned int burstlenght; + sc_time clk; unsigned int numberOfPendingTransactions; unsigned int transactionsSent; unsigned int transactionsReceived; @@ -54,8 +55,8 @@ private: template -TracePlayer::TracePlayer(sc_module_name, string pathToTrace, unsigned int burstLength, simulation::ISimulation *simulationManager) : - payloadEventQueue(this, &TracePlayer::peqCallback), file(pathToTrace), burstlenght(burstLength), +TracePlayer::TracePlayer(sc_module_name, string pathToTrace, unsigned int burstLength, sc_time clk, simulation::ISimulation *simulationManager) : + payloadEventQueue(this, &TracePlayer::peqCallback), file(pathToTrace), burstlenght(burstLength), clk(clk), numberOfPendingTransactions(0), transactionsSent(0), transactionsReceived(0), simulationManager(simulationManager) { if (!file.is_open()) @@ -112,7 +113,7 @@ void TracePlayer::generateNextPayload() payload->set_byte_enable_length(0); payload->set_streaming_width(burstlenght); - sc_time sendingTime = sc_time(std::stoi(time.c_str()), SC_NS); + sc_time sendingTime = std::stoi(time.c_str())*clk; GenerationExtension* genExtension = new GenerationExtension(sendingTime); payload->set_auto_extension(genExtension); From 9d276335faaa77340a7b7707e74bd20f3c5e04ff Mon Sep 17 00:00:00 2001 From: Janik Schlemminger Date: Tue, 15 Jul 2014 13:14:34 +0200 Subject: [PATCH 2/3] fixed bug in controller state cleanup method --- analyzer/analyzer/evaluationtool.cpp | 4 ++-- analyzer/analyzer/paths.pro | 6 ++++-- dram/src/controller/core/ControllerState.cpp | 13 ++----------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/analyzer/analyzer/evaluationtool.cpp b/analyzer/analyzer/evaluationtool.cpp index 16f2af3d..5b9ec6d3 100644 --- a/analyzer/analyzer/evaluationtool.cpp +++ b/analyzer/analyzer/evaluationtool.cpp @@ -85,7 +85,7 @@ void EvaluationTool::runTests() { QString resourcesAbsPath = QApplication::applicationDirPath() + this->resourcesRelPath; qDebug() << resourcesAbsPath; - PythonCaller pythonCaller(this->resourcesRelPath); + PythonCaller pythonCaller(resourcesAbsPath); ui->traceTestTreeWidget->clear(); ui->testLight->setGray(); @@ -120,7 +120,7 @@ void EvaluationTool::calculateMetrics() { QString resourcesAbsPath = QApplication::applicationDirPath() + this->resourcesRelPath; qDebug() << resourcesAbsPath; - PythonCaller pythonCaller(this->resourcesRelPath); + PythonCaller pythonCaller(resourcesAbsPath); ui->traceMetricTreeWidget->clear(); for(int row = 0; row < traceFilesModel->rowCount(); ++row) { diff --git a/analyzer/analyzer/paths.pro b/analyzer/analyzer/paths.pro index 4502b6fe..102db5af 100644 --- a/analyzer/analyzer/paths.pro +++ b/analyzer/analyzer/paths.pro @@ -8,6 +8,8 @@ CONFIG(qwt){ CONFIG(python){ - LIBS += -lpython3.4m - INCLUDEPATH += /opt/python/include/python3.4m +# LIBS += -L/opt/python/lib -lpython3.4m +# INCLUDEPATH += /opt/python/include/python3.4m + LIBS += -lpython3.3m + INCLUDEPATH += /usr/include/python3.3 } diff --git a/dram/src/controller/core/ControllerState.cpp b/dram/src/controller/core/ControllerState.cpp index 4c27f6a5..7d0d6741 100644 --- a/dram/src/controller/core/ControllerState.cpp +++ b/dram/src/controller/core/ControllerState.cpp @@ -63,15 +63,9 @@ const ScheduledCommand ControllerState::getLastScheduledCommand(Bank bank) void ControllerState::change(const ScheduledCommand& scheduledCommand) { - //TODO double check if slot free? bus.blockSlot(scheduledCommand.getStart()); -// if(getLastCommand(scheduledCommand.getCommand()).getStart() > scheduledCommand.getStart()) -// cout << commandToString(scheduledCommand.getCommand()) << " wurde vorgezogen! " << std::endl; - lastScheduledByCommandAndBank[scheduledCommand.getCommand()][scheduledCommand.getBank()] = scheduledCommand; - //lastScheduledByBank[scheduledCommand.getCommand()] = scheduledCommand; - switch (scheduledCommand.getCommand()) { @@ -107,10 +101,6 @@ void ControllerState::change(const ScheduledCommand& scheduledCommand) default: break; } - -// cout << "Last Data Strobe Commands Size: " << lastDataStrobeCommands.size() << std::endl; -// cout << "Last Activates Size: " << lastActivates.size() << std::endl; -// cout << "Bus Slots: " << bus.slotSet.size(); } void ControllerState::cleanUp(sc_time time) @@ -123,7 +113,8 @@ void ControllerState::cleanUp(sc_time time) tmp.push_back(command); } lastDataStrobeCommands = tmp; - lastActivates.erase(lastActivates.begin(), lastActivates.lower_bound(time - config->Timings.tActHistory())); + if(time >= config->Timings.tActHistory()) + lastActivates.erase(lastActivates.begin(), lastActivates.lower_bound(time - config->Timings.tActHistory())); } } /* namespace controller */ From dc9d1b4b1f3e8cf61a451f2d9475d61bf42a242a Mon Sep 17 00:00:00 2001 From: Janik Schlemminger Date: Tue, 15 Jul 2014 14:35:13 +0200 Subject: [PATCH 3/3] address decoder simplified --- .../resources/configs/amconfigs/am_wideio.xml | 4 +- dram/src/common/xmlAddressdecoder.cpp | 120 +++--------------- dram/src/common/xmlAddressdecoder.h | 43 ++----- dram/src/simulation/Arbiter.h | 5 +- 4 files changed, 33 insertions(+), 139 deletions(-) diff --git a/dram/resources/configs/amconfigs/am_wideio.xml b/dram/resources/configs/amconfigs/am_wideio.xml index 24eb2a9d..fc29d918 100755 --- a/dram/resources/configs/amconfigs/am_wideio.xml +++ b/dram/resources/configs/amconfigs/am_wideio.xml @@ -11,10 +11,10 @@ --> - + - + diff --git a/dram/src/common/xmlAddressdecoder.cpp b/dram/src/common/xmlAddressdecoder.cpp index dbacde12..1c19a64d 100644 --- a/dram/src/common/xmlAddressdecoder.cpp +++ b/dram/src/common/xmlAddressdecoder.cpp @@ -9,113 +9,31 @@ string xmlAddressDecoder::addressConfigURI = ""; xmlAddressDecoder::xmlAddressDecoder(string addressConfigURI) { - doc = new XMLDocument(); - loadXML(addressConfigURI,*doc); - addressmap = doc->FirstChildElement("dramconfig")->FirstChildElement("addressmap"); - int from; - int to; + tinyxml2::XMLDocument doc; - // get channel: - // TiXmlElement* channel = addressmap->FirstChildElement("channel"); - // - // - // from = getAttribute(channel, "from"); - // to = getAttribute(channel, "to"); - // - // channelShift = from; - // channelMask = pow(2.0, to + 1.0) - pow(2.0, from + 0.0); - // channelSize = pow(2.0, to - from + 1.0); + loadXML(addressConfigURI, doc); + tinyxml2::XMLElement* addressmap = doc.FirstChildElement("dramconfig")->FirstChildElement("addressmap"); - // get row: - XMLElement* row = addressmap->FirstChildElement("row"); - row->QueryIntAttribute("from",&from); - row->QueryIntAttribute("to",&to); + for(XMLElement* child = addressmap->FirstChildElement(); child != NULL; child = child->NextSiblingElement()) + { + int from; + int to; - rowShift = from; - rowMask = pow(2.0, to + 1.0) - pow(2.0, from + 0.0); - rowSize = pow(2.0, to - from + 1.0); - - // get bank: - XMLElement* bank = addressmap->FirstChildElement("bank"); - - bank->QueryIntAttribute("from",&from); - bank->QueryIntAttribute("to",&to); - - bankShift = from; - bankMask = pow(2.0, to + 1.0) - pow(2.0, from + 0.0); - bankSize = pow(2.0, to - from + 1.0); - - // get colum: - XMLElement* colum = addressmap->FirstChildElement("colum"); - - colum->QueryIntAttribute("from",&from); - colum->QueryIntAttribute("to",&to); - - columShift = from; - columMask = pow(2.0, to + 1.0) - pow(2.0, from + 0.0); - columSize = pow(2.0, to - from + 1.0); - - // get bytes: - // TiXmlElement* bytes = addressmap->FirstChildElement("bytes"); - // - // from = getAttribute(bytes, "from"); - // to = getAttribute(bytes, "to"); - - // bytesShift = from; - // bytesMask = pow(2.0, to + 1.0) - pow(2.0, from + 0.0); - // bytesSize = pow(2.0, to - from + 1.0); + child->QueryAttribute("from", &from); + child->QueryAttribute("to", &to); + shifts[child->Name()] = from; + masks[child->Name()] = pow(2.0, to + 1.0) - pow(2.0, from + 0.0); + } } -xmlAddressDecoder::~xmlAddressDecoder() +DecodedAddress xmlAddressDecoder::decodeAddress(sc_dt::uint64 addr) { - delete doc; -} - -void xmlAddressDecoder::getNode(unsigned int addr, node * n) -{ - n->channel = 0; - n->row = (addr & rowMask) >> rowShift; - n->bank = (addr & bankMask) >> bankShift; - n->colum = (addr & columMask) >> columShift; -} - -void xmlAddressDecoder::getBRC(unsigned int addr, unsigned int &bank, unsigned int &row, - unsigned int &colum) -{ - row = (addr & rowMask) >> rowShift; - bank = (addr & bankMask) >> bankShift; - colum = (addr & columMask) >> columShift; -} - -void xmlAddressDecoder::getCBRC(unsigned int addr, unsigned int &channel, unsigned int &bank, - unsigned int &row, unsigned int &colum) -{ - channel = (addr & channelMask) >> channelShift; - getBRC(addr, bank, row, colum); -} -void xmlAddressDecoder::getC(unsigned int addr, unsigned int &channel) -{ - channel = (addr & channelMask) >> channelShift; -} - -unsigned int xmlAddressDecoder::getNumberOfBanks() -{ - return bankSize; -} - -unsigned int xmlAddressDecoder::getNumberOfRowsPerBank() -{ - return rowSize; -} - -unsigned int xmlAddressDecoder::getNumberOfColumsPerRow() -{ - return columSize; -} - -unsigned int xmlAddressDecoder::getNumberOfBytesPerColumn() -{ - return 1; + DecodedAddress n; + n.channel = 0; + n.row = (addr & masks["row"]) >> shifts["row"]; + n.bank = (addr & masks["bank"]) >> shifts["bank"]; + n.column = (addr & masks["column"]) >> shifts["column"]; + return n; } diff --git a/dram/src/common/xmlAddressdecoder.h b/dram/src/common/xmlAddressdecoder.h index f6fa9e2a..3cd3d6fe 100755 --- a/dram/src/common/xmlAddressdecoder.h +++ b/dram/src/common/xmlAddressdecoder.h @@ -18,17 +18,20 @@ #include #include #include +#include #include "third_party/tinyxml2.h" -struct node +struct DecodedAddress { + DecodedAddress():channel(0),rank(0),bankgroup(0),row(0),bank(0),column(0),bytes(0){} unsigned int channel; + unsigned int rank; + unsigned int bankgroup; unsigned int row; unsigned int bank; - unsigned int colum; - tlm::tlm_command command; - tlm::tlm_phase phase; + unsigned int column; + unsigned int bytes; }; class xmlAddressDecoder @@ -43,39 +46,13 @@ public: return decoder; } - void getNode(unsigned int addr, node * n); - void getBRC(unsigned int addr, unsigned int &bank, unsigned int &row, unsigned int &colum); - void getCBRC(unsigned int addr, unsigned int &channel, unsigned int &bank, unsigned int &row, unsigned int &colum); - void getC(unsigned int addr, unsigned int &channel); - unsigned int getNumberOfBanks(); - unsigned int getNumberOfRowsPerBank(); - unsigned int getNumberOfColumsPerRow(); - unsigned int getNumberOfBytesPerColumn(); + DecodedAddress decodeAddress(sc_dt::uint64 addr); private: xmlAddressDecoder(std::string URI); - ~xmlAddressDecoder(); - unsigned int channelMask; - unsigned int rowMask; - unsigned int bankMask; - unsigned int columMask; - unsigned int bytesMask; - - unsigned int channelShift; - unsigned int rowShift; - unsigned int bankShift; - unsigned int columShift; - unsigned int bytesShift; - - unsigned int channelSize; - unsigned int bankSize; - unsigned int rowSize; - unsigned int columSize; - unsigned int bytesSize; - - tinyxml2::XMLDocument * doc; - tinyxml2::XMLElement* addressmap; + std::map masks; + std::map shifts; }; #endif diff --git a/dram/src/simulation/Arbiter.h b/dram/src/simulation/Arbiter.h index 813845cd..fb0d66c8 100644 --- a/dram/src/simulation/Arbiter.h +++ b/dram/src/simulation/Arbiter.h @@ -135,10 +135,9 @@ private: void appendDramExtension(int socketId, tlm_generic_payload& payload) { unsigned int burstlength = payload.get_streaming_width(); - node n; - xmlAddressDecoder::getInstance().getNode(static_cast(payload.get_address()), &n); + DecodedAddress n = xmlAddressDecoder::getInstance().decodeAddress(payload.get_address()); Bank bank(n.bank); - DramExtension* extension = new DramExtension(Thread(socketId+1), Channel(n.channel), bank, bank.getBankGroup(), Row(n.row), Column(n.colum),burstlength); + DramExtension* extension = new DramExtension(Thread(socketId+1), Channel(n.channel), bank, bank.getBankGroup(), Row(n.row), Column(n.column),burstlength); payload.set_auto_extension(extension); } };