|
|
1.1 root 1: /*******************************************************************
2: * *
3: * File: CIFPLOT/extractor.c *
4: * Written by Dan Fitzpatrick *
5: * copyright 1980 -- Regents of the University of California *
6: * *
7: ********************************************************************/
8:
9: #include <stdio.h>
10: #include "defs.h"
11: #include "globals.h"
12: #include "structs.h"
13: #include "out_structs.h"
14: #include "ext_defs.h"
15:
16: #define EXTRACTOR "/vb/grad/fitz/bin/extnmos"
17:
18: #define TEMP_FILE "/usr/tmp/cextXXXXXX"
19:
20: #define EXT_WRITE(x,n) if(write(extFileDesc,x,n) != n) { \
21: perror(extTempFile);\
22: Error("Bad write on extractor temp file",RUNTIME);\
23: }
24: #define DECL_LAYER(name,n) l = FindLayer(name);\
25: if(l == NIL) {\
26: Error("NMOS layer not defined",INTERNAL);\
27: }\
28: ExtMap[l->LNum] = n;
29:
30: IMPORT char *mktemp();
31: IMPORT struct LCell *FindLayer();
32:
33: char *extTempFile;
34: int extPassword = EXT_MAGIC_WORD;
35: int extFileDesc;
36: int *ExtMap; /* map from cifplot internal form to standard form */
37: int ExtRecordSize; /* number of bytes for each record */
38:
39:
40: InitExtractor() {
41: int i;
42: struct LCell *l;
43:
44: ExtRecordSize = MAX(sizeof(struct ExtNewSwathRecord),
45: sizeof(struct ExtEdgeRecord));
46: ExtRecordSize = MAX(sizeof(struct ExtPointRecord),ExtRecordSize);
47: SetScale = 1;
48: scale = 0.02;
49:
50: /* Make Extractor Map */
51: ExtMap = (int *) alloc((MaxLayers+9)*sizeof(int));
52: for(i=0;i<MaxLayers+9;i++)
53: ExtMap[i] = -1;
54: DECL_LAYER("NM",METAL);
55: DECL_LAYER("NI",IMPLANT);
56: DECL_LAYER("NP",POLY);
57: DECL_LAYER("ND",DIFFUSION);
58: DECL_LAYER("NC",CUT);
59: DECL_LAYER("NB",BURIED);
60: }
61:
62: OpenExtractor() {
63: int i;
64:
65: extTempFile = mktemp(TEMP_FILE);
66: if((extFileDesc = creat(extTempFile,0666)) < 0) {
67: perror(extTempFile);
68: Error("Can't create extractor temp file",RUNTIME);
69: }
70: EXT_WRITE(&extPassword,sizeof(int));
71: EXT_WRITE(&ConvertFactor,sizeof(double));
72: i = Window.ymin;
73: EXT_WRITE(&i,sizeof(int));
74: }
75:
76: int extPrev;
77:
78: ExtractorOutput(xcurrent)
79: int xcurrent;
80: {
81: struct ExtNewSwathRecord tmp;
82: tmp.type = NEW_SWATH;
83: tmp.top = xcurrent;
84: tmp.bottom = extPrev;
85: EXT_WRITE(&tmp,ExtRecordSize);
86: extPrev = xcurrent;
87: }
88:
89: /**** THIS SHOULD BE BUFFERED ****/
90: OutputExtEdge(x,deltax,layer,start)
91: real x,deltax;
92: int layer,start;
93: {
94: struct ExtEdgeRecord tmp;
95: tmp.layer = ExtMap[layer];
96: if(tmp.layer == -1) return;
97: tmp.type = EXT_EDGE;
98: tmp.x = x;
99: tmp.deltax = deltax;
100: tmp.start = start;
101: EXT_WRITE(&tmp,ExtRecordSize);
102: }
103:
104: OutputExtPoint(y,x,name,layer)
105: real x,y;
106: char *name;
107: int layer;
108: {
109: struct ExtPointRecord tmp;
110: if(layer == -1)
111: tmp.layer = ALL;
112: else
113: tmp.layer = ExtMap[layer];
114: tmp.type = EXT_POINT;
115: tmp.x = CONVERT(x);
116: tmp.y = CONVERT(y);
117: tmp.name = strlen(name);
118: EXT_WRITE(&tmp,ExtRecordSize);
119: EXT_WRITE(name,tmp.name);
120: }
121:
122: Extract() {
123: if(close(extFileDesc) < 0) {
124: perror(extTempFile);
125: Error("Can't close extractor temp file",RUNTIME);
126: }
127: if(!debug) {
128: /*
129: execl(EXTRACTOR,EXTRACTOR,extTempFile,baseName,0);
130: perror(EXTRACTOR);
131: */
132: Error("Can't run extractor",INTERNAL);
133: }
134: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.