home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / cad / pcb.arc / PCBROUTE.C < prev    next >
C/C++ Source or Header  |  1989-03-05  |  4KB  |  100 lines

  1. /*
  2. ** printed circuit board autorouter, Copyright (C) Randy Nevin 1989.
  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 in good faith to help you,
  15. ** and i want to act as a central clearing house for future versions. you
  16. ** should contact me before undertaking a significant development effort, to
  17. ** avoid reinventing the wheel. if you come up with an enhancement you
  18. ** consider particularly useful, i would appreciate being informed so that it
  19. ** can be incorporated in future versions. my address is: Randy Nevin,
  20. ** 1731 211th PL NE, Redmond, WA 98053. this code is available directly from
  21. ** the author; just send a floppy and a self-addressed floppy mailer with
  22. ** sufficient postage.
  23. **
  24. ** HISTORY
  25. ** (name        date        description)
  26. ** ----------------------------------------------------
  27. ** randy nevin        2/1/89        initial version
  28. ** randy nevin        2/4/89        made retrace table driven, instead of
  29. **                    doubly-nested switch statements.
  30. ** randy nevin        2/4/89        changed dir from int to char (cut
  31. **                    storage for it in half).
  32. ** randy nevin        2/8/89        changed SetQueue and ReSetQueue to
  33. **                    give priority to goal nodes.
  34. ** randy nevin        2/11/89        don't output incremental search
  35. **                    results if stdout is redirected.
  36. ** randy nevin        2/11/89        released version 1.00
  37. */
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <io.h>
  42. #include <time.h>
  43. #include <string.h>
  44. #include "cell.h"
  45.  
  46. /*
  47. ** if you run out of memory while routing large boards, there are two things
  48. ** you can do: (1) go into your config.sys file and disable everything you
  49. ** don't need. getting rid of things like ansi.sys, ramdisks, disk caches, and
  50. ** other terminate and stay resident (tsr) programs can free a lot of memory.
  51. ** (2) link the router, inspect the .map file, relink with the /CPARMAXALLOC:n
  52. ** switch, where n is calculated to allow for a near heap of about 5k. read
  53. ** the linker documentation before you do this. for me, the route.map file
  54. ** says the program needs 81EFh bytes. to this i add 1400h (5k) for a near
  55. ** heap to get 95EFh bytes or 95Fh paragraphs, which is 2399 decimal.
  56. */
  57.  
  58. int justboard = 0; /* need all data structures, not just the board */
  59.  
  60. extern void Initialize( FILE * );
  61. extern void Solve( void );
  62. extern void Report( FILE * );
  63.  
  64. void main( int, char *[] );
  65.  
  66. void main ( argc, argv ) /* input board, route traces, output routed board */
  67.     int argc;
  68.     char *argv[];
  69.     {
  70.     char *self, *p;
  71.     FILE *fin, *fout;
  72.     long start, stop;
  73.  
  74.     printf( "Copyright (C) Randy Nevin, 1989. Version 1.00\n" );
  75.     printf( "See source code for rights granted.\n\n" );
  76.     start = time( NULL );
  77.     self = argv[0];
  78.     /* get rid of initial part of path */
  79.     if ((p = strrchr( self, '\\' )) || (p = strrchr( self, ':' )))
  80.         self = ++p;
  81.     if (argc != 3) { /* need infile and outfile */
  82.         printf( "usage: %s infile outfile\n", self );
  83.         exit( -1 );
  84.         }
  85.     if (!(fin = fopen( argv[1], "r" ))) {
  86.         printf( "can't open %s\n", argv[1] );
  87.         exit( -1 );
  88.         }
  89.     if (!(fout = fopen( argv[2], "wb" ))) {
  90.         printf( "can't open %s\n", argv[2] );
  91.         exit( -1 );
  92.         }
  93.     Initialize( fin );
  94.     Solve();
  95.     Report( fout );
  96.     stop = time( NULL ) - start;
  97.     printf( "time = %ld second%s\n", stop, (stop == 1) ? "" : "s" );
  98.     exit( 0 );
  99.     }
  100.