aboutsummaryrefslogtreecommitdiffstats
path: root/sources/apps/QUAC-TRNG/scripts/top_ents.py
diff options
context:
space:
mode:
authorAtaberk <olgunataberk@gmail.com>2022-09-25 17:22:03 +0200
committerAtaberk <olgunataberk@gmail.com>2022-09-25 17:22:03 +0200
commitdc0b3db1b4f1895a07e5fe280ee3790e87f97b9f (patch)
treeb47203aa281bdd959def4451c84d310cd9cf2e12 /sources/apps/QUAC-TRNG/scripts/top_ents.py
downloaddram-bender-dc0b3db1b4f1895a07e5fe280ee3790e87f97b9f.tar.gz
Initial commit
Diffstat (limited to 'sources/apps/QUAC-TRNG/scripts/top_ents.py')
-rw-r--r--sources/apps/QUAC-TRNG/scripts/top_ents.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/sources/apps/QUAC-TRNG/scripts/top_ents.py b/sources/apps/QUAC-TRNG/scripts/top_ents.py
new file mode 100644
index 0000000..2a74569
--- /dev/null
+++ b/sources/apps/QUAC-TRNG/scripts/top_ents.py
@@ -0,0 +1,35 @@
+import os
+import argparse
+import pandas as pd
+import numpy as np
+
+parser = argparse.ArgumentParser(description = "Postprocess entropy files and obtain top-10 segments with the highest entropy")
+parser.add_argument('dimm', help="DIMM label")
+parser.add_argument('pattern', help="4-bit data pattern [1000, 1001, 0111, etc]")
+parser.add_argument('temp', help="temperature in centigrades")
+args = parser.parse_args()
+
+dimm = args.dimm
+pattern = args.pattern
+temp = args.temp
+
+no_segments = 8192
+no_bitlines = 512 * 128
+
+fn = "data/" + dimm + "/ent/" + temp + "C/1_1000_128_32768_" + pattern + "_floats.bin"
+dirname = "data/" + dimm + "/ent/" + temp + "C/"
+
+arr = np.fromfile(fn, dtype=np.float32)
+arr = arr.reshape(no_segments, no_bitlines)
+arr = arr.sum(axis = 1)
+indices = arr.argsort()[-10:][::-1]
+print(indices)
+print(arr[indices])
+
+log = open(dirname + "top.txt", "w")
+log.write("10\n")
+for index in indices:
+ # bank is always 1
+ # multiply segment # by 4 to get starting row addr
+ log.write("1 " + str(int(index) * 4) + " " + str(arr[index]) + " " + pattern + "\n")
+log.close()