Index: trunk/util/boxsym-rnd/generator.awk =================================================================== --- trunk/util/boxsym-rnd/generator.awk (revision 2856) +++ trunk/util/boxsym-rnd/generator.awk (revision 2857) @@ -66,7 +66,7 @@ # draw pins of a given slot:loc, with first pin touching the box at x0;y0 # px and py are x and y dir for the pin line, stx and sty are stepping to # the next coord. State is stored in ST -function draw_pins(slot, ALIGN, loc, x0, y0, stx, sty ,ST,n,v,i) +function draw_pins(slot, ALIGN, loc, x0, y0, stx, sty ,ST,n,v,i,siden) { if (slot == "") { # all slots for(n = 0; n < nslots; n++) @@ -77,6 +77,7 @@ ST["y"] = y0 + ALIGN[loc, "y0"] ST["pdir"] = loc + siden = 0 for(n = 0; n < SLOT[slot, "npins"]; n++) { pin = PINS[slot, n] if (PIN[pin, "loc"] == loc) { @@ -86,6 +87,11 @@ draw_pin(pin, ST, i, A) ST["x"] += stx ST["y"] += sty + if ((ALIGN["midgap", loc] != "") && (siden == ALIGN["midgap", loc])) { + ST["x"] += stx + ST["y"] += sty + } + siden++ } } else { @@ -92,6 +98,11 @@ draw_pin(pin, ST, "", A) ST["x"] += stx ST["y"] += sty + if ((ALIGN["midgap", loc] != "") && (siden == ALIGN["midgap", loc])) { + ST["x"] += stx + ST["y"] += sty + } + siden++ } } } @@ -112,7 +123,7 @@ { diff = ALIGN["box",boxloc] - ALIGN[loc,"count"] if (how == "center") - ALIGN[loc, target_field] = diff/2 + ALIGN[loc, target_field] = diff/2-0.5 else if ((how == "begin") || (how == "")) ALIGN[loc, target_field] = 0 else if (how == "end") @@ -138,6 +149,20 @@ return adj1 || adj2 } +# Calculate where to place a gap (after which pin) so that an even number of +# pins on an odd sized side distribute symmetrical +function align_get_midgap(size, numpins, how) +{ + if (how != "center") + return "" + + if ((numpins < 2) || (numpins % 2) || ((size % 2) != 0)) + return "" + +# we have even number of pins for odd size + return numpins/2-1 +} + function align_pins(sn, ALIGN, TXTBRD) { ALIGN["top","count"] = count_pins(sn, "top", ALIGN["cfg", "expand_slot"], TXTBRD) @@ -160,6 +185,10 @@ ALIGN["box","height"] += align_adjust_center(ALIGN["box","height"], ALIGN["left", "count"], SLOT[sn, "pinalign", "left"], ALIGN["right", "count"], SLOT[sn, "pinalign", "right"]) ALIGN["box","width"] += align_adjust_center(ALIGN["box","width"], ALIGN["bottom", "count"], SLOT[sn, "pinalign", "bottom"], ALIGN["top", "count"], SLOT[sn, "pinalign", "top"]) + ALIGN["midgap", "left"] = align_get_midgap(ALIGN["box","height"], ALIGN["left", "count"], SLOT[sn, "pinalign", "left"]) + ALIGN["midgap", "right"] = align_get_midgap(ALIGN["box","height"], ALIGN["right", "count"], SLOT[sn, "pinalign", "right"]) + ALIGN["midgap", "top"] = align_get_midgap(ALIGN["box","width"], ALIGN["top", "count"], SLOT[sn, "pinalign", "top"]) + ALIGN["midgap", "bottom"] = align_get_midgap(ALIGN["box","width"], ALIGN["bottom", "count"], SLOT[sn, "pinalign", "bottom"]) align_calc(ALIGN, "left", "height", "y0", SLOT[sn, "pinalign", "left"]) align_calc(ALIGN, "right", "height", "y0", SLOT[sn, "pinalign", "right"])