Index: bga.awk =================================================================== --- bga.awk (nonexistent) +++ bga.awk (revision 27184) @@ -0,0 +1,124 @@ +function pinalpha(p, s) +{ + if (p >= alphabet_len) + s = pinalpha(int(p/alphabet_len)-1) + return s sprintf("%s", substr(alphabet, (p % alphabet_len)+1, 1)) +} + +function automap(algo, pivot, revx, revy ,xx,yy) +{ + if (algo == 1) { + for(y = 0; y < ny; y++) { + if (revy) + yy = ny - y - 1 + else + yy = y + for(x = 0; x < nx; x++) { + if (revx) + xx = nx - x - 1 + else + xx = x + if (pivot) + MAP[x,y] = pinalpha(xx) yy+1 + else + MAP[x,y] = pinalpha(yy) xx+1 + } + } + } +} + +BEGIN { + help_auto() + set_arg(P, "?spacing", "0.5mm") + set_arg(P, "?balldia", "0.35mm") + set_arg(P, "?silkmark", "arc") + + proc_args(P, "nx,ny,spacing,balldia,silkmark,map,width,height,automap,automap2,alphabet", "") + + step = parse_dim(P["spacing"]) + + half=step/2 + + nx = int(P["nx"]) + ny = int(P["ny"]) + + alphabet = P["alphabet"] + if (alphabet == "") + alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + alphabet_len = length(alphabet) + + if (P["map"] != "") { + v = split(P["map"], A, ":") + x = 0 + y = 0 + for(n = 1; n <= v; n++) { + if ((A[n] == "") || (A[n] == "#")) { + x = 0 + y++ + continue; + } + if (x > nx) + nx = x + if (y > ny) + ny = y + print x,y,A[n] > "/dev/stderr" + MAP[x, y] = A[n] + x++ + } + ny++; + } + else { + if ((nx == "") || (ny == "")) + error("missing argument: need nx,ny or a map") + if (P["automap"] ~ "alnum") + automap(1, (P["automap2"] ~ "pivot"), (P["automap2"] ~ "reversex"), (P["automap2"] ~ "reversey")) + else if ((P["automap"] ~ "none") || (P["automap"] == "")) { + } + else + error("automap should be alnum or none") + } + + balldia = parse_dim(P["balldia"]) + bw = parse_dim(P["width"]) + bh = parse_dim(P["height"]) + + if (bw == "") + bw = (nx+1)*step + if (bh == "") + bh = (ny+1)*step + + xo = (nx-1)*step/2 + yo = (ny-1)*step/2 + + subc_begin(nx "*" ny, "U1", 0, -bh) + + proto = subc_proto_create_pad_circle(balldia) + + for(x = 0; x < nx; x++) { + for(y = 0; y < ny; y++) { + xx = x * step - xo + yy = y * step - yo + name = MAP[x,y] + if (name == "!") + continue + if (name == "") + name = "NC" + subc_pstk(proto, xx, yy, 0, name) + } + } + + dimension(-xo, -yo, -xo+step, -yo, bw/2, "spacing") + dimension(-xo-balldia/2, +yo, -xo+balldia/2, +yo, -bw*0.75, "balldia") + + + xx = -1 * (bw/2) + yy = -1 * (bh/2) + subc_rectangle("top-silk", xx, yy, bw/2, bh/2) + + dimension(xx, yy, bw/2, yy, bw/2, "width") + dimension(bw/2, yy, bw/2, bh/2, +bh/2, "height") + + silkmark(P["silkmark"], xx, yy, half*1.5) + + subc_end() +} Index: bga_lht =================================================================== --- bga_lht (nonexistent) +++ bga_lht (revision 27184) @@ -0,0 +1,74 @@ +#!/bin/sh + +# Reference: Microchip Packaging Specification DS00000049BX (en012702.pdf), SSOP + +#@@example bga(map=a1:a2:a2:#:b1:!:b3:#:c1:c2:!) + +#@@purpose Generate ball grid array + +#@@desc Generate a grid of circular pads for BGA chips + +#@@params nx,ny,spacing,balldia,silkmark,map,width,height,automap,automap2 + +#@@param:nx number of pins in the X direction +#@@optional:nx +#@@default:nx deduced from the map + +#@@param:ny number of pins in the Y direction +#@@optional:ny +#@@default:ny deduced from the map + +#@@param:spacing spacing between the pins +#@@dim:spacing +#@@default:spacing 0.5 mm + +#@@param:balldia diameter of a ball +#@@dim:balldia +#@@default:spacing 0.35 mm + +#@@include silkmark.help +#@@optional:silkmark +#@@default:silkmark square +#@@preview_args:silkmark 3,3 + +#@@param:map pin name map; a colon separated list of names, from left to right, rows first. If a name is empty or is a hash mark, a new row is started. If a name is a !, the given pin is missing and no pad is generated. +#@@optional:map + +#@@param:width width of the box (silk rectangle x size) +#@@dim:width +#@@optional:width +#@@default:width two columns wider than the array + +#@@param:height height of the box (silk rectangle y size) +#@@dim:height +#@@optional:height +#@@default:height two columns higher than the array + + +#@@param:automap assume a regular nx*ny array, automap (autonumber) the pins +#@@optional:automap +#@@enum:automap:none do not autonumber pins +#@@enum:automap:alnum number y rows from A..Z (then AA..AZ) from top to bottom, number x rows from 0..nx left to right +#@@default:none +#@@preview_args:automap 3,3 +#@@thumbsize:automap 3 +#@@thumbnum:automap 1 + +#@@param:automap2 change how automap behaves - multiple values separated by colon are accepted (e.g. automap2=pivot,reversex) +#@@enum:automap2:pivot swap x and y +#@@enum:automap2:reversex number x from right to left +#@@enum:automap2:reversey number y from bottom up +#@@preview_args:automap2 3,3,automap=alnum +#@@thumbsize:automap2 3 +#@@thumbnum:automap2 1 + +#@@param:alphabet the alphabet automap may use for rows; use A..Z if unspecified, else use the letters in this alphabet (in order). List letters without separator, e.g. ABCDEF +#@@preview_args:automap2 3,3,automap=alnum,alphabet=QDT +#@@thumbsize:automap2 3 +#@@thumbnum:automap2 1 + + +#@@include common.awk + +awk -f `dirname $0`/common.awk -f `dirname $0`/bga.awk -v "args=$*" -v gen=`basename $0` -v "genfull=$0" + Property changes on: bga_lht ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: common.awk =================================================================== --- common.awk (revision 27183) +++ common.awk (revision 27184) @@ -378,6 +378,28 @@ return proto } +function subc_proto_create_pad_circle(dia, mask_dia, paste_dia ,proto) +{ + proto = subc_proto_alloc() + subc_pstk_no_hole(proto) + + dia = either(dia, DEFAULT["pad_dia"]) + + PROTO_COMMENT[proto] = "# Circular smd pad " unit(dia) + PROTO[proto] = PROTO[proto] " li:shape {" NL + + subc_pstk_add_shape_circ(proto, "top-copper", 0, 0, dia) + + mask_dia = either(mask_dia, DEFAULT["pad_mask_dia"]) + subc_pstk_add_shape_circ(proto, "top-mask", 0, 0, mask_dia) + + paste_dia = either(mask_dia, DEFAULT["pad_paste_dia"]) + subc_pstk_add_shape_circ(proto, "top-mask", 0, 0, paste_dia) + + PROTO[proto] = PROTO[proto] " }" NL + return proto +} + # generate a padstack reference function subc_pstk(proto, x, y, rot, termid, name, clearance, s) { @@ -787,35 +809,35 @@ for(n = 1; n <= v; n++) { if (S[n] == "angled") { - element_line(x+half, y, x, y+half) + subc_line("top-silk", x+half, y, x, y+half) } else if (S[n] == "square") { - element_line(x, y+step, x+2*half, y+step) - element_line(x+step, y, x+2*half, y+step) + subc_line("top-silk", x, y+step, x+2*half, y+step) + subc_line("top-silk", x+step, y, x+2*half, y+step) } else if ((S[n] == "external") || (S[n] == "externalx")) { - element_line(x, y+half, x-step+half, y+half/2) - element_line(x, y+half, x-step+half, y+half*1.5) - element_line(x-step+half, y+half/2, x-step+half, y+half*1.5) + subc_line("top-silk", x, y+half, x-step+half, y+half/2) + subc_line("top-silk", x, y+half, x-step+half, y+half*1.5) + subc_line("top-silk", x-step+half, y+half/2, x-step+half, y+half*1.5) } else if (S[n] == "externaly") { - element_line(x+half, y, x-half/2+half, y-step+half) - element_line(x+half, y, x+half/2+half, y-step+half) - element_line(x-half/2+half, y-step+half, x+half/2+half, y-step+half) + subc_line("top-silk", x+half, y, x-half/2+half, y-step+half) + subc_line("top-silk", x+half, y, x+half/2+half, y-step+half) + subc_line("top-silk", x-half/2+half, y-step+half, x+half/2+half, y-step+half) } else if (S[n] == "external45") { - element_line(x, y, x-half, y-half/3) - element_line(x, y, x-half/3, y-half) - element_line(x-half, y-half/3, x-half/3, y-half) + subc_line("top-silk", x, y, x-half, y-half/3) + subc_line("top-silk", x, y, x-half/3, y-half) + subc_line("top-silk", x-half, y-half/3, x-half/3, y-half) } else if (S[n] == "arc") { - element_arc(x, y, step/2, step/2, 180, 270) + subc_arc("top-silk", x, y, step/2, 180, 270) } else if (S[n] == "circle") { - element_arc(x, y, step/2, step/2, 0, 360) + subc_arc("top-silk", x, y, step/2, 0, 360) } else if (S[n] == "dot") { - element_arc(x-step/2, y-step/2, step/4, step/4, 0, 360) + subc_arc("top-silk", x-step/2, y-step/2, step/4, 0, 360) } else if ((S[n] != "none") && (S[n] != "")) { error("invalid silkmark parameter: " S[n])