summaryrefslogtreecommitdiff
path: root/chip_design/generate-chipdesign.py
diff options
context:
space:
mode:
Diffstat (limited to 'chip_design/generate-chipdesign.py')
-rwxr-xr-xchip_design/generate-chipdesign.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/chip_design/generate-chipdesign.py b/chip_design/generate-chipdesign.py
index d231c8d..d834078 100755
--- a/chip_design/generate-chipdesign.py
+++ b/chip_design/generate-chipdesign.py
@@ -27,7 +27,6 @@ chip_w, chip_h = (30, 30)
# Minimum distance between centers
power_distance = 17
-
all_components = powers + regulars
def fillin(cases, template_vars):
@@ -55,8 +54,8 @@ for i, (w, h) in enumerate(all_components):
newpreds = [
'(>= {var_x} 0)',
'(>= {var_y} 0)',
- '(<= {var_x} {chip_w})',
- '(<= {var_y} {chip_h})',
+ '(<= (+ {var_x} {var_w}) {chip_w})',
+ '(<= (+ {var_y} {var_h}) {chip_h})',
]
# Dimensions are restricted:
# either width and height are w, h; or they are rotated.
@@ -78,10 +77,10 @@ for i in range(len(all_components)):
# other (j) must be below, on the left of pivot (i).
# or above or on the right (mind the width/height!).
altpreds = [
- '(<= y{j} y{i})',
- '(<= x{j} x{i})',
+ '(<= (+ y{j} h{j}) y{i})',
+ '(<= (+ x{j} w{j}) x{i})',
'(>= y{j} (+ y{i} h{i}))',
- '(>= x{j} (+ x{i} x{i}))',
+ '(>= x{j} (+ x{i} w{i}))',
]
preds += ['(or %s)' % ' '.join(fillin(altpreds, vars()))]
@@ -105,13 +104,28 @@ for i in range(len(powers)):
]
preds += ['(or %s)' % ' '.join(fillin(altpreds, vars()))]
+# Require that each component is attached to power resource
+for i in range(len(powers), len(all_components)):
+ altpreds = []
+ for j in range(len(powers)):
+ # Power (j) top/right side hits component (i) bottom/left side or
+ # Power (j) bottom/left side hits component (i) top/right side.
+ # (note: copied from above overlap check with '>='/'<=' -> '='.)
+ altpreds += fillin([
+ '(= (+ y{j} h{j}) y{i})',
+ '(= (+ x{j} w{j}) x{i})',
+ '(= y{j} (+ y{i} h{i}))',
+ '(= x{j} (+ x{i} w{i}))',
+ ], vars())
+ preds += ['(or %s)' % ' \n'.join(altpreds)]
+
# Begin generator
s = """(benchmark test.smt
-:logic QF_UFLRA
+:logic QF_UFLIA
:extrafuns
(
"""
-s += "\n".join("(%s Real)" % x for x in literals)
+s += "\n".join("(%s Int)" % x for x in literals)
s += """
)
:formula