home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume2 / wire / part2 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  30.3 KB

  1. From: panda!talcott!uwvax!geowhiz!karsh
  2. Subject: wirewrap program part 02 of 02
  3. Reply-To: karsh@geowhiz.UUCP (Bruce Karsh)
  4. Keywords: wirewrap circuit board construction cad cadcam cam pc chip
  5. Newsgroups: mod.sources
  6. Approved: john@genrad.UUCP
  7.  
  8. Mod.sources:  Volume 2, Issue 36
  9. Submitted by: uwvax!geowhiz!karsh <karsh@geowhiz.UUCP> (Bruce Karsh)
  10.  
  11.  
  12.  
  13. #!/bin/sh
  14. #
  15. # This is a release of my wirewrap program.  It has been used
  16. # to make several boards here, and seems to be pretty reliable. 
  17. # It was written on a Masscomp MC500, but I don't think there
  18. # are any serious machine dependencies in it.  (But then again,
  19. # I'm often suprised by how easy it is to inadvertantly write
  20. # machine dependent code.)
  21. # I'd like to hear some bug reports and success stories.  I will
  22. # try to send out bug fixes as quickly as I can.
  23. # As usual, unpack all parts by running through sh, then run make.
  24. # Unix Wirewrap Source Code:
  25. # cnvtnum.c    gettoken.c    getwired.c    getwirelen.c    header1.c
  26. # header2.c    initialize.c    insertname.c    insertx.c    main.c
  27. # mywrite.c    mywrite2.c    namecmp.c    namecmp2.c    output1.c
  28. # output2.c    output3.c    readin.c    setptr.c    setrowandcol.c
  29. # sort1.c        sort2.c        test.c
  30. # .h files:
  31. #   wirewrap.h
  32. # Documentation:
  33. #   wirewrap.1 README PACKINGLIST
  34. # Unix wirewrap makefile:
  35. #   Makefile
  36. # Test Data:
  37. #   autocal
  38. # Example listing:
  39. #   autocal.listing
  40. # ----
  41. # Bruce Karsh
  42. # U. Wisc. Dept. Geology and Geophysics
  43. # 1215 W Dayton, Madison, WI 53706
  44. # (608) 262-1697
  45. # {ihnp4,seismo}!uwvax!geowhiz!karsh
  46. #
  47. echo 'Start of wirewrap program, part 02 of 02:'
  48. echo 'x - Makefile'
  49. sed 's/^X//' > Makefile << '/'
  50. Xwirewrap:     initialize.o readin.o main.o setptr.o setrowandcol.o \
  51. X              sort1.o getwired.o output3.o getwirelen.o \
  52. X              insertx.o output1.o mywrite.o header1.o sort2.o \
  53. X              output2.o header2.o mywrite2.o \
  54. X              test.o cnvtnum.o namecmp.o insertname.o gettoken.o \
  55. X              namecmp2.o
  56. X    cc -o wirewrap initialize.o readin.o main.o setptr.o \
  57. X              setrowandcol.o sort1.o getwired.o output3.o \
  58. X              getwirelen.o output1.o insertx.o mywrite.o \
  59. X              header1.o sort2.o output2.o header2.o mywrite2.o \
  60. X              test.o cnvtnum.o namecmp.o gettoken.o \
  61. X              insertname.o namecmp2.o -lm
  62. X
  63. Xclean:
  64. X    rm -f *.o
  65. X
  66. Xpackage:
  67. X    packmail -hREADME -t'wirewrap program' `/bin/cat PACKINGLIST`
  68. X
  69. Xgettoken.o: wirewrap.h
  70. Xgetwired.o: wirewrap.h
  71. Xgetwirelen.o: wirewrap.h
  72. Xinitialize.o: wirewrap.h
  73. Xinsertname.o: wirewrap.h
  74. Xmain.o: wirewrap.h
  75. Xmywrite.o: wirewrap.h
  76. Xmywrite2.o: wirewrap.h
  77. Xnamecmp.o: wirewrap.h
  78. Xnamecmp2.o: wirewrap.h
  79. Xoutput1.o: wirewrap.h
  80. Xoutput2.o: wirewrap.h
  81. Xoutput3.o: wirewrap.h
  82. Xreadin.o: wirewrap.h
  83. Xsetptr.o: wirewrap.h
  84. Xsetrowandcol.o: wirewrap.h
  85. Xsort1.o: wirewrap.h
  86. Xsort2.o: wirewrap.h
  87. Xtest.o: wirewrap.h
  88. /
  89. echo 'x - PACKINGLIST'
  90. sed 's/^X//' > PACKINGLIST << '/'
  91. XMakefile
  92. XPACKINGLIST
  93. XREADME
  94. Xautocal
  95. Xautocal.listing
  96. Xcnvtnum.c
  97. Xgettoken.c
  98. Xgetwired.c
  99. Xgetwirelen.c
  100. Xheader1.c
  101. Xheader2.c
  102. Xinitialize.c
  103. Xinsertname.c
  104. Xinsertx.c
  105. Xmain.c
  106. Xmywrite.c
  107. Xmywrite2.c
  108. Xnamecmp.c
  109. Xnamecmp2.c
  110. Xoutput1.c
  111. Xoutput2.c
  112. Xoutput3.c
  113. Xreadin.c
  114. Xsetptr.c
  115. Xsetrowandcol.c
  116. Xsort1.c
  117. Xsort2.c
  118. Xtest.c
  119. Xwirewrap.1
  120. Xwirewrap.h
  121. /
  122. echo 'x - README'
  123. sed 's/^X//' > README << '/'
  124. XThis is a release of my wirewrap program.  It has been used
  125. Xto make several boards here, and seems to be pretty reliable. 
  126. XIt was written on a Masscomp MC500, but I don't think there
  127. Xare any serious machine dependencies in it.  (But then again,
  128. XI'm often suprised by how easy it is to inadvertantly write
  129. Xmachine dependent code.)
  130. X
  131. XI'd like to hear some bug reports and success stories.  I will
  132. Xtry to send out bug fixes as quickly as I can.
  133. X
  134. XAs usual, unpack all parts by running through sh, then run make.
  135. X
  136. XUnix Wirewrap Source Code:
  137. Xcnvtnum.c    gettoken.c    getwired.c    getwirelen.c    header1.c
  138. Xheader2.c    initialize.c    insertname.c    insertx.c    main.c
  139. Xmywrite.c    mywrite2.c    namecmp.c    namecmp2.c    output1.c
  140. Xoutput2.c    output3.c    readin.c    setptr.c    setrowandcol.c
  141. Xsort1.c        sort2.c        test.c
  142. X
  143. X.h files:
  144. X  wirewrap.h
  145. X
  146. XDocumentation:
  147. X  wirewrap.1 README PACKINGLIST
  148. X
  149. XUnix wirewrap makefile:
  150. X  Makefile
  151. X
  152. XTest Data:
  153. X  autocal
  154. X
  155. XExample listing:
  156. X  autocal.listing
  157. X
  158. X----
  159. XBruce Karsh
  160. XU. Wisc. Dept. Geology and Geophysics
  161. X1215 W Dayton, Madison, WI 53706
  162. X(608) 262-1697
  163. X{ihnp4,seismo}!uwvax!geowhiz!karsh
  164. /
  165. echo 'x - autocal'
  166. sed 's/^X//' > autocal << '/'
  167. X/*
  168. X**  Auto calibration circuitry for UW Digital recording packages.
  169. X*/
  170. X:chip    I/O-edge    1a    80    2    56    1    4
  171. X    .    .    .    GAP4    .    .    .    .
  172. X    10SEC    .    .    .    .    .    .    SKEY-    
  173. X    .    .    .    .    .    .    .    .
  174. X    .    .    .    TST+    .    .    .    .
  175. X
  176. X    .    .    .    .    .    .    .    g
  177. X    .    .    .    .    .    .    .    .
  178. X    bgld-    .    bcal+    .    .    .    .    .
  179. X    .    .    .    PD3    .    .    .    .
  180. X    .    .    .    .    .    .    .    .
  181. X    .    .    .    .    .    .    .    .
  182. X
  183. X:chip    UPI/O    10a    1    1    37    53    4
  184. X    Q
  185. X
  186. X:chip    RUN.FF1    8c    14    3    53    41    4
  187. X    .    .    .    .    .    .    .
  188. X    jamrun+    .    .    .    .    .    .
  189. X
  190. X:chip    RUN.FF2    2e    16    3    35    5    4
  191. X    .    .    .    .    RON+    .    .    .
  192. X    .    .    .    .    .    .    .    .
  193. X
  194. X:chip    Buffer.4050    2g    16    3    17    5    4
  195. X    .    .    .    .    .    .    .    .
  196. X    .    .    cal+    bcal+    .    gld-    bgld-    .
  197. X
  198. X:chip    count.4020    2h    16    3    8    5    4
  199. X    .    q13    stop+    .    .    .    .    -
  200. X    .    clk/2    calrun-    .    .    q10    .    +
  201. X
  202. X:chip    runff.4013    3g    14    3    17    11    4
  203. X    calrun-    .    10SEC    g    jamrun-    stop+    -
  204. X    stop+    calena+    g    Q    jamrun+    jamrun-    +
  205. X
  206. X:chip    or.4071    3h    14    3    8    11    4
  207. X    mp    acal    cal+    seqi    calrun-    seqm    -
  208. X    seqm    ap    apms    calena+    TST+    RON+    +
  209. X
  210. X:chip    and.4081    4g    14    3    17    17    4
  211. X    SKEY-    TST+    gld-    mp    TST+    PD3    -
  212. X    jamrun+    apms    acal    ap    q10    q13    +
  213. X
  214. X:chip    xor.4030    4h    14    3    8    17    4
  215. X    seq4    seq12    seql    seqn    seql    seq6    -
  216. X    seq1    seqn    seqm    clk    GAP4    g    +
  217. X
  218. X:chip    shift.4015    5g    16    3    17    23    4
  219. X    clk    seq8    .    .    seq1    q13    seqi    -
  220. X    clk    seq4    .    seq6    .    q13    seq4    +
  221. X
  222. X:chip    shift.4015    5h    16    3    8    23    4
  223. X    clk    .    .    .    .    q13    seq8    -
  224. X    clk    seq12    .    .    .    q13    seq12    +
  225. X
  226. X:chip    syncff.4013    6h    14    3    8    29    4
  227. X    clk/2    clk/2-    clk    calrun-    clk/2-    g    -
  228. X    g    g    g    g    .    .    +
  229. X
  230. X:SPECIAL
  231. X    +    -
  232. /
  233. echo 'x - cnvtnum.c'
  234. sed 's/^X//' > cnvtnum.c << '/'
  235. X#include <ctype.h>
  236. Xchar *cnvtnump; /* Pointer to next character to process. */
  237. Xint cnvtnumv;   /* 1 if valid number, 0 otherwise. */
  238. X/*************************************/
  239. X/*  cnvtnum - convert ascii to int.  */
  240. X/*  Works like atoi() except that it */
  241. X/*  leaves the externel variables set*/
  242. X/*  to help in error recovery.       */
  243. X/*************************************/
  244. Xcnvtnum(str)
  245. Xchar *str;
  246. X{
  247. Xint sign=1;
  248. Xint result=0;
  249. Xcnvtnump = str;
  250. Xcnvtnumv=0;
  251. X
  252. X/* Skip leading blanks. */
  253. X
  254. Xwhile(*cnvtnump == ' ' || *cnvtnump == '\t')cnvtnump++;
  255. X
  256. X/* Pick up leading sign. */
  257. X
  258. Xif(*cnvtnump == '+')
  259. X  {
  260. X  sign = 1;
  261. X  *cnvtnump++;
  262. X  }
  263. Xelse if(*cnvtnump == '-')
  264. X  {
  265. X  sign = -1;
  266. X  *cnvtnump++;
  267. X  }
  268. X
  269. X/* Pick up digits. */
  270. X
  271. Xwhile(isdigit(*cnvtnump))
  272. X  {
  273. X  result=10*result+ (*cnvtnump-'0');
  274. X  cnvtnump++;
  275. X  cnvtnumv=1;
  276. X  }
  277. X
  278. Xreturn(sign*result);
  279. X}
  280. /
  281. echo 'x - gettoken.c'
  282. sed 's/^X//' > gettoken.c << '/'
  283. X#include <ctype.h>
  284. X#include <stdio.h>
  285. X#include "wirewrap.h"
  286. X/*
  287. X** gettoken - return a whitespace delimited token.
  288. X**            Tokens are truncated at 79 characters.
  289. X**          Return code is zero if a token is
  290. X**          returned, otherwise an end of file
  291. X**          was reached and -1 is returned.
  292. X*/
  293. Xgettoken(token)
  294. Xchar *token;
  295. X{
  296. Xchar chr;
  297. Xint tokenptr;
  298. Xstatic int firsttime=1;
  299. Xstatic int nextchr;
  300. Xint comment;
  301. Xtokenptr=0;
  302. Xtoken[tokenptr]=0;
  303. Xcomment=0;
  304. X
  305. X/* If first time through, get a look-ahead character. */
  306. X
  307. Xif(firsttime == 1)
  308. X  {
  309. X  nextchr=getchar();
  310. X  firsttime=0;
  311. X  }
  312. X
  313. Xfor(;;)
  314. X  {
  315. X  /* Get a character from the input. */
  316. X
  317. X  if(nextchr == EOF)
  318. X    chr=EOF;
  319. X  else
  320. X    {
  321. X    chr=nextchr;
  322. X    nextchr=getchar();
  323. X    }
  324. X
  325. X  /* Test if start of a comment. */
  326. X
  327. X  if(chr == '/' && nextchr == '*')
  328. X    {
  329. X    nextchr = getchar();
  330. X    comment = 1;
  331. X    continue;
  332. X    }
  333. X
  334. X  /* Test if end of a comment. */
  335. X
  336. X  if(chr == '*' && nextchr == '/' && comment == 1)
  337. X    {
  338. X    nextchr=getchar();
  339. X    comment=0;
  340. X    continue;
  341. X    }
  342. X
  343. X  /* Test if EOF within a comment. */
  344. X
  345. X  if(chr == EOF && comment == 1)break;
  346. X
  347. X  /* Test if a newline char within a comment. */
  348. X
  349. X  if(chr == '\n' && comment == 1)
  350. X    {
  351. X    inputline++;
  352. X    continue;
  353. X    }
  354. X
  355. X  /* Test if any other character within a comment. */
  356. X
  357. X  if(comment == 1)continue;
  358. X    
  359. X  /* Process end of file. */
  360. X
  361. X  if(chr == EOF)break;
  362. X
  363. X  /* Process white space character. */
  364. X
  365. X  if(isspace(chr))
  366. X    {
  367. X
  368. X    /* Process new line character. */
  369. X    if(chr == '\n')
  370. X      {
  371. X      if(tokenptr != 0)
  372. X
  373. X        /* Process new line character which terminates a token */
  374. X
  375. X        ungetc(chr,stdin);
  376. X      else
  377. X
  378. X        /* Process a new line character which does not terminate a token */
  379. X
  380. X        inputline++;
  381. X      }
  382. X
  383. X  /* Process any white space character that terminates a token */
  384. X
  385. X    if(tokenptr != 0) return(0);
  386. X
  387. X  /* Process a white space character that doesn't terminate a token */
  388. X
  389. X    else continue;
  390. X    }
  391. X  else
  392. X
  393. X  /* Process a non white space charater */
  394. X
  395. X    if(tokenptr<79)
  396. X      {
  397. X
  398. X      /* Process a non white space charater before the 79'th char of a token */
  399. X
  400. X      token[tokenptr]=chr;
  401. X      tokenptr++;
  402. X      token[tokenptr]=0;
  403. X      }
  404. X    else
  405. X
  406. X      /* Process a non white space character after the 79'th char of a token */
  407. X
  408. X      continue;
  409. X  }
  410. X
  411. X/* Process end of file */
  412. X
  413. Xif(tokenptr==0)return(-1);else return(0);
  414. X}
  415. /
  416. echo 'x - getwired.c'
  417. sed 's/^X//' > getwired.c << '/'
  418. X/**********************************************
  419. X*  getwired - do the wire routing.            *
  420. X*                          *
  421. X*    When getwired is called, the signal list *
  422. X*  is sorted in order by signalname.  This    *
  423. X*  routine connects adjacent pins with the    *
  424. X*  same signal name together.  Pins are conn- *
  425. X*  nected together with either top to top     *
  426. X*  wraps or bottom to bottom wraps everywhere.*
  427. X*  The last wrap may really be wrapped as a   *
  428. X*  top to bottom wrap if there is an odd num- *
  429. X*  ber of pins in the string.  But it is still*
  430. X*  represented as a top to top wrap.          *
  431. X**********************************************/
  432. X
  433. X#include "wirewrap.h"
  434. X
  435. Xgetwired()
  436. X{
  437. Xint indexlo,indexhi,count,i;
  438. Xchar currentsignal[NAMELENGTH];
  439. Xindexhi = 0;
  440. Xwhile(indexhi < nextfree)
  441. X  {
  442. X  indexlo = indexhi;
  443. X  indexhi = indexhi + 1;
  444. X  for(i=0;i<NAMELENGTH;i++)
  445. X    currentsignal[i] = pinarray[indexlo].signalname->signalname[i];
  446. X  while((indexhi < nextfree) && 
  447. X         !namecmp(pinarray[indexhi].signalname->signalname,currentsignal)
  448. X        )indexhi++;
  449. X  if(namecmp(currentsignal,NULLSIGNAL))
  450. X    { 
  451. X    count = indexlo;
  452. X    while(count < indexhi-1)
  453. X      {
  454. X      pinarray[count].inner = count+1;
  455. X      pinarray[count+1].inner = count;
  456. X      count = count + 2;
  457. X      }
  458. X    count = indexlo + 1;
  459. X    while(count < indexhi-1)
  460. X      {
  461. X      pinarray[count].outer = count+1;
  462. X      pinarray[count+1].outer = count;
  463. X      count = count + 2;
  464. X      }
  465. X    }
  466. X  }
  467. X}
  468. /
  469. echo 'x - getwirelen.c'
  470. sed 's/^X//' > getwirelen.c << '/'
  471. X#define sqr(a) ( (a)*(a) )
  472. X#include <math.h>
  473. X#include "wirewrap.h"
  474. Xdouble getwirelength(row1,col1,row2,col2)
  475. Xint row1,col1,row2,col2;
  476. X{
  477. Xdouble wlength;
  478. X
  479. X/* Compute straight line distance. */
  480. X
  481. Xwlength = .1 * sqrt((double) sqr(row1-row2)+sqr(col1-col2));
  482. X
  483. X/* Apply linear regression coefficients */
  484. X
  485. Xwlength = wlength * lengthfactor + pinpart;
  486. X
  487. X/* Round up to the nearest larger .5 inch */
  488. X
  489. Xwlength = wlength * 2 + 1;
  490. Xwlength = (int) wlength;
  491. Xwlength = wlength/2.0;
  492. X
  493. X/* Make sure that it is at least as long as the minimum length. */
  494. X
  495. Xif(wlength < minlength) wlength = minlength;
  496. Xreturn(wlength);
  497. X}
  498. /
  499. echo 'x - header1.c'
  500. sed 's/^X//' > header1.c << '/'
  501. Xheader1()
  502. X{
  503. Xchar outline[80];
  504. X
  505. Xoutline[0]=0;
  506. Xinsertx("chip",outline,10);
  507. Xinsertx("pin",outline,23);
  508. Xinsertx("chip",outline,28);
  509. Xprintf("%s\n",outline);
  510. Xoutline[0]=0;
  511. Xinsertx("name",outline,10);
  512. Xinsertx("num",outline,23);
  513. Xinsertx("position",outline,28);
  514. Xinsertx("row col",outline,42);
  515. Xprintf("%s\n",outline);
  516. X}
  517. /
  518. echo 'x - header2.c'
  519. sed 's/^X//' > header2.c << '/'
  520. Xheader2()
  521. X{
  522. Xchar outline[80];
  523. Xoutline[0]=0;
  524. Xinsertx("signal",outline,1);
  525. Xinsertx("pin",outline,14);
  526. Xinsertx("inner wire",outline,18);
  527. Xinsertx("outer wire",outline,39);
  528. Xprintf("%s\n",outline);
  529. Xoutline[0]=0;
  530. Xinsertx("name ",outline,1);
  531. Xinsertx("num",outline,14);
  532. Xprintf("%s\n",outline);
  533. X}
  534. /
  535. echo 'x - initialize.c'
  536. sed 's/^X//' > initialize.c << '/'
  537. X/*******************************************
  538. X* initialize - initialize global variables *
  539. X*******************************************/
  540. X
  541. X#include "wirewrap.h"
  542. X
  543. Xinitialize()
  544. X{
  545. Xchipleader = 0;
  546. Xsiglistleader = 0;
  547. Xnextfree = 0;
  548. Xlinenum = 67;
  549. Xinputline=1;
  550. X}
  551. /
  552. echo 'x - insertname.c'
  553. sed 's/^X//' > insertname.c << '/'
  554. X#include "wirewrap.h"
  555. Xinsertname(from,to,pos)
  556. Xchar *from, *to;
  557. Xint pos;
  558. X{
  559. Xchar *p;
  560. Xint l;
  561. X
  562. X/* Pad with trailing blanks. */
  563. X
  564. Xl=strlen(to);
  565. Xwhile(l<(pos-1))
  566. X  {
  567. X  to[l]=' ';
  568. X  l++;
  569. X  }
  570. Xto[l]=0;
  571. X
  572. X/* Append the from string to the to string. */
  573. X
  574. Xl=pos-1;
  575. Xfor(p=from; p-from < NAMELENGTH; p++)
  576. X  {
  577. X  to[l] = *p;
  578. X  l++;
  579. X  }
  580. Xto[l]=0;
  581. X}
  582. /
  583. echo 'x - insertx.c'
  584. sed 's/^X//' > insertx.c << '/'
  585. Xinsertx(from,to,pos)
  586. Xchar *from, *to;
  587. Xint pos;
  588. X{
  589. Xchar *p;
  590. Xint l;
  591. X
  592. X/* Pad with trailing blanks. */
  593. X
  594. Xl=strlen(to);
  595. Xwhile(l<(pos-1))
  596. X  {
  597. X  to[l]=' ';
  598. X  l++;
  599. X  }
  600. Xto[l]=0;
  601. X
  602. X/* Append the from string to the to string. */
  603. X
  604. Xl=pos-1;
  605. Xfor(p=from; *p != 0; p++)
  606. X  {
  607. X  to[l] = *p;
  608. X  l++;
  609. X  }
  610. Xto[l]=0;
  611. X}
  612. /
  613. echo 'x - main.c'
  614. sed 's/^X//' > main.c << '/'
  615. X#include "wirewrap.h"
  616. Xmain()
  617. X{
  618. Xinitialize();
  619. Xreadin();    /* Read the input file. */
  620. X
  621. X#ifdef DEBUG
  622. X  printf("Dump of pin array after inputting data\n");
  623. X  test();
  624. X#endif
  625. X
  626. Xsort1();                 /* Sort by signal name. */
  627. X
  628. X#ifdef DEBUG
  629. X  printf("Dump of pin array after sort by signal name\n");
  630. X  test();
  631. X#endif
  632. X
  633. Xgetwired();              /* Wire the pins togther. */
  634. X
  635. X#ifdef DEBUG
  636. X  printf("Dump of pin array after doing the wiring.\n");
  637. X  test();
  638. X#endif
  639. X
  640. Xoutput1();              /* Output the first printout. (Chip side view) */
  641. X
  642. Xsort2();                /* Sort by (row,col). */
  643. X
  644. X#ifdef DEBUG
  645. X  printf("Dump of pin array after sorting by (row,col)\n");
  646. X  test();
  647. X#endif
  648. X
  649. Xoutput2();             /* Output the second printout. (Pin side view) */
  650. X
  651. Xoutput3();             /* Output the third printout. (Wire lengths) */
  652. X}
  653. /
  654. echo 'x - mywrite.c'
  655. sed 's/^X//' > mywrite.c << '/'
  656. X#include "wirewrap.h"
  657. X
  658. Xmywrite(outline)
  659. Xchar *outline;
  660. X{
  661. Xif(linenum > 60)
  662. X  {
  663. X  printf(" ");
  664. X  header1();
  665. X  linenum=3;
  666. X  }
  667. X  printf("%s\n",outline);
  668. X  linenum++;
  669. X}
  670. /
  671. echo 'x - mywrite2.c'
  672. sed 's/^X//' > mywrite2.c << '/'
  673. X#include "wirewrap.h"
  674. X
  675. Xmywrite2(outline)
  676. Xchar *outline;
  677. X{
  678. Xif(linenum > 60)
  679. X  {
  680. X  printf(" ");
  681. X  header2();
  682. X  linenum=3;
  683. X  }
  684. X  printf("%s\n",outline);
  685. X  linenum++;
  686. X}
  687. /
  688. echo 'x - namecmp.c'
  689. sed 's/^X//' > namecmp.c << '/'
  690. X/*
  691. X** namecmp - compare two names.  Works like strcmp()
  692. X*/
  693. X#include "wirewrap.h"
  694. Xnamecmp(a,b)
  695. Xchar a[NAMELENGTH],b[NAMELENGTH];
  696. X{
  697. Xint i;
  698. Xfor(i=0;i<NAMELENGTH;i++)
  699. X  {
  700. X  if(a[i]<b[i])return(-1);
  701. X  else if (a[i]>b[i])return(1);
  702. X  }
  703. Xreturn(0);
  704. X}
  705. /
  706. echo 'x - namecmp2.c'
  707. sed 's/^X//' > namecmp2.c << '/'
  708. X/*
  709. X** namecmp2 - compare two names.  Works like strcmp()
  710. X**            This is the same as namecmp except that
  711. X**          namecmp2 ignores case.
  712. X*/
  713. X#include "wirewrap.h"
  714. Xnamecmp2(a,b)
  715. Xchar a[NAMELENGTH],b[NAMELENGTH];
  716. X{
  717. Xint i;
  718. Xfor(i=0;i<NAMELENGTH;i++)
  719. X  {
  720. X  if(tolower(a[i])<tolower(b[i]))return(-1);
  721. X  else if (tolower(a[i])>tolower(b[i]))return(1);
  722. X  }
  723. Xreturn(0);
  724. X}
  725. /
  726. echo 'x - output1.c'
  727. sed 's/^X//' > output1.c << '/'
  728. X#include "wirewrap.h"
  729. Xoutput1()
  730. X{
  731. Xchar currentsig[12],outline[80], sig[12], wrap, newstring[80];
  732. Xint count, i;
  733. X
  734. Xcurrentsig[0] = 0;
  735. Xcount = 0;
  736. Xoutline[0] = 0;
  737. Xwhile(count < nextfree)
  738. X  {
  739. X  for(i=0;i<12;i++)sig[i] = pinarray[count].signalname->signalname[i];
  740. X  if(namecmp(sig,currentsig))
  741. X    {
  742. X    insertname(sig,outline,1);
  743. X    if((pinarray[count].signalname->special) != 0)
  744. X      insertx("Special",outline,2+NAMELENGTH);
  745. X    mywrite(outline);
  746. X    outline[0]=0;
  747. X    for(i=0;i<12;i++)currentsig[i]=sig[i];
  748. X    wrap='T';
  749. X    }
  750. X  if(wrap == 'T')wrap='B'; else wrap='T';
  751. X  newstring[0]=0;
  752. X  insertname(pinarray[count].mychip->name,outline,10);
  753. X  sprintf(newstring,"%d",pinarray[count].pinnum);
  754. X  insertx(newstring,outline,12+NAMELENGTH);
  755. X  insertname(pinarray[count].mychip->position,outline,17+NAMELENGTH);
  756. X  sprintf(newstring,"(%d,%d)",pinarray[count].row, pinarray[count].col);
  757. X  insertx(newstring,outline,30+NAMELENGTH);
  758. X  if(namecmp(sig,NULLSIGNAL) && (!pinarray[count].signalname->special))
  759. X    insertx(wrap,outline,39+NAMELENGTH);
  760. X  mywrite(outline);
  761. X  outline[0] = 0;
  762. X  count++;
  763. X  }
  764. X}
  765. /
  766. echo 'x - output2.c'
  767. sed 's/^X//' > output2.c << '/'
  768. X#include "wirewrap.h"
  769. X
  770. Xoutput2()
  771. X{
  772. Xint oldrow,oldcol,runflag,count,already,specialsig;
  773. Xint innerptr,innerwrap,outerptr,outerwrap;
  774. Xchar tempstr[80],outline[80];
  775. Xdouble wlength,getwirelength();
  776. Xprintf(" ");
  777. Xheader2();
  778. Xoldrow = -100;
  779. Xoldcol = -100;
  780. Xlinenum = 3;
  781. Xrunflag = 0;
  782. Xfor(count=0;count<nextfree;count++)
  783. X  {
  784. X  outline[0]=0;
  785. X  if((pinarray[count].row == oldrow) &&
  786. X   (pinarray[count].col == (oldcol + 1)))
  787. X    runflag = 1;
  788. X  else
  789. X    {
  790. X    if(runflag != 0)
  791. X      {
  792. X      mywrite2(" ");
  793. X      runflag=0;
  794. X      }
  795. X    }
  796. X  oldrow = pinarray[count].row;
  797. X  oldcol = pinarray[count].col;
  798. X
  799. X  /* SET UP THE SIGNAL NAME AND PIN NUMBER */
  800. X
  801. X  insertname(pinarray[count].signalname->signalname,outline,1);
  802. X  sprintf(tempstr,"%d",pinarray[count].pinnum);
  803. X  insertx(tempstr,outline,14);
  804. X
  805. X  /* FIGURE SOME STUFF OUT FOR THE INNER WRAP */
  806. X
  807. X  innerptr = pinarray[count].inner;
  808. X  innerwrap = (pinarray[count].inner != -1);
  809. X  if(innerwrap)
  810. X    already = (pinarray[count].inner < count);
  811. X  else
  812. X    already = 0;
  813. X  specialsig = pinarray[count].signalname->special;
  814. X
  815. X  /* SET UP LENGTH OF INNER WIRE */
  816. X
  817. X  if(specialsig)
  818. X    insertx("SPEC",outline,18);
  819. X  if(already && (! specialsig))
  820. X    insertx("TEST",outline,18);
  821. X  if(innerwrap && (! already) && (! specialsig))
  822. X    {
  823. X    wlength=getwirelength(pinarray[count].row,pinarray[count].col,
  824. X                  pinarray[innerptr].row,pinarray[innerptr].col);
  825. X    wlength = (double) ( (int) (wlength * 10) ) / 10;
  826. X    sprintf(tempstr,"%.1f",wlength);
  827. X    insertx(tempstr,outline,18);
  828. X    }
  829. X
  830. X  /* SET UP ROW1 AND COL1 */
  831. X
  832. X  sprintf(tempstr,"%d",pinarray[count].row);
  833. X  insertx(tempstr,outline,23);
  834. X  insertx(",",outline,strlen(outline)+1);
  835. X  sprintf(tempstr,"%d",pinarray[count].col);
  836. X  insertx(tempstr,outline,strlen(outline)+1);
  837. X
  838. X  /* SET UP ROW2 AND COL2 */
  839. X
  840. X  if((!specialsig) && innerwrap)
  841. X    {
  842. X    insertx(" ",outline,strlen(outline)+1);
  843. X    sprintf(tempstr,"%d",pinarray[innerptr].row);
  844. X    insertx(tempstr,outline,strlen(outline)+1);
  845. X    insertx(",",outline,strlen(outline)+1);
  846. X    sprintf(tempstr,"%d",pinarray[innerptr].col);
  847. X    insertx(tempstr,outline,strlen(outline)+1);
  848. X    }
  849. X
  850. X  /* FIGURE SOME STUFF OUT FOR THE OUTER WRAP */
  851. X
  852. X  outerptr = pinarray[count].outer;
  853. X  outerwrap =(pinarray[count].outer != -1);
  854. X  if(outerwrap)
  855. X    already=(pinarray[count].outer < count);
  856. X  else
  857. X    already=0;
  858. X  specialsig = pinarray[count].signalname->special;
  859. X
  860. X  /* SET UP LENGTH OF OUTER WIRE */
  861. X
  862. X  if(specialsig)
  863. X    insertx("SPEC",outline,39);
  864. X  if(already && (!specialsig))
  865. X    insertx("TEST",outline,39);
  866. X  if(outerwrap && (!already) && (!specialsig))
  867. X    {
  868. X    wlength=getwirelength(pinarray[count].row,pinarray[count].col,
  869. X                  pinarray[outerptr].row,pinarray[outerptr].col);
  870. X    wlength = (double) ( (int) (wlength * 10) ) / 10;
  871. X    sprintf(tempstr,"%.1f",wlength);
  872. X    insertx(tempstr,outline,39);
  873. X    }
  874. X
  875. X  /* SET UP ROW1 AND COL1 */
  876. X
  877. X  sprintf(tempstr,"%d",pinarray[count].row);
  878. X  insertx(tempstr,outline,44);
  879. X  insertx(",",outline,strlen(outline)+1);
  880. X  sprintf(tempstr,"%d",pinarray[count].col);
  881. X  insertx(tempstr,outline,strlen(outline)+1);
  882. X
  883. X  /* SET UP ROW2 AND COL2 */
  884. X
  885. X  if((!specialsig) && outerwrap)
  886. X    {
  887. X    insertx(" ",outline,strlen(outline)+1);
  888. X    sprintf(tempstr,"%d",pinarray[outerptr].row);
  889. X    insertx(tempstr,outline,strlen(outline)+1);
  890. X    insertx(",",outline,strlen(outline)+1);
  891. X    sprintf(tempstr,"%d",pinarray[outerptr].col);
  892. X    insertx(tempstr,outline,strlen(outline)+1);
  893. X    }
  894. X
  895. X  /* SET UP EMPTY/FULL FLAG */
  896. X
  897. X  if((!specialsig) && outerwrap)
  898. X    {
  899. X    insertx(" ",outline,strlen(outline)+1);
  900. X    if(pinarray[outerptr].inner == -1)
  901. X      insertx("E",outline,strlen(outline)+1);
  902. X    else
  903. X      insertx("F",outline,strlen(outline)+1);
  904. X    }
  905. X  mywrite2(outline);
  906. X  }
  907. X}
  908. /
  909. echo 'x - output3.c'
  910. sed 's/^X//' > output3.c << '/'
  911. X#include "wirewrap.h"
  912. X
  913. Xoutput3()
  914. X{
  915. Xdouble wirelength,getwirelength();
  916. Xint longctr, i, len, total, ctr[21];
  917. X
  918. X/* Zero out counters */
  919. X
  920. X        longctr = 0;
  921. X        for(i=2;i<=20;i++)ctr[i]=0;
  922. X        
  923. X/* Print heading. */
  924. X
  925. X        printf("\014");
  926. X        printf(" WIRE LENGTH SUMMARY\n");
  927. X        printf(" -------------------\n");
  928. X        printf("\n");
  929. X        printf(" Wire   Number\n");
  930. X        printf("Length   Used\n");
  931. X        
  932. X/* Wire counting loop. */
  933. X        
  934. X        for(i=0; i<nextfree;i++)
  935. X        {
  936. X        
  937. X        /* Count inner wire length*/
  938. X        
  939. X                if( (pinarray[i].inner != -1) &&
  940. X                (!pinarray[i].signalname->special) )
  941. X                  {
  942. X                  wirelength=getwirelength(pinarray[i].row,pinarray[i].col,
  943. X                                pinarray[pinarray[i].inner].row,
  944. X                                pinarray[pinarray[i].inner].col);
  945. X                  len=wirelength / 0.5 + 0.1;
  946. X                  if(len > 20)
  947. X                    longctr++;
  948. X                  else
  949. X                    ctr[len]++;
  950. X                  }
  951. X        
  952. X        /* Count outer wire length*/
  953. X                
  954. X                if( (pinarray[i].outer != -1 ) &&
  955. X                (!pinarray[i].signalname->special) )
  956. X                  {
  957. X                  wirelength=getwirelength(pinarray[i].row,pinarray[i].col,
  958. X                                pinarray[pinarray[i].outer].row,
  959. X                                pinarray[pinarray[i].outer].col);
  960. X                  len=wirelength / 0.5 + 0.1;
  961. X                  if(len > 20)
  962. X                    longctr++;
  963. X                  else
  964. X                    ctr[len]++;
  965. X                  }
  966. X        }
  967. X
  968. X        /* Only count each wire once. */
  969. X                for(i=2;i<=20;i++)ctr[i]=ctr[i]/2;
  970. X                longctr=longctr/2;
  971. X        
  972. X        /* Make listing. */
  973. X        
  974. X                for(i=2;i<=20;i++)
  975. X                  {
  976. X                  if(ctr[i] > 0)
  977. X                     {
  978. X             printf("%-9.1f %d\n",(.5*i),ctr[i]);
  979. X                     }
  980. X                  }
  981. X        if(longctr > 0)
  982. X          {
  983. X          printf("> 10.0 %d\n",longctr);
  984. X          }
  985. X        
  986. X        /* Total up how many wires used. */
  987. X        
  988. X        total=0;
  989. X        for(i=2;i<=20;i++)total+=ctr[i];
  990. X        total += longctr;
  991. X        printf("Total number of wires used: %d\n",total);
  992. X}
  993. /
  994. echo 'x - setrowandcol.c'
  995. sed 's/^X//' > setrowandcol.c << '/'
  996. X/*********************************************************/
  997. X/*                                                       */
  998. X/* setrowandcol: sets up the row and column field of the */
  999. X/* pin list entry based on the pin orientation, width,   */
  1000. X/* pincount and (row1,col1).                             */
  1001. X/*                                                       */
  1002. X/*********************************************************/
  1003. X
  1004. X#include "wirewrap.h"
  1005. X
  1006. Xsetrowandcol(thispin)
  1007. Xstruct pin *thispin;
  1008. X{
  1009. Xint width,row1,col1,pinsrow,pincount;
  1010. X/*
  1011. X** Pick up width, (row1,col1), and pincount for this chip.
  1012. X*/
  1013. Xwidth = (thispin -> mychip) -> width;
  1014. Xrow1 = (thispin -> mychip) -> row1;
  1015. Xcol1 = (thispin -> mychip) -> col1;
  1016. Xpincount = (thispin -> mychip) -> pincount;
  1017. X/*
  1018. X** Process SIPs (single inline packages).  These are entered as 
  1019. X** having a width of zero.  All other chips are assumed to be
  1020. X** DIPs (dual inline packages).
  1021. X** An n pin SIP has n pins per row.  An n pin DIP has n/2 pins per row.
  1022. X*/
  1023. Xif(width == 0)
  1024. X  pinsrow = pincount;
  1025. Xelse
  1026. X  pinsrow = pincount/2;
  1027. X/*
  1028. X** Following is the calculation of row and column numbers for each
  1029. X** of the four orientations.
  1030. X*/
  1031. Xswitch ((thispin -> mychip) -> orientation)
  1032. X  {
  1033. X  case 1: if(thispin -> pinnum > pinsrow)
  1034. X             {
  1035. X             thispin -> row = row1 + width;
  1036. X             thispin -> col = col1 + pincount - thispin -> pinnum;
  1037. X             }
  1038. X           else
  1039. X             {
  1040. X             thispin -> row = row1;
  1041. X             thispin -> col = col1 + thispin -> pinnum - 1;
  1042. X             }
  1043. X           break;
  1044. X  case 2 : if(thispin -> pinnum > pinsrow)
  1045. X             {
  1046. X             thispin -> row = row1 + pincount - thispin -> pinnum;
  1047. X             thispin -> col = col1 - width;
  1048. X             }
  1049. X           else
  1050. X             {
  1051. X             thispin -> row = row1 + thispin -> pinnum - 1;
  1052. X             thispin -> col = col1;
  1053. X             }
  1054. X           break;
  1055. X  case 3 : if(thispin -> pinnum > pinsrow)
  1056. X             {
  1057. X             thispin -> row = row1 - width;
  1058. X             thispin -> col = col1 - pincount + thispin -> pinnum;
  1059. X             }
  1060. X           else
  1061. X             {
  1062. X             thispin -> row = row1;
  1063. X             thispin -> col = col1 - thispin -> pinnum + 1;
  1064. X             }
  1065. X           break;
  1066. X  case 4 : if(thispin -> pinnum > pinsrow)
  1067. X             {
  1068. X             thispin -> row = row1 - pincount + thispin -> pinnum;
  1069. X             thispin -> col = col1 + width;
  1070. X             }
  1071. X           else
  1072. X             {
  1073. X             thispin -> row = row1 - thispin -> pinnum + 1;
  1074. X             thispin -> col = col1;
  1075. X             }
  1076. X  }
  1077. X}
  1078. /
  1079. echo 'x - sort1.c'
  1080. sed 's/^X//' > sort1.c << '/'
  1081. X/*******************************************************
  1082. X*  Batcher's method sort by signalname.               *
  1083. X*  Reference: Knuth Sorting & Searching, Section 5.2.2 *
  1084. X*******************************************************/
  1085. X
  1086. X#include "wirewrap.h"
  1087. X
  1088. Xsort1()
  1089. X{
  1090. Xstruct pin tempin;
  1091. Xint p,q,r,d,n,i,j,m;
  1092. X
  1093. X/*Find the 'middle' of the array.*/
  1094. Xn = nextfree;
  1095. Xi = 1;
  1096. Xj = 2;
  1097. Xwhile(j < n)
  1098. X  {
  1099. X  i = j;
  1100. X  j = j+j;
  1101. X  }
  1102. Xm = i;  /*m is the middle of the array*/
  1103. X        
  1104. X/* Batcher's method*/
  1105. Xp = m;
  1106. Xwhile(p > 0)
  1107. X  {
  1108. X  q = m;
  1109. X  r = 0;
  1110. X  d =p;
  1111. X  for(;;)
  1112. X    {
  1113. X    for(i= 0;i < n-d;i++)
  1114. X      {
  1115. X      if ( (i&p) == r)
  1116. X        if(namecmp(pinarray[i].signalname->signalname,
  1117. X           pinarray[i+d].signalname->signalname)>0)
  1118. X          {
  1119. X          tempin = pinarray[i+d];
  1120. X          pinarray[i+d] = pinarray[i];
  1121. X          pinarray[i] = tempin;
  1122. X          }
  1123. X      }
  1124. X      if(p != q)
  1125. X        {
  1126. X        d = q - p;
  1127. X        q = q/2;
  1128. X        r = p;
  1129. X        }
  1130. X      else 
  1131. X        break;
  1132. X    }
  1133. X  p = p/2;
  1134. X  }
  1135. X}
  1136. /
  1137. echo 'x - sort2.c'
  1138. sed 's/^X//' > sort2.c << '/'
  1139. X/*******************************************************
  1140. X*  Batcher's method sort by signalname.               *
  1141. X*  Reference: Knuth Sorting & Searching, Section 5.2.2 *
  1142. X*******************************************************/
  1143. X
  1144. X#include "wirewrap.h"
  1145. X
  1146. Xsort2()
  1147. X{
  1148. Xstruct pin tempin;
  1149. Xint p,q,r,d,n,i,j,m;
  1150. Xint a,b,innera,innerb,outera,outerb;
  1151. X
  1152. X/*Find the 'middle' of the array.*/
  1153. Xn = nextfree;
  1154. Xi = 1;
  1155. Xj = 2;
  1156. Xwhile(j < n)
  1157. X  {
  1158. X  i = j;
  1159. X  j = j+j;
  1160. X  }
  1161. Xm = i;  /*m is the middle of the array*/
  1162. X        
  1163. X/* Batcher's method*/
  1164. Xp = m;
  1165. Xwhile(p > 0)
  1166. X  {
  1167. X  q = m;
  1168. X  r = 0;
  1169. X  d =p;
  1170. X  for(;;)
  1171. X    {
  1172. X    for(i= 0;i < n-d;i++)
  1173. X      {
  1174. X      if ( (i&p) == r)
  1175. X        if(   (pinarray[i].row >  pinarray[i+d].row) 
  1176. X          || ((pinarray[i].row == pinarray[i+d].row)
  1177. X          &&  (pinarray[i].col >  pinarray[i+d].col)))
  1178. X          {
  1179. X          /* First decide which two to swap. */
  1180. X          a=i;
  1181. X          b=i+d;
  1182. X          /* Then decide which ones reference them. */
  1183. X          innera = pinarray[a].inner;
  1184. X          outera = pinarray[a].outer;
  1185. X          innerb=pinarray[b].inner;
  1186. X          outerb=pinarray[b].outer;
  1187. X          /* Update those. */
  1188. X          if(innera != -1)pinarray[innera].inner=b;
  1189. X          if(outera != -1)pinarray[outera].outer=b;
  1190. X          if(innerb != -1)pinarray[innerb].inner=a;
  1191. X          if(outerb != -1)pinarray[outerb].outer=a;
  1192. X          /* Now make the swap. */
  1193. X          tempin = pinarray[b];
  1194. X          pinarray[b] = pinarray[a];
  1195. X          pinarray[a] = tempin;
  1196. X          }
  1197. X      }
  1198. X      if(p != q)
  1199. X        {
  1200. X        d = q - p;
  1201. X        q = q/2;
  1202. X        r = p;
  1203. X        }
  1204. X      else 
  1205. X        break;
  1206. X    }
  1207. X  p = p/2;
  1208. X  }
  1209. X}
  1210. /
  1211. echo 'x - test.c'
  1212. sed 's/^X//' > test.c << '/'
  1213. X#include "wirewrap.h"
  1214. X#ifdef DEBUG
  1215. X
  1216. Xtest()
  1217. X{
  1218. Xint i;
  1219. Xfor(i=0; i<nextfree;i++)
  1220. X  {
  1221. X  printf("Printing pin %d\n",i);
  1222. X  printf(" Location: (%d,%d) Inner: %d Outer: %d %s\n",pinarray[i].row,
  1223. X         pinarray[i].col, pinarray[i].inner, pinarray[i].outer,
  1224. X         pinarray[i].signalname->signalname);
  1225. X  }
  1226. X}
  1227. X#endif
  1228. /
  1229. echo 'x - wirewrap.h'
  1230. sed 's/^X//' > wirewrap.h << '/'
  1231. X/***********************************************************/
  1232. X/*                                                         */
  1233. X/*  wirewrap: Wirewrap PC board Routing and documentation  */
  1234. X/*            generation system                            */
  1235. X/*                                                         */
  1236. X/***********************************************************/
  1237. X
  1238. X#include <stdio.h>
  1239. X#define minlength 1.5
  1240. X#define pinpart 0.626
  1241. X#define lengthfactor 1.01674
  1242. X#define numpins 1500     /* Maximum number of pins program can handle */
  1243. X#define NAMELENGTH 12    /* Number of chars in a signal name, chip name,
  1244. X                            or a chip position. */
  1245. X/* Following token definitions must be at least NAMELENGTH bytes long */
  1246. X#define NULLSIGNAL    ".            "
  1247. X#define CHIPTOKEN     ":CHIP        "
  1248. X#define SPECIALTOKEN  ":SPECIAL     "
  1249. X
  1250. X/* Important structures used throughout the program */
  1251. X
  1252. Xstruct signallist           /* One entry for every signal */
  1253. X  {
  1254. X  char signalname[NAMELENGTH];
  1255. X  struct signallist *succ;
  1256. X  char special;
  1257. X  }*siglistleader;
  1258. X
  1259. Xstruct chip                /* One entry for every chip */
  1260. X  {
  1261. X  char name[NAMELENGTH];
  1262. X  char position[NAMELENGTH];
  1263. X  unsigned int pincount, width, row1, col1, orientation;
  1264. X  struct chip *succ;
  1265. X  }*chipleader;
  1266. X
  1267. Xstruct pin                  /* One entry for every pin */
  1268. X  {
  1269. X  struct signallist *signalname;
  1270. X  struct chip *mychip;
  1271. X  unsigned int pinnum;
  1272. X  unsigned int row,col;
  1273. X  int inner,outer;
  1274. X  }*pinptr;
  1275. X
  1276. X/* Global variables */
  1277. X
  1278. Xstruct pin pinarray[numpins];  /* Used pin list */
  1279. Xint nextfree;                  /* Index of next free entry in the pin list */
  1280. Xint linenum;                   /* Line number within the page that the output
  1281. X                                  listing is at */
  1282. Xint inputline;               /* Line number in the input file. */
  1283. X/* #define DEBUG  /* Turns on extra debugging output. */
  1284. /
  1285. echo 'Part 02 of wirewrap program complete.'
  1286. exit
  1287.  
  1288.  
  1289.