diff options
author | Clifford Wolf <clifford@clifford.at> | 2015-07-18 13:10:40 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-07-18 13:10:40 +0200 |
commit | 48154cb6f452d3bdb4da36cc267b4b6c45588dc9 (patch) | |
tree | 3ec3be9ef7e8db1fb7c764ed8202e0215a8eb7c7 /icefuzz/extract.py | |
parent | 13e63e6b65e044e348356731b55610d02cb308b9 (diff) | |
download | icestorm-48154cb6f452d3bdb4da36cc267b4b6c45588dc9.tar.gz icestorm-48154cb6f452d3bdb4da36cc267b4b6c45588dc9.tar.bz2 icestorm-48154cb6f452d3bdb4da36cc267b4b6c45588dc9.zip |
Imported full dev sources
Diffstat (limited to 'icefuzz/extract.py')
-rw-r--r-- | icefuzz/extract.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/icefuzz/extract.py b/icefuzz/extract.py new file mode 100644 index 0000000..9fa8a8c --- /dev/null +++ b/icefuzz/extract.py @@ -0,0 +1,60 @@ +#!/usr/bin/python + +from __future__ import division +from __future__ import print_function +import sys, re + +db = set() +text_db = dict() +mode_8k = False +cur_text_db = None +max_x, max_y = 0, 0 + +if sys.argv[1] == '-8': + sys.argv = sys.argv[1:] + mode_8k = True + +for filename in sys.argv[1:]: + with open(filename, "r") as f: + for line in f: + if line == "\n": + pass + elif line.startswith("GlobalNetwork"): + cur_text_db = set() + elif line.startswith("IO"): + match = re.match("IO_Tile_(\d+)_(\d+)", line) + assert match + max_x = max(max_x, int(match.group(1))) + max_y = max(max_y, int(match.group(2))) + cur_text_db = text_db.setdefault("io", set()) + elif line.startswith("Logic"): + cur_text_db = text_db.setdefault("logic", set()) + elif line.startswith("RAM"): + match = re.match(r"RAM_Tile_\d+_(\d+)", line) + if int(match.group(1)) % 2 == 1: + cur_text_db = text_db.setdefault("ramb_8k" if mode_8k else "ramb", set()) + else: + cur_text_db = text_db.setdefault("ramt_8k" if mode_8k else "ramt", set()) + else: + assert line.startswith(" ") + cur_text_db.add(line) + +def logic_op_prefix(match): + x = int(match.group(1)) + y = int(match.group(2)) + if x == 0: return " IO_L.logic_op_" + if y == 0: return " IO_B.logic_op_" + if x == max_x: return " IO_R.logic_op_" + if y == max_y: return " IO_T.logic_op_" + assert False + +for tile_type in text_db: + for line in text_db[tile_type]: + line = re.sub(" T_(\d+)_(\d+)\.logic_op_", logic_op_prefix, line) + line = re.sub(" T_\d+_\d+\.", " ", line) + m = re.match(" *(\([\d ]+\)) +\([\d ]+\) +\([\d ]+\) +(.*\S)", line) + if m: db.add("%s %s %s" % (tile_type, m.group(1), m.group(2))) + +for line in sorted(db): + print(line) + |