diff --git a/DRAMSys/library/resources/scripts/createTraceDB.sql b/DRAMSys/library/resources/scripts/createTraceDB.sql index 5f1d0d38..ff5e7ce5 100644 --- a/DRAMSys/library/resources/scripts/createTraceDB.sql +++ b/DRAMSys/library/resources/scripts/createTraceDB.sql @@ -23,7 +23,9 @@ CREATE TABLE GeneralInfo( MCconfig TEXT, Memspec TEXT, Traces TEXT, - WindowSize INTEGER + WindowSize INTEGER, + FlexibleRefresh INTEGER, + MaxRefBurst INTEGER ); CREATE TABLE Power( diff --git a/DRAMSys/library/src/common/TlmRecorder.cpp b/DRAMSys/library/src/common/TlmRecorder.cpp index d7a68f5f..30587582 100644 --- a/DRAMSys/library/src/common/TlmRecorder.cpp +++ b/DRAMSys/library/src/common/TlmRecorder.cpp @@ -285,8 +285,8 @@ void TlmRecorder::prepareSqlStatements() updatePhaseString = "UPDATE Phases SET PhaseEnd = :end WHERE Transact = :trans AND PhaseName = :name"; insertGeneralInfoString = - "INSERT INTO GeneralInfo (NumberOfTransactions,TraceEnd,NumberOfBanks,clk,UnitOfTime,MCconfig,Memspec,Traces, WindowSize) VALUES" - "(:numberOfTransactions,:end,:numberOfBanks,:clk,:unitOfTime,:mcconfig,:memspec,:traces,:windowSize)"; + "INSERT INTO GeneralInfo (NumberOfTransactions,TraceEnd,NumberOfBanks,clk,UnitOfTime,MCconfig,Memspec,Traces, WindowSize, FlexibleRefresh, MaxRefBurst) VALUES" + "(:numberOfTransactions,:end,:numberOfBanks,:clk,:unitOfTime,:mcconfig,:memspec,:traces,:windowSize, :flexibleRefresh, :maxRefBurst)"; insertDebugMessageString = "INSERT INTO DebugMessages (Time,Message) Values (:time,:message)"; insertPowerString = "INSERT INTO Power VALUES (:time,:averagePower)"; @@ -323,6 +323,17 @@ void TlmRecorder::insertGeneralInfo() sqlite3_bind_int64(insertGeneralInfoStatement, 9, 0); else sqlite3_bind_int64(insertGeneralInfoStatement, 9, (Configuration::getInstance().memSpec.clk*Configuration::getInstance().WindowSize).value()); + if(Configuration::getInstance().ControllerCoreEnableRefPostpone || Configuration::getInstance().ControllerCoreEnableRefPullIn) + sqlite3_bind_int(insertGeneralInfoStatement, 10, 1); + else + { + sqlite3_bind_int(insertGeneralInfoStatement, 10, 0); + sqlite3_bind_int(insertGeneralInfoStatement, 11, 0); + } + if (Configuration::getInstance().ControllerCoreMaxPulledInARCmd > Configuration::getInstance().ControllerCoreMaxPostponedARCmd) + sqlite3_bind_int64(insertGeneralInfoStatement, 11, Configuration::getInstance().ControllerCoreMaxPulledInARCmd); + else + sqlite3_bind_int64(insertGeneralInfoStatement, 11, Configuration::getInstance().ControllerCoreMaxPostponedARCmd); executeSqlStatement(insertGeneralInfoStatement); } diff --git a/DRAMSys/traceAnalyzer/scripts/tests.py b/DRAMSys/traceAnalyzer/scripts/tests.py index 9b2e5703..d4d93993 100755 --- a/DRAMSys/traceAnalyzer/scripts/tests.py +++ b/DRAMSys/traceAnalyzer/scripts/tests.py @@ -39,6 +39,7 @@ class DramConfig(object): tXSRDLL = 0 # min delay to row access command after srefx for dll commands tAL = 0 # additive delay (delayed execution in dram) tRFC = 0 # min ref->act delay + tREFI = 0 # time between REF commands def readConfigFromFiles(self, connection): print("Parsing dram configuration") @@ -83,6 +84,7 @@ class DramConfig(object): self.tXSRDLL = self.tXSR self.tAL = self.clk * memspec.getIntValue("AL") self.tRFC = self.clk * memspec.getIntValue("RFC") + self.tREFI = self.clk * memspec.getIntValue("REFI") elif (self. memoryType == "DDR4"): self.nActivateWindow = 4 @@ -109,6 +111,7 @@ class DramConfig(object): self.tXSRDLL = self.clk * memspec.getIntValue("XSDLL") self.tAL = self.clk * memspec.getIntValue("AL") self.tRFC = self.clk * memspec.getIntValue("RFC") + self.tREFI = self.clk * memspec.getIntValue("REFI") elif (self. memoryType == "DDR3"): self.nActivateWindow = 4 @@ -135,6 +138,7 @@ class DramConfig(object): self.tXSRDLL = self.clk * memspec.getIntValue("XSDLL"); self.tAL = self.clk * memspec.getIntValue("AL"); self.tRFC = self.clk * memspec.getIntValue("RFC"); + self.tREFI = self.clk * memspec.getIntValue("REFI"); else: raise Exception("MemoryType not supported yet. Insert a coin into the coin machine and try again") @@ -470,6 +474,66 @@ def no_commands_during_refresh(connection): return TestSuceeded() +@test +def max_number_ref_burst(connection): + """Checks that the maximum number of REFA commands in a burst is not exceeded""" + cursor = connection.cursor() + query = """SELECT PhaseBegin, PhaseEnd FROM phases WHERE PhaseName = 'REFA' """ + query2 = """SELECT FlexibleRefresh, MaxRefBurst FROM GeneralInfo""" + prevrow = [0] * 2 + cnt = 0 + maxRefBurst = 0 # If flexible refresh is not enabled there shouldn't be any refreshes in sequence + + cursor.execute(query); + result = cursor.fetchall(); + cursor.execute(query2); + result2 = cursor.fetchall(); + maxRefBurst = result2[0][1] + flexibleRef = result2[0][0] + + if (flexibleRef): + maxRefBurst = maxRefBurst - 1 # Since the intersections will be used for this test, use -1 from the max + else: + maxRefBurst = 0 + + for row in result: + if (prevrow[1] == row[0]): + cnt += 1 + else: + cnt = 0 # Reset the counter every time a burst ends + prevrow = row + if(cnt > maxRefBurst): + return TestFailed("Maximum number of REFA in a burst was exceeded at {0} with {1} REFA in sequence. Maximum allowed is {2}.".format(formatTime(row[0]), cnt, maxRefBurst)) + + return TestSuceeded() + +@test +def max_time_without_ref(connection): + """Checks that the maximum time allowed between REFA commands""" + cursor = connection.cursor() + query = """SELECT PhaseBegin, PhaseEnd FROM phases WHERE PhaseName = 'REFA' """ + query2 = """SELECT FlexibleRefresh, MaxRefBurst FROM GeneralInfo""" + prevrow = [0] * 2 + + cursor.execute(query); + result = cursor.fetchall(); + cursor.execute(query2); + result2 = cursor.fetchall(); + maxRefBurst = result2[0][1] + flexibleRef = result2[0][0] + + if (flexibleRef): + maxTimeWithoutRef = ((maxRefBurst + 1) * dramconfig.tREFI) + dramconfig.tRP # Bursts are possible, so max should be the possible burst size + 1 + else: + maxTimeWithoutRef = dramconfig.tREFI + dramconfig.tRP + + for row in result: + timeBetweenRefs = row[0] - prevrow[1] + if (timeBetweenRefs > maxTimeWithoutRef): + return TestFailed("Maximum time between REF commands was exceeded at {0} with {1} between REFs. Maximum allowed is {2}.".format(formatTime(row[0]), formatTime(timeBetweenRefs), formatTime(maxTimeWithoutRef))) + prevrow = row + + return TestSuceeded() # ----------- activate checks --------------------------------------- @test