Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site seismo.CSS.GOV Posting-Version: version B 2.10.2 9/3/84; site genrad.UUCP Path: seismo!cbosgd!ulysses!allegra!mit-eddie!genrad!sources-request From: sources-request@genrad.UUCP Newsgroups: mod.sources Subject: wirewrap program part 02 of 02 Message-ID: <1015@genrad.UUCP> Date: 18 Aug 85 12:47:28 GMT Sender: john@genrad.UUCP Reply-To: karsh@geowhiz.UUCP (Bruce Karsh) Organization: UW Madison, Dept. of Geology & Geophysics Lines: 1290 Keywords: wirewrap circuit board construction cad cadcam cam pc chip Approved: john@genrad.UUCP Mod.sources: Volume 2, Issue 36 Submitted by: uwvax!geowhiz!karsh (Bruce Karsh) #!/bin/sh # # This is a release of my wirewrap program. It has been used # to make several boards here, and seems to be pretty reliable. # It was written on a Masscomp MC500, but I don't think there # are any serious machine dependencies in it. (But then again, # I'm often suprised by how easy it is to inadvertantly write # machine dependent code.) # # I'd like to hear some bug reports and success stories. I will # try to send out bug fixes as quickly as I can. # # As usual, unpack all parts by running through sh, then run make. # # Unix Wirewrap Source Code: # cnvtnum.c gettoken.c getwired.c getwirelen.c header1.c # header2.c initialize.c insertname.c insertx.c main.c # mywrite.c mywrite2.c namecmp.c namecmp2.c output1.c # output2.c output3.c readin.c setptr.c setrowandcol.c # sort1.c sort2.c test.c # # .h files: # wirewrap.h # # Documentation: # wirewrap.1 README PACKINGLIST # # Unix wirewrap makefile: # Makefile # # Test Data: # autocal # # Example listing: # autocal.listing # # ---- # Bruce Karsh # U. Wisc. Dept. Geology and Geophysics # 1215 W Dayton, Madison, WI 53706 # (608) 262-1697 # {ihnp4,seismo}!uwvax!geowhiz!karsh # echo 'Start of wirewrap program, part 02 of 02:' echo 'x - Makefile' sed 's/^X//' > Makefile << '/' Xwirewrap: initialize.o readin.o main.o setptr.o setrowandcol.o \ X sort1.o getwired.o output3.o getwirelen.o \ X insertx.o output1.o mywrite.o header1.o sort2.o \ X output2.o header2.o mywrite2.o \ X test.o cnvtnum.o namecmp.o insertname.o gettoken.o \ X namecmp2.o X cc -o wirewrap initialize.o readin.o main.o setptr.o \ X setrowandcol.o sort1.o getwired.o output3.o \ X getwirelen.o output1.o insertx.o mywrite.o \ X header1.o sort2.o output2.o header2.o mywrite2.o \ X test.o cnvtnum.o namecmp.o gettoken.o \ X insertname.o namecmp2.o -lm X Xclean: X rm -f *.o X Xpackage: X packmail -hREADME -t'wirewrap program' `/bin/cat PACKINGLIST` X Xgettoken.o: wirewrap.h Xgetwired.o: wirewrap.h Xgetwirelen.o: wirewrap.h Xinitialize.o: wirewrap.h Xinsertname.o: wirewrap.h Xmain.o: wirewrap.h Xmywrite.o: wirewrap.h Xmywrite2.o: wirewrap.h Xnamecmp.o: wirewrap.h Xnamecmp2.o: wirewrap.h Xoutput1.o: wirewrap.h Xoutput2.o: wirewrap.h Xoutput3.o: wirewrap.h Xreadin.o: wirewrap.h Xsetptr.o: wirewrap.h Xsetrowandcol.o: wirewrap.h Xsort1.o: wirewrap.h Xsort2.o: wirewrap.h Xtest.o: wirewrap.h / echo 'x - PACKINGLIST' sed 's/^X//' > PACKINGLIST << '/' XMakefile XPACKINGLIST XREADME Xautocal Xautocal.listing Xcnvtnum.c Xgettoken.c Xgetwired.c Xgetwirelen.c Xheader1.c Xheader2.c Xinitialize.c Xinsertname.c Xinsertx.c Xmain.c Xmywrite.c Xmywrite2.c Xnamecmp.c Xnamecmp2.c Xoutput1.c Xoutput2.c Xoutput3.c Xreadin.c Xsetptr.c Xsetrowandcol.c Xsort1.c Xsort2.c Xtest.c Xwirewrap.1 Xwirewrap.h / echo 'x - README' sed 's/^X//' > README << '/' XThis is a release of my wirewrap program. It has been used Xto make several boards here, and seems to be pretty reliable. XIt was written on a Masscomp MC500, but I don't think there Xare any serious machine dependencies in it. (But then again, XI'm often suprised by how easy it is to inadvertantly write Xmachine dependent code.) X XI'd like to hear some bug reports and success stories. I will Xtry to send out bug fixes as quickly as I can. X XAs usual, unpack all parts by running through sh, then run make. X XUnix Wirewrap Source Code: Xcnvtnum.c gettoken.c getwired.c getwirelen.c header1.c Xheader2.c initialize.c insertname.c insertx.c main.c Xmywrite.c mywrite2.c namecmp.c namecmp2.c output1.c Xoutput2.c output3.c readin.c setptr.c setrowandcol.c Xsort1.c sort2.c test.c X X.h files: X wirewrap.h X XDocumentation: X wirewrap.1 README PACKINGLIST X XUnix wirewrap makefile: X Makefile X XTest Data: X autocal X XExample listing: X autocal.listing X X---- XBruce Karsh XU. Wisc. Dept. Geology and Geophysics X1215 W Dayton, Madison, WI 53706 X(608) 262-1697 X{ihnp4,seismo}!uwvax!geowhiz!karsh / echo 'x - autocal' sed 's/^X//' > autocal << '/' X/* X** Auto calibration circuitry for UW Digital recording packages. X*/ X:chip I/O-edge 1a 80 2 56 1 4 X . . . GAP4 . . . . X 10SEC . . . . . . SKEY- X . . . . . . . . X . . . TST+ . . . . X X . . . . . . . g X . . . . . . . . X bgld- . bcal+ . . . . . X . . . PD3 . . . . X . . . . . . . . X . . . . . . . . X X:chip UPI/O 10a 1 1 37 53 4 X Q X X:chip RUN.FF1 8c 14 3 53 41 4 X . . . . . . . X jamrun+ . . . . . . X X:chip RUN.FF2 2e 16 3 35 5 4 X . . . . RON+ . . . X . . . . . . . . X X:chip Buffer.4050 2g 16 3 17 5 4 X . . . . . . . . X . . cal+ bcal+ . gld- bgld- . X X:chip count.4020 2h 16 3 8 5 4 X . q13 stop+ . . . . - X . clk/2 calrun- . . q10 . + X X:chip runff.4013 3g 14 3 17 11 4 X calrun- . 10SEC g jamrun- stop+ - X stop+ calena+ g Q jamrun+ jamrun- + X X:chip or.4071 3h 14 3 8 11 4 X mp acal cal+ seqi calrun- seqm - X seqm ap apms calena+ TST+ RON+ + X X:chip and.4081 4g 14 3 17 17 4 X SKEY- TST+ gld- mp TST+ PD3 - X jamrun+ apms acal ap q10 q13 + X X:chip xor.4030 4h 14 3 8 17 4 X seq4 seq12 seql seqn seql seq6 - X seq1 seqn seqm clk GAP4 g + X X:chip shift.4015 5g 16 3 17 23 4 X clk seq8 . . seq1 q13 seqi - X clk seq4 . seq6 . q13 seq4 + X X:chip shift.4015 5h 16 3 8 23 4 X clk . . . . q13 seq8 - X clk seq12 . . . q13 seq12 + X X:chip syncff.4013 6h 14 3 8 29 4 X clk/2 clk/2- clk calrun- clk/2- g - X g g g g . . + X X:SPECIAL X + - / echo 'x - cnvtnum.c' sed 's/^X//' > cnvtnum.c << '/' X#include Xchar *cnvtnump; /* Pointer to next character to process. */ Xint cnvtnumv; /* 1 if valid number, 0 otherwise. */ X/*************************************/ X/* cnvtnum - convert ascii to int. */ X/* Works like atoi() except that it */ X/* leaves the externel variables set*/ X/* to help in error recovery. */ X/*************************************/ Xcnvtnum(str) Xchar *str; X{ Xint sign=1; Xint result=0; Xcnvtnump = str; Xcnvtnumv=0; X X/* Skip leading blanks. */ X Xwhile(*cnvtnump == ' ' || *cnvtnump == '\t')cnvtnump++; X X/* Pick up leading sign. */ X Xif(*cnvtnump == '+') X { X sign = 1; X *cnvtnump++; X } Xelse if(*cnvtnump == '-') X { X sign = -1; X *cnvtnump++; X } X X/* Pick up digits. */ X Xwhile(isdigit(*cnvtnump)) X { X result=10*result+ (*cnvtnump-'0'); X cnvtnump++; X cnvtnumv=1; X } X Xreturn(sign*result); X} / echo 'x - gettoken.c' sed 's/^X//' > gettoken.c << '/' X#include X#include X#include "wirewrap.h" X/* X** gettoken - return a whitespace delimited token. X** Tokens are truncated at 79 characters. X** Return code is zero if a token is X** returned, otherwise an end of file X** was reached and -1 is returned. X*/ Xgettoken(token) Xchar *token; X{ Xchar chr; Xint tokenptr; Xstatic int firsttime=1; Xstatic int nextchr; Xint comment; Xtokenptr=0; Xtoken[tokenptr]=0; Xcomment=0; X X/* If first time through, get a look-ahead character. */ X Xif(firsttime == 1) X { X nextchr=getchar(); X firsttime=0; X } X Xfor(;;) X { X /* Get a character from the input. */ X X if(nextchr == EOF) X chr=EOF; X else X { X chr=nextchr; X nextchr=getchar(); X } X X /* Test if start of a comment. */ X X if(chr == '/' && nextchr == '*') X { X nextchr = getchar(); X comment = 1; X continue; X } X X /* Test if end of a comment. */ X X if(chr == '*' && nextchr == '/' && comment == 1) X { X nextchr=getchar(); X comment=0; X continue; X } X X /* Test if EOF within a comment. */ X X if(chr == EOF && comment == 1)break; X X /* Test if a newline char within a comment. */ X X if(chr == '\n' && comment == 1) X { X inputline++; X continue; X } X X /* Test if any other character within a comment. */ X X if(comment == 1)continue; X X /* Process end of file. */ X X if(chr == EOF)break; X X /* Process white space character. */ X X if(isspace(chr)) X { X X /* Process new line character. */ X if(chr == '\n') X { X if(tokenptr != 0) X X /* Process new line character which terminates a token */ X X ungetc(chr,stdin); X else X X /* Process a new line character which does not terminate a token */ X X inputline++; X } X X /* Process any white space character that terminates a token */ X X if(tokenptr != 0) return(0); X X /* Process a white space character that doesn't terminate a token */ X X else continue; X } X else X X /* Process a non white space charater */ X X if(tokenptr<79) X { X X /* Process a non white space charater before the 79'th char of a token */ X X token[tokenptr]=chr; X tokenptr++; X token[tokenptr]=0; X } X else X X /* Process a non white space character after the 79'th char of a token */ X X continue; X } X X/* Process end of file */ X Xif(tokenptr==0)return(-1);else return(0); X} / echo 'x - getwired.c' sed 's/^X//' > getwired.c << '/' X/********************************************** X* getwired - do the wire routing. * X* * X* When getwired is called, the signal list * X* is sorted in order by signalname. This * X* routine connects adjacent pins with the * X* same signal name together. Pins are conn- * X* nected together with either top to top * X* wraps or bottom to bottom wraps everywhere.* X* The last wrap may really be wrapped as a * X* top to bottom wrap if there is an odd num- * X* ber of pins in the string. But it is still* X* represented as a top to top wrap. * X**********************************************/ X X#include "wirewrap.h" X Xgetwired() X{ Xint indexlo,indexhi,count,i; Xchar currentsignal[NAMELENGTH]; Xindexhi = 0; Xwhile(indexhi < nextfree) X { X indexlo = indexhi; X indexhi = indexhi + 1; X for(i=0;isignalname[i]; X while((indexhi < nextfree) && X !namecmp(pinarray[indexhi].signalname->signalname,currentsignal) X )indexhi++; X if(namecmp(currentsignal,NULLSIGNAL)) X { X count = indexlo; X while(count < indexhi-1) X { X pinarray[count].inner = count+1; X pinarray[count+1].inner = count; X count = count + 2; X } X count = indexlo + 1; X while(count < indexhi-1) X { X pinarray[count].outer = count+1; X pinarray[count+1].outer = count; X count = count + 2; X } X } X } X} / echo 'x - getwirelen.c' sed 's/^X//' > getwirelen.c << '/' X#define sqr(a) ( (a)*(a) ) X#include X#include "wirewrap.h" Xdouble getwirelength(row1,col1,row2,col2) Xint row1,col1,row2,col2; X{ Xdouble wlength; X X/* Compute straight line distance. */ X Xwlength = .1 * sqrt((double) sqr(row1-row2)+sqr(col1-col2)); X X/* Apply linear regression coefficients */ X Xwlength = wlength * lengthfactor + pinpart; X X/* Round up to the nearest larger .5 inch */ X Xwlength = wlength * 2 + 1; Xwlength = (int) wlength; Xwlength = wlength/2.0; X X/* Make sure that it is at least as long as the minimum length. */ X Xif(wlength < minlength) wlength = minlength; Xreturn(wlength); X} / echo 'x - header1.c' sed 's/^X//' > header1.c << '/' Xheader1() X{ Xchar outline[80]; X Xoutline[0]=0; Xinsertx("chip",outline,10); Xinsertx("pin",outline,23); Xinsertx("chip",outline,28); Xprintf("%s\n",outline); Xoutline[0]=0; Xinsertx("name",outline,10); Xinsertx("num",outline,23); Xinsertx("position",outline,28); Xinsertx("row col",outline,42); Xprintf("%s\n",outline); X} / echo 'x - header2.c' sed 's/^X//' > header2.c << '/' Xheader2() X{ Xchar outline[80]; Xoutline[0]=0; Xinsertx("signal",outline,1); Xinsertx("pin",outline,14); Xinsertx("inner wire",outline,18); Xinsertx("outer wire",outline,39); Xprintf("%s\n",outline); Xoutline[0]=0; Xinsertx("name ",outline,1); Xinsertx("num",outline,14); Xprintf("%s\n",outline); X} / echo 'x - initialize.c' sed 's/^X//' > initialize.c << '/' X/******************************************* X* initialize - initialize global variables * X*******************************************/ X X#include "wirewrap.h" X Xinitialize() X{ Xchipleader = 0; Xsiglistleader = 0; Xnextfree = 0; Xlinenum = 67; Xinputline=1; X} / echo 'x - insertname.c' sed 's/^X//' > insertname.c << '/' X#include "wirewrap.h" Xinsertname(from,to,pos) Xchar *from, *to; Xint pos; X{ Xchar *p; Xint l; X X/* Pad with trailing blanks. */ X Xl=strlen(to); Xwhile(l<(pos-1)) X { X to[l]=' '; X l++; X } Xto[l]=0; X X/* Append the from string to the to string. */ X Xl=pos-1; Xfor(p=from; p-from < NAMELENGTH; p++) X { X to[l] = *p; X l++; X } Xto[l]=0; X} / echo 'x - insertx.c' sed 's/^X//' > insertx.c << '/' Xinsertx(from,to,pos) Xchar *from, *to; Xint pos; X{ Xchar *p; Xint l; X X/* Pad with trailing blanks. */ X Xl=strlen(to); Xwhile(l<(pos-1)) X { X to[l]=' '; X l++; X } Xto[l]=0; X X/* Append the from string to the to string. */ X Xl=pos-1; Xfor(p=from; *p != 0; p++) X { X to[l] = *p; X l++; X } Xto[l]=0; X} / echo 'x - main.c' sed 's/^X//' > main.c << '/' X#include "wirewrap.h" Xmain() X{ Xinitialize(); Xreadin(); /* Read the input file. */ X X#ifdef DEBUG X printf("Dump of pin array after inputting data\n"); X test(); X#endif X Xsort1(); /* Sort by signal name. */ X X#ifdef DEBUG X printf("Dump of pin array after sort by signal name\n"); X test(); X#endif X Xgetwired(); /* Wire the pins togther. */ X X#ifdef DEBUG X printf("Dump of pin array after doing the wiring.\n"); X test(); X#endif X Xoutput1(); /* Output the first printout. (Chip side view) */ X Xsort2(); /* Sort by (row,col). */ X X#ifdef DEBUG X printf("Dump of pin array after sorting by (row,col)\n"); X test(); X#endif X Xoutput2(); /* Output the second printout. (Pin side view) */ X Xoutput3(); /* Output the third printout. (Wire lengths) */ X} / echo 'x - mywrite.c' sed 's/^X//' > mywrite.c << '/' X#include "wirewrap.h" X Xmywrite(outline) Xchar *outline; X{ Xif(linenum > 60) X { X printf(" "); X header1(); X linenum=3; X } X printf("%s\n",outline); X linenum++; X} / echo 'x - mywrite2.c' sed 's/^X//' > mywrite2.c << '/' X#include "wirewrap.h" X Xmywrite2(outline) Xchar *outline; X{ Xif(linenum > 60) X { X printf(" "); X header2(); X linenum=3; X } X printf("%s\n",outline); X linenum++; X} / echo 'x - namecmp.c' sed 's/^X//' > namecmp.c << '/' X/* X** namecmp - compare two names. Works like strcmp() X*/ X#include "wirewrap.h" Xnamecmp(a,b) Xchar a[NAMELENGTH],b[NAMELENGTH]; X{ Xint i; Xfor(i=0;ib[i])return(1); X } Xreturn(0); X} / echo 'x - namecmp2.c' sed 's/^X//' > namecmp2.c << '/' X/* X** namecmp2 - compare two names. Works like strcmp() X** This is the same as namecmp except that X** namecmp2 ignores case. X*/ X#include "wirewrap.h" Xnamecmp2(a,b) Xchar a[NAMELENGTH],b[NAMELENGTH]; X{ Xint i; Xfor(i=0;itolower(b[i]))return(1); X } Xreturn(0); X} / echo 'x - output1.c' sed 's/^X//' > output1.c << '/' X#include "wirewrap.h" Xoutput1() X{ Xchar currentsig[12],outline[80], sig[12], wrap, newstring[80]; Xint count, i; X Xcurrentsig[0] = 0; Xcount = 0; Xoutline[0] = 0; Xwhile(count < nextfree) X { X for(i=0;i<12;i++)sig[i] = pinarray[count].signalname->signalname[i]; X if(namecmp(sig,currentsig)) X { X insertname(sig,outline,1); X if((pinarray[count].signalname->special) != 0) X insertx("Special",outline,2+NAMELENGTH); X mywrite(outline); X outline[0]=0; X for(i=0;i<12;i++)currentsig[i]=sig[i]; X wrap='T'; X } X if(wrap == 'T')wrap='B'; else wrap='T'; X newstring[0]=0; X insertname(pinarray[count].mychip->name,outline,10); X sprintf(newstring,"%d",pinarray[count].pinnum); X insertx(newstring,outline,12+NAMELENGTH); X insertname(pinarray[count].mychip->position,outline,17+NAMELENGTH); X sprintf(newstring,"(%d,%d)",pinarray[count].row, pinarray[count].col); X insertx(newstring,outline,30+NAMELENGTH); X if(namecmp(sig,NULLSIGNAL) && (!pinarray[count].signalname->special)) X insertx(wrap,outline,39+NAMELENGTH); X mywrite(outline); X outline[0] = 0; X count++; X } X} / echo 'x - output2.c' sed 's/^X//' > output2.c << '/' X#include "wirewrap.h" X Xoutput2() X{ Xint oldrow,oldcol,runflag,count,already,specialsig; Xint innerptr,innerwrap,outerptr,outerwrap; Xchar tempstr[80],outline[80]; Xdouble wlength,getwirelength(); Xprintf(" "); Xheader2(); Xoldrow = -100; Xoldcol = -100; Xlinenum = 3; Xrunflag = 0; Xfor(count=0;countsignalname,outline,1); X sprintf(tempstr,"%d",pinarray[count].pinnum); X insertx(tempstr,outline,14); X X /* FIGURE SOME STUFF OUT FOR THE INNER WRAP */ X X innerptr = pinarray[count].inner; X innerwrap = (pinarray[count].inner != -1); X if(innerwrap) X already = (pinarray[count].inner < count); X else X already = 0; X specialsig = pinarray[count].signalname->special; X X /* SET UP LENGTH OF INNER WIRE */ X X if(specialsig) X insertx("SPEC",outline,18); X if(already && (! specialsig)) X insertx("TEST",outline,18); X if(innerwrap && (! already) && (! specialsig)) X { X wlength=getwirelength(pinarray[count].row,pinarray[count].col, X pinarray[innerptr].row,pinarray[innerptr].col); X wlength = (double) ( (int) (wlength * 10) ) / 10; X sprintf(tempstr,"%.1f",wlength); X insertx(tempstr,outline,18); X } X X /* SET UP ROW1 AND COL1 */ X X sprintf(tempstr,"%d",pinarray[count].row); X insertx(tempstr,outline,23); X insertx(",",outline,strlen(outline)+1); X sprintf(tempstr,"%d",pinarray[count].col); X insertx(tempstr,outline,strlen(outline)+1); X X /* SET UP ROW2 AND COL2 */ X X if((!specialsig) && innerwrap) X { X insertx(" ",outline,strlen(outline)+1); X sprintf(tempstr,"%d",pinarray[innerptr].row); X insertx(tempstr,outline,strlen(outline)+1); X insertx(",",outline,strlen(outline)+1); X sprintf(tempstr,"%d",pinarray[innerptr].col); X insertx(tempstr,outline,strlen(outline)+1); X } X X /* FIGURE SOME STUFF OUT FOR THE OUTER WRAP */ X X outerptr = pinarray[count].outer; X outerwrap =(pinarray[count].outer != -1); X if(outerwrap) X already=(pinarray[count].outer < count); X else X already=0; X specialsig = pinarray[count].signalname->special; X X /* SET UP LENGTH OF OUTER WIRE */ X X if(specialsig) X insertx("SPEC",outline,39); X if(already && (!specialsig)) X insertx("TEST",outline,39); X if(outerwrap && (!already) && (!specialsig)) X { X wlength=getwirelength(pinarray[count].row,pinarray[count].col, X pinarray[outerptr].row,pinarray[outerptr].col); X wlength = (double) ( (int) (wlength * 10) ) / 10; X sprintf(tempstr,"%.1f",wlength); X insertx(tempstr,outline,39); X } X X /* SET UP ROW1 AND COL1 */ X X sprintf(tempstr,"%d",pinarray[count].row); X insertx(tempstr,outline,44); X insertx(",",outline,strlen(outline)+1); X sprintf(tempstr,"%d",pinarray[count].col); X insertx(tempstr,outline,strlen(outline)+1); X X /* SET UP ROW2 AND COL2 */ X X if((!specialsig) && outerwrap) X { X insertx(" ",outline,strlen(outline)+1); X sprintf(tempstr,"%d",pinarray[outerptr].row); X insertx(tempstr,outline,strlen(outline)+1); X insertx(",",outline,strlen(outline)+1); X sprintf(tempstr,"%d",pinarray[outerptr].col); X insertx(tempstr,outline,strlen(outline)+1); X } X X /* SET UP EMPTY/FULL FLAG */ X X if((!specialsig) && outerwrap) X { X insertx(" ",outline,strlen(outline)+1); X if(pinarray[outerptr].inner == -1) X insertx("E",outline,strlen(outline)+1); X else X insertx("F",outline,strlen(outline)+1); X } X mywrite2(outline); X } X} / echo 'x - output3.c' sed 's/^X//' > output3.c << '/' X#include "wirewrap.h" X Xoutput3() X{ Xdouble wirelength,getwirelength(); Xint longctr, i, len, total, ctr[21]; X X/* Zero out counters */ X X longctr = 0; X for(i=2;i<=20;i++)ctr[i]=0; X X/* Print heading. */ X X printf("\014"); X printf(" WIRE LENGTH SUMMARY\n"); X printf(" -------------------\n"); X printf("\n"); X printf(" Wire Number\n"); X printf("Length Used\n"); X X/* Wire counting loop. */ X X for(i=0; ispecial) ) X { X wirelength=getwirelength(pinarray[i].row,pinarray[i].col, X pinarray[pinarray[i].inner].row, X pinarray[pinarray[i].inner].col); X len=wirelength / 0.5 + 0.1; X if(len > 20) X longctr++; X else X ctr[len]++; X } X X /* Count outer wire length*/ X X if( (pinarray[i].outer != -1 ) && X (!pinarray[i].signalname->special) ) X { X wirelength=getwirelength(pinarray[i].row,pinarray[i].col, X pinarray[pinarray[i].outer].row, X pinarray[pinarray[i].outer].col); X len=wirelength / 0.5 + 0.1; X if(len > 20) X longctr++; X else X ctr[len]++; X } X } X X /* Only count each wire once. */ X for(i=2;i<=20;i++)ctr[i]=ctr[i]/2; X longctr=longctr/2; X X /* Make listing. */ X X for(i=2;i<=20;i++) X { X if(ctr[i] > 0) X { X printf("%-9.1f %d\n",(.5*i),ctr[i]); X } X } X if(longctr > 0) X { X printf("> 10.0 %d\n",longctr); X } X X /* Total up how many wires used. */ X X total=0; X for(i=2;i<=20;i++)total+=ctr[i]; X total += longctr; X printf("Total number of wires used: %d\n",total); X} / echo 'x - setrowandcol.c' sed 's/^X//' > setrowandcol.c << '/' X/*********************************************************/ X/* */ X/* setrowandcol: sets up the row and column field of the */ X/* pin list entry based on the pin orientation, width, */ X/* pincount and (row1,col1). */ X/* */ X/*********************************************************/ X X#include "wirewrap.h" X Xsetrowandcol(thispin) Xstruct pin *thispin; X{ Xint width,row1,col1,pinsrow,pincount; X/* X** Pick up width, (row1,col1), and pincount for this chip. X*/ Xwidth = (thispin -> mychip) -> width; Xrow1 = (thispin -> mychip) -> row1; Xcol1 = (thispin -> mychip) -> col1; Xpincount = (thispin -> mychip) -> pincount; X/* X** Process SIPs (single inline packages). These are entered as X** having a width of zero. All other chips are assumed to be X** DIPs (dual inline packages). X** An n pin SIP has n pins per row. An n pin DIP has n/2 pins per row. X*/ Xif(width == 0) X pinsrow = pincount; Xelse X pinsrow = pincount/2; X/* X** Following is the calculation of row and column numbers for each X** of the four orientations. X*/ Xswitch ((thispin -> mychip) -> orientation) X { X case 1: if(thispin -> pinnum > pinsrow) X { X thispin -> row = row1 + width; X thispin -> col = col1 + pincount - thispin -> pinnum; X } X else X { X thispin -> row = row1; X thispin -> col = col1 + thispin -> pinnum - 1; X } X break; X case 2 : if(thispin -> pinnum > pinsrow) X { X thispin -> row = row1 + pincount - thispin -> pinnum; X thispin -> col = col1 - width; X } X else X { X thispin -> row = row1 + thispin -> pinnum - 1; X thispin -> col = col1; X } X break; X case 3 : if(thispin -> pinnum > pinsrow) X { X thispin -> row = row1 - width; X thispin -> col = col1 - pincount + thispin -> pinnum; X } X else X { X thispin -> row = row1; X thispin -> col = col1 - thispin -> pinnum + 1; X } X break; X case 4 : if(thispin -> pinnum > pinsrow) X { X thispin -> row = row1 - pincount + thispin -> pinnum; X thispin -> col = col1 + width; X } X else X { X thispin -> row = row1 - thispin -> pinnum + 1; X thispin -> col = col1; X } X } X} / echo 'x - sort1.c' sed 's/^X//' > sort1.c << '/' X/******************************************************* X* Batcher's method sort by signalname. * X* Reference: Knuth Sorting & Searching, Section 5.2.2 * X*******************************************************/ X X#include "wirewrap.h" X Xsort1() X{ Xstruct pin tempin; Xint p,q,r,d,n,i,j,m; X X/*Find the 'middle' of the array.*/ Xn = nextfree; Xi = 1; Xj = 2; Xwhile(j < n) X { X i = j; X j = j+j; X } Xm = i; /*m is the middle of the array*/ X X/* Batcher's method*/ Xp = m; Xwhile(p > 0) X { X q = m; X r = 0; X d =p; X for(;;) X { X for(i= 0;i < n-d;i++) X { X if ( (i&p) == r) X if(namecmp(pinarray[i].signalname->signalname, X pinarray[i+d].signalname->signalname)>0) X { X tempin = pinarray[i+d]; X pinarray[i+d] = pinarray[i]; X pinarray[i] = tempin; X } X } X if(p != q) X { X d = q - p; X q = q/2; X r = p; X } X else X break; X } X p = p/2; X } X} / echo 'x - sort2.c' sed 's/^X//' > sort2.c << '/' X/******************************************************* X* Batcher's method sort by signalname. * X* Reference: Knuth Sorting & Searching, Section 5.2.2 * X*******************************************************/ X X#include "wirewrap.h" X Xsort2() X{ Xstruct pin tempin; Xint p,q,r,d,n,i,j,m; Xint a,b,innera,innerb,outera,outerb; X X/*Find the 'middle' of the array.*/ Xn = nextfree; Xi = 1; Xj = 2; Xwhile(j < n) X { X i = j; X j = j+j; X } Xm = i; /*m is the middle of the array*/ X X/* Batcher's method*/ Xp = m; Xwhile(p > 0) X { X q = m; X r = 0; X d =p; X for(;;) X { X for(i= 0;i < n-d;i++) X { X if ( (i&p) == r) X if( (pinarray[i].row > pinarray[i+d].row) X || ((pinarray[i].row == pinarray[i+d].row) X && (pinarray[i].col > pinarray[i+d].col))) X { X /* First decide which two to swap. */ X a=i; X b=i+d; X /* Then decide which ones reference them. */ X innera = pinarray[a].inner; X outera = pinarray[a].outer; X innerb=pinarray[b].inner; X outerb=pinarray[b].outer; X /* Update those. */ X if(innera != -1)pinarray[innera].inner=b; X if(outera != -1)pinarray[outera].outer=b; X if(innerb != -1)pinarray[innerb].inner=a; X if(outerb != -1)pinarray[outerb].outer=a; X /* Now make the swap. */ X tempin = pinarray[b]; X pinarray[b] = pinarray[a]; X pinarray[a] = tempin; X } X } X if(p != q) X { X d = q - p; X q = q/2; X r = p; X } X else X break; X } X p = p/2; X } X} / echo 'x - test.c' sed 's/^X//' > test.c << '/' X#include "wirewrap.h" X#ifdef DEBUG X Xtest() X{ Xint i; Xfor(i=0; isignalname); X } X} X#endif / echo 'x - wirewrap.h' sed 's/^X//' > wirewrap.h << '/' X/***********************************************************/ X/* */ X/* wirewrap: Wirewrap PC board Routing and documentation */ X/* generation system */ X/* */ X/***********************************************************/ X X#include X#define minlength 1.5 X#define pinpart 0.626 X#define lengthfactor 1.01674 X#define numpins 1500 /* Maximum number of pins program can handle */ X#define NAMELENGTH 12 /* Number of chars in a signal name, chip name, X or a chip position. */ X/* Following token definitions must be at least NAMELENGTH bytes long */ X#define NULLSIGNAL ". " X#define CHIPTOKEN ":CHIP " X#define SPECIALTOKEN ":SPECIAL " X X/* Important structures used throughout the program */ X Xstruct signallist /* One entry for every signal */ X { X char signalname[NAMELENGTH]; X struct signallist *succ; X char special; X }*siglistleader; X Xstruct chip /* One entry for every chip */ X { X char name[NAMELENGTH]; X char position[NAMELENGTH]; X unsigned int pincount, width, row1, col1, orientation; X struct chip *succ; X }*chipleader; X Xstruct pin /* One entry for every pin */ X { X struct signallist *signalname; X struct chip *mychip; X unsigned int pinnum; X unsigned int row,col; X int inner,outer; X }*pinptr; X X/* Global variables */ X Xstruct pin pinarray[numpins]; /* Used pin list */ Xint nextfree; /* Index of next free entry in the pin list */ Xint linenum; /* Line number within the page that the output X listing is at */ Xint inputline; /* Line number in the input file. */ X/* #define DEBUG /* Turns on extra debugging output. */ / echo 'Part 02 of wirewrap program complete.' exit