aboutsummaryrefslogtreecommitdiff
path: root/icebox
diff options
context:
space:
mode:
Diffstat (limited to 'icebox')
-rwxr-xr-xicebox/icebox_asc2hlc.py2
-rwxr-xr-xicebox/icebox_hlc2asc.py52
-rwxr-xr-xicebox/icebox_html.py6
-rwxr-xr-xicebox/icebox_vlog.py11
4 files changed, 42 insertions, 29 deletions
diff --git a/icebox/icebox_asc2hlc.py b/icebox/icebox_asc2hlc.py
index 4f0f6fa..facca4b 100755
--- a/icebox/icebox_asc2hlc.py
+++ b/icebox/icebox_asc2hlc.py
@@ -797,7 +797,7 @@ class Tile:
self.ic.max_y - 1, entry[3])
if dst == 'fabout':
dst = lookup_fabout(*self.xy)
- self.buffer_and_routing.add((src, '<->', dst))
+ self.buffer_and_routing.add((src, '~>', dst))
continue
if entry[1] == 'buffer':
if match:
diff --git a/icebox/icebox_hlc2asc.py b/icebox/icebox_hlc2asc.py
index 3f3df90..08b5556 100755
--- a/icebox/icebox_hlc2asc.py
+++ b/icebox/icebox_hlc2asc.py
@@ -509,7 +509,6 @@ def logic_expression_to_lut(s, args):
for j in range(len(args)))) else '0'
for i in range(1 << len(args)))
-
class ParseError(Exception):
pass
@@ -533,7 +532,9 @@ class Main:
and len(fields[1]) >= 2 and fields[1][0] == '"' \
and fields[1][-1] == '"' \
and self.ic is None and self.device is None:
- self.device = fields[1][1:-1]
+ self.device = fields[1][1:-1].lower()
+ if self.device.startswith('lp') or self.device.startswith('hx'):
+ self.device = self.device[2:]
if self.device == '1k':
self.ic = icebox.iceconfig()
self.ic.setup_empty_1k()
@@ -702,14 +703,6 @@ class Tile:
continue
add_entry(entry, bits)
- # Let the routing bits be specified in both a->b and b->a direction.
- for bits, *entry in self.db:
- if not ic.tile_has_entry(x, y, (bits, *entry)):
- continue
- if entry[0] != "routing":
- continue
- add_entry((entry[0], entry[2], entry[1]), bits)
-
self.buffers = []
self.routings = []
self.bits_set = set()
@@ -749,11 +742,19 @@ class Tile:
bits_set.add((int(match.group(2)), int(match.group(3))))
if set.intersection(bits_set, bits_clear):
- raise ValueError("trying to set/clear the same bit(s) at once")
+ raise ValueError(
+ "trying to set/clear the same bit(s) at once set:{} clear:{}".format(
+ bits_set, bits_clear))
if set.intersection(bits_set, self.bits_cleared) or \
set.intersection(bits_clear, self.bits_set):
- raise ParseError("conflicting bits")
+ raise ParseError("""\
+conflicting bits {}
+ setting:{:<30} - current clear:{}
+clearing:{:<30} - current set :{}""".format(
+ bits,
+ str(bits_set), self.bits_cleared,
+ str(bits_clear), self.bits_set))
self.bits_set.update(bits_set)
self.bits_cleared.update(bits_clear)
@@ -776,7 +777,7 @@ class Tile:
if (src, dst) not in self.buffers:
self.buffers.append((src, dst))
self.apply_directive('buffer', src, dst)
- elif len(fields) == 3 and fields[1] == '<->':
+ elif len(fields) == 3 and fields[1] == '~>':
src = untranslate_netname(self.x, self.y,
self.ic.max_x - 1,
self.ic.max_y - 1, fields[0])
@@ -787,7 +788,7 @@ class Tile:
if (src, dst) not in self.routings:
self.routings.append((src, dst))
self.apply_directive('routing', src, dst)
- elif len(fields) >= 5 and (fields[1] == '->' or fields[1] == '<->'):
+ elif len(fields) >= 5 and (fields[1] == '->' or fields[1] == '~>'):
self.read(fields[:3])
self.read(fields[2:])
else:
@@ -831,8 +832,19 @@ class LogicCell:
if fields[0] == 'lut' and len(fields) == 2 and self.lut_bits is None:
self.lut_bits = fields[1]
elif fields[0] == 'out' and len(fields) >= 3 and fields[1] == '=':
- self.lut_bits = logic_expression_to_lut(
- ' '.join(fields[2:]), ('in_0', 'in_1', 'in_2', 'in_3'))
+ m = re.match("([0-9]+)'b([01]+)", fields[2])
+ if m:
+ lut_bits = m.group(2)
+ if len(lut_bits) != int(m.group(1)):
+ raise ParseError
+ m = len(lut_bits)
+ if m < 16:
+ lut_bits = (16-m) * "0" + lut_bits
+ # Verilog 16'bXXXX is MSB first but the bitstream wants LSB.
+ self.lut_bits = lut_bits[::-1]
+ else:
+ self.lut_bits = logic_expression_to_lut(
+ ' '.join(fields[2:]), ('in_0', 'in_1', 'in_2', 'in_3'))
elif fields == ['enable_carry']:
self.seq_bits[0] = '1'
elif fields == ['enable_dff']:
@@ -841,11 +853,11 @@ class LogicCell:
self.seq_bits[2] = '1'
elif fields == ['async_setreset']:
self.seq_bits[3] = '1'
- elif len(fields) > 3 and (fields[1] == '->' or fields[1] == '<->'):
+ elif len(fields) > 3 and (fields[1] == '->' or fields[1] == '~>'):
self.read(fields[:3])
self.read(fields[2:])
return
- elif len(fields) == 3 and (fields[1] == '->' or fields[1] == '<->'):
+ elif len(fields) == 3 and (fields[1] == '->' or fields[1] == '~>'):
prefix = 'lutff_%d/' % self.index
# Strip prefix if it is given
@@ -1002,10 +1014,10 @@ class IOBlock:
== ("padin_glb_netwk", fields[2][10:])]
assert len(bit) == 1
self.tile.ic.extra_bits.add(bit[0])
- elif len(fields) > 3 and (fields[1] == '->' or fields[1] == '<->'):
+ elif len(fields) > 3 and (fields[1] == '->' or fields[1] == '~>'):
self.read(fields[:3])
self.read(fields[2:])
- elif len(fields) == 3 and (fields[1] == '->' or fields[1] == '<->'):
+ elif len(fields) == 3 and (fields[1] == '->' or fields[1] == '~>'):
prefix = 'io_%d/' % self.index
# Strip prefix if it is given
diff --git a/icebox/icebox_html.py b/icebox/icebox_html.py
index 5358c16..fe1ba0c 100755
--- a/icebox/icebox_html.py
+++ b/icebox/icebox_html.py
@@ -35,7 +35,7 @@ def usage():
sys.exit(0)
try:
- opts, args = getopt.getopt(sys.argv[1:], "x:y:d:8:3")
+ opts, args = getopt.getopt(sys.argv[1:], "x:y:d:83")
except:
usage()
@@ -418,8 +418,8 @@ nets are connected with nets from cells in its neighbourhood.</p>""")
print("<h2>Routing Configuration</h2>")
print("""<p>This section lists the routing configuration bits in the tile.
-The entries titled "routing" configure transfer gates, the entries titled
-"buffer" configure tri-state drivers.</p>""")
+All routing resources are directional tristate buffers that are in tristate mode
+in the all-zeros configuration.</p>""")
grpgrp = dict()
config_groups = dict()
diff --git a/icebox/icebox_vlog.py b/icebox/icebox_vlog.py
index 5736011..a86f11e 100755
--- a/icebox/icebox_vlog.py
+++ b/icebox/icebox_vlog.py
@@ -350,6 +350,7 @@ for segs in sorted(ic.group_segments(extra_connections=extra_connections, extra_
if re.match(r"ram/RDATA_", s[2]): count_drivers += 1
if re.match(r"io_./D_IN_", s[2]): count_drivers += 1
if re.match(r"lutff_./out", s[2]): count_drivers += 1
+ if re.match(r"lutff_./lout", s[2]): count_drivers += 1
if count_drivers != 1 and check_driver:
failed_drivers_check.append(n)
@@ -851,11 +852,11 @@ for lut in luts_queue:
l_expr = make_lut_expr(bits[0:len(bits)//2], sigs[1:])
h_expr = make_lut_expr(bits[len(bits)//2:len(bits)], sigs[1:])
if h_expr == l_expr: return h_expr
- if sigs[0] == "0": return l_expr
- if sigs[0] == "1": return h_expr
- if h_expr == "1" and l_expr == "0": return sigs[0]
- if h_expr == "0" and l_expr == "1": return "!" + sigs[0]
- return "%s ? %s : %s" % (sigs[0], h_expr, l_expr)
+ if sigs[0] == "1'b0": return l_expr
+ if sigs[0] == "1'b1": return h_expr
+ if h_expr == "1'b1" and l_expr == "1'b0": return sigs[0]
+ if h_expr == "1'b0" and l_expr == "1'b1": return "!" + sigs[0]
+ return "(%s ? %s : %s)" % (sigs[0], h_expr, l_expr)
lut_expr = make_lut_expr(lut_bits, [net_in3, net_in2, net_in1, net_in0])
lut_assigns.append([net_lout, "/* LUT %2d %2d %2d */ %s" % (lut[0], lut[1], lut[2], lut_expr)])
max_net_len = max(max_net_len, len(net_lout))