|
|
1.1 root 1: extern struct _iobuf {
2: int _cnt;
3: char *_ptr;
4: char *_base;
5: short _flag;
6: char _file;
7: } _iob[20];
8: struct _iobuf *fopen();
9: struct _iobuf *fdopen();
10: struct _iobuf *freopen();
11: long ftell();
12: char *fgets();
13: struct _Point {
14: int x;
15: int y;
16: };
17: struct _Rectangle {
18: struct _Point ll;
19: struct _Point ur;
20: };
21: struct _Object {
22: struct _Object *link;
23: };
24: struct _Pool {
25: struct _Object *freelist;
26: struct _Object *arealist;
27: int objsize;
28: };
29: struct _Vpool {
30: struct _Object *next;
31: struct _Object *arealist;
32: int left;
33: int quantum;
34: };
35: struct _SEQFILE {
36: int hidden;
37: };
38: extern char *myname;
39: extern int nullstring;
40: extern char *stringtab;
41: extern char *execname();
42: extern struct _iobuf *chkfopen();
43: extern struct _Pool *newpool();
44: extern struct _Vpool *newvpool();
45: extern char *maketemp();
46: extern char *permspace();
47: extern struct _SEQFILE *seqopen();
48: extern char *strchr();
49: extern char *strrchr();
50: extern char debug;
51: struct _Bsim_hd {
52: int magic;
53: int vdd;
54: int vss;
55: int offtrans;
56: int offcap;
57: int ntrans;
58: int maxnode;
59: int offarrays;
60: int ngroups;
61: int nnodes;
62: int nsws;
63: int nargs;
64: int nops;
65: int nctrls;
66: char clean;
67: };
68: struct _Bsim_tr {
69: char type;
70: char selfgate;
71: int group;
72: int numb;
73: float length;
74: float width;
75: int src;
76: int drn;
77: int gate;
78: };
79: union _Objgroup {
80: struct {
81: char type;
82: char powstr;
83: short nnodes;
84: int nodeoffset;
85: int domoffset;
86: int vssoffset;
87: int vddoffset;
88: } gen;
89: struct {
90: char type;
91: int opoffset;
92: int argoffset;
93: int nodeoffset;
94: } pol;
95: struct {
96: char type;
97: int inoffset;
98: int outoffset;
99: int nodeoffset;
100: } inv;
101: };
102: struct _Objnode {
103: int orignum;
104: int size;
105: int ctrloffset;
106: int swoffset;
107: char selfgate;
108: };
109: struct _Objsw {
110: char flags;
111: char str;
112: short relnode;
113: int gate;
114: };
115: struct _Objctrl {
116: int group;
117: int gate;
118: };
119: extern struct _Bsim_tr *firsttrans ();
120: extern struct _Bsim_tr *nexttrans ();
121: union _Group {
122: struct {
123: union _Group *qlink;
124: struct _Node *nodelist;
125: char type;
126: char powstr;
127: short nnodes;
128: char *domtab;
129: struct _Sw *vsslist;
130: struct _Sw *vddlist;
131: } gen;
132: struct {
133: union _Group *qlink;
134: struct _Node *nodelist;
135: char type;
136: char *oplist;
137: struct _Node **arglist;
138: } pol;
139: struct {
140: union _Group *qlink;
141: struct _Node *nodelist;
142: char type;
143: struct _Node *input;
144: struct _Node *output;
145: } inv;
146: };
147: struct _Delay {
148: struct _Delay *forw;
149: struct _Delay *back;
150: union _Group **ctrllist;
151: struct _Node *node;
152: char delta[3];
153: int when;
154: } ;
155: struct _Node {
156: char val;
157: char nextval;
158: char flags;
159: char size;
160: int orignum;
161: union {
162: union _Group **ctrllist;
163: struct _Delay *delay;
164: } u;
165: struct _Sw *swlist;
166: };
167: struct _Sw {
168: char flags;
169: char str;
170: short relnode;
171: struct _Node *gate;
172: };
173: struct _Tnode {
174: struct _Tnode *forw;
175: struct _Tnode *back;
176: char str0;
177: char str1;
178: char xstr0;
179: char xstr1;
180: char val;
181: struct _Sw *swlist;
182: };
183: extern char nottab [];
184: extern char *nettoname();
185: extern char valstring[];
186: extern char dqueue;
187: extern char devalgen;
188: extern char ddelay;
189: extern struct _Node *findnode();
190: extern struct _Node *nettonode();
191: extern union _Group *nodetogroup();
192: extern union _Group **getctrllist();
193: extern char debug;
194: extern struct _SEQFILE *objfile;
195: extern struct _Bsim_hd header;
196: extern union _Group *group;
197: extern union _Group **ctrl;
198: extern struct _Node *node;
199: extern struct _Sw *sw;
200: extern struct _Node **arg;
201: extern char *op;
202: extern struct _Tnode *tnode;
203: extern struct _Tnode *list;
204: extern union _Group endofq;
205: extern union _Group *firstonq;
206: extern union _Group *lastonq;
207: static struct _Node *firstnode, *lastnode;
208: static struct _Tnode *pasttnode;
209: static struct _Tnode *toplist;
210: static char anyxs;
211: static char *tnodename (this)
212: register struct _Tnode *this;
213: {
214: register int n;
215: switch (n = this - tnode) {
216: case 0:
217: return "vss";
218: case 1:
219: return "vdd";
220: default:
221: return nettoname (firstnode[n-2].orignum);
222: }
223: }
224: prop_on (domtab)
225: register char *domtab;
226: {
227: register struct _Tnode *this, *that, *newl;
228: register struct _Sw *s;
229: struct _Tnode *l;
230: char v;
231: for (l = toplist; l > &list[0]; l--) {
232: if (devalgen)
233: printf ("prop_on level %d\n", l-list);
234: for (this = l->forw; this != l; this = this->forw) {
235: if (this->str0 == l->str0) {
236: if ( (domtab[this->str1] >= ( this->str0)))
237: continue;
238: if (this->str1 == this->str0) {
239: { if (devalgen) printf ("\tonprop from %s, myval_%d\n", tnodename(this), 2); s = this->swlist; if (s != 0) { for (;;) { switch (s->gate->val) { default: fatal ("bad val"); case 2: anyxs = 1; break; case 0: if ( ! (s->flags & 0x02)) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; goto labx; case 1: if (s->flags & 0x02) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; labx: if (2 != 1) { { (v) = ( this->str0); if (( this->str0) > ( s->str)) (v) = ( s->str); }; if (v > that->str0) { that->str0 = v; if (v > that->str1) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } if (2 != 0) { { (v) = ( this->str1); if (( this->str1) > ( s->str)) (v) = ( s->str); }; if (v > that->str1) { that->str1 = v; if (v > that->str0) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } break; } if (s->flags & 0x04) break; s++; } } };
240: continue;
241: } else {
242: { if (devalgen) printf ("\tonprop from %s, myval_%d\n", tnodename(this), 0); s = this->swlist; if (s != 0) { for (;;) { switch (s->gate->val) { default: fatal ("bad val"); case 2: anyxs = 1; break; case 0: if ( ! (s->flags & 0x02)) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; goto lab0; case 1: if (s->flags & 0x02) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; lab0: if (0 != 1) { { (v) = ( this->str0); if (( this->str0) > ( s->str)) (v) = ( s->str); }; if (v > that->str0) { that->str0 = v; if (v > that->str1) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } if (0 != 0) { { (v) = ( this->str1); if (( this->str1) > ( s->str)) (v) = ( s->str); }; if (v > that->str1) { that->str1 = v; if (v > that->str0) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } break; } if (s->flags & 0x04) break; s++; } } };
243: if ( (domtab[this->str0] >= ( this->str1)))
244: continue;
245: if (this->str0 < this->str1)
246: continue;
247: newl = &list[this->str1];
248: }
249: } else {
250: if ( (domtab[this->str0] >= ( this->str1)))
251: continue;
252: { if (devalgen) printf ("\tonprop from %s, myval_%d\n", tnodename(this), 1); s = this->swlist; if (s != 0) { for (;;) { switch (s->gate->val) { default: fatal ("bad val"); case 2: anyxs = 1; break; case 0: if ( ! (s->flags & 0x02)) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; goto lab1; case 1: if (s->flags & 0x02) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; lab1: if (1 != 1) { { (v) = ( this->str0); if (( this->str0) > ( s->str)) (v) = ( s->str); }; if (v > that->str0) { that->str0 = v; if (v > that->str1) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } if (1 != 0) { { (v) = ( this->str1); if (( this->str1) > ( s->str)) (v) = ( s->str); }; if (v > that->str1) { that->str1 = v; if (v > that->str0) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } break; } if (s->flags & 0x04) break; s++; } } };
253: if ( (domtab[this->str1] >= ( this->str0)))
254: continue;
255: if (this->str1 < this->str0)
256: continue;
257: newl = &list[this->str0];
258: }
259: that = this->forw;
260: { (this)->forw->back = (this)->back; (this)->back->forw = (this)->forw; };
261: { (this)->back = ( newl)->back; ( newl)->back = (this); (this)->forw = ( newl); (this)->back->forw = (this); };
262: this = that->back;
263: }
264: }
265: }
266: prop_xon (domtab)
267: register char *domtab;
268: {
269: register struct _Tnode *this, *that, *newl;
270: register struct _Sw *s;
271: struct _Tnode *l;
272: char v;
273: for (l = toplist; l > &list[0]; l--) {
274: if (devalgen)
275: printf ("prop_xon level %d\n", l-list);
276: for (this = l->forw; this != l; this = this->forw) {
277: if (this->xstr0 == l->str0) {
278: if ( (domtab[this->xstr1] >= ( this->xstr0)))
279: continue;
280: if (this->xstr1 == this->xstr0) {
281: { if (devalgen) printf ("\txonprop from %s, myval_%d\n", tnodename(this), 2); s = this->swlist; if (s != 0) { for (;;) { switch (s->gate->val) { default: fatal ("bad val"); case 0: if ( ! (s->flags & 0x02)) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; goto labx; case 2: that = &tnode[s->relnode]; if (s->flags & 0x02) { if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; } else { if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; } goto labx; case 1: if (s->flags & 0x02) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; labx: if (2 != 1) { { (v) = ( this->xstr0); if (( this->xstr0) > ( s->str)) (v) = ( s->str); }; if (v > that->xstr0) { that->xstr0 = v; if (v > that->xstr1) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } if (2 != 0) { { (v) = ( this->xstr1); if (( this->xstr1) > ( s->str)) (v) = ( s->str); }; if (v > that->xstr1) { that->xstr1 = v; if (v > that->xstr0) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } break; } if (s->flags & 0x04) break; s++; } } };
282: continue;
283: } else {
284: { if (devalgen) printf ("\txonprop from %s, myval_%d\n", tnodename(this), 0); s = this->swlist; if (s != 0) { for (;;) { switch (s->gate->val) { default: fatal ("bad val"); case 0: if ( ! (s->flags & 0x02)) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; goto lab0; case 2: that = &tnode[s->relnode]; if (s->flags & 0x02) { if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; } else { if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; } goto lab0; case 1: if (s->flags & 0x02) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; lab0: if (0 != 1) { { (v) = ( this->xstr0); if (( this->xstr0) > ( s->str)) (v) = ( s->str); }; if (v > that->xstr0) { that->xstr0 = v; if (v > that->xstr1) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } if (0 != 0) { { (v) = ( this->xstr1); if (( this->xstr1) > ( s->str)) (v) = ( s->str); }; if (v > that->xstr1) { that->xstr1 = v; if (v > that->xstr0) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } break; } if (s->flags & 0x04) break; s++; } } };
285: if ( (domtab[this->xstr0] >= ( this->xstr1)))
286: continue;
287: if (this->xstr0 < this->xstr1)
288: continue;
289: newl = &list[this->xstr1];
290: }
291: } else {
292: if ( (domtab[this->xstr0] >= ( this->xstr1)))
293: continue;
294: { if (devalgen) printf ("\txonprop from %s, myval_%d\n", tnodename(this), 1); s = this->swlist; if (s != 0) { for (;;) { switch (s->gate->val) { default: fatal ("bad val"); case 0: if ( ! (s->flags & 0x02)) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; goto lab1; case 2: that = &tnode[s->relnode]; if (s->flags & 0x02) { if (s->flags & 0x08 && this->val == 0 && that->val == 0) break; } else { if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; } goto lab1; case 1: if (s->flags & 0x02) break; that = &tnode[s->relnode]; if (s->flags & 0x08 && this->val == 1 && that->val == 1) break; lab1: if (1 != 1) { { (v) = ( this->xstr0); if (( this->xstr0) > ( s->str)) (v) = ( s->str); }; if (v > that->xstr0) { that->xstr0 = v; if (v > that->xstr1) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } if (1 != 0) { { (v) = ( this->xstr1); if (( this->xstr1) > ( s->str)) (v) = ( s->str); }; if (v > that->xstr1) { that->xstr1 = v; if (v > that->xstr0) { { (that)->forw->back = (that)->back; (that)->back->forw = (that)->forw; }; newl = &list[v]; { (that)->back = ( newl)->back; ( newl)->back = (that); (that)->forw = ( newl); (that)->back->forw = (that); }; } } } break; } if (s->flags & 0x04) break; s++; } } };
295: if ( (domtab[this->xstr1] >= ( this->xstr0)))
296: continue;
297: if (this->xstr1 < this->xstr0)
298: continue;
299: newl = &list[this->xstr0];
300: }
301: that = this->forw;
302: { (this)->forw->back = (this)->back; (this)->back->forw = (this)->forw; };
303: { (this)->back = ( newl)->back; ( newl)->back = (this); (this)->forw = ( newl); (this)->back->forw = (this); };
304: this = that->back;
305: }
306: }
307: }
308: dumpstr (s, domtab)
309: char *s;
310: char *domtab;
311: {
312: register struct _Tnode *this;
313: puts (s);
314: for (this = &tnode[2]; this < pasttnode; this++)
315: printf ("\ttnode[%d] %s str0=%d>%d str1=%d>%d\n",
316: this-tnode, nettoname(firstnode[this-tnode-2].orignum),
317: this->str0, domtab[this->str0],
318: this->str1, domtab[this->str1]
319: );
320: }
321: dumpxstr (s, domtab)
322: char *s;
323: char *domtab;
324: {
325: register struct _Tnode *this;
326: puts (s);
327: for (this = &tnode[2]; this < pasttnode; this++) {
328: printf ("\ttnode[%d] %s ",
329: this-tnode, nettoname(firstnode[this-tnode-2].orignum)
330: );
331: printf ("str0=%d str1=%d xstr0=%d xstr1=%d\n",
332: this->str0, domtab[this->str0],
333: this->str1, domtab[this->str1],
334: this->xstr0, domtab[this->xstr0],
335: this->xstr1, domtab[this->xstr1]
336: );
337: }
338: }
339: evalgen (g)
340: register union _Group *g;
341: {
342: register struct _Node *n;
343: register struct _Tnode *this, *l;
344: register char *domtab;
345: char v;
346: if (devalgen)
347: printf ("evalgen group %d\n", g - group);
348: domtab = g->gen.domtab;
349: firstnode = g->gen.nodelist;
350: lastnode = &firstnode[g->gen.nnodes - 3];
351: tnode[0].str0 = tnode[1].str1 = g->gen.powstr;
352: tnode[0].str1 = tnode[0].str1 = 0;
353: toplist = &list[g->gen.powstr];
354: v = 0;
355: for (l = &list[0]; l <= toplist; l++) {
356: l->forw = l->back = l;
357: l->str0 = v++;
358: }
359: tnode[0].swlist = g->gen.vsslist;
360: tnode[1].swlist = g->gen.vddlist;
361: { (&tnode[0])->back = ( toplist)->back; ( toplist)->back = (&tnode[0]); (&tnode[0])->forw = ( toplist); (&tnode[0])->back->forw = (&tnode[0]); };
362: { (&tnode[1])->back = ( toplist)->back; ( toplist)->back = (&tnode[1]); (&tnode[1])->forw = ( toplist); (&tnode[1])->back->forw = (&tnode[1]); };
363:
364: this = &tnode[2];
365: for (n = firstnode; n <= lastnode; this++, n++) {
366: this->swlist = n->swlist;
367: this->val = n->val;
368: v = n->size;
369: if (n->flags & 0x08)
370: v = g->gen.powstr;
371: switch (n->val) {
372: case 0:
373: this->str0 = v;
374: this->str1 = 0;
375: break;
376: case 1:
377: this->str0 = 0;
378: this->str1 = v;
379: break;
380: case 2:
381: this->str0 = v;
382: this->str1 = v;
383: break;
384: }
385: l = &list[v];
386: { (this)->back = ( l)->back; ( l)->back = (this); (this)->forw = ( l); (this)->back->forw = (this); };
387: }
388: pasttnode = this;
389:
390: anyxs = 0;
391: if (devalgen)
392: dumpstr ("before prop over 1's", domtab);
393: prop_on (domtab);
394: if (devalgen)
395: dumpstr ("after prop over 1's", domtab);
396:
397: if (! anyxs) {
398: this = &tnode[2];
399: for (n = firstnode; n <= lastnode; n++, this++) {
400: if ( (domtab[this->str0] >= ( this->str1))) {
401: if (n->nextval != 0)
402: assign (n, 0, 1);
403: } else if ( (domtab[this->str1] >= ( this->str0))) {
404: if (n->nextval != 1)
405: assign (n, 1, 1);
406: } else {
407: if (n->nextval != 2)
408: assign (n, 2, 1);
409: }
410: }
411: return;
412: }
413:
414: for (l = &list[0]; l <= toplist; l++)
415: l->forw = l->back = l;
416: for (this = tnode; this < pasttnode; this++) {
417: this->xstr0 = this->str0;
418: this->xstr1 = this->str1;
419: if (this->xstr0 > this->xstr1)
420: l = &list[this->xstr0];
421: else
422: l = &list[this->xstr1];
423: { (this)->back = ( l)->back; ( l)->back = (this); (this)->forw = ( l); (this)->back->forw = (this); };
424: }
425: prop_xon (domtab);
426: if (devalgen)
427: dumpxstr ("after prop over X's", domtab);
428:
429: this = &tnode[2];
430: for (n = firstnode; n <= lastnode; n++, this++) {
431: if ( (domtab[this->str0] >= ( this->str1)) && (domtab[this->str0] >= ( this->xstr1))) {
432: if (n->nextval != 0)
433: assign (n, 0, 1);
434: } else if ( (domtab[this->str1] >= ( this->str0)) && (domtab[this->str1] >= ( this->xstr0))) {
435: if (n->nextval != 1)
436: assign (n, 1, 1);
437: } else {
438: if (n->nextval != 2)
439: assign (n, 2, 1);
440: }
441: }
442: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.