aboutsummaryrefslogtreecommitdiffstats
path: root/icebox
diff options
context:
space:
mode:
authorTim 'mithro' Ansell <me@mith.ro>2018-05-30 13:11:18 -0700
committerTim 'mithro' Ansell <me@mith.ro>2018-05-30 13:21:48 -0700
commitdd5565826677a0b36e6147aca6c6600dfbb704ce (patch)
treeeab6b46f40018611516259303cb89bbeaf3c7728 /icebox
parentf7e9fec63a3f88bee8c27e858da319ea03d68d14 (diff)
downloadicestorm-dd5565826677a0b36e6147aca6c6600dfbb704ce.tar.gz
icestorm-dd5565826677a0b36e6147aca6c6600dfbb704ce.tar.bz2
icestorm-dd5565826677a0b36e6147aca6c6600dfbb704ce.zip
Better error message when bit pattern is missing.
Previously; ``` self.apply_directive('buffer', src, dst) File "/usr/local/google/home/tansell/work/catx/vtr/env/conda/bin/icebox_hlc2asc", line 698, in apply_directive bits, = [entry[0] for entry in self.db if entry[1:] == fields] ValueError: not enough values to unpack (expected 1, got 0) ``` Now: ``` Parse error in line 2108: span12_y4_g14_0 -> span4_y4_g11_7 <-> span4_x7_g4_0 No bit pattern for ['buffer', 'sp12_h_r_11', 'sp4_h_r_7'] in LogicTile(1k, 7, 4) ```
Diffstat (limited to 'icebox')
-rwxr-xr-xicebox/icebox_hlc2asc.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/icebox/icebox_hlc2asc.py b/icebox/icebox_hlc2asc.py
index 97a0386..c1c778c 100755
--- a/icebox/icebox_hlc2asc.py
+++ b/icebox/icebox_hlc2asc.py
@@ -692,10 +692,15 @@ class Tile:
self.bits_set = set()
self.bits_cleared = set()
+ def __str__(self):
+ return "{}({}, {}, {})".format(self.__class__.__name__, self.ic.device, self.x, self.y)
+
def apply_directive(self, *fields):
fields = list(fields)
- bits, = [entry[0] for entry in self.db if entry[1:] == fields]
- self.set_bits(bits)
+ bits = [entry[0] for entry in self.db if entry[1:] == fields]
+ if len(bits) == 0:
+ raise ParseError("No bit pattern for {} in {}".format(fields, self))
+ self.set_bits(bits[0])
def set_bits(self, bits):
bits_set = set()
@@ -1010,9 +1015,12 @@ def main1(path):
stack.append(stack[-1].new_block(fields[:-1]))
else:
stack[-1].read(fields)
- except ParseError:
+ except ParseError as e:
sys.stderr.write("Parse error in line %d:\n" % (i + 1))
sys.stderr.write(line)
+ if e.args:
+ sys.stderr.write("\n")
+ print(*e.args, file=sys.stderr)
sys.exit(1)
if len(stack) != 1:
sys.stderr.write("Parse error: unexpected end of file")