Index: trunk/util/boxsym-rnd/7400.sg =================================================================== --- trunk/util/boxsym-rnd/7400.sg (revision 2757) +++ trunk/util/boxsym-rnd/7400.sg (revision 2758) @@ -1,3 +1,5 @@ +refdes U?? + begin slot power shape box begin pin Vcc Index: trunk/util/boxsym-rnd/draw.awk =================================================================== --- trunk/util/boxsym-rnd/draw.awk (revision 2757) +++ trunk/util/boxsym-rnd/draw.awk (revision 2758) @@ -1,54 +1,12 @@ BEGIN { - # given in xschem coords: - grid=40 - pinsize=5 - - # given in grid coords: + # given in pin_grid coords: border=0.5 - pinlen=0.5 } -function pinbox(x, y, name, type, dir, pinnum, extra_attr ,attr) +function draw_box(SYM, w, h, border, shape) { - attr = "{name=" name - if (type != "") - attr = attr " type=" type - if (dir != "") - attr = attr " dir=" dir - if (pinnum != "") - attr = attr " pinnumber=" pinnum - if (extra_attr != "") - attr = attr " " extra_attr - attr = attr "}" - print "B 5", x*grid-pinsize, y*grid-pinsize, x*grid+pinsize, y*grid+pinsize, attr > ofn -} - -function line(x1, y1, x2, y2, extra_attr) -{ - print "L 4", x1*grid, y1*grid, x2*grid, y2*grid, "{" extra_attr "}" > ofn -} - -function text(x, y, str, rot, mir, hor, sizex, sizey, extra_attr) -{ - if (sizex == "") sizex = def_text_size - if (sizey == "") sizey = def_text_size - print "T {" str "}", x*grid, y*grid, int(rot), int(mir), sizex, sizey, "{" extra_attr "}" > ofn -} - -function header() -{ - print "v {xschem version=symgen-1.0 file_version=1.1}" > ofn -} - -### high level file output ### -function draw_box(w, h, border, shape) -{ - if ((shape ~ "^box") || (shape == "")) { - line(0-border, 0-border, w+border, 0-border); # top - line(0-border, 0-border, 0-border, h+border); # left - line(w+border, 0-border, w+border, h+border); # right - line(0-border, h+border, w+border, h+border); # bottom - } + if ((shape ~ "^box") || (shape == "")) + sym_rect(SYM, 0-border*pin_grid, 0-border*pin_grid, (w+border)*pin_grid, (h+border)*pin_grid) else print "Error: can not draw box of unknown shape " shape } Index: trunk/util/boxsym-rnd/generator.awk =================================================================== --- trunk/util/boxsym-rnd/generator.awk (revision 2757) +++ trunk/util/boxsym-rnd/generator.awk (revision 2758) @@ -1,3 +1,7 @@ +BEGIN { + refdes="U?" +} + function count_pins(slot, loc, expand_slot, n,cnt, pin, cinc, TMP) { cnt = 0 @@ -23,37 +27,38 @@ function draw_pin(pin, ST, slotidx, SLT ,x2,y2,pname) { - x2 = ST["x"] + pinlen*ST["px"] - y2 = ST["y"] + pinlen*ST["py"] - line(ST["x"], ST["y"], x2, y2) + x2 = ST["x"] + y2 = ST["y"] +# line(ST["x"], ST["y"], x2, y2) + + pname = pin sub(/^.*::/,"", pname) dbg("draw_pin(): pname=" pname) - if(slotidx != "") { + if (slotidx != "") { dbg("draw_pin(): " pin " slotidx=" slotidx " " PIN[pin, "loc"] " " PIN[pin, "dir"] " " SLT[slotidx]) - # function pinbox(x, y, name, type, dir, pinnum, extra_attr) - pinbox(x2, y2, pname, "", PIN[pin, "dir"], SLT[slotidx], "") - } else { - dbg("draw_pin(): " pin " " PIN[pin, "loc"] " " PIN[pin, "dir"] " " PIN[pin, "num"]) - pinbox(x2, y2, pname, "", PIN[pin, "dir"], PIN[pin, "num"], "") + + sym_term(SYM, x2, y2, ST["pdir"], PIN[pin, "num"]) } + else { + sym_term(SYM, x2, y2, PIN[pin, "dir"], PIN[pin, "num"]) + } } # 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, px, py, stx, sty ,ST,n,v,i) +function draw_pins(slot, ALIGN, loc, x0, y0, stx, sty ,ST,n,v,i) { if (slot == "") { # all slots for(n = 0; n < nslots; n++) - draw_pins(SLOTS[n], ALIGN, loc, x0, y0, px, py, stx, sty, ST) + draw_pins(SLOTS[n], ALIGN, loc, x0, y0, stx, sty, ST) return } if (ST["x"] == "") ST["x"] = x0 + ALIGN[loc, "x0"] if (ST["y"] == "") ST["y"] = y0 + ALIGN[loc, "y0"] - ST["px"] = px - ST["py"] = py + ST["pdir"] = loc for(n = 0; n < SLOT[slot, "npins"]; n++) { pin = PINS[slot, n] if (PIN[pin, "loc"] == loc) { @@ -61,14 +66,14 @@ v = split(PIN[pin, "num"], A, "[:]") for(i = 1; i <= v; i++) { draw_pin(pin, ST, i, A) - ST["x"] += stx - ST["y"] += sty + ST["x"] += stx * pin_grid + ST["y"] += sty * pin_grid } } else { draw_pin(pin, ST, "", A) - ST["x"] += stx - ST["y"] += sty + ST["x"] += stx * pin_grid + ST["y"] += sty * pin_grid } } } @@ -78,11 +83,11 @@ { bw = ALIGN["box","width"] bh = ALIGN["box","height"] - # x0 y0 px py stx sty - draw_pins(sn, ALIGN, "left", -border, 0, -1, +0, +0, +1) - draw_pins(sn, ALIGN, "right", bw+border, 0, +1, +0, +0, +1) - draw_pins(sn, ALIGN, "top", border, -border, +0, -1, +1, +0) - draw_pins(sn, ALIGN, "bottom", border, bh+border, +0, +1, +1, +0) + # x0 y0 stx sty + draw_pins(sn, ALIGN, "left", -border, 0, +0, +1) + draw_pins(sn, ALIGN, "right", bw+border, 0, +0, +1) + draw_pins(sn, ALIGN, "top", border, -border, +1, +0) + draw_pins(sn, ALIGN, "bottom", border, bh+border, +1, +0) } function align_calc(ALIGN, loc, boxloc, target_field, how ,diff) @@ -119,9 +124,13 @@ ofn=basename ".sym" ALIGN["cfg", "expand_slot"] = 1 align_pins("", ALIGN) - header() - draw_box(ALIGN["box","width"], ALIGN["box","height"], border, "") + sym_begin(refdes, 0, -half) + sym_rect(SYM, 0, -half, xs * step + xo, P["ny"] * step + yo - half) + + draw_box(SYM, ALIGN["box","width"], ALIGN["box","height"], border, "") draw_all_pin("", ALIGN, 1) + sym_end() + delete SYM ofn="" } @@ -130,9 +139,11 @@ ofn=basename "_" sn ".sym" ALIGN["cfg", "expand_slot"] = 0 align_pins(sn, ALIGN) - header() - draw_box(ALIGN["box","width"], ALIGN["box","height"], border, "") + sym_begin(refdes, 0, -half) + draw_box(SYM, ALIGN["box","width"], ALIGN["box","height"], border, "") draw_all_pin(sn, ALIGN, 0) + sym_end() + delete SYM ofn="" } Index: trunk/util/boxsym-rnd/parser.awk =================================================================== --- trunk/util/boxsym-rnd/parser.awk (revision 2757) +++ trunk/util/boxsym-rnd/parser.awk (revision 2758) @@ -92,6 +92,7 @@ basename=FILENAME sub("[.][^.]*$", "", basename) } - +/^[\t ]*#/ { next } +($1 == refdes) { refdes = $2 } /begin slot/ { parse_slot() } ($1 == "pinalign") { SLOT["", "pinalign", $2] = $3 }