From 40c3c72ff09f07e23f4bc6e46c86c6a4be72e94f Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 12 Dec 2016 01:28:23 +0100 Subject: ChipDesign: add FIXME and print coordinate --- chip_design/generate-chipdesign.py | 12 ++++++++---- chip_design/solution-to-latex.py | 26 ++++++++++++-------------- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'chip_design') diff --git a/chip_design/generate-chipdesign.py b/chip_design/generate-chipdesign.py index d834078..23328ae 100755 --- a/chip_design/generate-chipdesign.py +++ b/chip_design/generate-chipdesign.py @@ -111,11 +111,15 @@ for i in range(len(powers), len(all_components)): # 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 '>='/'<=' -> '='.) + # Additionally: to "hit" the power resource over the X axis, an + # component Y coordinate must be within the power resource. + # FIXME need to check whether there is an overlap + pr_range = ' (>= x{j} )' 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}))', + '(and (= (+ y{j} h{j}) y{i})'' )', + '(and (= (+ x{j} w{j}) x{i})'' )', + '(and (= y{j} (+ y{i} h{i}))'' )', + '(and (= x{j} (+ x{i} w{i}))'' )', ], vars()) preds += ['(or %s)' % ' \n'.join(altpreds)] diff --git a/chip_design/solution-to-latex.py b/chip_design/solution-to-latex.py index 798267a..6c74f4c 100755 --- a/chip_design/solution-to-latex.py +++ b/chip_design/solution-to-latex.py @@ -70,6 +70,11 @@ def print_boxes(): attrs = ','.join(attrs) + # HACK: print coords for debugging + if sys.argv[-1] == 'debug': + print(x, y, w, h) + continue + # For easier detection, reduce box dimension (add margin) margin = 0.01 x += margin @@ -80,22 +85,15 @@ def print_boxes(): tpl = r"\draw[{attrs}] ({x}, {y}) rectangle ({x2}, {y2});" print(tpl.strip().format(**vars())) + # Reset for printing text + x, y, w, h = component + x2, y2 = x + w, y + h + # Draw number for debugging tx = x + w/2 ty = y + h/2 - text = r"%s\\(%s x %s)" % (i, w, h) + text = r"%s\\(%s,%s)\\(%s x %s)" % (i, x, y, w, h) print(r'\node[align=center] at (%f,%f) {%s};' % (tx, ty, text)) -def print_grid(): - # XXX currently hard-coding grid size - print(r'\draw[step=1,gray,very thin] (0, 0) grid (30, 30);') - -if not True: - # Complete picture - print(r'\begin{tikzpicture}') - print_grid() - print_boxes() - print(r'\end{tikzpicture}') -else: - # Just the boxes. - print_boxes() +# Just the boxes. +print_boxes() -- cgit v1.2.1