home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / tech / pcbsrcs2 / pcbroute.c < prev    next >
C/C++ Source or Header  |  1991-02-07  |  5KB  |  119 lines

  1. /*
  2. ** printed circuit board autorouter, Copyright (C) Randy Nevin 1989, 1990.
  3. **
  4. ** you may give this software to anyone, make as many copies as you like, and
  5. ** post it on public computer bulletin boards and file servers. you may not
  6. ** sell it or charge any fee for distribution (except for media and postage),
  7. ** remove this comment or the copyright notice from the code, or claim that
  8. ** you wrote this code or anything derived from it. you may modify the code as
  9. ** much as you want (please document clearly with comments, and maintain the
  10. ** coding style), but programs which are derived from this one are subject to
  11. ** the conditions stated here. i am providing this code so that people can
  12. ** learn from it, so if you distribute it, please include source code, not
  13. ** just executables. contact me to report bugs or suggest enhancements; i do
  14. ** not guarantee support, but i will make an effort to help you, and i want to
  15. ** act as a central clearing house for future versions. you should contact me
  16. ** before undertaking a significant development effort, to avoid reinventing
  17. ** the wheel. if you come up with an enhancement you consider particularly
  18. ** useful, i would appreciate being informed so that it can be incorporated in
  19. ** future versions. my address is: Randy Nevin, 1731 211th PL NE, Redmond,
  20. ** WA 98053, USA. this code is available directly from the author; just send a
  21. ** 360k floppy and a self-addressed floppy mailer with sufficient postage.
  22. **
  23. ** HISTORY
  24. ** (name        date        description)
  25. ** ----------------------------------------------------
  26. ** randy nevin        2/1/89        initial version
  27. ** randy nevin        2/4/89        made retrace table driven, instead of
  28. **                    doubly-nested switch statements.
  29. ** randy nevin        2/4/89        changed dir from int to char (cut
  30. **                    storage for it in half).
  31. ** randy nevin        2/8/89        changed SetQueue and ReSetQueue to
  32. **                    give priority to goal nodes.
  33. ** randy nevin        2/11/89        don't output incremental search
  34. **                    results if stdout is redirected.
  35. ** randy nevin        2/11/89        released version 1.00
  36. ** randy nevin        5/7/89        added /N switch (don't sort
  37. **                    non-PRIORITY CONNECTs)
  38. ** randy nevin        12/27/89    removed code for compensating from
  39. **                    edge of hole to center of hole; just
  40. **                    approximate distance between centers
  41. **                    of two holes (simplify)
  42. ** randy nevin        12/29/89    added code to keep traces from
  43. **                    touching corner of a hole/via cell,
  44. **                    and to keep from drilling a via where
  45. **                    a corner of its cell touches a trace
  46. ** randy nevin        12/29/89    released version 1.10
  47. */
  48.  
  49. #include <stdio.h>
  50. #include <stdlib.h>
  51. #include <io.h>
  52. #include <time.h>
  53. #include <string.h>
  54. #include "cell.h"
  55.  
  56. /*
  57. ** if you run out of memory while routing large boards, there are two things
  58. ** you can do: (1) go into your config.sys file and disable everything you
  59. ** don't need. getting rid of things like ansi.sys, ramdisks, disk caches, and
  60. ** other terminate and stay resident (tsr) programs can free a lot of memory.
  61. ** (2) link the router, inspect the .map file, relink with the /CPARMAXALLOC:n
  62. ** switch, where n is calculated to allow for a near heap of about 5k. read
  63. ** the linker documentation before you do this. for me, the route.map file
  64. ** says the program needs 81EFh bytes. to this i add 1400h (5k) for a near
  65. ** heap to get 95EFh bytes or 95Fh paragraphs, which is 2399 decimal.
  66. */
  67.  
  68. int JustBoard = 0; /* need all data structures, not just the board */
  69. int SortConnects = 1; /* default is to sort non-PRIORITY CONNECTs */
  70. int Ntotal; /* total number of CONNECTs to make */
  71.  
  72. extern int Initialize( char *, int );
  73. extern void Solve( void );
  74. extern void Report( FILE * );
  75.  
  76. void main( int, char *[] );
  77.  
  78. void main ( argc, argv ) /* input board, route traces, output routed board */
  79.     int argc;
  80.     char *argv[];
  81.     {
  82.     char *self, *p;
  83.     FILE *fp;
  84.     long start, stop;
  85.  
  86.     printf( "Copyright (C) Randy Nevin, 1989, 1990. Version 1.10\n" );
  87.     printf( "See source code for rights granted.\n\n" );
  88.     start = time( NULL );
  89.     self = argv[0];
  90.     /* get rid of initial part of path */
  91.     if ((p = strrchr( self, '\\' )) || (p = strrchr( self, ':' )))
  92.         self = ++p;
  93.     /* get rid of extension */
  94.     if ((p = strrchr( self, '.' )) && !stricmp( p, ".EXE" ))
  95.         *p = 0;
  96.     if (argc == 4 && !stricmp( argv[1], "/n" )) {
  97.         SortConnects = 0; /* don't do sorting */
  98.         argv[1] = argv[2];
  99.         argv[2] = argv[3];
  100.         argc = 3;
  101.         }
  102.     else if (argc != 3) { /* need infile and outfile */
  103.         fprintf( stderr, "usage: %s [/N] infile outfile\n", self );
  104.         fprintf( stderr,
  105.             " N = no sorting of non-PRIORITY CONNECTs\n" );
  106.         exit( -1 );
  107.         }
  108.     if (!(fp = fopen( argv[2], "wb" ))) {
  109.         fprintf( stderr, "can't open %s\n", argv[2] );
  110.         exit( -1 );
  111.         }
  112.     Ntotal = Initialize( argv[1], 1 ); /* echo memory used */
  113.     Solve();
  114.     Report( fp );
  115.     stop = time( NULL ) - start;
  116.     printf( "time = %ld second%s\n", stop, (stop == 1) ? "" : "s" );
  117.     exit( 0 );
  118.     }
  119.