home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume08 / cif2ps < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  66.8 KB

  1. From decwrl!wuarchive!cs.utexas.edu!uunet!allbery Fri Nov  3 19:52:59 PST 1989
  2. Article 1147 of comp.sources.misc:
  3. Path: decwrl!wuarchive!cs.utexas.edu!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v08i100: cif2ps: a CIF to PostScript translator
  7. Message-ID: <71226@uunet.UU.NET>
  8. Date: 3 Nov 89 01:25:28 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Reply-To: gwr@gomez.mitre.org (Gordon W. Ross)
  11. Lines: 2787
  12. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  13.  
  14. Posting-number: Volume 8, Issue 100
  15. Submitted-by: gwr@gomez.mitre.org (Gordon W. Ross)
  16. Archive-name: cif2ps
  17.  
  18. I've posted my version of "cif2ps" to comp.sources.misc this evening.
  19. Your site should be receiving it soon.  Please accept my apology for
  20. not posting it sooner.  I have been busy, and cif2ps is not a high
  21. priority.  On the brighter side though, I've added support for CIF
  22. objects other than boxes, as well as a limited plot depth option.
  23.  
  24. Here is the header from the posting to comp.sources.misc:
  25.  
  26. This package includes the source for "cif2ps," a program to create a
  27. PostScript representation of an integrated circuit from a layout
  28. stored in Caltech Intermediate Form (CIF).  A README, Makefile, and
  29. manual page are included as well as some sample CIF files.
  30.  
  31. This version was derived from a version distributed by Marc Lesure
  32. of Engineering Computer Services, Arizona State University.
  33. The original version (called "cifp") was written by Arthur Simoneau,
  34. of The Aerospace Corporation, El Segundo, California.
  35.  
  36. My additions to this program include:
  37. run time customization of plot styles for all CIF layers, limited
  38. plot depth option, technology-independent handling of CIF layers,
  39. PostScript functions for filling an object using a clipping path,
  40. automatic ordering of drawing operations for minimal obliteration,
  41. reduced output size, and support for CIF objects other than boxes.
  42.  
  43. A few test files are included.  Running "make test" will generate a
  44. layer-key for Scalable CMOS (SCMOS).  The file "everything.cif" has
  45. one object of each CIF type: a box, roundflash, polygon, and wire.
  46. The file "scmos-test.cif" is a sample layout from the old "cifp."
  47.  
  48. This version of "cif2ps" is distributed without any promise of
  49. support, though I would appreciate bug reports and changes.
  50.  
  51. Gordon W. Ross    gwr@gomez.mitre.org    (617) 271-3205 (daytime)
  52. The MITRE Corp. (M/S E025)  Burlington Road, Bedford, MA 01730
  53.  
  54. #! /bin/sh
  55. # This is a shell archive, meaning:
  56. # 1. Remove everything above the #! /bin/sh line.
  57. # 2. Save the resulting text in a file.
  58. # 3. Execute the file with /bin/sh (not csh) to create the files:
  59. #    README
  60. #    cif2ps.1
  61. #    Makefile
  62. #    psheader.ps
  63. #    define.h
  64. #    cif2ps.c
  65. #    cifgood.c
  66. #    cifplot.c
  67. #    layers.c
  68. #    styles.c
  69. #    layerkey.csh
  70. #    everything.cif
  71. #    scmos-test.cif
  72. # This archive created: Tue Oct 31 17:33:48 1989
  73. # By:    Gordon W. Ross (The MITRE Corporation, Bedford, MA.)
  74. export PATH; PATH=/bin:$PATH
  75. echo shar: extracting "'README'" '(4221 characters)'
  76. if test -f 'README'
  77. then
  78.     echo shar: will not over-write existing file "'README'"
  79. else
  80. sed 's/^X //' << \SHAR_EOF > 'README'
  81. X This package includes the source for "cif2ps," a program to create a
  82. X PostScript representation of an integrated circuit from a layout
  83. X stored in Caltech Intermediate Form (CIF).  A README, Makefile, and
  84. X manual page are included as well as some sample CIF files.
  85. X This version was derived from a version distributed by Marc Lesure
  86. X of Engineering Computer Services, Arizona State University.
  87. X The original version (called "cifp") was written by Arthur Simoneau,
  88. X of The Aerospace Corporation, El Segundo, California.
  89. X My additions to this program include:
  90. X run time customization of plot styles for all CIF layers, limited
  91. X plot depth option, technology-independent handling of CIF layers,
  92. X PostScript functions for filling an object using a clipping path,
  93. X automatic ordering of drawing operations for minimal obliteration,
  94. X reduced output size, and support for CIF objects other than boxes.
  95. X A few test files are included.  Running "make test" will generate a
  96. X layer-key for Scalable CMOS (SCMOS).  The file "everything.cif" has
  97. X one object of each CIF type: a box, roundflash, polygon, and wire.
  98. X The file "scmos-test.cif" is a sample layout from the old "cifp."
  99. X This version of "cif2ps" is distributed without any promise of
  100. X support, though I would appreciate bug reports and changes.
  101. X Gordon W. Ross    gwr@gomez.mitre.org    (617) 271-3205 (daytime)
  102. X The MITRE Corp. (M/S E025)  Burlington Road, Bedford, MA 01730
  103. X Included below are the contents of README files from older versions.
  104. X ------------------------------------------------------------------
  105. X [ README file from Marc Lesure's version of "cif2ps":  -GWR ]
  106. X This code was originally written by Arthur Simoneau, The Aerospace
  107. X Corporation, El Segundo, California. and was called 'cifp'.  'cifp' would
  108. X only take MAGIC SCMOS cif input and generate postscript for a single
  109. X page of output.
  110. X I've since taken it and modified it to accept cmos-pw technology for
  111. X our local needs at Arizona State University.  The biggest improvement
  112. X I made was to get multiple page output.  Each page is numbered with
  113. X (x,y) coordinates so you know its proper sequence.  Also each page
  114. X overlaps with its neighbor, so you can cut and paste if you want.
  115. X The program will rescale the user-specific scale to avoid producing
  116. X blank pages.  A scaling limit of 5 by 5 has been put in the program to
  117. X eliminate massive outputs.  Cif2ps can generate a postscript file in
  118. X the multi-megabyte range very easily.  I renamed the program to
  119. X 'cif2ps' to be more descriptive of its function.
  120. X Two test files have been included, cmos-pw.test.cif and scmos.test.cif.
  121. X The file cmos-pw.test.cif was generated using the IGS2CIF program
  122. X version 2a.04 on a HP EGS Graphics system.  The file scmos.test.cif is
  123. X from the original 'cifp' distribution.  To plot this file you must use
  124. X the '-T' option on 'cif2ps'.
  125. X [ The "-T" option is no longer needed or available.  -GWR ]
  126. X Cif2ps is now used here in place of cifplot from the Berkeley VSLI
  127. X distribution.
  128. X STANDARD DISCLAIMER:
  129. X -------------------
  130. X The authors and their organizations assume no responsibility for the
  131. X use by the recipient of this program.
  132. X Marc Lesure
  133. X Engineering Computer Services
  134. X Arizona State University
  135. X ---------------------------------------------------------------
  136. X [ README file from Arthur Simoneau's original "cifp":  -GWR ]
  137. X If somebody wants to modify this code you should be aware that the
  138. X order of the "filled boxes" are important.  The last filled box wins
  139. X all of the pixels and so improper order can cause the p-well to
  140. X obliterate all of the CIF geometries.
  141. X [ Filled objects are now handled in a more sophisticated manner. -GWR ]
  142. X I will be maintaining this code and adding missing features as they
  143. X become desirable, so instead of re-inventing the wheel you should
  144. X contact me before making any changes to see if I have already done
  145. X them.  Also, I would like to maintain knowledge of where this code is
  146. X so I would appreciate any new sites request the code from me rather
  147. X than siphoning it from another site.
  148. X I will gladly respond to any bug reports if a suitable example
  149. X displaying the bug is sent to me.
  150. X Cheers,
  151. X Arthur Simoneau
  152. X The Aerospace Corporation
  153. X El Segundo, California
  154. X art@aerospace
  155. X [ I was not able to reach art@aerospace  -GWR ]
  156. SHAR_EOF
  157. if test 4221 -ne "`wc -c < 'README'`"
  158. then
  159.     echo shar: error transmitting "'README'" '(should have been 4221 characters)'
  160. fi
  161. fi # end of overwriting check
  162. echo shar: extracting "'cif2ps.1'" '(5278 characters)'
  163. if test -f 'cif2ps.1'
  164. then
  165.     echo shar: will not over-write existing file "'cif2ps.1'"
  166. else
  167. sed 's/^X //' << \SHAR_EOF > 'cif2ps.1'
  168. X .TH CIF2PS LOCAL "23 June 1989"
  169. X .UC 4
  170. X .SH NAME
  171. X Cif2ps \- CIF to postscript translator
  172. X .SH SYNOPSIS
  173. X .na
  174. X .B cif2ps
  175. X .RB [ \-r ]
  176. X .RB [ \-c
  177. X .IR cell ]
  178. X .RB [ \-d
  179. X .IR depth ]
  180. X .RB [ \-f
  181. X .IR font-size ]
  182. X .RB [ \-w
  183. X .IR width ]
  184. X .RB [ \-h
  185. X .IR height ]
  186. X .RB [ \-s
  187. X .IR LAYER=style-string ]
  188. X .RI [ in-file.cif \ [ out-file.ps ]]
  189. X .ad
  190. X .br
  191. X .SH DESCRIPTION
  192. X .I Cif2ps
  193. X converts a CIF file produced by Magic or another VLSI layout editor
  194. X into PostScript.  The output file produced is complete and suitable
  195. X for printing on a letter-size PostScript printer.
  196. X The first file name (i.e.
  197. X .IR in-file.cif )
  198. X is the input file
  199. X The second file name (i.e.
  200. X .IR out-file.ps )
  201. X is the output file.
  202. X If no file names are given the program reads from standard input
  203. X and writes to standard output.
  204. X If just one file name is specified, it is used as input.
  205. X .PP
  206. X .I Cif2ps
  207. X options are :
  208. X .TP
  209. X .B \-r
  210. X rotate the plot by 90 degrees (cumulative if repeated).
  211. X .TP
  212. X .BI \-c \ cell
  213. X .I cell
  214. X (name or CIF number) should be plotted.
  215. X By default the top-level cell (number zero) is plotted.
  216. X CIF files generated by Magic have a "dummy" top-level cell
  217. X used only for specifying scale factors and the "real" top-level
  218. X cell (as seen in Magic) is number one.
  219. X .TP
  220. X .BI \-d \ depth
  221. X Cells instantiated
  222. X .I depth
  223. X levels or more below the top level should not be plotted.
  224. X The default is zero, meaning plot at all depths.
  225. X A depth of one restricts plotting to the top level.
  226. X .TP
  227. X .BI \-f \ font-size
  228. X Use a font (Helvetica) scaled to a height of
  229. X .I font-size
  230. X points.  The default is 6 points.
  231. X .TP
  232. X .BI \-w \ width
  233. X the plot should be made
  234. X .I width
  235. X pages wide.  By default the width is one page.
  236. X .TP
  237. X .BI \-h \ height
  238. X the plot should be made
  239. X .I height
  240. X pages wide.  By default the height is one page.
  241. X .PP
  242. X .I Cif2ps
  243. X will rescale a user-specific dimension if neccesary to avoid
  244. X producing blank pages.  The largest dimesion allowed is 5 pages by 5 pages
  245. X (25 pages of output).
  246. X .TP
  247. X .BI \-s \ LAYER=style-string
  248. X set the drawing style for the layer named
  249. X .I LAYER
  250. X to the string
  251. X .I style-string.
  252. X Any number of
  253. X .BI \-s \ LAYER=style-string
  254. X pairs of arguments may be given, each defining one CIF layer.
  255. X If
  256. X .I style-string
  257. X is omitted then
  258. X .I LAYER
  259. X is not plotted.
  260. X Built-in default styles are provided for some technologies
  261. X (MOSIS SCMOS and Bulk CMOS, Oct symbolic).
  262. X See
  263. X .B Style Customiztion
  264. X below for information on style strings.
  265. X .SH "Style Customization"
  266. X .PP
  267. X Style strings (used with the
  268. X .B \-s
  269. X option) are simply strings of PostScript commands (with one exception).
  270. X The commands are used to fill each figure generated by
  271. X .I cif2ps.
  272. X The exception is that styles using the printer's built-in
  273. X gray fill function need special handling because this
  274. X fill function uses an opaque fill method (obliterating any
  275. X drawings previously inside the filled area).
  276. X Style strings which use the printer's built-in gray fill do so
  277. X by prepending a special code "G" and a number to the otherwise
  278. X ordinary PostScript string.  The number following the "G"
  279. X is the gray-level to be used, with zero (0) being black and one
  280. X (1.0) being white.  Note that for this special code to be recognized
  281. X the "G" must be the first letter in the style string.
  282. X .PP
  283. X .I Cif2ps
  284. X will write all gray fill boxes in order of decreasing gray-level
  285. X before writing any of the regular PostScript fill styles.
  286. X This produces a plot with most layers being rendered
  287. X with transparent overlap regions.
  288. X .PP
  289. X The PostScript functions provided in addition to gray fill are:
  290. X .TP
  291. X "\fIs a\fR L"
  292. X Fill the region with lines spaced by \fIs\fR pixcels and rotated
  293. X (counter-clockwise) by angle \fIa\fR degrees from horizontal.
  294. X .TP
  295. X "X"
  296. X Draw an "X" across the figure.
  297. X .TP
  298. X "stroke"
  299. X A PostScript primitive which draws a line along the current path
  300. X and then clears the path.  Since the current path is cleared
  301. X by "stroke" it must be used \fIafter\fR any of the above commands.
  302. X .PP
  303. X Some examples:
  304. X .TP
  305. X ""
  306. X (null string) Don't draw anyting for this layer.
  307. X .TP
  308. X "G0"
  309. X Fill with black.
  310. X .TP
  311. X "G.5"
  312. X Fill with 50% gray.
  313. X .TP
  314. X "8 45 L"
  315. X Fill with lines spaced by 8 pixcels and rotated 45 degrees.
  316. X (The lines will have a slope of one.)
  317. X .TP
  318. X "G.75 32 135 L"
  319. X Fill with light gray (75%) and then fill with lines
  320. X spaced by 32 pixcels and rotated by 135 degrees (slope = -1).
  321. X .TP
  322. X "G.5 X stroke"
  323. X Fill with dark gray (50%), draw an "X" from the corners,
  324. X and draw an outline of the figure.
  325. X This produces a box with an diagonals similar to contacts in Magic.
  326. X .SH "SEE ALSO"
  327. X Magic
  328. X .SH AUTHORS
  329. X Arthur Simoneau (of The Aerospace Corporation, El Segundo, Calif)
  330. X wrote the original version, "cifp."
  331. X .br
  332. X Marc Lesure (of Arizona State University, Tempe, AZ)
  333. X modified 'cifp' to produce 'cif2ps',
  334. X adding scale factors and multi-page output.
  335. X .br
  336. X Gordon Ross (of The MITRE Corporation, Bedford, MA)
  337. X added: run-time style customization options,
  338. X transluscent fill operators using PostScript,
  339. X support for CIF polygons, circles, and wires,
  340. X and reduced output file size.
  341. X .SH BUGS
  342. X .PP
  343. X Text is plotted only in the top-most cell chosen for plotting.
  344. X .PP
  345. X The output can (still) become very large.
  346. X Full depth plotting can easily produce output ten times the size of
  347. X the CIF file.  A work-around is to limit the plot depth with the
  348. X .BI \-d \ depth
  349. X option.
  350. X .PP
  351. X Multi-page plots cause repetition of the entire PostScript output for
  352. X each page.  This could be reduced if cif2ps did some clipping.
  353. SHAR_EOF
  354. if test 5278 -ne "`wc -c < 'cif2ps.1'`"
  355. then
  356.     echo shar: error transmitting "'cif2ps.1'" '(should have been 5278 characters)'
  357. fi
  358. fi # end of overwriting check
  359. echo shar: extracting "'Makefile'" '(1045 characters)'
  360. if test -f 'Makefile'
  361. then
  362.     echo shar: will not over-write existing file "'Makefile'"
  363. else
  364. sed 's/^X //' << \SHAR_EOF > 'Makefile'
  365. X DEST    = /vlsi/mitre
  366. X CC    = cc -f68881
  367. X CFLAGS    = -O
  368. X LDFLAGS =
  369. X PROGRAM    = cif2ps
  370. X SRCS    = cif2ps.c cifgood.c cifplot.c layers.c styles.c
  371. X OBJS    = cif2ps.o cifgood.o cifplot.o layers.o styles.o psheader.o
  372. X FILES    = README cif2ps.1 Makefile psheader.ps define.h $(SRCS) \
  373. X     layerkey.csh everything.cif scmos-test.cif
  374. X all:        $(PROGRAM)
  375. X $(PROGRAM): $(OBJS)
  376. X     $(CC) $(LDFLAGS) -o $@ $(OBJS)
  377. X lint:    $(SRCS)
  378. X     lint $(SRCS)
  379. X test:    scmos-key.cif
  380. X     cif2ps scmos-key.cif
  381. X scmos-key.cif:
  382. X     layerkey.csh CPG CAA CMF CMS \
  383. X     CWG CWP CWN CSG CSP CSN CCP CCA CVA COG >$@
  384. X dist:    
  385. X     shar -v -c -b -p "X " $(FILES) >Dist.sha
  386. X .SUFFIXES: .ps
  387. X .ps.c:
  388. X     ( echo "/* This file was generated from $? */" ;\
  389. X       echo "char *$*[] = {" ;\
  390. X       sed 's/.*/"&",/' <$? ;\
  391. X       echo "0 }; /* end of $* */" ) >$@
  392. X .ps.o:
  393. X     $(MAKE) $(MFLAGS) $*.c
  394. X     $(CC) $(CFLAGS) -c $*.c
  395. X     rm -f $*.c
  396. X clean:
  397. X     rm -f $(OBJS) psheader.c
  398. X install:    $(PROGRAM)
  399. X     cp -p $(PROGRAM) $(DEST)/bin
  400. X     cp -p cif2ps.1 $(DEST)/man/man1
  401. X ###
  402. X cif2ps.o:    define.h
  403. X cifgood.o:    define.h
  404. X cifplot.o:    define.h
  405. X layers.o:    define.h
  406. X styles.o:    define.h
  407. SHAR_EOF
  408. if test 1045 -ne "`wc -c < 'Makefile'`"
  409. then
  410.     echo shar: error transmitting "'Makefile'" '(should have been 1045 characters)'
  411. fi
  412. fi # end of overwriting check
  413. echo shar: extracting "'psheader.ps'" '(1843 characters)'
  414. if test -f 'psheader.ps'
  415. then
  416.     echo shar: will not over-write existing file "'psheader.ps'"
  417. else
  418. sed 's/^X //' << \SHAR_EOF > 'psheader.ps'
  419. X % PostScript from \"cif2ps,\" a CIF to PostScript translator by:
  420. X %    Arthur Simoneau, The Aerospace Corporation, El Segundo, Calif
  421. X % with additions by:
  422. X %    Marc Lesure, Arizona State University, Tempe, AZ (May 1988)
  423. X % as well as:
  424. X %    Gordon W. Ross, The MITRE Corporation, Bedford, MA (June 1989)
  425. X %        (proud author of this header code :-)
  426. X % Header code follows:
  427. X /B {    % dx dy x1 y1 ==> ---
  428. X     % Build a box: size=(dx,dy); lower_left=(x1,y1)
  429. X     newpath moveto dup 0 exch    % dx dy 0 dy
  430. X     rlineto exch 0            % dy dx 0
  431. X     rlineto 0 exch neg        % 0 -dy
  432. X     rlineto closepath
  433. X } bind def % B
  434. X /L {    % step angle ==> ---
  435. X     % Fill the current path with lines spaced by STEP and
  436. X     % rotated from the X-axis by ANGLE degrees ccw.
  437. X     gsave clip 0 setgray 0 setlinewidth
  438. X     matrix setmatrix
  439. X     rotate dup scale        %
  440. X     pathbbox newpath        % x1 y1 x2 y2
  441. X     1 add cvi 4 1 roll        % y2' x1 y1 x2
  442. X     1 add cvi 4 1 roll        % x2' y2' x1 y1
  443. X     1 sub cvi exch 1 sub cvi    % x2' y2' y1' x1'
  444. X     2 copy exch translate
  445. X     3 1 roll sub            % x2' x1' dy
  446. X     3 1 roll sub exch        % dx dy
  447. X     { % repeat (dy) times        % dx
  448. X         0 0 moveto dup 0    % dx dx 0
  449. X         rlineto stroke        % dx
  450. X         0 1 translate        % dx
  451. X     } repeat pop
  452. X     grestore
  453. X } bind def % L
  454. X /WW 1 def    % default Wire Width (space from line)
  455. X /Wto {        % x1 y1 x2 y2 ==> x2 y2
  456. X %    Draws a path spaced WW from the line (x1,y1)-(x2,y2)
  457. X newpath
  458. X %    wire angle a=atan(dy/dx)
  459. X 4 2 roll 4 copy    exch        % x2 y2 x1 y1 x2 y2 y1 x1
  460. X 3 1 roll sub 3 1 roll sub    % x2 y2 x1 y1 dy dx
  461. X atan dup 4 1 roll        % x2 y2 a x1 y1 a
  462. X WW exch 90 add dup 180 add arc    % x2 y2 a
  463. X 3 copy pop 3 2 roll        % x2 y2 x2 y2 a
  464. X WW exch 90 sub dup 180 add arc    % x2 y2
  465. X closepath            % x2 y2  (leave for next Wto)
  466. X } bind def % Wto
  467. X /X {    % Draw an X on the current figure
  468. X     gsave clip
  469. X     pathbbox newpath    % x1 y1 x2 y2
  470. X     4 copy moveto lineto    % x1 y1 x2 y2
  471. X     3 1 roll exch        % x1 y2 x2 y1
  472. X     moveto lineto stroke    %
  473. X     grestore
  474. X } bind def % X
  475. X % End of header code
  476. SHAR_EOF
  477. if test 1843 -ne "`wc -c < 'psheader.ps'`"
  478. then
  479.     echo shar: error transmitting "'psheader.ps'" '(should have been 1843 characters)'
  480. fi
  481. fi # end of overwriting check
  482. echo shar: extracting "'define.h'" '(2178 characters)'
  483. if test -f 'define.h'
  484. then
  485.     echo shar: will not over-write existing file "'define.h'"
  486. else
  487. sed 's/^X //' << \SHAR_EOF > 'define.h'
  488. X /*
  489. X  *    Global defines.
  490. X  *    See "cif2ps.c" for authors' names and addresses.
  491. X  *    Please honor the authors by not removing their attributions.
  492. X  */
  493. X #include <stdio.h>
  494. X /* The following dimensions are all in points (1/72 in.) */
  495. X #define PAGEMARGIN    36
  496. X #define PAGEWIDTH    ( 8.5 * 72 - 2 * PAGEMARGIN)
  497. X #define PAGELENGTH    (11.0 * 72 - 2 * PAGEMARGIN)
  498. X #define DEFPOINTS    6    /* default points size of text */
  499. X #define BIGINT    0x7FFFFF
  500. X #define false 0
  501. X #define true 1
  502. X #define MAXTOKEN        64
  503. X #define MAXSYMBOLS    256
  504. X #define MAXLINE        1024
  505. X #define LNAMELEN    7
  506. X #define MAXLAYERS    32
  507. X #define MAXNINETY_FOUR    64
  508. X #define DSTYPE        1
  509. X #define BOXTYPE        2
  510. X #define CALLTYPE    3
  511. X #define NINETY_FOURTYPE    4
  512. X #define NGONTYPE    5
  513. X #define ROUNDTYPE    6
  514. X #define WIRETYPE    7
  515. X #define WHITE    ' '
  516. X #define COMMA    ','
  517. X typedef    struct    {
  518. X     int    x, y;
  519. X     }    pointpairtype;
  520. X typedef struct    {
  521. X     int    layer;
  522. X     int    llx,lly,urx,ury;
  523. X     }    boxtype;
  524. X typedef struct    {
  525. X     int    layer;
  526. X     int    numPoints;
  527. X     int    *ptrPoints;
  528. X     }    ngontype;
  529. X typedef struct    {
  530. X     int    layer;
  531. X     int    x,y,r;
  532. X     }    roundtype;
  533. X typedef struct    {
  534. X     int    layer;
  535. X     int    numPoints;
  536. X     int    *ptrPoints;
  537. X     int    width;
  538. X     }    wiretype;
  539. X typedef struct    {
  540. X     int    name, a, b;
  541. X     }    dstype;
  542. X typedef struct    {
  543. X     char    name[MAXNINETY_FOUR];
  544. X     int    x, y, layer;
  545. X     }    ninety_fourtype;
  546. X typedef struct    {
  547. X     int    symbol;
  548. X     float    matrix[3][3];
  549. X     }    calltype;
  550. X typedef    struct    symboldumb    {
  551. X     struct    symboldumb    *next;
  552. X     int    typer;
  553. X     union    {
  554. X         boxtype    *box;
  555. X         dstype    *ds;
  556. X         calltype    *call;
  557. X         ninety_fourtype    *ninety_four;
  558. X         ngontype    *ngon;
  559. X         roundtype    *round;
  560. X         wiretype    *wire;
  561. X         }    primitive;
  562. X     }    symboltype;
  563. X typedef    struct    {
  564. X     int    symbol, a, b;
  565. X     char    name[MAXTOKEN];
  566. X     symboltype    *pointer;
  567. X     pointpairtype    ll, ur;
  568. X     }    tabletype;
  569. X typedef    struct    {
  570. X         char    *name;
  571. X     char    *style;
  572. X     }    layertype;
  573. X symboltype    *allocsymbol();
  574. X tabletype    symbol_table[MAXSYMBOLS];
  575. X FILE    *ciffile;
  576. X int    no_lines;
  577. X layertype    layers[MAXLAYERS];
  578. X int    order[MAXLAYERS];
  579. X int    layer, numlayers;
  580. X int    last_symbol, current_symbol_index;
  581. X symboltype    *present_symbol;
  582. X char *cur_style;
  583. X float    scale, trans_x, trans_y, a_over_b;
  584. X float    matrix[3][3], top_matrix[3][3];
  585. X int    pagex,pagey;
  586. X int    length,width;
  587. X int    totpages;
  588. X int    font_points;    /* point-size of label font */
  589. X char *psheader[];
  590. X char *style_lookup();
  591. SHAR_EOF
  592. if test 2178 -ne "`wc -c < 'define.h'`"
  593. then
  594.     echo shar: error transmitting "'define.h'" '(should have been 2178 characters)'
  595. fi
  596. fi # end of overwriting check
  597. echo shar: extracting "'cif2ps.c'" '(15796 characters)'
  598. if test -f 'cif2ps.c'
  599. then
  600.     echo shar: will not over-write existing file "'cif2ps.c'"
  601. else
  602. sed 's/^X //' << \SHAR_EOF > 'cif2ps.c'
  603. X /*
  604. X     cif2ps is based on the program 'cifp' originally written by
  605. X     Arthur Simoneau, The Aerospace Corporation, El Segundo, Calif
  606. X     Modified by Marc Lesure, Arizona State University, Tempe, AZ
  607. X     Changes to 'cifp' include support of cmos-pw layers, scaling
  608. X     factors to spread output over several pages of 8.5 x 11 paper,
  609. X     printing multiple layers.
  610. X     Modified by Gordon W Ross, The MITRE Corporation, Bedford, MA
  611. X     Designed new PostScript routines to reduce output file size.
  612. X     Added automatic style selection and run-time customization.
  613. X     Added rotation option.  (June 1989)
  614. X     Please honor the authors by not removing their attributions.
  615. X */
  616. X #include <stdio.h>
  617. X extern char *sprintf(); /* missing from stdio.h on Sun! */
  618. X #include <ctype.h>
  619. X #include "define.h"
  620. X int    maxwidth = 5;
  621. X int    maxlength = 5;
  622. X int    depth_lim, depth_now;
  623. X main(argc, argv)
  624. X int    argc;
  625. X char    *argv[];
  626. X {
  627. X     char *s,*cifname,*plotname,*sym_name;
  628. X     /* Initialize */
  629. X     ciffile=stdin;
  630. X     cifname="(stdin)";
  631. X     sym_name=0;    /* default (see below) */
  632. X     depth_lim=0;
  633. X     length = width = 1;
  634. X     totpages = 0;
  635. X     font_points = DEFPOINTS;
  636. X     no_lines = 0;
  637. X     layer = 0;
  638. X     last_symbol = -1;
  639. X     identity_matrix(top_matrix); /* need for "-r" option */
  640. X     while (--argc && ++argv && **argv == '-') {
  641. X         s = argv[0] + 1;
  642. X         switch (*s) {
  643. X         case 'c':
  644. X             sym_name = *++argv;
  645. X             argc--;
  646. X             break;
  647. X         case 'd':
  648. X             depth_lim = atoi(*++argv);
  649. X             argc--;
  650. X             break;
  651. X         case 'f':
  652. X             font_points = atoi(*++argv);
  653. X             argc--;
  654. X             break;
  655. X         case 'h':
  656. X             length = atoi(*++argv);
  657. X             argc--;
  658. X             break;
  659. X         case 'w':
  660. X             width = atoi(*++argv);
  661. X             argc--;
  662. X             break;
  663. X         case 'r':    /* rotate by 90 degrees */
  664. X             {
  665. X                 float rotate[3][3];
  666. X                 identity_matrix(rotate);
  667. X                 rotate[0][0] = 0;
  668. X                 rotate[0][1] = -1;
  669. X                 rotate[1][0] = 1;
  670. X                 rotate[1][1] = 0;
  671. X                 hit_matrix(rotate,
  672. X                        top_matrix,
  673. X                        top_matrix);
  674. X             }
  675. X             break;
  676. X         case 's':
  677. X             set_style(*++argv);
  678. X             argc--;
  679. X             break;
  680. X         default:
  681. X             printf("cif2ps: unknown flag - %s\n",*s);
  682. X             exit(0);
  683. X         }
  684. X     }
  685. X     if (argc) {    /* input file name supplied? */
  686. X         cifname = *argv++; argc--;
  687. X         if (!freopen(cifname, "r", stdin)) {
  688. X         fprintf(stderr, "%s: can't read\n", cifname);
  689. X         exit(1);
  690. X         }
  691. X     }
  692. X     if (argc) {    /* output file name supplied? */
  693. X         plotname = *argv++; argc--;
  694. X         if (!freopen(plotname, "w", stdout)) {
  695. X         fprintf(stderr, "%s: can't write\n", plotname);
  696. X         exit(1);
  697. X         }
  698. X     }
  699. X     if (argc) {    /* extra args must be errors */
  700. X         fprintf(stderr,
  701. X     "Usage: cif2ps [-w width] [-h height] [input [output]]\n");
  702. X         exit(0);
  703. X     }
  704. X     if (width <= 0) {
  705. X         printf("-w exceeds lower limit - setting to 1\n");
  706. X         width = 1;
  707. X     }
  708. X     if (length <= 0) {
  709. X         printf("-l exceeds lower limit - setting to 1\n");
  710. X         length = 1;
  711. X     }
  712. X     if (width > maxwidth) {
  713. X         printf("-w exceeds upper limit - setting to %d\n",maxwidth);
  714. X         width = maxwidth;
  715. X     }
  716. X     if (length > maxlength) {
  717. X         printf("-l exceeds upper limit - setting to %d\n",maxlength);
  718. X         length = maxlength;
  719. X     }
  720. X     copy_matrix(top_matrix, matrix);
  721. X     ds("DS 0", DSTYPE); /* cell 0 is predefined. Yech! -GWR */
  722. X     nine("9 top_level");
  723. X     do_cif();    /* parse input */
  724. X     style_sort();    /* determine plot order for layers */
  725. X     plot_symbol(sym_name);
  726. X }    /*main*/
  727. X plot_symbol(sym_name)
  728. X char    *sym_name;
  729. X {
  730. X     pointpairtype    ll, ur;
  731. X     int    sym_index = 0;
  732. X     /* get the symbol number */
  733. X     if (sym_name) {
  734. X         if (isdigit(*sym_name)) {
  735. X             sym_index = get_index(atoi(sym_name));
  736. X         } else {
  737. X             sym_index = sym_lookup(sym_name);
  738. X         }
  739. X         if (sym_index < 0) {
  740. X             fprintf(stderr,
  741. X                 "%s: symbol not found\n",
  742. X                 sym_name);
  743. X             output_all_symbolnums(stderr);
  744. X             exit(1);
  745. X         }
  746. X     } else {
  747. X         /* use default choice of symbol */
  748. X         /* usually want "1" if it exists, else "0" */
  749. X         sym_index = get_index(1);
  750. X         if (sym_index < 0) sym_index = 0;
  751. X     }
  752. X     ll.x = BIGINT;
  753. X     ur.x = -BIGINT;
  754. X     ll.y = BIGINT;
  755. X     ur.y = -BIGINT;
  756. X     
  757. X     get_bounds(sym_index, &ll, &ur);
  758. X     if ((ll.x == BIGINT) || (ll.y == BIGINT)) {
  759. X         fprintf(stderr, "cell number %s is empty\n",
  760. X             sym_name);
  761. X         exit(1);
  762. X     }
  763. X     get_pair(ll.x, ll.y, &ll);
  764. X     get_pair(ur.x, ur.y, &ur);
  765. X     fix_bbox(&ll, &ur); /* transformed? */
  766. X     
  767. X     get_window(&ll, &ur);
  768. X     init_cif();
  769. X     putHeader();
  770. X     
  771. X     for(pagey=0; pagey < length; pagey++) {
  772. X         for(pagex=0; pagex < width; pagex++) {
  773. X             startPage();
  774. X             plot_boxes(symbol_table[sym_index].pointer);
  775. X             plot_textes(symbol_table[sym_index].pointer);
  776. X             finishPage();
  777. X         }
  778. X     }
  779. X     putTrailer();
  780. X }    /*plotcif*/
  781. X int
  782. X sym_lookup(sym_name)    /* return symbol table index */
  783. X char    *sym_name;
  784. X {
  785. X     int    i;
  786. X     for(i = 0; i <= last_symbol; i++) {
  787. X         if (symbol_table[i].name &&
  788. X             !strcmp(symbol_table[i].name, sym_name))
  789. X             return(i);
  790. X     }
  791. X     return(-1);
  792. X }
  793. X get_window(ll, ur)
  794. X pointpairtype    *ll, *ur;
  795. X {
  796. X     /* assigns global variables: scale, trans_x, trans_y */
  797. X     /* Note: scale maps from CIF coordinates to 72'nds of inches */
  798. X     float    scalex, scaley;
  799. X     float   deltax, deltay;
  800. X     int    newsize;
  801. X     trans_x = - ll->x;
  802. X     trans_y = - ll->y;
  803. X     deltax = ur->x - ll->x;
  804. X     scalex = width * PAGEWIDTH / deltax;
  805. X     deltay = ur->y - ll->y;
  806. X     scaley = length * PAGELENGTH / deltay;
  807. X     if (scalex < scaley) {
  808. X         scale = scalex;
  809. X         newsize = ((deltay * scale) / PAGELENGTH) + 1;
  810. X         if (newsize != length) {
  811. X             printf("output length changed from %d to %d\n",
  812. X                 length, newsize);
  813. X             length = newsize;
  814. X         }
  815. X     } else {
  816. X         scale = scaley; 
  817. X         newsize = ((deltax * scale) / PAGEWIDTH) + 1;
  818. X         if (newsize != width) {
  819. X             printf("output width changed from %d to %d\n",
  820. X                 newsize,length);
  821. X             width = newsize;
  822. X         }
  823. X     }
  824. X }    /*get_window*/
  825. X plot_boxes(symbol)
  826. X symboltype    *symbol;
  827. X {
  828. X     int i;
  829. X     /* first we plot all the opaque (gray fill) styles */
  830. X     for (i=0; i<numlayers; i++) {
  831. X         layer = order[i];
  832. X         if (style_gray(layers[layer].style)) {
  833. X             printf("%% %s\n", layers[layer].name);
  834. X             depth_now = 0;
  835. X             plot_boxes_sub(symbol);
  836. X         }
  837. X     }
  838. X     puts("0 setgray");
  839. X     /* plot the remaining styles (any order is fine) */
  840. X     for (i = 0; i < numlayers; i++) {
  841. X         layer = i;
  842. X         if (style_rest(layers[layer].style)) {
  843. X             printf("%% %s\n", layers[layer].name);
  844. X             depth_now = 0;
  845. X             plot_boxes_sub(symbol);
  846. X         }
  847. X     }
  848. X }    /*plot_boxes*/
  849. X plot_boxes_sub(symbol)
  850. X symboltype    *symbol;
  851. X {
  852. X float    temp_matrix[3][3];
  853. X     while(symbol != NULL)
  854. X         {
  855. X         switch(symbol->typer)
  856. X             {
  857. X         case BOXTYPE:
  858. X             plot_box(symbol->primitive.box);
  859. X             break;
  860. X         case NGONTYPE:
  861. X             plot_ngon(symbol->primitive.ngon);
  862. X             break;
  863. X         case ROUNDTYPE:
  864. X             plot_round(symbol->primitive.round);
  865. X             break;
  866. X         case WIRETYPE:
  867. X             plot_wire(symbol->primitive.wire);
  868. X             break;
  869. X         case CALLTYPE:
  870. X             /* if at depth_lim, skip calls */
  871. X             if (depth_lim &&
  872. X                 (depth_lim <= (depth_now + 1)))
  873. X                 break;
  874. X             depth_now++;
  875. X             copy_matrix(matrix, temp_matrix);
  876. X             hit_matrix(matrix,
  877. X                 symbol->primitive.call->matrix,
  878. X                 matrix);
  879. X             plot_boxes_sub(
  880. X         symbol_table[symbol->primitive.call->symbol].pointer);
  881. X             copy_matrix(temp_matrix, matrix);
  882. X             depth_now--;
  883. X             break;
  884. X         case DSTYPE:
  885. X         case NINETY_FOURTYPE:
  886. X             break;
  887. X         default:
  888. X             fprintf(stderr, "ERROR Not known %d in plot boxes\n",
  889. X                             symbol->typer);
  890. X             break;
  891. X             }
  892. X         symbol = symbol->next;
  893. X         }
  894. X     return;
  895. X }    /*plot_boxes_sub*/
  896. X plot_textes(symbol)
  897. X symboltype    *symbol;
  898. X {
  899. X ninety_fourtype        *ninety_four;
  900. X     puts("0 setgray");
  901. X     while(symbol != NULL)
  902. X         {
  903. X         switch(symbol->typer)
  904. X             {
  905. X         case CALLTYPE:    /* only plots text in top level */
  906. X         case DSTYPE:
  907. X         case BOXTYPE:
  908. X         case NGONTYPE:
  909. X         case ROUNDTYPE:
  910. X         case WIRETYPE:
  911. X             break;
  912. X         case NINETY_FOURTYPE:
  913. X             ninety_four = symbol->primitive.ninety_four;
  914. X             plot_text(ninety_four);
  915. X             break;
  916. X         default:
  917. X             fprintf(stderr, "ERROR unknown %d in plot_textes\n",
  918. X                             symbol->typer);
  919. X             break;
  920. X             }
  921. X         symbol = symbol->next;
  922. X         }
  923. X }    /*plot_textes*/
  924. X bound_point(ll,ur,x,y)
  925. X pointpairtype    *ll, *ur;
  926. X int x,y;
  927. X {
  928. X     if (ll->x > x) ll->x = x;
  929. X     if (ll->y > y) ll->y = y;
  930. X     if (ur->x < x) ur->x = x;
  931. X     if (ur->y < y) ur->y = y;
  932. X }
  933. X bound_box(ll,ur,box)
  934. X pointpairtype    *ll, *ur;
  935. X boxtype *box;
  936. X {
  937. X     bound_point(ll,ur,box->llx,box->lly);
  938. X     bound_point(ll,ur,box->urx,box->ury);
  939. X }
  940. X bound_ngon(ll,ur,ngon)
  941. X pointpairtype    *ll, *ur;
  942. X ngontype *ngon;
  943. X {
  944. X     int n = ngon->numPoints;
  945. X     int *a = ngon->ptrPoints;
  946. X     do {
  947. X         bound_point(ll,ur,a[0],a[1]);
  948. X         n--; a += 2;
  949. X     } while (n);
  950. X }
  951. X bound_round(ll,ur,round)
  952. X pointpairtype    *ll, *ur;
  953. X roundtype *round;
  954. X {
  955. X     bound_point(ll,ur,
  956. X             round->x - round->r,
  957. X             round->y - round->r);
  958. X     bound_point(ll,ur,
  959. X             round->x + round->r,
  960. X             round->y + round->r);
  961. X }
  962. X bound_wire(ll,ur,wire)
  963. X pointpairtype    *ll, *ur;
  964. X wiretype *wire;
  965. X {
  966. X     int n = wire->numPoints;
  967. X     int *a = wire->ptrPoints;
  968. X     do {
  969. X         bound_point(ll,ur,a[0],a[1]);
  970. X         n--; a += 2;
  971. X     } while (n);
  972. X     ll->x -= wire->width;
  973. X     ll->y -= wire->width;
  974. X     ur->x += wire->width;
  975. X     ur->y += wire->width;
  976. X }
  977. X get_bounds(sym, ll, ur)
  978. X int    sym;
  979. X pointpairtype    *ll, *ur;
  980. X {
  981. X int        local_sym;
  982. X symboltype    *symbol;
  983. X pointpairtype    local_ll, local_ur;
  984. X float    temp_matrix[3][3];
  985. X     symbol = symbol_table[sym].pointer;
  986. X     while(symbol != NULL)
  987. X         {
  988. X         switch(symbol->typer)
  989. X             {
  990. X         case DSTYPE:
  991. X         case NINETY_FOURTYPE:
  992. X             break;
  993. X         case BOXTYPE:
  994. X             bound_box(ll,ur,symbol->primitive.box);
  995. X             break;
  996. X         case NGONTYPE:
  997. X             bound_ngon(ll,ur,symbol->primitive.ngon);
  998. X             break;
  999. X         case ROUNDTYPE:
  1000. X             bound_round(ll,ur,symbol->primitive.round);
  1001. X             break;
  1002. X         case WIRETYPE:
  1003. X             bound_wire(ll,ur,symbol->primitive.wire);
  1004. X             break;
  1005. X         case CALLTYPE:
  1006. X             local_sym = symbol->primitive.call->symbol;
  1007. X             if (symbol_table[local_sym].ll.x == BIGINT)
  1008. X                 {
  1009. X                 get_bounds(local_sym,
  1010. X                     &(symbol_table[local_sym].ll),
  1011. X                     &(symbol_table[local_sym].ur));
  1012. X                 }
  1013. X             copy_matrix(matrix, temp_matrix);
  1014. X             copy_matrix(symbol->primitive.call->matrix, matrix);
  1015. X             get_pair(symbol_table[local_sym].ll.x,
  1016. X                 symbol_table[local_sym].ll.y, &local_ll);
  1017. X             get_pair(symbol_table[local_sym].ur.x,
  1018. X                 symbol_table[local_sym].ur.y, &local_ur);
  1019. X             copy_matrix(temp_matrix, matrix);
  1020. X             /* local_ll and local_ur may be transformed
  1021. X              * such that left>right or lower>upper ...
  1022. X              */
  1023. X             fix_bbox(&local_ll, &local_ur);
  1024. X             if (ll->x > local_ll.x)
  1025. X                 ll->x = local_ll.x;
  1026. X             if (ll->y > local_ll.y)
  1027. X                 ll->y = local_ll.y;
  1028. X             if (ur->x < local_ur.x)
  1029. X                 ur->x = local_ur.x;
  1030. X             if (ur->y < local_ur.y)
  1031. X                 ur->y = local_ur.y;
  1032. X             break;
  1033. X         default:
  1034. X             fprintf(stderr, "ERROR Not known %d in get_bounds\n",
  1035. X                             symbol->typer);
  1036. X             break;
  1037. X             }
  1038. X         symbol = symbol->next;
  1039. X         }
  1040. X }    /*get_bounds*/
  1041. X get_pair(x, y, pair)
  1042. X int    x, y;
  1043. X pointpairtype    *pair;
  1044. X {
  1045. X     pair->x = (x * matrix[0][0]) + (y * matrix[0][1]) + matrix[0][2];
  1046. X     pair->y = (x * matrix[1][0]) + (y * matrix[1][1]) + matrix[1][2];
  1047. X }    /*get_pair*/
  1048. X call_symbol(cif)
  1049. X char    *cif;
  1050. X {
  1051. X int    last_read, callnum;
  1052. X char    token[MAXTOKEN];
  1053. X char    ciftemp[MAXLINE];
  1054. X int    rotate_x, rotate_y;
  1055. X float    multi_matrix[3][3];
  1056. X float    temp_a_over_b, translate_x, translate_y;
  1057. X calltype    *call, *alloccall();
  1058. X     bang_symbol();
  1059. X     present_symbol->typer = CALLTYPE;
  1060. X     call = alloccall();
  1061. X     present_symbol->primitive.call = call;
  1062. X     last_read = get_token(cif, 2, token);
  1063. X     if (last_read == -1)
  1064. X         {
  1065. X         fprintf(stderr, "no symbol in CALL\n");
  1066. X         cif_output(stderr, cif);
  1067. X         return;
  1068. X         }
  1069. X     (void) sscanf(token, "%d", &callnum);
  1070. X     call->symbol = get_index(callnum);
  1071. X     if (call->symbol == -1)
  1072. X         {
  1073. X         sprintf(ciftemp, "DS %d", callnum);
  1074. X         temp_a_over_b = a_over_b;
  1075. X         ds(ciftemp, CALLTYPE);
  1076. X         a_over_b = temp_a_over_b;
  1077. X         call->symbol = get_index(callnum);
  1078. X         if (call->symbol == -1)
  1079. X             {
  1080. X             fprintf(stderr, "Error in call cif\n");
  1081. X             cif_output(stderr, cif);
  1082. X             }
  1083. X         }
  1084. X     identity_matrix(multi_matrix);
  1085. X     while(1) {
  1086. X         last_read = get_token(cif, last_read, token);
  1087. X         if (last_read == -1) break;
  1088. X         if (token[0] == 'M')
  1089. X             {
  1090. X             switch(token[1])
  1091. X                 {
  1092. X             case 'X':
  1093. X                 multi_matrix[0][0] = -1;
  1094. X                 hit_matrix(multi_matrix,
  1095. X                        call->matrix,
  1096. X                        call->matrix);
  1097. X                 multi_matrix[0][0] = 1;
  1098. X                 break;
  1099. X             case 'Y':
  1100. X                 multi_matrix[1][1] = -1;
  1101. X                 hit_matrix(multi_matrix,
  1102. X                        call->matrix,
  1103. X                        call->matrix);
  1104. X                 multi_matrix[1][1] = 1;
  1105. X                 break;
  1106. X             default:
  1107. X                 fprintf(stderr,
  1108. X                     "Error in mirror %c\n",
  1109. X                     token[1]);
  1110. X                 cif_output(stderr, cif);
  1111. X                 break;
  1112. X                 }    /*switch mirror*/
  1113. X             }    /*if mirror*/
  1114. X         else if (token[0] == 'R')
  1115. X             {
  1116. X             last_read = get_token(cif, last_read, token);
  1117. X             if (last_read == -1)
  1118. X                 {
  1119. X                 fprintf(stderr, "error in rotate\n");
  1120. X                 cif_output(stderr, cif);
  1121. X                 break;
  1122. X                 }
  1123. X             (void) sscanf(token, "%d", &rotate_x);
  1124. X             rotate_x = sign(rotate_x);
  1125. X             last_read = get_token(cif, last_read, token);
  1126. X             if (last_read == -1)
  1127. X                 {
  1128. X                 fprintf(stderr, "error2 in rotate\n");
  1129. X                 cif_output(stderr, cif);
  1130. X                 break;
  1131. X                 }
  1132. X             (void) sscanf(token, "%d", &rotate_y);
  1133. X             rotate_y = sign(rotate_y);
  1134. X             switch(rotate_x)
  1135. X                 {
  1136. X             case 1:
  1137. X                 if (rotate_y != 0)
  1138. X                     fprintf(stderr,
  1139. X                         "Bad rotation x %d y %d\n",
  1140. X                         rotate_x, rotate_y);
  1141. X                 break;
  1142. X             case -1:
  1143. X                 if (rotate_y != 0)
  1144. X                     {
  1145. X                     fprintf(stderr,
  1146. X                         "Bad rotation x %d y %d\n",
  1147. X                         rotate_x, rotate_y);
  1148. X                     break;
  1149. X                     }
  1150. X                 multi_matrix[0][0] = -1;
  1151. X                 multi_matrix[1][1] = -1;
  1152. X                 hit_matrix(multi_matrix,
  1153. X                        call->matrix,
  1154. X                        call->matrix);
  1155. X                 identity_matrix(multi_matrix);
  1156. X                 break;
  1157. X             case 0:
  1158. X                 switch(rotate_y)
  1159. X                     {
  1160. X                 case 1:
  1161. X                     multi_matrix[0][0] = 0;
  1162. X                     multi_matrix[1][1] = 0;
  1163. X                     multi_matrix[0][1] = -1;
  1164. X                     multi_matrix[1][0] = 1;
  1165. X                     hit_matrix(multi_matrix,
  1166. X                            call->matrix,
  1167. X                            call->matrix);
  1168. X                     identity_matrix(multi_matrix);
  1169. X                     break;
  1170. X                 case -1:
  1171. X                     multi_matrix[0][0] = 0;
  1172. X                     multi_matrix[1][1] = 0;
  1173. X                     multi_matrix[0][1] = 1;
  1174. X                     multi_matrix[1][0] = -1;
  1175. X                     hit_matrix(multi_matrix,
  1176. X                            call->matrix,
  1177. X                            call->matrix);
  1178. X                     identity_matrix(multi_matrix);
  1179. X                     break;
  1180. X                 default:
  1181. X                     fprintf(stderr,
  1182. X                         "Bad rotation x %d y %d\n",
  1183. X                         rotate_x, rotate_y);
  1184. X                     break;
  1185. X                     }    /*switch y*/
  1186. X                 break;
  1187. X             default:
  1188. X                 fprintf(stderr, "Bad rotation x %d y %d\n",
  1189. X                     rotate_x, rotate_y);
  1190. X                 break;
  1191. X                 }    /*switch rotation*/
  1192. X             }    /*if rotate*/
  1193. X         else if (token[0] == 'T')
  1194. X             {
  1195. X             last_read = get_token(cif, last_read, token);
  1196. X             if (last_read == -1)
  1197. X                 {
  1198. X                 fprintf(stderr, "error in translate\n");
  1199. X                 cif_output(stderr, cif);
  1200. X                 break;
  1201. X                 }
  1202. X             (void) sscanf(token, "%f", &translate_x);
  1203. X             translate_x *= a_over_b;
  1204. X             last_read = get_token(cif, last_read, token);
  1205. X             if (last_read == -1)
  1206. X                 {
  1207. X                 fprintf(stderr, "error2 in translate\n");
  1208. X                 cif_output(stderr, cif);
  1209. X                 break;
  1210. X                 }
  1211. X             (void) sscanf(token, "%f", &translate_y);
  1212. X             translate_y *= a_over_b;
  1213. X             if ((translate_x != 0) || (translate_y != 0))
  1214. X                 {
  1215. X                 multi_matrix[0][2] = translate_x;
  1216. X                 multi_matrix[1][2] = translate_y;
  1217. X                 hit_matrix(multi_matrix,
  1218. X                        call->matrix,
  1219. X                        call->matrix);
  1220. X                 identity_matrix(multi_matrix);
  1221. X                 }
  1222. X             }    /*if translate*/
  1223. X         else
  1224. X             {
  1225. X             fprintf(stderr, "error---out of calls\n");
  1226. X             cif_output(stderr, cif);
  1227. X             fprintf(stderr, "\ttoken %s\n", token);
  1228. X             break;
  1229. X             }
  1230. X         }    /* while(1) */
  1231. X }    /*call_symbol*/
  1232. X sign(x)
  1233. X int x;
  1234. X {
  1235. X     int z;
  1236. X     z = 0;
  1237. X     if (x > 0) z = 1;
  1238. X     if (x < 0) z = -1;
  1239. X     return(z);
  1240. X }
  1241. X identity_matrix(matrix)
  1242. X float    matrix[3][3];
  1243. X {
  1244. X     matrix[0][0] = 1;
  1245. X     matrix[0][1] = 0;
  1246. X     matrix[0][2] = 0;
  1247. X     matrix[1][0] = 0;
  1248. X     matrix[1][1] = 1;
  1249. X     matrix[1][2] = 0;
  1250. X     matrix[2][0] = 0;
  1251. X     matrix[2][1] = 0;
  1252. X     matrix[2][2] = 1;
  1253. X }    /*identity_matrix*/
  1254. X hit_matrix(left_matrix, right_matrix, to_matrix)
  1255. X float    left_matrix[3][3], right_matrix[3][3], to_matrix[3][3];
  1256. X {
  1257. X int    i, j;
  1258. X float    temp[3][3];
  1259. X     for(i = 0; i < 3; i++)
  1260. X         for(j = 0; j < 3; j++)
  1261. X             temp[i][j] = left_matrix[i][0] * right_matrix[0][j]
  1262. X                        + left_matrix[i][1] * right_matrix[1][j]
  1263. X                    + left_matrix[i][2] * right_matrix[2][j];
  1264. X     copy_matrix(temp, to_matrix);
  1265. X }    /*hit_matrix*/
  1266. X copy_matrix(from_matrix, to_matrix)
  1267. X float    from_matrix[3][3], to_matrix[3][3];
  1268. X {
  1269. X int    i, j;
  1270. X     for(i = 0; i < 3; i++)
  1271. X         {
  1272. X         for(j = 0; j < 3; j++)
  1273. X             to_matrix[i][j] = from_matrix[i][j];
  1274. X         }
  1275. X }    /*copy_matrix*/
  1276. X fix_bbox(ll, ur)
  1277. X pointpairtype *ll, *ur;
  1278. X {
  1279. X     float temp;
  1280. X     if (ll->x > ur->x) {    /* swap */
  1281. X         temp = ll->x;
  1282. X         ll->x = ur->x;
  1283. X         ur->x = temp;
  1284. X     }
  1285. X     if (ll->y > ur->y) {    /* swap */
  1286. X         temp = ll->y;
  1287. X         ll->y = ur->y;
  1288. X         ur->y = temp;
  1289. X     }
  1290. X }
  1291. SHAR_EOF
  1292. if test 15796 -ne "`wc -c < 'cif2ps.c'`"
  1293. then
  1294.     echo shar: error transmitting "'cif2ps.c'" '(should have been 15796 characters)'
  1295. fi
  1296. fi # end of overwriting check
  1297. echo shar: extracting "'cifgood.c'" '(13422 characters)'
  1298. if test -f 'cifgood.c'
  1299. then
  1300.     echo shar: will not over-write existing file "'cifgood.c'"
  1301. else
  1302. sed 's/^X //' << \SHAR_EOF > 'cifgood.c'
  1303. X /*
  1304. X  *    CIF parser code.
  1305. X  *    See "cif2ps.c" for authors' names and addresses.
  1306. X  *    Please honor the authors by not removing their attributions.
  1307. X  */
  1308. X #include "define.h"
  1309. X #include <malloc.h>
  1310. X #define DELTA_A    'a' - 'A'
  1311. X init_cif()
  1312. X {
  1313. X     layer = 0;
  1314. X }    /*init_cif*/
  1315. X get_next_cifline(stringer)
  1316. X char    *stringer;
  1317. X {
  1318. X     int    i;
  1319. X     int    c;
  1320. X     for(i = 0; i < MAXLINE; i++) {
  1321. X         c = getchar();
  1322. X         if (c == ';') {
  1323. X             stringer[i] = '\0';
  1324. X             return(i);
  1325. X             }
  1326. X         else if (c == '\n')
  1327. X             {
  1328. X             stringer[i] = ' ';
  1329. X             no_lines++;
  1330. X             }
  1331. X         else if (c == EOF)
  1332. X             {
  1333. X             stringer[i] = '\0';
  1334. X             if (i) return(i);
  1335. X             return(EOF);
  1336. X             }
  1337. X         else if (c == '(')
  1338. X             {
  1339. X             while (getchar() != ')') ;
  1340. X             }
  1341. X         else
  1342. X             stringer[i] = c;
  1343. X     } /* for (i ...) */
  1344. X     fprintf(stderr, "Cifline exceeded bounds\n");
  1345. X     stringer[i] = '\0';
  1346. X     cif_output(stderr, stringer);
  1347. X     exit(1);
  1348. X     /*NOTREACHED*/
  1349. X }    /*get_next_cifline*/
  1350. X cif_output(filer, cif)
  1351. X FILE    *filer;
  1352. X char    *cif;
  1353. X {
  1354. X     fprintf(filer, "%s\t\t(*near line %d*)\n", cif, no_lines);
  1355. X }    /*cif_output*/
  1356. X trim_cif(cif)
  1357. X char    *cif;
  1358. X {
  1359. X int    i, j, toggle_white;
  1360. X     i = 0;
  1361. X     j = 0;
  1362. X     toggle_white = 1;        /*so no white at beginning*/
  1363. X     for (i = 0; i < MAXLINE; i++)
  1364. X         {
  1365. X         if (cif[i] == COMMA)
  1366. X             {
  1367. X                 cif[i] = WHITE;
  1368. X             }
  1369. X         if (cif[i] == '\0')
  1370. X             {
  1371. X             cif[j] = '\0';
  1372. X             return;
  1373. X             }
  1374. X         else if (white(cif[i]))
  1375. X             {
  1376. X             if ( !toggle_white)    /*makes one white space*/
  1377. X                 {
  1378. X                 cif[j++] = ' ';
  1379. X                 toggle_white = 1;
  1380. X                 }
  1381. X             }
  1382. X         else
  1383. X             {
  1384. X             cif[j++] = cif[i];
  1385. X             if (toggle_white) toggle_white = 0;
  1386. X             }
  1387. X         }    /*for*/
  1388. X }    /*trim_cif*/
  1389. X white(chr)
  1390. X char    chr;
  1391. X {
  1392. X     switch(chr)
  1393. X         {
  1394. X     case ' ':
  1395. X     case '\t':
  1396. X         return(1);
  1397. X     default:
  1398. X         return(0);
  1399. X         }
  1400. X }    /*white*/
  1401. X symboltype
  1402. X *allocsymbol()
  1403. X {
  1404. X unsigned    size = sizeof(symboltype);
  1405. X symboltype    *symbol;
  1406. X     symbol =(symboltype *) malloc(size);
  1407. X     symbol->typer = 0;
  1408. X     symbol->primitive.box = NULL;
  1409. X     symbol->next = NULL;
  1410. X     return(symbol);
  1411. X }    /*allocsymbol*/
  1412. X     boxtype
  1413. X *allocbox()
  1414. X {
  1415. X     unsigned    size = sizeof(boxtype);
  1416. X     boxtype    *box;
  1417. X     box = (boxtype *) malloc(size);
  1418. X     return(box);
  1419. X }    /*allocbox*/
  1420. X int
  1421. X get_index(num)
  1422. X int    num;
  1423. X {
  1424. X     int    i;
  1425. X     for(i = 0; i <= last_symbol; i++)
  1426. X         {
  1427. X         if (symbol_table[i].symbol == num) return(i);
  1428. X         }
  1429. X     return(-1);
  1430. X }    /*get_index*/
  1431. X output_all_symbolnums(filer)
  1432. X FILE    *filer;
  1433. X {
  1434. X int    i;
  1435. X     fprintf(filer, "Symbols are:\n");
  1436. X     for(i = 0; i <= last_symbol; i++)
  1437. X         fprintf(filer, "%d\t%s\n", symbol_table[i].symbol,
  1438. X                             symbol_table[i].name);
  1439. X }    /*output_all_symbolnums*/
  1440. X do_cif()
  1441. X {
  1442. X char    cif[MAXLINE];
  1443. X     while (get_next_cifline(cif) != EOF) {
  1444. X         trim_cif(cif);
  1445. X         switch(cif[0]) {
  1446. X         case 'D':
  1447. X             switch(cif[1])
  1448. X                 {
  1449. X                case 'S':
  1450. X                 ds(cif, DSTYPE);
  1451. X                 break;
  1452. X                case 'F':
  1453. X                 df();
  1454. X                 break;
  1455. X                default:
  1456. X                 fprintf(stderr, "Unknown command in CIF\n");
  1457. X                 cif_output(stderr, cif);
  1458. X                 break;
  1459. X                 }    /*switch(cif[1]*/
  1460. X             break;
  1461. X         case '9':
  1462. X             switch(cif[1])
  1463. X                 {
  1464. X                case WHITE:
  1465. X                 nine(cif);
  1466. X                 break;
  1467. X                case '4':
  1468. X                 ninety_four(cif);
  1469. X                 break;
  1470. X                default:
  1471. X                 fprintf(stderr, "Unknown command in CIF\n");
  1472. X                 cif_output(stderr, cif);
  1473. X                 break;
  1474. X                 }    /*switchcif[1]*/
  1475. X             break;
  1476. X         case 'B':
  1477. X             cif_box(cif);
  1478. X             break;
  1479. X         case 'C':
  1480. X             call_symbol(cif);
  1481. X             break;
  1482. X         case 'L':
  1483. X             cif_change_layer(cif);
  1484. X             break;
  1485. X         case 'P':
  1486. X             cif_polygon(cif);
  1487. X             break;
  1488. X         case 'R':
  1489. X             cif_round(cif);
  1490. X             break;
  1491. X         case 'W':
  1492. X             cif_wire(cif);
  1493. X             break;
  1494. X         case 0:
  1495. X             break;
  1496. X         case 'E':
  1497. X             return;
  1498. X         default:
  1499. X             fprintf(stderr, "Syntax error:\n");
  1500. X             cif_output(stderr, cif);
  1501. X             break;
  1502. X         }    /*switch*/
  1503. X     } /* while (get_next_cifline(cif)...) */
  1504. X     fprintf(stderr, "Premature end of file\n");
  1505. X }    /*do_cif*/
  1506. X ds(cif, typer)
  1507. X char    *cif;
  1508. X int    typer;
  1509. X {
  1510. X int    last_read, symnum, temp_index;
  1511. X char    token[MAXTOKEN];
  1512. X symboltype    *symbol;
  1513. X     last_read = get_token(cif, 2, token); /* space optional */
  1514. X     if (last_read == -1)
  1515. X         {
  1516. X         fprintf(stderr, "no symbol in DS\n");
  1517. X         cif_output(stderr, cif);
  1518. X         return;
  1519. X         }
  1520. X     (void) sscanf(token, "%d", &symnum);
  1521. X     temp_index = get_index(symnum);
  1522. X     if (temp_index == -1)
  1523. X         {
  1524. X         if (++last_symbol == MAXSYMBOLS)
  1525. X             {
  1526. X             fprintf(stderr, "Exceeded the number of allowed symbols\n");
  1527. X             exit(1);
  1528. X             }
  1529. X         temp_index = last_symbol;
  1530. X         }
  1531. X     symbol_table[temp_index].symbol = symnum;
  1532. X     symbol_table[temp_index].ll.x = BIGINT;
  1533. X     symbol_table[temp_index].ll.y = BIGINT;
  1534. X     symbol_table[temp_index].ur.x = -BIGINT;
  1535. X     symbol_table[temp_index].ur.y = -BIGINT;
  1536. X     symbol_table[temp_index].name[0] = '\0';
  1537. X     symbol_table[temp_index].a = 1;
  1538. X     symbol_table[temp_index].b = 1;
  1539. X     a_over_b = 1;
  1540. X     symbol = allocsymbol();
  1541. X     if (typer == DSTYPE)
  1542. X         {
  1543. X         current_symbol_index = temp_index;
  1544. X         present_symbol = symbol;
  1545. X         }
  1546. X     symbol->typer = DSTYPE;
  1547. X     symbol_table[temp_index].pointer = symbol;
  1548. X     *symbol_table[temp_index].name = '\0';
  1549. X     last_read = get_token(cif, last_read, token);
  1550. X     if (last_read == -1) return;
  1551. X     (void) sscanf(token, "%d", &(symbol_table[temp_index].a));
  1552. X     if (symbol_table[temp_index].a == 0)
  1553. X         {
  1554. X         fprintf(stderr, "read a 0 for A in DS\n");
  1555. X         cif_output(stderr, cif);
  1556. X         symbol_table[temp_index].a = 1;
  1557. X         }
  1558. X     last_read = get_token(cif, last_read, token);
  1559. X     if (last_read == -1)
  1560. X         {
  1561. X         fprintf(stderr, "A but no B in DS\n");
  1562. X         cif_output(stderr, cif);
  1563. X         a_over_b = ((float) symbol_table[temp_index].a) /
  1564. X                     ((float) symbol_table[temp_index].b);
  1565. X         return;
  1566. X         }
  1567. X     (void) sscanf(token, "%d", &(symbol_table[temp_index].b));
  1568. X     if (symbol_table[temp_index].b == 0)
  1569. X         {
  1570. X         fprintf(stderr, "read a 0 for B in DS\n");
  1571. X         cif_output(stderr, cif);
  1572. X         symbol_table[temp_index].b = 1;
  1573. X         }
  1574. X     a_over_b = ((float) symbol_table[temp_index].a) /
  1575. X                     ((float) symbol_table[temp_index].b);
  1576. X }    /*ds*/
  1577. X     int
  1578. X get_token(cif, from, token)    /* copies token into *token */
  1579. X char    *cif;
  1580. X int    from;
  1581. X char    *token;
  1582. X {
  1583. X     int    i;
  1584. X     /* passed end of cif statement yet? */
  1585. X     if ((from > 0) && (cif[from - 1] == '\0'))
  1586. X         return(-1);
  1587. X     /* skip leading white space */
  1588. X     while (cif[from] == WHITE) from++;
  1589. X     for (i = 0; ((cif[i+from] != WHITE) && (cif[i+from] != COMMA));i++)
  1590. X         {
  1591. X         if (i >= MAXTOKEN-1) {
  1592. X           fprintf(stderr,"token overflow!\n");
  1593. X           cif_output(stderr,cif);
  1594. X           exit(1);
  1595. X         }
  1596. X         if (cif[i + from] == '\0')
  1597. X             break;
  1598. X         token[i] = cif[i + from];
  1599. X         }
  1600. X     token[i] = '\0';
  1601. X     if (i == 0)
  1602. X         return(-1);
  1603. X     else
  1604. X         return(i + from + 1);
  1605. X }    /*get_token*/
  1606. X df()
  1607. X {
  1608. X     current_symbol_index = 0;
  1609. X     present_symbol = symbol_table[current_symbol_index].pointer;
  1610. X }    /*df*/
  1611. X cif_box(cif)
  1612. X char    *cif;
  1613. X {
  1614. X int    next_one, i;
  1615. X int    temp[4];
  1616. X char    token[MAXTOKEN];
  1617. X boxtype    *box, *allocbox();
  1618. X     bang_symbol();
  1619. X     present_symbol->typer = BOXTYPE;
  1620. X     box = allocbox();
  1621. X     present_symbol->primitive.box = box;
  1622. X     box->layer = layer;
  1623. X     next_one = 1; /* space optional */
  1624. X     for(i = 0; i < 4; i++) {
  1625. X         next_one = get_token(cif, next_one, token);
  1626. X         if (next_one == -1)
  1627. X             {
  1628. X             fprintf(stderr, "incomplete box\n");
  1629. X             cif_output(stderr, cif);
  1630. X             return;
  1631. X             }
  1632. X         (void) sscanf(token, "%d", &(temp[i]));
  1633. X     }
  1634. X     /* *temp = width, height, center-x, center-y */
  1635. X     box->llx = a_over_b * (temp[2] - temp[0]/2);
  1636. X     box->urx = a_over_b * (temp[2] + temp[0]/2);
  1637. X     box->lly = a_over_b * (temp[3] - temp[1]/2);
  1638. X     box->ury = a_over_b * (temp[3] + temp[1]/2);
  1639. X }    /*cif_box*/
  1640. X cif_change_layer(cif)
  1641. X char    *cif;
  1642. X {
  1643. X     char    token[MAXTOKEN];
  1644. X     if (-1 == get_token(cif, 1, token)) { /* space optional */
  1645. X         fprintf(stderr, "Error in layer command\n");
  1646. X         cif_output(stderr, cif);
  1647. X         exit(1);
  1648. X     }
  1649. X     layer = layer_lookup(token);
  1650. X }    /*cif_change_layers*/
  1651. X #define PATHMALLOC 4    /* number of points per malloc */
  1652. X cif_path(cif,ptpoints,ptarray)
  1653. X char *cif;    /* the input statement */
  1654. X int *ptpoints;    /* place to return number of points */
  1655. X int **ptarray;    /* place to return address of array */
  1656. X {
  1657. X     static char *error = "can't read path";
  1658. X     static char token[MAXTOKEN];
  1659. X     static int x,y;
  1660. X     int points=0;
  1661. X     int column=0;    /* current column in cif line */
  1662. X     int pointsMax = PATHMALLOC; /* initial size of array */
  1663. X     int *pointsArray = (int *) malloc(
  1664. X             (unsigned) (PATHMALLOC*2*sizeof(int)));
  1665. X     /* read all the points into the array */
  1666. X     while(-1 != (column = get_token(cif, column, token))) {
  1667. X       if(1 != sscanf(token, "%d", &x)) {
  1668. X         fprintf(stderr,"%s point %d X\n", error, points);
  1669. X         cif_output(stderr,cif);
  1670. X         points=0;
  1671. X         break;
  1672. X       }
  1673. X       column = get_token(cif, column, token);
  1674. X       if((column == -1) || (1 != sscanf(token, "%d", &y))) {
  1675. X         fprintf(stderr,"%s point %d Y\n", error, points);
  1676. X         cif_output(stderr,cif);
  1677. X         points=0;
  1678. X         break;
  1679. X       }
  1680. X       /* make sure there's room for the new X,Y */
  1681. X       if (points >= pointsMax) {
  1682. X         pointsMax += PATHMALLOC;
  1683. X         pointsArray = (int *) realloc((char *) pointsArray,
  1684. X             (unsigned) (pointsMax * 2 * sizeof(int)));
  1685. X       }
  1686. X       if (!pointsArray) {
  1687. X         fprintf(stderr,"out of memory\n");
  1688. X         exit(1);
  1689. X       }
  1690. X       /* store the X,Y pair in the array */
  1691. X       pointsArray[2*points] = x * a_over_b;
  1692. X       pointsArray[2*points+1] = y * a_over_b;
  1693. X       points++;
  1694. X     } /* while (-1 != (column = get_token(...))) */
  1695. X     *ptpoints = points;
  1696. X     *ptarray = pointsArray;
  1697. X } /* cif_path() */
  1698. X cif_polygon(cif)
  1699. X char    *cif;
  1700. X {
  1701. X     static char *error = "can't read polygon";
  1702. X     ngontype *ngon;
  1703. X     int points=0;
  1704. X     int *pointsArray;
  1705. X     /* read in the path (list of points) */
  1706. X     cif_path(&(cif[1]), &points, &pointsArray);
  1707. X     /* make sure polygon has enough points */
  1708. X     if (points < 3) {
  1709. X       fprintf(stderr,"degenerate polygon\n");
  1710. X       cif_output(stderr,cif);
  1711. X       free((char *) pointsArray);
  1712. X       return;
  1713. X     }
  1714. X     /* Finish up... */
  1715. X     bang_symbol();
  1716. X     present_symbol->typer = NGONTYPE;
  1717. X     ngon = (ngontype *) malloc(sizeof(ngontype));
  1718. X     present_symbol->primitive.ngon = ngon;
  1719. X     ngon->layer = layer;
  1720. X     ngon->numPoints = points;
  1721. X     ngon->ptrPoints = pointsArray;
  1722. X } /* cif_polygon() */
  1723. X cif_round(cif)
  1724. X char    *cif;
  1725. X {
  1726. X     static char *error = "can't read roundflash %s\n";
  1727. X     static char token[MAXTOKEN];
  1728. X     static int x,y,r;
  1729. X     int    column=1; /* space optional */
  1730. X     roundtype *round;
  1731. X     column = get_token(cif, column, token);
  1732. X     if((column == -1) || (1 != sscanf(token, "%d", &x))) {
  1733. X       fprintf(stderr,error,"X");
  1734. X       cif_output(stderr,cif);
  1735. X       return;
  1736. X     }
  1737. X     column = get_token(cif, column, token);
  1738. X     if((column == -1) || (1 != sscanf(token, "%d", &y))) {
  1739. X       fprintf(stderr,error,"Y");
  1740. X       cif_output(stderr,cif);
  1741. X       return;
  1742. X     }
  1743. X     column = get_token(cif, column, token);
  1744. X     if((column == -1) || (1 != sscanf(token, "%d", &r))) {
  1745. X       fprintf(stderr,error,"radius");
  1746. X       cif_output(stderr,cif);
  1747. X       return;
  1748. X     }
  1749. X     /* Finish up... */
  1750. X     bang_symbol();
  1751. X     present_symbol->typer = ROUNDTYPE;
  1752. X     round = (roundtype *) malloc(sizeof(roundtype));
  1753. X     present_symbol->primitive.round = round;
  1754. X     round->layer = layer;
  1755. X     round->x = x * a_over_b;
  1756. X     round->y = y * a_over_b;
  1757. X     round->r = r * a_over_b;
  1758. X } /* cif_round() */
  1759. X cif_wire(cif)
  1760. X char    *cif;
  1761. X {
  1762. X     static char *error = "can't read wire";
  1763. X     static char token[MAXTOKEN];
  1764. X     static int width;
  1765. X     int column=1;    /* current column in cif line */
  1766. X     wiretype *wire;
  1767. X     int points=0;
  1768. X     int *pointsArray;
  1769. X     /* read the wire width */
  1770. X     column = get_token(cif, column, token);
  1771. X     if((column == -1) || (1 != sscanf(token, "%d", &width))) {
  1772. X       fprintf(stderr,error,"width");
  1773. X       cif_output(stderr,cif);
  1774. X       return;
  1775. X     }
  1776. X     /* read in the path (list of points) */
  1777. X     cif_path(&(cif[column]), &points, &pointsArray);
  1778. X     /* make sure wire has enough points */
  1779. X     if (points < 2) {
  1780. X       fprintf(stderr,"degenerate wire\n");
  1781. X       cif_output(stderr,cif);
  1782. X       free((char *) pointsArray);
  1783. X       return;
  1784. X     }
  1785. X     /* Finish up... */
  1786. X     bang_symbol();
  1787. X     present_symbol->typer = WIRETYPE;
  1788. X     wire = (wiretype *) malloc(sizeof(wiretype));
  1789. X     present_symbol->primitive.wire = wire;
  1790. X     wire->layer = layer;
  1791. X     wire->width = width * a_over_b;
  1792. X     wire->numPoints = points;
  1793. X     wire->ptrPoints = pointsArray;
  1794. X } /* cif_wire() */
  1795. X nine(cif)
  1796. X char    *cif;
  1797. X {
  1798. X int    foobar;
  1799. X char    token[MAXTOKEN];
  1800. X     foobar = get_token(cif, 1, token); /* space optional */
  1801. X     if (foobar == -1)
  1802. X         {
  1803. X         fprintf(stderr, "Error in 9 command\n");
  1804. X         cif_output(stderr, cif);
  1805. X         return;
  1806. X         }
  1807. X     (void) sscanf(token, "%s", symbol_table[current_symbol_index].name);
  1808. X }    /*nine*/
  1809. X bang_symbol()
  1810. X {
  1811. X     present_symbol->next = allocsymbol();
  1812. X     present_symbol = present_symbol->next;
  1813. X }    /*bang_symbol*/
  1814. X ninety_four(cif)
  1815. X char    *cif;
  1816. X {
  1817. X int    last_read;
  1818. X char    token[MAXTOKEN];
  1819. X ninety_fourtype    *ninety_four, *allocninety_four();
  1820. X     bang_symbol();
  1821. X     present_symbol->typer = NINETY_FOURTYPE;
  1822. X     ninety_four = allocninety_four();
  1823. X     present_symbol->primitive.ninety_four = ninety_four;
  1824. X     last_read = get_token(cif, 2, token); /* space optional */
  1825. X     if (last_read == -1)
  1826. X         {
  1827. X         fprintf(stderr, "no text in ninety_four\n");
  1828. X         cif_output(stderr, cif);
  1829. X         return;
  1830. X         }
  1831. X     (void) sscanf(token, "%s", ninety_four->name);
  1832. X     last_read = get_token(cif, last_read, token);
  1833. X     if (last_read == -1)
  1834. X         {
  1835. X         fprintf(stderr, "no x in ninety_four\n");
  1836. X         cif_output(stderr, cif);
  1837. X         return;
  1838. X         }
  1839. X     (void) sscanf(token, "%d", &(ninety_four->x));
  1840. X     ninety_four->x *= a_over_b;
  1841. X     last_read = get_token(cif, last_read, token);
  1842. X     if (last_read == -1)
  1843. X         {
  1844. X         fprintf(stderr, "no y in ninety_four\n");
  1845. X         cif_output(stderr, cif);
  1846. X         return;
  1847. X         }
  1848. X     (void) sscanf(token, "%d", &(ninety_four->y));
  1849. X     ninety_four->y *= a_over_b;
  1850. X     last_read = get_token(cif, last_read, token);
  1851. X     if (last_read != -1)    /*don't need layer on 94*/
  1852. X         ninety_four->layer = -1;
  1853. X }    /*ninety_four*/
  1854. X calltype
  1855. X *alloccall()
  1856. X {
  1857. X unsigned    size = sizeof(calltype);
  1858. X calltype    *call;
  1859. X     call =(calltype *) malloc(size);
  1860. X     call->symbol = -999;
  1861. X     identity_matrix(call->matrix);
  1862. X     return(call);
  1863. X }    /*alloccall*/
  1864. X     ninety_fourtype
  1865. X *allocninety_four()
  1866. X {
  1867. X unsigned    size = sizeof(ninety_fourtype);
  1868. X ninety_fourtype    *ninety_four;
  1869. X     ninety_four =(ninety_fourtype *) malloc(size);
  1870. X     ninety_four->layer = 0;
  1871. X     ninety_four->x = 0;
  1872. X     ninety_four->y = 0;
  1873. X     ninety_four->name[0] = '\0';
  1874. X     return(ninety_four);
  1875. X }    /*allocninety_four*/
  1876. SHAR_EOF
  1877. if test 13422 -ne "`wc -c < 'cifgood.c'`"
  1878. then
  1879.     echo shar: error transmitting "'cifgood.c'" '(should have been 13422 characters)'
  1880. fi
  1881. fi # end of overwriting check
  1882. echo shar: extracting "'cifplot.c'" '(3227 characters)'
  1883. if test -f 'cifplot.c'
  1884. then
  1885.     echo shar: will not over-write existing file "'cifplot.c'"
  1886. else
  1887. sed 's/^X //' << \SHAR_EOF > 'cifplot.c'
  1888. X /*
  1889. X  *    Output generation code.
  1890. X  *    See "cif2ps.c" for authors' names and addresses.
  1891. X  *    Please honor the authors by not removing their attributions.
  1892. X  */
  1893. X #include "define.h"
  1894. X plot_box(box)
  1895. X boxtype    *box;
  1896. X {
  1897. X     pointpairtype ll, ur;
  1898. X     int dx, dy;
  1899. X     if (box->layer != layer) return;
  1900. X     get_pair(box->llx, box->lly, &ll);
  1901. X     get_pair(box->urx, box->ury, &ur);
  1902. X     dx = ur.x - ll.x;
  1903. X     dy = ur.y - ll.y;
  1904. X     printf("%d %d %d %d B %s\n",
  1905. X            dx, dy, ll.x, ll.y, cur_style);
  1906. X }    /*plot_box*/
  1907. X plot_ngon(ngon)
  1908. X ngontype    *ngon;
  1909. X {
  1910. X     pointpairtype point;
  1911. X     int n = ngon->numPoints;
  1912. X     int *a = ngon->ptrPoints;
  1913. X     if (ngon->layer != layer) return;
  1914. X     get_pair(a[0], a[1], &point);
  1915. X     printf("%d %d moveto %% P %d\n", point.x, point.y, n);
  1916. X     n--; a += 2;
  1917. X     do {
  1918. X         get_pair(a[0], a[1], &point);
  1919. X         printf("%d %d lineto\n", point.x, point.y);
  1920. X         n--; a += 2;
  1921. X     } while (n);
  1922. X     printf("closepath %s\n", cur_style);
  1923. X }    /* plot_ngon */
  1924. X plot_round(round)
  1925. X roundtype    *round;
  1926. X {
  1927. X     pointpairtype center;
  1928. X     if (round->layer != layer) return;
  1929. X     get_pair(round->x, round->y, ¢er);
  1930. X     printf("newpath %d %d %d 0 360 arc closepath %s\n",
  1931. X            (int) center.x, (int) center.y,
  1932. X            (int) round->r, cur_style);
  1933. X }    /* plot_round */
  1934. X plot_wire(wire)
  1935. X wiretype    *wire;
  1936. X {
  1937. X     pointpairtype point;
  1938. X     int n = wire->numPoints;
  1939. X     int *a = wire->ptrPoints;
  1940. X     if (wire->layer != layer) return;
  1941. X     printf("/WW %d 2 div def ",wire->width);
  1942. X     get_pair(a[0], a[1], &point);
  1943. X     printf("%d %d %% W %d\n", point.x, point.y, n);
  1944. X     n--; a += 2;
  1945. X     do {
  1946. X         get_pair(a[0], a[1], &point);
  1947. X         printf("%d %d Wto %s\n",
  1948. X                point.x, point.y, cur_style);
  1949. X         n--; a += 2;
  1950. X     } while (n);
  1951. X     printf("pop pop\n");
  1952. X }    /* plot_wire */
  1953. X plot_text(ninety_four)
  1954. X ninety_fourtype    *ninety_four;
  1955. X {
  1956. X     pointpairtype    pair;
  1957. X     get_pair(ninety_four->x, ninety_four->y, &pair);
  1958. X     plot_string(pair.x, pair.y, ninety_four->name);
  1959. X }    /*plot_text*/
  1960. X plot_string(x, y, stringer)
  1961. X int x, y;
  1962. X char    *stringer;
  1963. X {
  1964. X     printf("%d %d moveto (%s) show\n", x, y, stringer);
  1965. X }    /*plot_string*/
  1966. X void printStrings(p)
  1967. X char **p;
  1968. X {
  1969. X     while(*p) puts(*p++);
  1970. X }
  1971. X putHeader()    /* goes before first page */
  1972. X {
  1973. X     /* Uses globals: psheader */
  1974. X     puts("%!PS-Adobe-1.0");
  1975. X     puts("%%Creator: cif2ps");
  1976. X     puts("%%DocumentFonts: Helvetica");
  1977. X     puts("%%Pages: (atend)");
  1978. X     puts("%%EndComments");
  1979. X     printStrings(psheader);
  1980. X     puts("%%EndProlog\n");
  1981. X }
  1982. X putTrailer()        /* goes after last page */
  1983. X {
  1984. X     /* Uses global: totpages */
  1985. X     puts("%%Trailer");
  1986. X     printf("%%%%Pages: %d\n", totpages);
  1987. X }
  1988. X startPage()
  1989. X {
  1990. X     printf("%%%%Page: %d:%d\n", pagex, pagey);
  1991. X     printf("%d dup translate %% margins\n", (int) PAGEMARGIN);
  1992. X     if ( (width > 1) || (length > 1)) {
  1993. X         /* multi-page plot: print the page number */
  1994. X         printf("/Helvetica findfont ");
  1995. X         printf("%d scalefont setfont\n", (int)DEFPOINTS);
  1996. X         printf("0 %d moveto (Page %d,%d) show\n",
  1997. X                (int)(-DEFPOINTS), pagex, pagey);
  1998. X     }
  1999. X     printf("/Helvetica findfont %d ", font_points);
  2000. X     printf("%g div scalefont setfont\n", scale);
  2001. X     printf("%g dup scale %% points/centi-micron\n", scale);
  2002. X     printf("%g %g translate %% cell_origin\n", trans_x, trans_y);
  2003. X     if (pagex || pagey) {
  2004. X         printf("%g %g translate %% page_origin\n",
  2005. X             (float)(-pagex * PAGEWIDTH / scale),
  2006. X             (float)(-pagey * PAGELENGTH / scale));
  2007. X     }
  2008. X }
  2009. X finishPage()
  2010. X {
  2011. X     printf("showpage\n");
  2012. X     totpages++;
  2013. X }    /*epilog*/
  2014. SHAR_EOF
  2015. if test 3227 -ne "`wc -c < 'cifplot.c'`"
  2016. then
  2017.     echo shar: error transmitting "'cifplot.c'" '(should have been 3227 characters)'
  2018. fi
  2019. fi # end of overwriting check
  2020. echo shar: extracting "'layers.c'" '(798 characters)'
  2021. if test -f 'layers.c'
  2022. then
  2023.     echo shar: will not over-write existing file "'layers.c'"
  2024. else
  2025. sed 's/^X //' << \SHAR_EOF > 'layers.c'
  2026. X /*
  2027. X  *    CIF Layer name storage and lookup functions.
  2028. X  *    See "cif2ps.c" for authors' names and addresses.
  2029. X  *    Please honor the authors by not removing their attributions.
  2030. X  */
  2031. X #include "define.h"
  2032. X #include <string.h>
  2033. X #include <malloc.h>
  2034. X int
  2035. X layer_lookup(name)    /* assigns a unique number to each CIF layer */
  2036. X char *name;
  2037. X {
  2038. X     int i;
  2039. X     char *new;
  2040. X     for (i=0; i<numlayers; i++) {
  2041. X         if (!strcmp(name,layers[i].name)) return(i);
  2042. X     }
  2043. X     /* layer was not found so define it */
  2044. X     if (numlayers>=MAXLAYERS) {
  2045. X         fprintf(stderr,"Too many layers\n");
  2046. X         exit(1);
  2047. X     }
  2048. X     new = malloc(LNAMELEN+1);
  2049. X     if (!new) {
  2050. X         fprintf(stderr,"layer_lookup: Out of memory\n");
  2051. X         exit(1);
  2052. X     }
  2053. X     layers[numlayers].name = strncpy(new,name,LNAMELEN);
  2054. X     layers[numlayers].name[LNAMELEN] = '\0';
  2055. X     layers[numlayers].style = 0;
  2056. X     return(numlayers++);
  2057. X }
  2058. SHAR_EOF
  2059. if test 798 -ne "`wc -c < 'layers.c'`"
  2060. then
  2061.     echo shar: error transmitting "'layers.c'" '(should have been 798 characters)'
  2062. fi
  2063. fi # end of overwriting check
  2064. echo shar: extracting "'styles.c'" '(3885 characters)'
  2065. if test -f 'styles.c'
  2066. then
  2067.     echo shar: will not over-write existing file "'styles.c'"
  2068. else
  2069. sed 's/^X //' << \SHAR_EOF > 'styles.c'
  2070. X /*
  2071. X  *    Style selection default table and related functions.
  2072. X  *    See "cif2ps.c" for authors' names and addresses.
  2073. X  *    Please honor the authors by not removing their attributions.
  2074. X  */
  2075. X #include "define.h"
  2076. X #include <string.h>
  2077. X #include <ctype.h>
  2078. X /*
  2079. X  *    Style table encoding:
  2080. X  *    The strings are pairs: LAYER, STYLE and
  2081. X  *    STYLE strings are merely PostScript except for the "G.n"
  2082. X  *    code which is special (and must be first in the string).
  2083. X  *    A spaces is required between components.
  2084. X  *
  2085. X  *    Drawing styles implemented:
  2086. X  *
  2087. X  *    "Gn"    fill with opaque gray stipple with level n where
  2088. X  *        n is a real number immediately after the 'G'.
  2089. X  *        The G must be the beginning of the string!
  2090. X  *
  2091. X  *    "n a L"    fill with lines spaced by n and rotated by a (degrees).
  2092. X  *
  2093. X  *    "X"    Put an X across the figure.
  2094. X  *
  2095. X  *    "stroke" Draw a box around the figure.
  2096. X  *            (this must be last if used).
  2097. X  */
  2098. X char *default_styles[] = {    /* pairs of strings */
  2099. X     /* MOSIS SCMOS layers */
  2100. X     "CPG", "G.3",
  2101. X     "CCP", "G0",
  2102. X     "CAA", "G.5",
  2103. X     "CCA", "G0",
  2104. X     "CMF", "8 45 L",
  2105. X     "CMS", "8 135 L",
  2106. X     "CVA", "G.2",
  2107. X     "CSP", "16 45 L",
  2108. X     "CSN", "16 135 L",
  2109. X     "CWP", "32 45 L",
  2110. X     "CWN", "32 135 L",
  2111. X     "COG", "G.7",
  2112. X     /* Oct Symbolic layers */
  2113. X     "POLY", "G.3",
  2114. X     "COPO", "G.3 X stroke",        /* poly contact */
  2115. X     "PDIF", "G.7 24 45 L",
  2116. X     "COPD", "G.7 X stroke",        /* pdiff contact */
  2117. X     "NDIF", "G.7 24 135 L",
  2118. X     "COND", "G.7 X stroke",        /* ndiff contact */
  2119. X     "MET1", "8 45 L",
  2120. X     "COM2", "8 45 L 8 135 L stroke",
  2121. X     "MET2", "8 135 L",
  2122. X     "PWEL", "32 45 L",
  2123. X     "COPS", "G.9 32 45 L X stroke",        /* psubs contact */
  2124. X     "NWEL", "32 135 L",
  2125. X     "CONS", "G.9 32 135 L X stroke",    /* nsubs contact */
  2126. X     "GLAS", "G.7 X stroke",
  2127. X     /* MOSIS Bulk CMOS layers */
  2128. X     "CP", "G.3",
  2129. X     "CD", "G.5",
  2130. X     "CM", "8 45 L",
  2131. X     "CQ", "8 135 L",    /* metal 2 */
  2132. X     "CM2","8 135 L",    /* metal 2, alternate name */
  2133. X     "CC", "G0",
  2134. X     "CV", "G.2 stroke",    /* via */
  2135. X     "CC2","G.2 stroke",    /* via, alternate name */
  2136. X     "CW", "23 45 L",
  2137. X     "CS", "16 45 L",
  2138. X     "CG", "G.7",
  2139. X     /* end of table marker -- MAKE SURE THIS STAYS! */
  2140. X     0, 0
  2141. X };
  2142. X char *style_lookup(name)    /* returns style string for layer */
  2143. X char *name;
  2144. X {
  2145. X     char **p;
  2146. X     for (p = default_styles; *p; p++) {
  2147. X         if (!strcmp(*(p++),name)) return(*p);
  2148. X     }
  2149. X     fprintf(stderr,"%s: layer style not found (ignoring)\n", name);
  2150. X     return("");
  2151. X }
  2152. X style_sort()    /* determines drawing order for layers */
  2153. X {
  2154. X     int i,j,tmp;
  2155. X     float grays[MAXLAYERS];
  2156. X     /* the lighter (higher value) gray levels are drawn first,
  2157. X      * so sort into decreasing order.
  2158. X      */
  2159. X     /* Read the gray levels and initialize order[] */
  2160. X     /* Also, make the ones starting with "G" come first */
  2161. X     i = 0; j = numlayers;
  2162. X     while (--j >= 0) {
  2163. X         if (!layers[j].style)
  2164. X             layers[j].style = style_lookup(layers[j].name);
  2165. X         if (1 == sscanf(layers[j].style,
  2166. X                 "G%f",&(grays[j]))) {
  2167. X             order[i++] = j;
  2168. X         } else {
  2169. X             order[j+i] = j;
  2170. X         }
  2171. X     }
  2172. X     /* Now only the first (i) elements need sorting */
  2173. X     /* Sort the array into decreasing gray levels.
  2174. X      * An exchange sort is used on indexes in order[].
  2175. X      * (The number of elements is always small.)
  2176. X      */
  2177. X     while (--i >= 0) {
  2178. X         for (j=0; j<i; j++) {
  2179. X             if (grays[order[j]] >= grays[order[i]])
  2180. X                 continue;
  2181. X             /* swap (put in decreasing order) */
  2182. X             tmp = order[i];
  2183. X             order[i] = order[j];
  2184. X             order[j] = tmp;
  2185. X         }
  2186. X     }
  2187. X }
  2188. X int style_gray(s)    /* returns true if style uses gray fill */
  2189. X     char *s;
  2190. X {
  2191. X     if (*s != 'G') return(0);
  2192. X     ++s;
  2193. X     while ( isdigit(*s) || (*s=='.') ) putchar(*s++);
  2194. X     puts(" setgray");
  2195. X     cur_style = "fill";
  2196. X     return(1);
  2197. X }
  2198. X int style_rest(s)    /* the rest can be done in any order */
  2199. X     char *s;
  2200. X {
  2201. X     if (*s == 'G') {    /* skip a gray fill code (already done)  */
  2202. X         ++s;
  2203. X         while ( isdigit(*s) || *s=='.' ) s++;
  2204. X         while ( isspace(*s) ) s++;
  2205. X     }
  2206. X     if (*s == '\0') return(0);
  2207. X     cur_style = s;
  2208. X     return(1);
  2209. X }
  2210. X set_style(s)        /* set style, i.e. "CSP=stroke" */
  2211. X char *s;
  2212. X {
  2213. X     int i;
  2214. X     char *p;
  2215. X     p = s;
  2216. X     while (isalnum(*p)) p++;    /* find non-alnum */
  2217. X     if (*p) *(p++) = '\0';            /* zap it */
  2218. X     i = layer_lookup(s);
  2219. X     layers[i].style = p;
  2220. X }
  2221. SHAR_EOF
  2222. if test 3885 -ne "`wc -c < 'styles.c'`"
  2223. then
  2224.     echo shar: error transmitting "'styles.c'" '(should have been 3885 characters)'
  2225. fi
  2226. fi # end of overwriting check
  2227. echo shar: extracting "'layerkey.csh'" '(501 characters)'
  2228. if test -f 'layerkey.csh'
  2229. then
  2230.     echo shar: will not over-write existing file "'layerkey.csh'"
  2231. else
  2232. sed 's/^X //' << \SHAR_EOF > 'layerkey.csh'
  2233. X #!/bin/csh -f
  2234. X # shell script to make a color/pattern key for cifplot.
  2235. X # Run this with an arg list of layer names to produce
  2236. X # CIF with a box showing each layer (on standard output).
  2237. X if "$1" == "" then
  2238. X     sh -c "echo $0\: expecting layer list as arguments. >&2"
  2239. X     exit(1)
  2240. X endif
  2241. X echo "( CIF layer key generated by $0 );"
  2242. X echo "DS 1 200 1;"
  2243. X # Write cell definitions, one cell for each layer
  2244. X set Y=1
  2245. X foreach L ($argv[1-])
  2246. X     echo "L $L; B 2 2 1 $Y; 94 $L 1 $Y;"
  2247. X     @ Y += 2
  2248. X end
  2249. X echo "DF;"
  2250. X echo "C 1;"
  2251. X echo End
  2252. SHAR_EOF
  2253. if test 501 -ne "`wc -c < 'layerkey.csh'`"
  2254. then
  2255.     echo shar: error transmitting "'layerkey.csh'" '(should have been 501 characters)'
  2256. fi
  2257. chmod +x 'layerkey.csh'
  2258. fi # end of overwriting check
  2259. echo shar: extracting "'everything.cif'" '(111 characters)'
  2260. if test -f 'everything.cif'
  2261. then
  2262.     echo shar: will not over-write existing file "'everything.cif'"
  2263. else
  2264. sed 's/^X //' << \SHAR_EOF > 'everything.cif'
  2265. X DS 1 100 1;
  2266. X L CMF;
  2267. X B 20 20 10 10;
  2268. X R 10 30 10;
  2269. X P 0 40
  2270. X  10 50
  2271. X  20 40;
  2272. X W 2
  2273. X   0 60
  2274. X  10 60
  2275. X  30 40
  2276. X  30 0;
  2277. X DF;
  2278. X C 1;
  2279. X E
  2280. SHAR_EOF
  2281. if test 111 -ne "`wc -c < 'everything.cif'`"
  2282. then
  2283.     echo shar: error transmitting "'everything.cif'" '(should have been 111 characters)'
  2284. fi
  2285. fi # end of overwriting check
  2286. echo shar: extracting "'scmos-test.cif'" '(3074 characters)'
  2287. if test -f 'scmos-test.cif'
  2288. then
  2289.     echo shar: will not over-write existing file "'scmos-test.cif'"
  2290. else
  2291. sed 's/^X //' << \SHAR_EOF > 'scmos-test.cif'
  2292. X DS 1 25 2;
  2293. X 9 loadadd11;
  2294. X L CMF;
  2295. X     B 48 12 216 3210;
  2296. X     B 120 36 180 3186;
  2297. X     B 36 12 138 3162;
  2298. X C 2 MX R 0 -1 T 12 3348;
  2299. X C 3 R 0 -1 T 276 3996;
  2300. X C 3 R 0 -1 T 876 3996;
  2301. X C 3 R 0 -1 T 1476 3996;
  2302. X C 3 R 0 -1 T 2076 3996;
  2303. X C 3 R 0 -1 T 2676 3996;
  2304. X DF;
  2305. X DS 3 25 2;
  2306. X 9 latch_left_pair;
  2307. X L CMF;
  2308. X     B 48 48 804 540;
  2309. X     B 36 36 810 498;
  2310. X     B 48 36 816 462;
  2311. X     B 48 36 816 162;
  2312. X     B 36 84 810 102;
  2313. X     B 48 48 804 36;
  2314. X C 2 MX R 1 0 T 648 336;
  2315. X C 2 R -1 0 T 648 240;
  2316. X DF;
  2317. X DS 2 25 2;
  2318. X 9 latch;
  2319. X L CWP;
  2320. X     B 888 168 252 0;
  2321. X     B 120 24 204 -96;
  2322. X L CMS;
  2323. X     B 96 300 -228 126;
  2324. X     B 420 48 450 252;
  2325. X     B 240 48 -12 204;
  2326. X     B 48 60 84 150;
  2327. X     B 48 48 480 144;
  2328. X     B 48 36 -12 90;
  2329. X     B 36 48 474 96;
  2330. X     B 528 48 228 48;
  2331. X     B 564 48 6 -48;
  2332. X     B 96 300 612 78;
  2333. X L CMF;
  2334. X     B 108 48 234 252;
  2335. X     B 48 48 -108 204;
  2336. X     B 48 84 -12 186;
  2337. X     B 120 36 -48 126;
  2338. X     B 48 108 84 174;
  2339. X     B 60 48 198 204;
  2340. X     B 48 12 372 222;
  2341. X     B 72 36 360 198;
  2342. X     B 48 48 468 204;
  2343. X     B 48 12 576 222;
  2344. X     B 72 36 588 198;
  2345. X     B 36 84 -90 66;
  2346. X     B 48 48 -12 84;
  2347. X     B 36 96 90 72;
  2348. X     B 36 72 342 144;
  2349. X     B 36 12 474 174;
  2350. X     B 48 24 480 156;
  2351. X     B 216 36 252 90;
  2352. X     B 108 24 450 132;
  2353. X     B 96 24 444 108;
  2354. X     B 48 12 168 66;
  2355. X     B 36 24 342 60;
  2356. X     B 36 36 474 78;
  2357. X     B 60 48 -102 0;
  2358. X     B 144 36 36 6;
  2359. X     B 48 12 -12 -18;
  2360. X     B 48 12 84 -18;
  2361. X     B 48 48 204 0;
  2362. X     B 72 36 360 30;
  2363. X     B 60 36 486 42;
  2364. X     B 36 156 606 102;
  2365. X     B 48 36 372 -6;
  2366. X     B 48 48 504 0;
  2367. X     B 48 48 612 0;
  2368. X     B 108 48 234 -48;
  2369. X L CPG;
  2370. X     B 24 300 -60 102;
  2371. X     B 24 300 36 102;
  2372. X     B 24 120 132 168;
  2373. X     B 24 96 324 180;
  2374. X     B 48 12 420 138;
  2375. X     B 132 24 378 120;
  2376. X     B 24 144 528 180;
  2377. X     B 72 48 156 84;
  2378. X     B 24 84 132 18;
  2379. X     B 24 132 324 42;
  2380. X     B 48 12 420 102;
  2381. X     B 36 24 522 96;
  2382. X     B 24 24 516 72;
  2383. X     B 24 192 624 156;
  2384. X     B 84 24 486 48;
  2385. X     B 84 24 594 48;
  2386. X     B 24 84 456 -6;
  2387. X     B 24 84 564 -6;
  2388. X L CAA;
  2389. X     B 48 48 204 252;
  2390. X     B 48 24 -12 216;
  2391. X     B 48 24 84 216;
  2392. X     B 60 24 198 216;
  2393. X     B 48 24 372 216;
  2394. X     B 432 24 180 192;
  2395. X     B 48 24 468 216;
  2396. X     B 48 24 576 216;
  2397. X     B 156 24 522 192;
  2398. X     B 144 24 -60 12;
  2399. X     B 48 24 -108 -12;
  2400. X     B 48 24 -12 -12;
  2401. X     B 336 24 228 12;
  2402. X     B 48 24 84 -12;
  2403. X     B 48 72 204 -36;
  2404. X     B 48 24 372 -12;
  2405. X     B 156 24 558 12;
  2406. X     B 48 24 504 -12;
  2407. X     B 48 24 612 -12;
  2408. X L CVA;
  2409. X     B 24 24 264 252;
  2410. X     B 24 24 -108 204;
  2411. X     B 24 24 84 144;
  2412. X     B 24 24 480 144;
  2413. X     B 24 24 -12 84;
  2414. X     B 24 24 264 -48;
  2415. X L CCA;
  2416. X     B 24 24 -12 204;
  2417. X     B 24 24 84 204;
  2418. X     B 24 24 198 204;
  2419. X     B 24 24 372 204;
  2420. X     B 24 24 468 204;
  2421. X     B 24 24 576 204;
  2422. X     B 24 24 -108 0;
  2423. X     B 24 24 -12 0;
  2424. X     B 24 24 84 0;
  2425. X     B 24 24 204 0;
  2426. X     B 24 24 372 0;
  2427. X     B 24 24 504 0;
  2428. X     B 24 24 612 0;
  2429. X L CCA;
  2430. X     B 24 24 204 252;
  2431. X     B 24 24 204 -48;
  2432. X L CCP;
  2433. X     B 24 24 420 120;
  2434. X     B 24 24 168 84;
  2435. X L CSP;
  2436. X     B 240 24 60 240;
  2437. X     B 300 24 474 240;
  2438. X     B 684 72 282 192;
  2439. X     B 96 72 204 -60;
  2440. X 94 GND -120 -48 CMS;
  2441. X 94 phi1_bar 456 -48 CPG;
  2442. X 94 Vdd 468 276 CMS;
  2443. X 94 phi1 564 -48 CPG;
  2444. X 94 in 636 0;
  2445. X 94 Vdd 612 -72 CMS;
  2446. X 94 out -108 204 CMF;
  2447. X 94 i1 504 0;
  2448. X 94 i2 168 84;
  2449. X 94 phi2 -60 252 CPG;
  2450. X 94 phi2_bar 36 252 CPG;
  2451. X DF;
  2452. X C 1;
  2453. X End
  2454. SHAR_EOF
  2455. if test 3074 -ne "`wc -c < 'scmos-test.cif'`"
  2456. then
  2457.     echo shar: error transmitting "'scmos-test.cif'" '(should have been 3074 characters)'
  2458. fi
  2459. fi # end of overwriting check
  2460. #    End of shell archive
  2461. exit 0
  2462.  
  2463. Gordon W. Ross    gwr@gomez.mitre.org    (617) 271-3205 (daytime)
  2464. The MITRE Corp. (M/S E025)  Burlington Road, Bedford, MA 01730
  2465.  
  2466.  
  2467.