aboutsummaryrefslogtreecommitdiffstats
path: root/icebox/icebox_colbuf.py
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-08-02 21:14:52 +0200
committerClifford Wolf <clifford@clifford.at>2015-08-02 21:14:52 +0200
commit266596b31f05eddf81e1da49c76923837b761e94 (patch)
tree5ada8346e6604f965c14ef4328d1a6287dd0ec04 /icebox/icebox_colbuf.py
parent0ee4b9f99b818dbfbb9215359baae9edb9310acf (diff)
downloadicestorm-266596b31f05eddf81e1da49c76923837b761e94.tar.gz
icestorm-266596b31f05eddf81e1da49c76923837b761e94.tar.bz2
icestorm-266596b31f05eddf81e1da49c76923837b761e94.zip
Added "colbuf -f"
Diffstat (limited to 'icebox/icebox_colbuf.py')
-rwxr-xr-xicebox/icebox_colbuf.py52
1 files changed, 33 insertions, 19 deletions
diff --git a/icebox/icebox_colbuf.py b/icebox/icebox_colbuf.py
index 8d1ac3b..ac4e6c4 100755
--- a/icebox/icebox_colbuf.py
+++ b/icebox/icebox_colbuf.py
@@ -26,7 +26,7 @@ fixup_mode = False
def usage():
print("""
-Usage: icebox_colbuf [options] [bitmap.txt]
+Usage: icebox_colbuf [options] [input.txt [output.txt]]
-c
check colbuf bits
@@ -52,7 +52,7 @@ for o, a in opts:
if len(args) == 0:
args.append("/dev/stdin")
-if len(args) != 1:
+if len(args) not in [1, 2]:
usage()
if check_mode == fixup_mode:
@@ -117,24 +117,38 @@ for tiles in [ic.io_tiles, ic.logic_tiles, ic.ramb_tiles, ic.ramt_tiles]:
if len(glbs):
driven_glbs_map[tile] = glbs
-if check_mode:
- error_count = 0
- for tile, bits in used_glbs_map.items():
- for bit in bits:
- if tile not in driven_glbs_map or bit not in driven_glbs_map[tile]:
- print("Missing driver for glb_netwk_%d in tile %s" % (bit, tile))
- error_count += 1
- for tile, bits in driven_glbs_map.items():
- for bit in bits:
- if tile not in used_glbs_map or bit not in used_glbs_map[tile]:
- print("Unused driver for glb_netwk_%d in tile %s" % (bit, tile))
- error_count += 1
- if error_count != 0:
+def set_colbuf(ic, tile, bit, value):
+ tile_dat = ic.tile(tile[0], tile[1])
+ tile_db = ic.tile_db(tile[0], tile[1])
+ for entry in tile_db:
+ if entry[1] == "ColBufCtrl" and entry[2] == "glb_netwk_%d" % bit:
+ match = re.match("B([0-9]+)\[([0-9]+)\]", entry[0][0])
+ l = tile_dat[int(match.group(1))]
+ n = int(match.group(2))
+ l = l[:n] + value + l[n+1:]
+ tile_dat[int(match.group(1))] = l
+ return
+ assert False
+
+error_count = 0
+for tile, bits in used_glbs_map.items():
+ for bit in bits:
+ if tile not in driven_glbs_map or bit not in driven_glbs_map[tile]:
+ print("Missing driver for glb_netwk_%d in tile %s" % (bit, tile))
+ set_colbuf(ic, tile, bit, "1")
+ error_count += 1
+for tile, bits in driven_glbs_map.items():
+ for bit in bits:
+ if tile not in used_glbs_map or bit not in used_glbs_map[tile]:
+ print("Unused driver for glb_netwk_%d in tile %s" % (bit, tile))
+ set_colbuf(ic, tile, bit, "0")
+ error_count += 1
+if error_count != 0:
+ if not fixup_mode:
print("Found %d errors!" % error_count)
sys.exit(1)
+ ic.write_file(args[0] if len(args) == 1 else args[1])
+ print("Corrected %d errors." % error_count)
+else:
print("No errors found.")
-if fixup_mode:
- print("Error: Fixup mode is not implemented yet!")
- sys.exit(1)
-