!*******************************************************************************1 %recordformat port(%integer x,w) %integerfnspec route(%string(31) name,%record(port)%arrayname a,b, %integer n,%string(4) lay,%integer twid,tsep,sepn) %routinespec croute(%string(31) name,%record(port)%arrayname a,b, %integer n,ya,xb,%string(4) lay,%integer twid,tsep) !******************************************************************************* %constant %string (2) blue ="M", metal ="M", nm="M" %constant %string (2) green ="D", diffusion="D", nd="D" %constant %string (2) red ="P", poly ="P", np="P" %constant %string (2) implant ="I", ni="I" %constant %string (2) glass ="G", ng="G" %constant %string (2) contact ="C", nc="C" %constant %string (2) buried ="B", nb="B" %constant %integer true = 0, false = 1 %external %string (2) %fn %spec contacts %external %routine %spec end symbol %external %routine %spec symbol (%string (31) name) %external %routine %spec box %alias "ILAPBOX" (%integer xl, yl, xu, yu) %external %routine %spec polygon %alias "ILAPPOLYGON" (%real x, y) %external %routine %spec wirex (%integer x, y, l) %external %routine %spec wirey (%integer x, y, l) %external %routine %spec ax (%integer u) %external %routine %spec ay (%integer v) %external %routine %spec axy (%real x, y) %external %routine %spec dx (%integer u) %external %routine %spec dy (%integer v) %external %routine %spec dxy (%real x, y) %external %routine %spec layer (%string (4) colour) %external %string (4) %function %spec clayer %external %routine %spec width (%integer size) %external %integer %function %spec cwidth %external %routine %spec draw (%string (31) name, %integer x, y) %external %routine %spec drawmx (%string (31) name, %integer x, y) %external %routine %spec drawmy (%string (31) name, %integer x, y) %external %routine %spec drawrot (%string (31) name, %integer x, y, rot) %external %routine %spec draw mx rot (%string (31) name, %integer x, y, rot) %external %routine %spec draw my rot (%string (31) name, %integer x, y, rot) %external %integer %function %spec SX (%string (31) name) %external %integer %function %spec SY (%string (31) name) %external %integer %function %spec LX (%string (31) name) %external %integer %function %spec LY (%string (31) name) %external %integer %function %spec symbol exists (%string (31) name) %external %routine %spec dm (%integer x, y) %external %routine %spec pm (%integer x, y) %external %routine %spec pdms (%integer x, y) %external %routine %spec pdmn (%integer x, y) %external %routine %spec pdmw (%integer x, y) %external %routine %spec pdme (%integer x, y) %external %routine %spec pdbn (%integer x, y) %external %routine %spec pdbs (%integer x, y) %external %routine %spec pdbe (%integer x, y) %external %routine %spec pdbw (%integer x, y) %external %routine %spec pdcn (%integer x, y) %external %routine %spec pdcs (%integer x, y) %external %routine %spec pdce (%integer x, y) %external %routine %spec pdcw (%integer x, y) %external %routine %spec pdbns (%integer x, y) %external %routine %spec pdbew (%integer x, y) !******************************************************************************* %externalstring(63)%fnspec itos(%integer n,p) %external %routine %spec die %alias "ILAPDISASTER" (%string (255) mess) %externalintegerfn route(%string(31) name,%record(port)%arrayname a,b, %integer n,%string(4) lay,%integer twid,tsep,sepn) %routine %spec fault (%string (255) mess) %integerarray ap(1:n,1:n) %integerarray apl(1:n) %integer i,j,k,l,p,q,x,sep,tws %for p=1,1,n %cycle %if a(p)_wa(p+1)_x %then fault("A ports ".itos(p,0). %c " and ".itos(p+1,0)." too close") %if b(p)_x+b(p)_w+tsep>b(p+1)_x %then fault("B ports ".itos(p,0). %c " and ".itos(p+1,0)." too close") %repeat tws=twid+tsep sep=1 %for p=1,1,n %cycle %if a(p)_x>=b(p)_x %and a(p)_x+a(p)_w<=b(p)_x+b(p)_w %then %c apl(p)=0 %and %continue ;! b port overlaps a port %if a(p)_x=b(p)_x %then %exit ap(p,i)=x i=i+1 %repeat ap(p,i)=b(p)_x apl(p)=i %finish %else %start i=1 %for j=p-1,-1,1 %cycle x=a(j)_x+a(j)_w+i*tws %if x<=b(p)_x+b(p)_w %then %exit ap(p,i)=x i=i+1 %repeat ap(p,i)=b(p)_x+b(p)_w apl(p)=-i %finish %if i>sep %then sep=i %repeat sep=tws*sep-tsep %if sepn>0 %then %start %if sepn0 %then i=a(p)_x %and j=twid %else %c i=a(p)_x+a(p)_w %and j=-twid %and l=-l wirex(i,0,j) ; i=i+j %for q=1,1,l %cycle k=i i=ap(p,q)+j %if i#k %then ax(i) %if qa(p+k)_x %then fault("A ports ".itos(p,0). %c " and ".itos(p+k,0)." too close") %repeat %if b(1)_xb(p+k)_x %then fault("B ports ".itos(p,0). %c " and ".itos(p+k,0)." too close") %repeat %if a(1)_xa(1)_x %then fault("corner too far right") %if a(1)_x>a(n)_x %and xbb(1)_x %then fault("corner too high") %if b(1)_x>b(n)_x %and yaa(1)_x %then {right} twidx=twid %and tsepx=tsep %and twsx=tws %c %else {left} twidx=-twid %and tsepx=-tsep %and twsx=-tws %if ya<=b(1)_x %then {up} twidy=twid %and twsy=tws %and yas=ya %c %else {down} twidy=-twid %and twsy=-tws %and yas=ya-twid %for p=1,1,n %cycle %if twidx=twid %then {right} xa=a(p)_x %else {left} xa=a(p)_x+a(p)_w wirex(xa,yas,twidx) {start wire off to right (left)} cx(p,1)=xa ; cy(p,1)=ya+twidy {first new corner} %for i=1,1,cp(p-1) %cycle ax(cx(p-1,i)-tsepx) {to right (left) as far as possible} ay(cy(p-1,i)+twsy) {up (down) as little as possible} cx(p,i+1)=cx(p-1,i)-twsx cy(p,i+1)=cy(p-1,i)+twsy %repeat i=cp(p-1) {just to make sure!} ax(xb) {go to corner line} %if twidy=twid %then {up} yb=b(p)_x+b(p)_w %else {down} yb=b(p)_x %if cy(p,i+1)=yb %then cp(p)=i+1 %else %start ay(yb) cx(p,i+2)=xb-twidx cy(p,i+2)=yb cp(p)=i+2 %finish %repeat endsymbol %routine fault(%string(255) f) die("Routing symbol """.name.""" : ".f) %end %end %endoffile