Fix case where make_prim allocates all global buffer pins

This is a low probability bug more likely to show up in low pin
count devices with few GBINs. In rare cases make_prim would
constrain all of the global buffer capable pins but not the clock
input. icecube would then fail to place the clock input. This is
fixed by always constraining the clock if all GBIN pins are used.
This commit is contained in:
David Shah 2017-10-20 15:18:39 +01:00
parent 4a930377f0
commit 42047c6114
1 changed files with 21 additions and 1 deletions

View File

@ -31,20 +31,40 @@ for idx in range(num):
print("endmodule", file=f)
with open(working_dir + "/prim_%02d.pcf" % idx, "w") as f:
p = np.random.permutation(pins)
used_pins = []
if np.random.choice([True, False]):
for i in range(w):
print("set_io a[%d] %s" % (i, p[i]), file=f)
used_pins.append(p[i])
if np.random.choice([True, False]):
for i in range(w):
print("set_io b[%d] %s" % (i, p[w+i]), file=f)
used_pins.append(p[w+i])
if np.random.choice([True, False]):
for i in range(w):
print("set_io y[%d] %s" % (i, p[2*w+i]), file=f)
used_pins.append(p[2*w+i])
if np.random.choice([True, False]):
print("set_io x %s" % p[3*w], file=f)
used_pins.append(p[3*w])
if np.random.choice([True, False]):
print("set_io y %s" % p[3*w+1], file=f)
if np.random.choice([True, False]):
used_pins.append(p[3*w+1])
# There is a low but non-zero probability, particularly on devices with
# fewer pins and GBINs such as the UltraPlus, that a permutation will be
# picked where all of the GBINs are already constrained at this point,
# hence icecube fails to assign clk successfully. This is fixed by
# forcing clock assignment if no GBINs are free.
global_free = False
for glbi in gpins:
if not glbi in used_pins:
global_free = True
break
if np.random.choice([True, False]) or not global_free:
print("set_io clk %s" % p[3*w+2], file=f)