2
* Electric(tm) VLSI Design System
5
* PLA generator for CMOS
6
* Written by: Wallace Kroeker at the University of Calgary
8
* Copyright (c) 2000 Static Free Software.
10
* Electric(tm) is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* Electric(tm) is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with Electric(tm); see the file COPYING. If not, write to
22
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23
* Boston, Mass 02111-1307, USA.
25
* Static Free Software
27
* Portola Valley, California 94028
28
* info@staticfreesoft.com
38
/* prototypes for local routines */
39
static NODEINST *plac_decode_bufs(NODEPROTO*, NODEINST*, NODEPROTO*, NODEINST*, NODEPROTO*, INTBIG,
41
static void plac_dec_exp(NODEPROTO*, NODEINST*, NODEPROTO*);
42
static BOOLEAN plac_decode_route(NODEPROTO*, NODEINST*, NODEPROTO*, NODEINST*, NODEPROTO*, NODEINST*,
45
NODEPROTO *plac_decode_gen(LIBRARY *library, NODEPROTO *pmos_np, NODEPROTO *nmos_np,
46
char *facet_name, INTBIG INPUTS)
49
NODEINST *p_ni, *n_ni, *first_buf, *last_buf;
52
decode_np = newnodeproto(facet_name, library);
53
p_ni = plac_make_instance(decode_np, pmos_np, 0, 0, FALSE);
54
if (p_ni == NONODEINST) return(NONODEPROTO);
55
modifynodeinst(p_ni, 0, 0, 0, 0, 2700, 0); /* rotate by 90 degrees */
57
X = p_ni->geom->highx - p_ni->geom->lowx; /* CHG */
59
X = X + 0 + 12*pla_lam; /* SEPARATION */
61
n_ni = plac_make_instance(decode_np, nmos_np, X, 0, FALSE);
62
if (n_ni == NONODEINST) return(NONODEPROTO);
63
modifynodeinst(n_ni, 0, 0, 0, 0, 2700, 0); /* rotate by 90 degrees */
65
first_buf = plac_decode_bufs(pmos_np, p_ni, nmos_np, n_ni, decode_np, X, &last_buf, INPUTS);
66
if (first_buf == NONODEINST) return(NONODEPROTO);
67
if (plac_decode_route(pmos_np, p_ni, nmos_np, n_ni, decode_np, first_buf,
68
last_buf, INPUTS)) return(NONODEPROTO);
69
plac_dec_exp(nmos_np, n_ni, decode_np);
71
/* ensure that the facet is the proper size */
72
(*el_curconstraint->solve)(decode_np);
77
NODEINST *plac_decode_bufs(NODEPROTO *pmos_np, NODEINST *p_ni, NODEPROTO *nmos_np,
78
NODEINST *n_ni, NODEPROTO *decode_np, INTBIG X, NODEINST **last_buf, INTBIG INPUTS)
80
NODEINST *first_p_ni, *last_p_ni, *last_n_ni, *newno, *newno_2;
81
PORTPROTO *pwr_e_pp, *pwr_w_pp, *gnd_e_pp, *gnd_w_pp, *p_pp, *n_pp;
84
char a_name[60], i_name[60], side;
85
INTBIG rows, diff, limit, x, i, cnt, Y, X_offset, amt_1, amt_2;
86
INTBIG lowx, lowy, highy;
89
first_p_ni = last_p_ni = last_n_ni = NONODEINST;
90
var = getval((INTBIG)pmos_np, VNODEPROTO, VINTEGER, "PLA_access_rows");
91
if (var != NOVARIABLE) rows = (INTBIG)((INTBIG *)var->addr); else
93
ttyputerr(_("ACCESS_rows defaulting to 2"));
97
if (INPUTS == TRUE) side = 'e'; else side = 'w';
98
lowx = p_ni->geom->lowx; /* highx = p_ni->geom->highx; */
99
lowy = p_ni->geom->lowy; highy = p_ni->geom->highy;
100
buf_np = getnodeproto("decoder_inv1");
101
if (buf_np != NONODEPROTO)
103
diff = (INTBIG)(buf_np->highy - buf_np->lowy);
104
if (diff < 0) diff = -diff;
106
if ((limit == 0) || ((rows % 4) != 0)) limit = limit + 1;
108
if (INPUTS == TRUE) Y = lowy - diff; else Y = highy;
110
if ((rows %4) == 0) X_offset = lowx - 18*pla_lam; else
111
X_offset = lowx - 38*pla_lam;
112
(void)sprintf(a_name, "PWR.m-2.w");
113
(void)sprintf(i_name, "PWR.m-2.e");
114
pwr_w_pp = getportproto(buf_np, a_name);
115
pwr_e_pp = getportproto(buf_np, i_name);
116
(void)sprintf(a_name, "GND.m-2.w");
117
(void)sprintf(i_name, "GND.m-2.e");
118
gnd_w_pp = getportproto(buf_np, a_name);
119
gnd_e_pp = getportproto(buf_np, i_name);
120
for (i= limit; i > 0; i--)
122
newno = plac_make_instance(decode_np, buf_np,
123
i*50*pla_lam + X_offset, Y, FALSE);
124
if (newno == NONODEINST) return(NONODEINST);
125
newno_2 = plac_make_instance(decode_np, buf_np,
126
X + i*50*pla_lam + X_offset, Y, FALSE);
127
if (newno_2 == NONODEINST) return(NONODEINST);
130
if (newno_2->transpose == 0) amt_2 = 900; else amt_2 = 2700;
131
if (newno->transpose == 0) amt_1 = 900; else amt_1 = 2700;
133
/* rotate by 90 degrees */
134
modifynodeinst(newno_2, 0, 0, 0, 0, 1800, 0);
135
modifynodeinst(newno, 0, 0, 0, 0, 1800, 0);
138
modifynodeinst(newno_2, 0, 0, 0, 0, amt_2, 1-newno_2->transpose*2);
139
modifynodeinst(newno, 0, 0, 0, 0, amt_1, 1-newno->transpose*2);
141
if ((last_p_ni == NONODEINST) && (last_n_ni == NONODEINST))
143
(void)newportproto(decode_np, newno_2, pwr_e_pp, "PWR.m-2.e");
144
(void)newportproto(decode_np, newno_2, gnd_e_pp, "GND.m-2.e");
145
first_p_ni = last_p_ni = newno;
146
last_n_ni = *last_buf = newno_2;
150
if ((pwr_w_pp != NOPORTPROTO) && (pwr_e_pp != NOPORTPROTO))
152
plac_wire("Metal-2", 14*pla_lam, last_p_ni,
153
pwr_w_pp, newno, pwr_e_pp, decode_np);
154
plac_wire("Metal-2", 14*pla_lam, last_n_ni,
155
pwr_w_pp, newno_2, pwr_e_pp, decode_np);
157
if ((gnd_w_pp != NOPORTPROTO) && (gnd_e_pp != NOPORTPROTO))
159
plac_wire("Metal-2", 14*pla_lam, last_n_ni,
160
gnd_w_pp, newno, gnd_e_pp, decode_np);
161
plac_wire("Metal-2", 14*pla_lam, last_n_ni,
162
gnd_w_pp, newno_2, gnd_e_pp, decode_np);
167
for (x = cnt; x < cnt+4; x++)
169
(void)sprintf(a_name, "ACCESS%ld.m-1.%c", x, side);
170
(void)sprintf(i_name, "LINE%ld.p.n", x % 4);
171
p_pp = getportproto(pmos_np, a_name);
172
n_pp = getportproto(buf_np, i_name);
173
if ((p_pp != NOPORTPROTO) && (n_pp != NOPORTPROTO))
174
plac_wire("Polysilicon", 2*pla_lam, p_ni, p_pp,
175
newno, n_pp, decode_np);
176
p_pp = getportproto(nmos_np, a_name);
177
if ((n_pp != NOPORTPROTO) && (p_pp != NOPORTPROTO))
178
plac_wire("Polysilicon", 2*pla_lam, n_ni, p_pp,
179
newno_2, n_pp, decode_np);
184
if ((pwr_w_pp != NOPORTPROTO) && (pwr_e_pp != NOPORTPROTO))
186
plac_wire("Metal-2", 14*pla_lam, last_n_ni, pwr_w_pp,
187
first_p_ni, pwr_e_pp, decode_np);
188
(void)newportproto(decode_np, last_p_ni, pwr_w_pp, "PWR.m-2.w");
190
if ((gnd_w_pp != NOPORTPROTO) && (gnd_e_pp != NOPORTPROTO))
192
plac_wire("Metal-2", 14*pla_lam, last_n_ni, gnd_w_pp,
193
first_p_ni, gnd_e_pp, decode_np);
194
(void)newportproto(decode_np, last_p_ni, gnd_w_pp, "GND.m-2.w");
199
void plac_dec_exp(NODEPROTO *nmos_np, NODEINST *n_ni, NODEPROTO *decode_np)
202
char name[100], side;
206
(void)sprintf(name, "DATA%ld.m-1.%c", x, side);
207
pp = getportproto(nmos_np, name);
208
while (pp != NOPORTPROTO)
210
(void)newportproto(decode_np, n_ni, pp, name);
212
(void)sprintf(name, "DATA%ld.m-1.%c", x, side);
213
pp = getportproto(nmos_np, name);
217
BOOLEAN plac_decode_route(NODEPROTO *pmos_np, NODEINST *p_ni, NODEPROTO *nmos_np,
218
NODEINST *n_ni, NODEPROTO *decode_np, NODEINST *first_buf, NODEINST *last_buf, INTBIG INPUTS)
220
INTBIG cnt, pwr_cnt, in_cnt, sep;
222
PORTPROTO *p_pp, *n_pp, *pwr_pp;
223
NODEINST *pm_ni_1, *pm_ni_2;
224
INTBIG p_X, p_Y, n_X, n_Y, Y;
231
/*** Make connection between N and P planes ***/
232
(void)sprintf(name, "DATA%d.m-1.n", 0);
233
p_pp = getportproto(pmos_np, name);
234
(void)sprintf(name, "DATA%d.m-1.s", 0);
235
n_pp = getportproto(nmos_np, name);
237
while ((p_pp != NOPORTPROTO) && (n_pp != NOPORTPROTO))
239
/* Connect them up here */
240
plac_wire("Metal-1", 4*pla_lam, p_ni, p_pp, n_ni, n_pp, decode_np);
242
/* now find the next ports */
244
(void)sprintf(name, "DATA%ld.m-1.n", cnt);
245
p_pp = getportproto(pmos_np, name);
246
(void)sprintf(name, "DATA%ld.m-1.s", cnt);
247
n_pp = getportproto(nmos_np, name);
250
/*** Make connection between PWR and P-plane ***/
251
(void)sprintf(name, "DATA%d.m-1.s", 0);
252
p_pp = getportproto(pmos_np, name);
253
(void)sprintf(name, "PWR%d.m-1.s", 0);
254
n_pp = getportproto(pmos_np, name);
255
if ((p_pp != NOPORTPROTO) && (n_pp != NOPORTPROTO))
256
plac_wire("Metal-1", 4*pla_lam, p_ni, p_pp, p_ni, n_pp, decode_np);
257
portposition(p_ni, n_pp, &p_X, &p_Y);
258
pm_ni_1 = plac_make_Pin(decode_np, p_X-13*pla_lam, p_Y,
259
6*pla_lam, "Metal-1-Metal-2-Con");
260
if (pm_ni_1 == NONODEINST) return(TRUE);
261
plac_wire("Metal-1", 4*pla_lam, p_ni, n_pp, pm_ni_1,
262
pm_ni_1->proto->firstportproto, decode_np);
263
if (INPUTS != TRUE) /* Buffers are at the top of the facet */
265
pwr_pp = getportproto(first_buf->proto, "PWR.m-2.w");
266
pm_ni_2 = plac_make_Pin(decode_np, p_X-13*pla_lam,
267
p_Y+24*pla_lam, 14*pla_lam, "Metal-2-Pin");
268
if (pm_ni_2 == NONODEINST) return(TRUE);
269
plac_wire("Metal-2", 14*pla_lam, pm_ni_1,
270
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
271
plac_wire("Metal-2", 14*pla_lam, first_buf, pwr_pp,
272
pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
275
(void)sprintf(name, "DATA%d.m-1.s", 1);
276
p_pp = getportproto(pmos_np, name);
279
while ((p_pp != NOPORTPROTO) && (n_pp != NOPORTPROTO))
281
/* Connect them up here */
282
plac_wire("Metal-1", 4*pla_lam, p_ni, p_pp, p_ni, n_pp, decode_np);
284
/* now find the next ports */
290
(void)sprintf(name, "PWR%ld.m-1.s", pwr_cnt);
291
p_pp = getportproto(pmos_np, name);
292
if (p_pp != NOPORTPROTO)
293
plac_wire("Metal-1", 4*pla_lam, p_ni, p_pp, p_ni, n_pp, decode_np);
294
portposition(p_ni, p_pp, &p_X, &p_Y);
295
pm_ni_2 = plac_make_Pin(decode_np, p_X-13*pla_lam, p_Y,
296
6*pla_lam, "Metal-1-Metal-2-Con");
297
if (pm_ni_2 == NONODEINST) return(TRUE);
298
plac_wire("Metal-1", 4*pla_lam, p_ni, p_pp, pm_ni_2,
299
pm_ni_2->proto->firstportproto, decode_np);
300
plac_wire("Metal-2", 14*pla_lam, pm_ni_1,
301
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
305
(void)sprintf(name, "DATA%ld.m-1.s", cnt);
306
p_pp = getportproto(pmos_np, name);
308
if (INPUTS == TRUE) /* Buffers are at the top of the facet */
310
pwr_pp = getportproto(first_buf->proto, "PWR.m-2.w");
311
pm_ni_2 = plac_make_Pin(decode_np, p_X-13*pla_lam,
312
p_Y-24*pla_lam, 14*pla_lam, "Metal-2-Pin");
313
if (pm_ni_2 == NONODEINST) return(TRUE);
314
plac_wire("Metal-2", 14*pla_lam, pm_ni_1,
315
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
316
plac_wire("Metal-2", 14*pla_lam, first_buf, pwr_pp,
317
pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
320
/*** Make connection between GND and N-plane ***/
321
(void)sprintf(name, "GND%d.m-1.n", 0);
322
n_pp = getportproto(nmos_np, name);
323
portposition(n_ni, n_pp, &p_X, &p_Y);
324
pm_ni_1 = plac_make_Pin(decode_np, p_X+13*pla_lam, p_Y,
325
6*pla_lam, "Metal-1-Metal-2-Con");
326
if (pm_ni_1 == NONODEINST) return(TRUE);
327
plac_wire("Metal-1", 4*pla_lam, n_ni, n_pp, pm_ni_1,
328
pm_ni_1->proto->firstportproto, decode_np);
329
if (INPUTS != TRUE) /* Buffers are at the top of the facet */
331
pwr_pp = getportproto(last_buf->proto, "GND.m-2.e");
332
pm_ni_2 = plac_make_Pin(decode_np, p_X+13*pla_lam,
333
p_Y+90*pla_lam, 14*pla_lam, "Metal-2-Pin");
334
if (pm_ni_2 == NONODEINST) return(TRUE);
335
plac_wire("Metal-2", 14*pla_lam, pm_ni_1,
336
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
337
plac_wire("Metal-2", 14*pla_lam, last_buf, pwr_pp,
338
pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
341
(void)sprintf(name, "GND%ld.m-1.n", cnt);
342
n_pp = getportproto(nmos_np, name);
343
while (n_pp != NOPORTPROTO)
345
/* Connect them up here */
346
portposition(n_ni, n_pp, &p_X, &p_Y);
347
pm_ni_2 = plac_make_Pin(decode_np, p_X+13*pla_lam, p_Y,
348
6*pla_lam, "Metal-1-Metal-2-Con");
349
if (pm_ni_2 == NONODEINST) return(TRUE);
350
plac_wire("Metal-1", 4*pla_lam, n_ni, n_pp, pm_ni_2,
351
pm_ni_2->proto->firstportproto, decode_np);
352
plac_wire("Metal-2", 14*pla_lam, pm_ni_1,
353
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
356
(void)sprintf(name, "GND%ld.m-1.n", cnt);
357
n_pp = getportproto(nmos_np, name);
359
if (INPUTS == TRUE) /* Buffers are at the bottom of the facet */
361
pwr_pp = getportproto(last_buf->proto, "GND.m-2.e");
362
pm_ni_2 = plac_make_Pin(decode_np, p_X+13*pla_lam,
363
p_Y-90*pla_lam, 14*pla_lam, "Metal-2-Pin");
364
if (pm_ni_2 == NONODEINST) return(TRUE);
365
plac_wire("Metal-2", 14*pla_lam, pm_ni_1,
366
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
367
plac_wire("Metal-2", 14*pla_lam, last_buf, pwr_pp,
368
pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
380
var = getval((INTBIG)pmos_np, VNODEPROTO, VINTEGER, "PLA_access_rows");
381
if (var != NOVARIABLE)
383
columns = (INTBIG)((INTBIG *)var->addr);
387
ttyputerr(_("DATA_cols defaulting to 2"));
391
init_offset = 8*pla_lam;
394
(void)sprintf(name, "ACCESS%ld.m-1.%c", cnt, ac_side);
395
p_pp = getportproto(pmos_np, name);
396
n_pp = getportproto(nmos_np, name);
397
while ((p_pp != NOPORTPROTO) && (n_pp != NOPORTPROTO))
401
portposition(p_ni, p_pp, &p_X, &p_Y);
402
portposition(n_ni, n_pp, &n_X, &n_Y);
405
Y = n_Y + init_offset + in_cnt*sep;
406
O_Y = Y + (columns - in_cnt - 1)*sep;
409
Y = n_Y - init_offset - in_cnt*sep;
410
O_Y = Y - (columns - in_cnt - 1)*sep;
412
pm_ni_1 = plac_make_Pin(decode_np, p_X, Y, 6*pla_lam,
413
"Metal-1-Polysilicon-Con");
414
if (pm_ni_1 == NONODEINST) return(TRUE);
415
pm_ni_2 = plac_make_Pin(decode_np, n_X, Y, 6*pla_lam,
416
"Metal-1-Polysilicon-Con");
417
if (pm_ni_2 == NONODEINST) return(TRUE);
418
plac_wire("Metal-1", 4*pla_lam, pm_ni_1,
419
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
420
plac_wire("Polysilicon", 2*pla_lam, p_ni, p_pp, pm_ni_1,
421
pm_ni_1->proto->firstportproto, decode_np);
422
plac_wire("Polysilicon", 2*pla_lam, n_ni, n_pp, pm_ni_2,
423
pm_ni_2->proto->firstportproto, decode_np);
425
pm_ni_1 = plac_make_Pin(decode_np, n_X, O_Y, 4*pla_lam, "Metal-1-Pin");
426
if (pm_ni_1 == NONODEINST) return(TRUE);
427
plac_wire("Metal-1", 4*pla_lam, pm_ni_1,
428
pm_ni_1->proto->firstportproto, pm_ni_2, pm_ni_2->proto->firstportproto, decode_np);
429
(void)sprintf(name, "INPUT%ld.m-1.%c", in_cnt, side);
430
(void)newportproto(decode_np, pm_ni_1, pm_ni_1->proto->firstportproto, name);
431
cnt += 2; /* Only route every second one */
432
(void)sprintf(name, "ACCESS%ld.m-1.%c", cnt, ac_side);
433
p_pp = getportproto(pmos_np, name);
434
n_pp = getportproto(nmos_np, name);
439
#endif /* PLATOOL - at top */