From cf3398c66f2b1c3c35b73ff1d932ef4b793f48a2 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Mon, 20 Jul 2020 13:46:25 +0200 Subject: [PATCH] Create working example for thermalsim. --- .../configs/amconfigs/am_wideio_thermal.json | 41 ++++++++ .../configs/simulator/wideio_thermal.json | 2 +- .../resources/simulations/wideio-thermal.json | 2 +- .../resources/traces/generateErrorTest.pl | 97 +++++++++++++------ DRAMSys/library/src/simulation/dram/Dram.cpp | 6 +- DRAMSys/library/src/simulation/dram/Dram.h | 1 + DRAMSys/simulator/StlPlayer.h | 6 +- 7 files changed, 119 insertions(+), 36 deletions(-) create mode 100644 DRAMSys/library/resources/configs/amconfigs/am_wideio_thermal.json diff --git a/DRAMSys/library/resources/configs/amconfigs/am_wideio_thermal.json b/DRAMSys/library/resources/configs/amconfigs/am_wideio_thermal.json new file mode 100644 index 00000000..96be2a29 --- /dev/null +++ b/DRAMSys/library/resources/configs/amconfigs/am_wideio_thermal.json @@ -0,0 +1,41 @@ +{ + "CONGEN": { + "BANK_BIT": [ + 4, + 5 + ], + "BYTE_BIT": [ + 0, + 1, + 2, + 3 + ], + "CHANNEL_BIT": [ + 25, + 26 + ], + "COLUMN_BIT": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12 + ], + "ROW_BIT": [ + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24 + ] + } +} \ No newline at end of file diff --git a/DRAMSys/library/resources/configs/simulator/wideio_thermal.json b/DRAMSys/library/resources/configs/simulator/wideio_thermal.json index b37cda4f..6ce8c0a4 100644 --- a/DRAMSys/library/resources/configs/simulator/wideio_thermal.json +++ b/DRAMSys/library/resources/configs/simulator/wideio_thermal.json @@ -10,7 +10,7 @@ "PowerAnalysis": true, "SimulationName": "wideio", "SimulationProgressBar": true, - "StoreMode": "ErrorModel", + "StoreMode": "Store", "ThermalSimulation": true, "UseMalloc": false, "WindowSize": 1000 diff --git a/DRAMSys/library/resources/simulations/wideio-thermal.json b/DRAMSys/library/resources/simulations/wideio-thermal.json index 82c23ff5..1e9a1c0b 100644 --- a/DRAMSys/library/resources/simulations/wideio-thermal.json +++ b/DRAMSys/library/resources/simulations/wideio-thermal.json @@ -1,6 +1,6 @@ { "simulation": { - "addressmapping": "am_wideio_4x256Mb_rbc.json", + "addressmapping": "am_wideio_thermal.json", "mcconfig": "fr_fcfs.json", "memspec": "JEDEC_256Mb_WIDEIO-200_128bit.json", "simconfig": "wideio_thermal.json", diff --git a/DRAMSys/library/resources/traces/generateErrorTest.pl b/DRAMSys/library/resources/traces/generateErrorTest.pl index 477c5185..39589e25 100644 --- a/DRAMSys/library/resources/traces/generateErrorTest.pl +++ b/DRAMSys/library/resources/traces/generateErrorTest.pl @@ -33,35 +33,72 @@ # Authors: # Matthias Jung # Eder F. Zulian +# Lukas Steiner use warnings; use strict; # Assuming this address mapping: -# -# -# -# -# -# -# +# { +# "CONGEN": { +# "BYTE_BIT": [ +# 0, +# 1, +# 2, +# 3 +# ], +# "BANK_BIT": [ +# 4, +# 5 +# ], +# "COLUMN_BIT": [ +# 6, +# 7, +# 8, +# 9, +# 10, +# 11, +# 12 +# ], +# "ROW_BIT": [ +# 13, +# 14, +# 15, +# 16, +# 17, +# 18, +# 19, +# 20, +# 21, +# 22, +# 23, +# 24 +# ], +# "CHANNEL_BIT": [ +# 25, +# 26 +# ] +# } +# } # This is how it should look like later: -# 31: write 0x0 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +# 31: write 0x0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -my $numberOfRows = 8192; -my $numberOfColumnsPerRow = 128; +my $numberOfChannels = 4; +my $numberOfRows = 4096; +my $numberOfColumns = 128; my $bytesPerColumn = 16; my $burstLength = 4; # burst length of 4 columns --> 4 columns written or read per access my $dataLength = $bytesPerColumn * $burstLength; -my $rowOffset = 0x4000; -my $colOffset = 0x80; +my $channelOffset = 0x2000000; +my $rowOffset = 0x2000; +my $columnOffset = 0x40; # Generate Data Pattern: my $dataPatternByte = "ff"; -my $dataPattern = ""; +my $dataPattern = "0x"; for(my $i = 0; $i < $dataLength; $i++) { $dataPattern .= $dataPatternByte; @@ -71,28 +108,34 @@ my $clkCounter = 0; my $addr = 0; # Generate Trace file (writes): -for(my $row = 0; $row < ($numberOfRows * $rowOffset); $row = $row + $rowOffset) +for(my $cha = 0; $cha < ($numberOfChannels * $channelOffset); $cha = $cha + $channelOffset) { - for(my $col = 0; $col < ($numberOfColumnsPerRow * $colOffset); $col = $col + ($colOffset * $burstLength)) + for(my $row = 0; $row < ($numberOfRows * $rowOffset); $row = $row + $rowOffset) { - my $addrHex = sprintf("0x%x", $addr); - print "$clkCounter:\twrite\t$addrHex\t$dataPattern\n"; - $clkCounter++; - $addr += $colOffset * $burstLength; + for(my $col = 0; $col < ($numberOfColumns * $columnOffset); $col = $col + ($columnOffset * $burstLength)) + { + my $addrHex = sprintf("0x%x", $addr); + print "$clkCounter:\twrite\t$addrHex\t$dataPattern\n"; + $clkCounter++; + $addr += $columnOffset * $burstLength; + } } } -$clkCounter = 350000000; +$clkCounter = 50000000; $addr = 0; # Generate Trace file (reads): -for(my $row = 0; $row < ($numberOfRows * $rowOffset); $row = $row + $rowOffset) +for(my $cha = 0; $cha < ($numberOfChannels * $channelOffset); $cha = $cha + $channelOffset) { - for(my $col = 0; $col < ($numberOfColumnsPerRow * $colOffset); $col = $col + ($colOffset * $burstLength)) + for(my $row = 0; $row < ($numberOfRows * $rowOffset); $row = $row + $rowOffset) { - my $addrHex = sprintf("0x%x", $addr); - print "$clkCounter:\tread\t$addrHex\t$dataPattern\n"; - $clkCounter++; - $addr += $colOffset * $burstLength; + for(my $col = 0; $col < ($numberOfColumns * $columnOffset); $col = $col + ($columnOffset * $burstLength)) + { + my $addrHex = sprintf("0x%x", $addr); + print "$clkCounter:\tread\t$addrHex\n"; + $clkCounter++; + $addr += $columnOffset * $burstLength; + } } -} +} \ No newline at end of file diff --git a/DRAMSys/library/src/simulation/dram/Dram.cpp b/DRAMSys/library/src/simulation/dram/Dram.cpp index fcbe7677..8238195c 100644 --- a/DRAMSys/library/src/simulation/dram/Dram.cpp +++ b/DRAMSys/library/src/simulation/dram/Dram.cpp @@ -117,11 +117,9 @@ Dram::~Dram() void Dram::reportPower() { - static bool alreadyCalled = false; - - if (!alreadyCalled) + if (!powerReported) { - alreadyCalled = true; + powerReported = true; DRAMPower->calcEnergy(); // Print the final total energy and the average power for diff --git a/DRAMSys/library/src/simulation/dram/Dram.h b/DRAMSys/library/src/simulation/dram/Dram.h index 518b1707..d39d07b6 100644 --- a/DRAMSys/library/src/simulation/dram/Dram.h +++ b/DRAMSys/library/src/simulation/dram/Dram.h @@ -51,6 +51,7 @@ class Dram : public sc_module { private: unsigned int bytesPerBurst = Configuration::getInstance().getBytesPerBurst(); + bool powerReported = false; protected: Dram(sc_module_name); diff --git a/DRAMSys/simulator/StlPlayer.h b/DRAMSys/simulator/StlPlayer.h index 1eb915a4..29f6e6ef 100644 --- a/DRAMSys/simulator/StlPlayer.h +++ b/DRAMSys/simulator/StlPlayer.h @@ -140,15 +140,15 @@ public: ("Malformed trace file. Data information could not be found (line " + std::to_string( lineCnt) + ").").c_str()); - // Check if data length in the trace file is correct. We need two characters to represent 1 byte in hexadecimal. - if (dataStr.length() != (dataLength * 2)) + // Check if data length in the trace file is correct. We need two characters to represent 1 byte in hexadecimal. Offset for 0x prefix. + if (dataStr.length() != (dataLength * 2 + 2)) SC_REPORT_FATAL("StlPlayer", ("Data in the trace file has an invalid length (line " + std::to_string( lineCnt) + ").").c_str()); // Set data for (unsigned i = 0; i < dataLength; i++) - data[i] = (unsigned char)std::stoi(dataStr.substr(i * 2, 2).c_str(), 0, 16); + data[i] = (unsigned char)std::stoi(dataStr.substr(i * 2 + 2, 2).c_str(), 0, 16); } // Fill up the payload.