aboutsummaryrefslogtreecommitdiffstats
path: root/icefuzz/glbcheck.py
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2016-06-19 16:24:50 +0200
committerClifford Wolf <clifford@clifford.at>2016-06-19 16:24:50 +0200
commit09387a0662a5c95e8e819acfc1300aa4c4939a5d (patch)
tree33cf725d4ada0100712c8bccbe386715c467f4a0 /icefuzz/glbcheck.py
parent49e3ad404a28faa1dbcbbc0acf3071bec3d5ddfe (diff)
downloadicestorm-09387a0662a5c95e8e819acfc1300aa4c4939a5d.tar.gz
icestorm-09387a0662a5c95e8e819acfc1300aa4c4939a5d.tar.bz2
icestorm-09387a0662a5c95e8e819acfc1300aa4c4939a5d.zip
Added icefuzz/glbcheck.py
Diffstat (limited to 'icefuzz/glbcheck.py')
-rw-r--r--icefuzz/glbcheck.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/icefuzz/glbcheck.py b/icefuzz/glbcheck.py
new file mode 100644
index 0000000..4c86f0e
--- /dev/null
+++ b/icefuzz/glbcheck.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+
+from sys import argv, exit
+
+asc_bits = set()
+glb_bits = set()
+
+# parsing .asc file
+with open(argv[1]) as f:
+ current_tile = None
+ current_line = None
+ for line in f:
+ if line.startswith("."):
+ if line.find("_tile ") >= 0:
+ f = line.split()
+ current_tile = "%02d.%02d" % (int(f[1]), int(f[2]))
+ current_line = 0
+ else:
+ current_tile = None
+ current_line = None
+ continue
+
+ if current_tile is not None:
+ for i in range(len(line)):
+ if line[i] == '1':
+ asc_bits.add("%s.%02d.%02d" % (current_tile, current_line, i))
+ current_line += 1
+
+# parsing .glb file
+with open(argv[2]) as f:
+ current_tile = None
+ for line in f:
+ if line.find("Tile_") >= 0:
+ f = line.replace("IO_", "").replace("RAM_", "").split("_")
+ assert len(f) == 3
+ current_tile = "%02d.%02d" % (int(f[1]), int(f[2]))
+ continue
+
+ if line.find("GlobalNetwork") >= 0:
+ current_tile = None
+ continue
+
+ if current_tile is not None:
+ f = line.replace("(", "").replace(")", "").split()
+ if len(f) >= 2:
+ glb_bits.add("%s.%02d.%02d" % (current_tile, int(f[1]), int(f[0])))
+
+# compare and report
+if asc_bits == glb_bits:
+ print("ASC and GLB files match.")
+ exit(0)
+
+only_in_asc = asc_bits - glb_bits
+only_in_glb = glb_bits - asc_bits
+assert len(only_in_asc) != 0 or len(only_in_glb) != 0
+
+if len(only_in_asc) != 0:
+ print("Only in ASC: %s" % sorted(only_in_asc))
+if len(only_in_glb) != 0:
+ print("Only in GLB: %s" % sorted(only_in_glb))
+
+exit(1)
+