From cf5f566744db0449d30d963d9da1f0de1e12ecdf Mon Sep 17 00:00:00 2001 From: Frederic Petrot Date: Fri, 8 Mar 2002 14:17:47 +0000 Subject: [PATCH] Importing MBKVTI sources into the new CVS tree --- alliance/src/mbkvti/Makefile.am | 1 + alliance/src/mbkvti/configure.in | 52 + alliance/src/mbkvti/src/Makefile.am | 3 + alliance/src/mbkvti/src/drive_vti_l.c | 462 ++++++ alliance/src/mbkvti/src/drive_vti_l.h | 43 + alliance/src/mbkvti/src/drive_vti_p.c | 497 +++++++ alliance/src/mbkvti/src/drive_vti_p.h | 35 + alliance/src/mbkvti/src/mcl.h | 33 + alliance/src/mbkvti/src/mcp.h | 33 + alliance/src/mbkvti/src/parse_vti_l.c | 1890 +++++++++++++++++++++++++ alliance/src/mbkvti/src/parse_vti_p.c | 1344 ++++++++++++++++++ 11 files changed, 4393 insertions(+) create mode 100644 alliance/src/mbkvti/Makefile.am create mode 100644 alliance/src/mbkvti/configure.in create mode 100644 alliance/src/mbkvti/src/Makefile.am create mode 100644 alliance/src/mbkvti/src/drive_vti_l.c create mode 100644 alliance/src/mbkvti/src/drive_vti_l.h create mode 100644 alliance/src/mbkvti/src/drive_vti_p.c create mode 100644 alliance/src/mbkvti/src/drive_vti_p.h create mode 100644 alliance/src/mbkvti/src/mcl.h create mode 100644 alliance/src/mbkvti/src/mcp.h create mode 100644 alliance/src/mbkvti/src/parse_vti_l.c create mode 100644 alliance/src/mbkvti/src/parse_vti_p.c diff --git a/alliance/src/mbkvti/Makefile.am b/alliance/src/mbkvti/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/mbkvti/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/mbkvti/configure.in b/alliance/src/mbkvti/configure.in new file mode 100644 index 00000000..2b928084 --- /dev/null +++ b/alliance/src/mbkvti/configure.in @@ -0,0 +1,52 @@ +dnl +dnl This file is part of the Alliance CAD System +dnl Copyright (C) Laboratoire LIP6 - Département ASIM +dnl Universite Pierre et Marie Curie +dnl +dnl Home page : http://www-asim.lip6.fr/alliance/ +dnl E-mail support : mailto:alliance-support@asim.lip6.fr +dnl +dnl This library is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU Library General Public License as published +dnl by the Free Software Foundation; either version 2 of the License, or (at +dnl your option) any later version. +dnl +dnl Alliance VLSI CAD System is distributed in the hope that it will be +dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with the GNU C Library; see the file COPYING. If not, write to the Free +dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +dnl +dnl Purpose : Auto stuffing Alliance +dnl Almost ten years since I wrote this stuff, I just can't +dnl believe it +dnl Date : 01/02/2002 +dnl Author : Frederic Petrot +dnl $Id: configure.in,v 1.1 2002/03/08 14:17:47 fred Exp $ +dnl +dnl +AC_INIT(src/parse_vti_p.c) +AM_INIT_AUTOMAKE(mbkvti, 4.9) +AC_PROG_INSTALL +AC_PROG_CC +AC_HEADER_STDC +AC_CHECK_HEADERS(strings.h unistd.h) +AC_C_CONST +AC_PROG_RANLIB + +changequote(,)dnl +INCLUDES=-I${ALLIANCE_INCLUDE} +LDFLAGS=-L${ALLIANCE_LIB} +changequote([,])dnl + +AC_SUBST(INCLUDES) +AC_SUBST(LDFLAGS) + + +AC_OUTPUT([ +Makefile +src/Makefile +]) diff --git a/alliance/src/mbkvti/src/Makefile.am b/alliance/src/mbkvti/src/Makefile.am new file mode 100644 index 00000000..4b1df1ff --- /dev/null +++ b/alliance/src/mbkvti/src/Makefile.am @@ -0,0 +1,3 @@ +lib_LIBRARIES = libMcp.a libMcl.a +libMcp_a_SOURCES = drive_vti_p.c drive_vti_p.h parse_vti_p.c mcp.h +libMcl_a_SOURCES = drive_vti_l.c drive_vti_l.h parse_vti_l.c mcl.h diff --git a/alliance/src/mbkvti/src/drive_vti_l.c b/alliance/src/mbkvti/src/drive_vti_l.c new file mode 100644 index 00000000..0b0c0344 --- /dev/null +++ b/alliance/src/mbkvti/src/drive_vti_l.c @@ -0,0 +1,462 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/******************************************************************************* +* mbk : logical vti v4r11 driver (hns, fne, hdn, fdn formats) * +* * +* version : 4.11 * +* date : 12/06/1998 * +* * +* Modified, rewritten and maintained by Frederic Petrot since september 1990 * +* Modified by Gregoire Avot : RC wire support. * +*******************************************************************************/ + +#define RCN_FLAG_USER_27 ((unsigned char) 0x00000020) +#ident "@(#)vti logical views driver version 8.00" + +#include +#include +#include +#include +#include +#include "drive_vti_l.h" +#include MUT_H +#include MLO_H +#include MLU_H +#include RCN_H + +/******************************************************************************* +* needed to allow edition with vi on big interfaces instances * +*******************************************************************************/ +#define LINEBREAK if (linelength > 70) { \ + (void)fputs("-\n", ptfile); \ + linelength = 0; \ + } + +/******************************************************************************* +* function getdate() * +*******************************************************************************/ +static void vtigetdate(date) +char *date; +{ +time_t timer; +char day[4], month[4]; +int year, nday, hour, minute, second; + + (void)time(&timer); + (void)strcpy(date, ctime(&timer)); + (void)sscanf(date, "%s %s %d %d:%d:%d 19%d", + day, month, &nday, &hour, &minute, &second, &year); + (void)sprintf(date, "%02d-%s-%02d %02d:%02d", + nday, month, year, hour, minute); +} + +/******************************************************************************* +* function busname * +*******************************************************************************/ +static char *busname(name) +char *name; +{ +static char buffer[255]; +static int sigindex=0; +char *s, *t; +char one = 1; + + if (!name) { + sprintf(buffer,"SIG_%d",sigindex++); + return buffer; + } + + s = name; + t = buffer; + while (*s) { + if (*s == ' ') + if (one) { + *t++ = '['; + s++; + one = 0; + } else { + *t++ = ']'; + *t++ = '['; + s++; + } + if (*s == SEPAR && !one) { + *t++ = ']'; + one = 1; + } + *t++ = *s++; + } + if (!one) + *t++ = ']'; + *t = '\0'; + return buffer; +} + +/******************************************************************************* +* function env() * +*******************************************************************************/ +static void env(tn, tp) +char *tn, *tp; +{ +char *s, *mbkgetenv(); /* what include is needed? stdlib.h but no on pc */ + + s = mbkgetenv("MBK_VTI_TN"); + *tn = s ? *s : 'e'; + if (islower(*tn)) + *tn = toupper(*tn); + s = mbkgetenv("MBK_VTI_TP"); + *tp = s ? *s : 'p'; + if (islower(*tp)) + *tp = toupper(*tp); +} + +void wire_point(ptsig,node,ptfile) +losig_list *ptsig; +int node; +FILE *ptfile; +{ +lonode_list *ptnode; +ptype_list *ptl; +struct rcnhns *org; + + ptnode=getlonode(ptsig, node); + ptl=getptype(ptnode->USER,HNSRCN_X); + + if(ptl) { + fprintf(ptfile,"X %d ",(int)ptl->DATA); + return; + } + + ptl=getptype(ptnode->USER,HNSRCN_I); + if(ptl) { + org=(struct rcnhns*)(((chain_list*)(ptl->DATA))->DATA); + fprintf(ptfile,"I %s %d ",org->insname,org->position); + return; + } + fprintf(ptfile,"P %ld ",ptnode->INDEX); + +} + +/******************************************************************************* +* function savelofig() * +*******************************************************************************/ +void vtisavelofig(ptfig) +lofig_list *ptfig; +{ +loins_list *ptins; +lotrs_list *pttrs; +locon_list *ptcon; +losig_list *ptsig; +chain_list *ptscan, *ptlist, *scanchain; +FILE *ptfile; +long nbio; +long con_id; +float f1, f2; +char date[30]; +long sig_vdd = -1, sig_vss = -1; +int linelength; +char *s; +int *old_index; /* table indexed by the file indexes giving mbk's one */ +static char tn, tp; +int idx_rcn=1; +lorcnet_list *ptrcnet; +num_list *scannum; +lonode_list *ptnode; +ptype_list *ptptype; +struct rcnhns *elem_rcnhns, *org; +lowire_list *scanwire; + + lofigchain( ptfig ); + if (!tn) /* either one, don't matter */ + env(&tn, &tp); + + if ((ptfile = mbkfopen(ptfig->NAME, OUT_LO, WRITE_TEXT)) == NULL) { + (void)fflush(stdout); + (void)fprintf(stderr, "*** mbk error ***\n"); + (void)fprintf(stderr, "vtisavelofig can't open file %s.%s\n", + ptfig->NAME, OUT_LO); + EXIT(1); + } else if (TRACE_MODE == YES) + (void)printf("--- mbk --- writing the file : %s.%s\n", + ptfig->NAME, OUT_LO); + + /* reverse instances, connectors and parameters order */ + ptfig->LOCON = (locon_list *)reverse((chain_list *)ptfig->LOCON); + ptfig->LOINS = (loins_list *)reverse((chain_list *)ptfig->LOINS); + ptfig->LOTRS = (lotrs_list *)reverse((chain_list *)ptfig->LOTRS); + for (ptins = ptfig->LOINS; ptins; ptins = ptins->NEXT) + ptins->LOCON = (locon_list *)reverse((chain_list *)ptins->LOCON); + + /* space for old indexes to be restored at the end */ + con_id = 1; + for (ptsig = ptfig->LOSIG; ptsig; ptsig = ptsig->NEXT) + con_id++; + old_index = (int *)mbkalloc((unsigned int)(con_id * sizeof(int))); + + /* changing signals indexes : externals signals must be first for vti */ + con_id = 0; + for (ptcon = ptfig->LOCON; ptcon; ptcon = ptcon->NEXT) { + old_index[++con_id] = ptcon->SIG->INDEX; + ptcon->SIG->INDEX = con_id; + ptcon->SIG->TYPE = EXTERNAL; + if (isvdd(ptcon->NAME)) + sig_vdd = con_id; + else if (isvss(ptcon->NAME)) + sig_vss = con_id; + ptrcnet=ptcon->SIG->PRCN; + if(ptrcnet) + if(!gettabnode(ptrcnet)) + buildtable(ptcon->SIG); + } + nbio = con_id; + for (ptsig = ptfig->LOSIG; ptsig; ptsig = ptsig->NEXT) { + if (ptsig->TYPE != EXTERNAL) { + old_index[++con_id] = ptsig->INDEX; + ptsig->INDEX = con_id; + s = getsigname(ptsig); + if (isvdd(s)) + sig_vdd = con_id; + else if (isvss(s)) + sig_vss = con_id; + ptrcnet=ptsig->PRCN; + if(ptrcnet) + if(!gettabnode(ptrcnet)) + buildtable(ptsig); + } + } + + if (sig_vdd == -1) { + sig_vdd = ++con_id; + (void)fprintf(stderr, "*** mbk warning ***\n vti %s driver detected", + OUT_LO); + (void)fprintf(stderr, " no '*vdd*' signal in figure %s (assigned to %ld)\n", + ptfig->NAME, sig_vdd); + } + if (sig_vss == -1) { + sig_vss = ++con_id; + (void)fprintf(stderr, "*** mbk warning ***\n vti %s driver detected", + OUT_LO); + (void)fprintf(stderr, " no '*vss*' signal in figure %s (assigned to %ld)\n", + ptfig->NAME, sig_vss); + } + + /* header */ + vtigetdate(date); + if (strcmp(OUT_LO, "hns") == 0) { + (void)fprintf(ptfile, "#cell1 %s %s hnSchematic 0 v7r5.6\n", + ptfig->NAME, TECHNO); + (void)fprintf(ptfile, "# %s %s mbkvti400 * .\n", date, date); + (void)fprintf(ptfile, "H 1 ;\n"); + } else { + (void)fprintf(ptfile, "#cell1 %s %s fnExtracted 4096 v7r5.6\n", + ptfig->NAME, TECHNO); + (void)fprintf(ptfile, "# %s %s mbkvti400 * .\n", date, date); + (void)fprintf(ptfile, "H 3 ;\n"); + } + (void)fprintf(ptfile, "B 0 %ld ;\n", nbio); + + /* connectors */ + for (ptcon = ptfig->LOCON; ptcon; ptcon = ptcon->NEXT) { + if( (scannum = ptcon->PNODE) ) { + for( ; scannum ; scannum=scannum->NEXT ) { + (void)fprintf(ptfile, "X "); /* unable to represent direction in hns */ + (void)fprintf(ptfile, "%ld ", ptcon->SIG->INDEX); + (void)fprintf(ptfile, "%d ", idx_rcn); + ptnode=getlonode(ptcon->SIG,scannum->DATA); + ptnode->USER=addptype(ptnode->USER,HNSRCN_X,(void*)idx_rcn); + (void)fprintf(ptfile, "%s;\n", busname(ptcon->NAME)); + idx_rcn++; + } + } + else { + (void)fprintf(ptfile, "X "); /* unable to represent direction in hns */ + (void)fprintf(ptfile, "%ld ", ptcon->SIG->INDEX); + (void)fprintf(ptfile, "%d ", idx_rcn++); + (void)fprintf(ptfile, "%s;\n", busname(ptcon->NAME)); + } + + } + + /* local models derived from the first instances */ + ptlist = NULL; + for (ptins = ptfig->LOINS; ptins; ptins = ptins->NEXT) { + idx_rcn=1; + for (ptscan = ptlist; ptscan; ptscan = ptscan->NEXT) + if (ptins->FIGNAME == (char *)ptscan->DATA) + break; + if (ptscan == NULL) { + ptlist = addchain(ptlist, (void *)ptins->FIGNAME); + linelength = fprintf(ptfile, "M HNS "); + linelength += fprintf(ptfile, "%s ", ptins->FIGNAME); + linelength += fprintf(ptfile, "| "); + linelength += fprintf(ptfile, "| "); + for (ptcon = ptins->LOCON; ptcon; ptcon = ptcon->NEXT) { + if( (scannum = ptcon->PNODE) ) { + for( ; scannum ; scannum=scannum->NEXT ) { + linelength += fprintf(ptfile, "%s ", busname(ptcon->NAME)); + } + } + else { + linelength += fprintf(ptfile, "%s ", busname(ptcon->NAME)); + } + LINEBREAK; + } + linelength += fprintf(ptfile, "| "); + LINEBREAK; + for (ptcon = ptins->LOCON; ptcon != NULL; ptcon = ptcon->NEXT) { + if( (scannum = ptcon->PNODE) ) { + for( ; scannum ; scannum=scannum->NEXT ) { + (void)fprintf(ptfile, "%d ", idx_rcn++); + } + } + else { + (void)fprintf(ptfile, "%d ", idx_rcn++); + } + LINEBREAK; + } + (void)fprintf(ptfile, ";\n"); + } + } + freechain(ptlist); + + /* instances */ + for (ptins = ptfig->LOINS; ptins != NULL; ptins = ptins->NEXT) { + + idx_rcn=1; + linelength = fprintf(ptfile, "I HNS "); + linelength += fprintf(ptfile, "%s ", ptins->FIGNAME); + linelength += fprintf(ptfile, "%s ", ptins->INSNAME); + linelength += fprintf(ptfile, "| "); + linelength += fprintf(ptfile, "| "); + + for (ptcon = ptins->LOCON; ptcon; ptcon = ptcon->NEXT) { + if( (scannum = ptcon->PNODE) ) { + for( ; scannum ; scannum=scannum->NEXT ) { + linelength += fprintf(ptfile, "%ld ", ptcon->SIG->INDEX); + + ptnode=getlonode(ptcon->SIG,scannum->DATA); + if( !(ptptype=getptype(ptnode->USER,HNSRCN_I)) ) { + ptnode->USER=addptype(ptnode->USER,HNSRCN_I,NULL); + ptptype=ptnode->USER; + } + elem_rcnhns=mbkalloc(sizeof(struct rcnhns)); + ptptype->DATA=addchain(((chain_list*)(ptptype->DATA)),elem_rcnhns); + elem_rcnhns->insname=ptins->INSNAME; + elem_rcnhns->position=idx_rcn; + RCN_CLEARFLAG(ptnode->FLAG,RCN_FLAG_USER_27); + idx_rcn++; + } + } + else { + linelength += fprintf(ptfile, "%ld ", ptcon->SIG->INDEX); + } + LINEBREAK; + } + (void)fprintf(ptfile, ";\n"); + } + + /* transistors */ + for (pttrs = ptfig->LOTRS; pttrs; pttrs = pttrs->NEXT) { + (void)fprintf(ptfile, "T "); + (void)fprintf(ptfile, "%c ", pttrs->TYPE == TRANSN ? tn : tp); + (void)fprintf(ptfile, "* "); + f1 = (float)pttrs->X / SCALE_X; + f2 = (float)pttrs->Y / SCALE_X; + (void)fprintf(ptfile, "[%.2f,%.2f] ", f1, f2); + f1 = (float)pttrs->WIDTH / SCALE_X; + f2 = (float)pttrs->LENGTH / SCALE_X; + (void)fprintf(ptfile, "%.2f %.2f ", f1, f2); + (void)fprintf(ptfile, "0 "); + (void)fprintf(ptfile, "%ld ", pttrs->GRID->SIG->INDEX); + (void)fprintf(ptfile, "%ld ", pttrs->SOURCE->SIG->INDEX); + (void)fprintf(ptfile, "%ld ", pttrs->DRAIN->SIG->INDEX); + (void)fprintf(ptfile, "%ld ", pttrs->TYPE == TRANSN ? sig_vss : sig_vdd); + (void)fprintf(ptfile, ";\n"); + } + + /* signals */ + for (ptsig = ptfig->LOSIG; ptsig; ptsig = ptsig->NEXT) { + ptrcnet=ptsig->PRCN; + if ((ptsig->TYPE == INTERNAL && ptsig->NAMECHAIN != NULL) || ptrcnet) { + s=getsigname(ptsig); + (void)fprintf(ptfile, "N "); + (void)fprintf(ptfile, "%ld ", ptsig->INDEX); + (void)fprintf(ptfile, "%s ", busname(s)); + (void)fprintf(ptfile, ";\n"); + if (ptsig->PRCN && ptsig->PRCN->CAPA && strcmp(OUT_LO, "hns")) { + (void)fprintf(ptfile, "C 0 * * "); /* type */ + (void)fprintf(ptfile, "%.3e ", ptsig->PRCN->CAPA); /* val */ + (void)fprintf(ptfile, "%ld ", ptsig->INDEX); /* equi */ + (void)fprintf(ptfile, "%ld ", sig_vss); /* bulk */ + (void)fprintf(ptfile, ";\n"); + } + if(ptrcnet) { + for(scanwire=ptrcnet->PWIRE;scanwire;scanwire=scanwire->NEXT) { + (void)fprintf(ptfile, "W "); + wire_point(ptsig,scanwire->NODE1,ptfile); + wire_point(ptsig,scanwire->NODE2,ptfile); + (void)fprintf(ptfile,"%.3e %.3e\n",scanwire->RESI,scanwire->CAPA); + } + + for(scanchain=getptype(ptsig->USER,LOFIGCHAIN)->DATA;scanchain;scanchain=scanchain->NEXT) { + ptcon=(locon_list*)(scanchain->DATA); + for(scannum=ptcon->PNODE;scannum;scannum=scannum->NEXT) { + ptnode=getlonode(ptsig,scannum->DATA); + if( !RCN_GETFLAG(ptnode->FLAG,RCN_FLAG_USER_27) ) { + if( (ptptype=getptype(ptnode->USER,HNSRCN_I)) ) { + org=((struct rcnhns*)(((chain_list*)(ptptype->DATA))->DATA)); + for(ptscan=((chain_list*)(ptptype->DATA))->NEXT;ptscan;ptscan=ptscan->NEXT) { + elem_rcnhns=(struct rcnhns*)(ptscan->DATA); + fprintf(ptfile,"W I %s %d I %s %d 0.0 0.0\n",elem_rcnhns->insname,elem_rcnhns->position,org->insname,org->position); + } + } + RCN_SETFLAG(ptnode->FLAG,RCN_FLAG_USER_27); + } + } + } + } + } + } + + (void)fprintf(ptfile, "E ;\n"); + + /* put back indexes in their place */ + for (ptsig = ptfig->LOSIG; ptsig; ptsig = ptsig->NEXT) + ptsig->INDEX = old_index[ptsig->INDEX]; + mbkfree(old_index); + + /* reverse instances, connectors and transistor order */ + ptfig->LOCON = (locon_list *)reverse((chain_list *)ptfig->LOCON); + ptfig->LOTRS = (lotrs_list *)reverse((chain_list *)ptfig->LOTRS); + ptfig->LOINS = (loins_list *)reverse((chain_list *)ptfig->LOINS); + for (ptins = ptfig->LOINS; ptins; ptins = ptins->NEXT) + ptins->LOCON = (locon_list *)reverse((chain_list *)ptins->LOCON); + + if (fclose(ptfile)) { + (void)fflush(stdout); + (void)fprintf(stderr, "*** mbk error ***\n"); + (void)fprintf(stderr, "vtisavelofig can't close file %s.%s\n", + ptfig->NAME, OUT_LO); + EXIT(1); + } +} diff --git a/alliance/src/mbkvti/src/drive_vti_l.h b/alliance/src/mbkvti/src/drive_vti_l.h new file mode 100644 index 00000000..32afb036 --- /dev/null +++ b/alliance/src/mbkvti/src/drive_vti_l.h @@ -0,0 +1,43 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/******************************************************************************* +* drive_vti_l.h : header file for the hns and fne driver * +* * +* version : 4.11 * +* date : 12/06/1998 * +* * +* Modified, rewritten and maintained by Frederic Petrot since september 1990 * +* Modified by Gregoire Avot for RCN support. * +*******************************************************************************/ +static void vtigetdate(); +void vtisavelofig(); + +#define HNSRCN_X 543345 +#define HNSRCN_I 543346 +struct rcnhns { + char *insname; + int position; +}; + +void wire_point(); diff --git a/alliance/src/mbkvti/src/drive_vti_p.c b/alliance/src/mbkvti/src/drive_vti_p.c new file mode 100644 index 00000000..cbcfb773 --- /dev/null +++ b/alliance/src/mbkvti/src/drive_vti_p.c @@ -0,0 +1,497 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/******************************************************************************* +* mbk : physical vti v7r5 & v8 driver (cp format) * +* * +* version : 3.05 * +* date : 13/05/92 * +* * +* Modified, rewritten and maintained by Frederic Petrot since september 1990 * +* * +*******************************************************************************/ + +#ident "@(#)vti symbolic layout view driver version 4.00" + +#include +#include +#include +#include +#include MUT_H +#include MPH_H +#include MPU_H +#include "drive_vti_p.h" + +/******************************************************************************* +* function getdate() * +*******************************************************************************/ +static void vtigetdate(date) +char *date; +{ +time_t timer; +char day[4], month[4]; +int year, nday, hour, minute, second; + + (void)time(&timer); + (void)strcpy(date, ctime(&timer)); + (void)sscanf(date, "%s %s %d %d:%d:%d 19%d", + day, month, &nday, &hour, &minute, &second, &year); + (void)sprintf(date, "%02d-%s-%02d %02d:%02d", + nday, month, year, hour, minute); +} + +/******************************************************************************* +* function busname * +*******************************************************************************/ +static char *busname(name) +char *name; +{ +static char buffer[255]; +char *s, *t; +char one = 1; + + if (!name) + return NULL; + + s = name; + t = buffer; + while (*s) { + if (*s == ' ') + if (one) { + *t++ = '['; + s++; + one = 0; + } else { + *t++ = ']'; + *t++ = '['; + s++; + } + if (*s == '_' && !one) { /* was SEPAR and not / */ + *t++ = ']'; + one = 1; + } + *t++ = *s++; + } + if (!one) + *t++ = ']'; + *t = '\0'; + return buffer; +} + +/******************************************************************************* +* function vtisavephfig() * +*******************************************************************************/ +void vtisavephfig(ptfig) +phfig_list *ptfig; +{ +chain_list *ptchain; +phcon_list *ptcon; +phins_list *ptins; +phseg_list *ptseg; +phvia_list *ptvia; +phref_list *ptref; +int npoint = 0; +int vix[LAST_CONTACT]; +int conindex = 0; /* connector index */ +char symm; +char type; /* connector orient */ +char *filename = ptfig->NAME; /* namealloc unnecessary */ +char figname[10]; +char insname[10]; +FILE *ptfile; +float f1, f2, f3, f4, f5; +char date[30]; + + /* open file */ + if ((ptfile = mbkfopen(filename, OUT_PH, WRITE_TEXT)) == (FILE *)NULL) { + (void)fflush(stdout); + (void)fprintf(stderr, "*** mbk error ***\n"); + (void)fprintf(stderr, "vtisavephfig can't open file %s.%s\n", + filename, OUT_PH); + EXIT(1); + } else if (TRACE_MODE == 'Y') + (void)printf("--- mbk --- writing file %s.%s\n", filename, OUT_PH); + + (void)memset(vix, (char)0, sizeof(vix)); + + /* header */ + vtigetdate(date); + (void)fprintf(ptfile, "#cell1 %s %s compose *\n", ptfig->NAME, TECHNO); + (void)fprintf(ptfile, "# %s %s mbkvti400 * .cp\n", date, date); + for (ptchain = ptfig->MODELCHAIN; ptchain; ptchain = ptchain->NEXT) + (void)fprintf(ptfile, "# %s\n", (char *)ptchain->DATA); + (void)fprintf(ptfile, "# .\n"); + (void)fprintf(ptfile, "V 4 VTIcompose 1.1\n"); + + /* boxes */ + f1 = (float)ptfig->XAB1 / SCALE_X; + f2 = (float)ptfig->YAB1 / SCALE_X; + f3 = (float)ptfig->XAB2 / SCALE_X; + f4 = (float)ptfig->YAB2 / SCALE_X; + (void)fprintf(ptfile, "A %g %g %g %g\n", f1, f2, f3, f4); + (void)fprintf(ptfile, "B %g %g %g %g\n", f1, f2, f3, f4); + + (void)fprintf(ptfile, "F F\n"); + + /* connectors */ + for (ptcon = ptfig->PHCON; ptcon; ptcon = ptcon->NEXT) { + switch (ptcon->ORIENT) { + case NORTH : + type = 'N'; + break; + case EAST : + type = 'E'; + break; + case SOUTH : + type = 'S'; + break; + case WEST : + type = 'W'; + break; + default : + break; + } +#if 0 + if (ptcon->XCON != ptfig->XAB1 && ptcon->XCON != ptfig->XAB2 + && ptcon->YCON != ptfig->YAB1 && ptcon->YCON != ptfig->YAB2) { + (void)fprintf(stderr, "*** mbk warning ***\n"); + (void)fprintf(stderr, "vti connector not on abutment box : "); + (void)fprintf(stderr, "x = %d , y = %d , name = %s , orient = %c\n", + ptcon->XCON, ptcon->YCON, + ptcon->NAME, ptcon->ORIENT); + (void)fprintf(stderr, "writing the file %s.%s\n", filename, OUT_PH); + } +#endif + f1 = (float)ptcon->XCON / SCALE_X; + f2 = (float)ptcon->YCON / SCALE_X; + f3 = (float)ptcon->WIDTH / SCALE_X; + (void)fprintf(ptfile, "C %s %g %g %s %g %d *", + busname(ptcon->NAME), f1, f2, decodelayer(ptcon->LAYER), + f3, ++conindex); + (void)fprintf(ptfile, " * %c %s\n", type, busname(ptcon->NAME)); + } + + /* instances */ + for (ptins = ptfig->PHINS; ptins; ptins = ptins->NEXT) { + switch (ptins->TRANSF) { + case NOSYM : + symm = 0; + break; + case SYM_Y : + symm = 6; + break; + case SYM_X : + symm = 4; + break; + case SYMXY : + symm = 2; + break; + case ROT_P : + symm = 1; + break; + case ROT_M : + symm = 3; + break; + case SY_RM : + symm = 5; + break; + case SY_RP : + symm = 7; + break; + default : + symm = -15; + } + f1 = (float)ptins->XINS / SCALE_X; + f2 = (float)ptins->YINS / SCALE_X; + (void)fprintf(ptfile, "I %s %g %g %d \"%s\" cp * *\n", + busname(ptins->INSNAME), f1, f2, symm, ptins->FIGNAME); + } + + /* contacts */ + for (ptvia = ptfig->PHVIA; ptvia; ptvia = ptvia->NEXT) { + switch (ptvia->TYPE) { + case CONT_VIA : + (void)strcpy(figname, "VIA12"); + (void)sprintf(insname, "via12x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_VIA2 : + (void)strcpy(figname, "VIA23"); + (void)sprintf(insname, "via23x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_VIA3 : + (void)strcpy(figname, "VIA34"); + (void)sprintf(insname, "via34x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_VIA4 : + (void)strcpy(figname, "VIA45"); + (void)sprintf(insname, "via45x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_VIA5 : + (void)strcpy(figname, "VIA56"); + (void)sprintf(insname, "via56x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_VIA6 : + (void)strcpy(figname, "VIA67"); + (void)sprintf(insname, "via67x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_VIA7 : + (void)strcpy(figname, "VIA78"); + (void)sprintf(insname, "via78x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_VIA8 : + (void)strcpy(figname, "VIA89"); + (void)sprintf(insname, "via89x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_POLY : + (void)strcpy(figname, "CPF"); + (void)sprintf(insname, "cpf%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_POLY2 : + (void)strcpy(figname, "CPF2"); + (void)sprintf(insname, "cpf2%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_DIF_N : + (void)strcpy(figname, "CDN"); + (void)sprintf(insname, "cdn%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_DIF_P : + (void)strcpy(figname, "CDP"); + (void)sprintf(insname, "cdp%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_BODY_N : + (void)strcpy(figname, "CBN"); + (void)sprintf(insname, "cbn%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_BODY_P : + (void)strcpy(figname, "CBP"); + (void)sprintf(insname, "cbp%d", ++vix[(int)ptvia->TYPE]); + break; + case C_X_N : + (void)strcpy(figname, "CXN"); + (void)sprintf(insname, "cxn%d", ++vix[(int)ptvia->TYPE]); + break; + case C_X_P : + (void)strcpy(figname, "CXP"); + (void)sprintf(insname, "cxp%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN1 : + (void)strcpy(figname, "TURN1"); + (void)sprintf(insname, "turn1x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN2 : + (void)strcpy(figname, "TURN2"); + (void)sprintf(insname, "turn2x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN3 : + (void)strcpy(figname, "TURN3"); + (void)sprintf(insname, "turn3x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN4 : + (void)strcpy(figname, "TURN4"); + (void)sprintf(insname, "turn4x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN5 : + (void)strcpy(figname, "TURN5"); + (void)sprintf(insname, "turn5x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN6 : + (void)strcpy(figname, "TURN6"); + (void)sprintf(insname, "turn6x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN7 : + (void)strcpy(figname, "TURN7"); + (void)sprintf(insname, "turn7x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN8 : + (void)strcpy(figname, "TURN8"); + (void)sprintf(insname, "turn8x%d", ++vix[(int)ptvia->TYPE]); + break; + case CONT_TURN9 : + (void)strcpy(figname, "TURN9"); + (void)sprintf(insname, "turn9x%d", ++vix[(int)ptvia->TYPE]); + break; + } + f1 = (float)ptvia->XVIA / SCALE_X; + f2 = (float)ptvia->YVIA / SCALE_X; + if ( ( ptvia->DX == 0 ) && + ( ptvia->DY == 0 ) ) + { + (void)fprintf(ptfile, "I %s %g %g %d \"%s\" ly * *\n", + insname, f1, f2, NOSYM, namealloc( figname ) ); + } + else + { + f3 = (float)ptvia->DX / SCALE_X; + f4 = (float)ptvia->DY / SCALE_X; + + (void)fprintf(ptfile, "D %g %g * %s 0 %g %g\n", f1, f2, figname, f3, f4 ); + ++npoint; + } + } + + /* references */ + for (ptref = ptfig->PHREF; ptref; ptref = ptref->NEXT) { + f1 = (float)ptref->XREF / SCALE_X; + f2 = (float)ptref->YREF / SCALE_X; + (void)fprintf(ptfile, "I %s %g %g %d \"%s\" ly * *\n", + busname(ptref->NAME), f1, f2, NOSYM, ptref->FIGNAME); + } + + /* segments */ + for (ptseg = ptfig->PHSEG; ptseg; ptseg = ptseg->NEXT) { + f1 = (float)ptseg->X1 / SCALE_X; + f2 = (float)ptseg->Y1 / SCALE_X; + f3 = (float)ptseg->X2 / SCALE_X; + f4 = (float)ptseg->Y2 / SCALE_X; + f5 = (float)ptseg->WIDTH / SCALE_X; + if (ptseg->TYPE == UP || ptseg->TYPE == RIGHT ) { + (void)fprintf(ptfile, "P %g %g * %s\n", f1, f2, + decodelayer(ptseg->LAYER)); + (void)fprintf(ptfile, "P %g %g * %s\n", f3, f4, + decodelayer(ptseg->LAYER)); + } else { + (void)fprintf(ptfile, "P %g %g * %s\n", f3, f4, + decodelayer(ptseg->LAYER)); + (void)fprintf(ptfile, "P %g %g * %s\n", f1, f2, + decodelayer(ptseg->LAYER)); + } + if (ptseg->NAME == NULL || *ptseg->NAME == '*') + (void)fprintf(ptfile, "W %g %g %g %g\n", + f1 - f5, f2 - f5, f3 + f5, f4 + f5); + else + (void)fprintf(ptfile, "W %g %g %g %g %s\n", + f1 - f5, f2 - f5, f3 + f5, f4 + f5, + busname(ptseg->NAME)); + ++npoint; + (void)fprintf(ptfile, "S %g %s %s P %d P %d\n", f5, + (ptseg->TYPE == UP || ptseg->TYPE == DOWN) ? "V" : "H", + decodelayer(ptseg->LAYER), npoint, npoint + 1); + ++npoint; + } + + /* end */ + (void)fprintf(ptfile, "E\n"); + + /* close file */ + if (fclose(ptfile)) { + (void)fflush(stdout); + (void)fprintf(stderr, "*** mbk error ***\n"); + (void)fprintf(stderr, "vtisavephfig can't close file %s.%s\n", + filename, OUT_PH); + EXIT(1); + } +} + +/******************************************************************************* +* function decodelayer() * +*******************************************************************************/ +static char *decodelayer(index) +char index; +{ + switch(index) { + case NWELL: + return "nwell"; + case PWELL: + return "pwell"; + case NTIE: + return "ntie"; + case PTIE: + return "ptie"; + case NDIF: + return "ndif"; + case PDIF: + return "pdif"; + case NTRANS: + return "ntrans"; + case PTRANS: + return "ptrans"; + case NTRANS_FAST: + return "ntrans_fast"; + case PTRANS_FAST: + return "ptrans_fast"; + case NTRANS_HVIO: + return "ntrans_hvio"; + case PTRANS_HVIO: + return "ptrans_hvio"; + case POLY: + return "poly"; + case POLY2: + return "poly2"; + case ALU1: + return "metal"; + case ALU2: + return "metal2"; + case ALU3: + return "metal3"; + case ALU4: + return "metal4"; + case ALU5: + return "metal5"; + case ALU6: + return "metal6"; + case ALU7: + return "metal7"; + case ALU8: + return "metal8"; + case ALU9: + return "metal9"; + case TALU1: + return "allowM"; + case TALU2: + return "allowM2"; + case TALU3: + return "allowM3"; + case TALU4: + return "allowM4"; + case TALU5: + return "allowM5"; + case TALU6: + return "allowM6"; + case TALU7: + return "allowM7"; + case TALU8: + return "allowM8"; + case TALU9: + return "allowM9"; + case CALU1: + return "conM"; + case CALU2: + return "conM2"; + case CALU3: + return "conM3"; + case CALU4: + return "conM4"; + case CALU5: + return "conM5"; + case CALU6: + return "conM6"; + case CALU7: + return "conM7"; + case CALU8: + return "conM8"; + case CALU9: + return "conM9"; + default: + return "unknown"; + } +} diff --git a/alliance/src/mbkvti/src/drive_vti_p.h b/alliance/src/mbkvti/src/drive_vti_p.h new file mode 100644 index 00000000..9e72cd4d --- /dev/null +++ b/alliance/src/mbkvti/src/drive_vti_p.h @@ -0,0 +1,35 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/******************************************************************************* +* driv_vti_p.h : header file for vti cp driver * +* * +* version : 3.00 * +* date : 07/11/91 * +* * +* Modified, rewritten and maintained by Frederic Petrot since september 1990 * +* * +*******************************************************************************/ +static char *decodelayer(); +static void vtigetdate(); +void vtisavephfig(); diff --git a/alliance/src/mbkvti/src/mcl.h b/alliance/src/mbkvti/src/mcl.h new file mode 100644 index 00000000..4ed24b49 --- /dev/null +++ b/alliance/src/mbkvti/src/mcl.h @@ -0,0 +1,33 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _MCL_H +#define _MCL_H +#ifdef __STDC__ +extern void vtiloadlofig(lofig_list *, char *, char); +extern void vtisavelofig(lofig_list *); +#else +extern void vtiloadlofig(); +extern void vtisavelofig(); +#endif +#endif diff --git a/alliance/src/mbkvti/src/mcp.h b/alliance/src/mbkvti/src/mcp.h new file mode 100644 index 00000000..91599bfa --- /dev/null +++ b/alliance/src/mbkvti/src/mcp.h @@ -0,0 +1,33 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _MCP_H +#define _MCP_H +#ifdef __STDC__ +extern void vtiloadphfig(phfig_list *ptfig, char *figname, char mode); +extern void vtisavephfig(phfig_list *ptfig); +#else +extern void vtiloadphfig(); +extern void vtisavephfig(); +#endif +#endif diff --git a/alliance/src/mbkvti/src/parse_vti_l.c b/alliance/src/mbkvti/src/parse_vti_l.c new file mode 100644 index 00000000..bb111369 --- /dev/null +++ b/alliance/src/mbkvti/src/parse_vti_l.c @@ -0,0 +1,1890 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/******************************************************************************* +* mbk : vti parser netlist view : hns & fne formats v4r11 * +* * +* Based upon material provided by Alain Greiner in 1990, in lex and yacc * +* * +* version 0.0 written by Hichang Li in june 1991 under the supervision of * +* Frederic Petrot * +* version n.x is a rewitting and update of version 0.0 written by Frederic * +* Petrot on september 1991 * +* * +* New versions are mostly bug corrections, or standardization matters and are * +* done by Frederic Petrot, since middle 1990. * +* * +* Rc nets support done by Gregoire Avot on April 1997. * +* * +* * +* version : 4.12 * +* date : 12/06/1998 * +*******************************************************************************/ + +#ident "@(#)vti logical views parser version 4.04" + +#include +#include +#include +#include +#include MUT_H +#include MLO_H +#include MLU_H +#include RCN_H + +#define LSIZE 16384 /* max line size for vfgets */ + +enum {SYNTAX_ERROR, NET_ERROR, OPEN_ERROR, PARSE_ERROR, CLOSE_ERROR, + NAME_ERROR, CON_SIGDIF, BAD_JOIN}; + +/* rcnet support */ +struct hns_X { + struct hns_X *NEXT; + long idx; + long rcn; +} ; + +struct hns_I { + struct hns_I *NEXT; + long idx; + loins_list *ins; + long rcn; +} ; + +struct hns_P { + struct hns_P *NEXT; + long idx; + losig_list *sig; + long rcn; +} ; + +/* flag : + 1 : node1 = hns_X + 2 : node1 = hns_I + 4 : node1 = hns_P + 8 : node2 = hns_X + 16 : node2 = hns_I + 32 : node2 = hns_P +*/ +struct hns_W { + struct hns_W *NEXT; + long flag; + void *node1; + void *node2; + float r; + float c; +} ; + +struct hns_X *HNS_X=NULL; +struct hns_I *HNS_I=NULL; +struct hns_P *HNS_P=NULL; +struct hns_W *HNS_W=NULL; +chain_list *FREE_HNS=NULL; + +#define HNSRCN 53432 +#define HNSRCNIDX 53433 +#define HNSPHCON 53434 +#define HNSRCNX 53435 +#define HNSRCNI 53436 + +static void buildrcn __P(( lofig_list* )); +static struct hns_I* givehnsi __P(( lofig_list*, int, loins_list* )); +static struct hns_X* givehnsx __P(( lofig_list*, int )); +static struct hns_P* givehnsp __P(( losig_list*, int )); +static struct hns_I* add_hns_I __P(( void )); +static struct hns_X* add_hns_X __P(( void )); +static struct hns_P* add_hns_P __P(( void )); +static struct hns_W* add_hns_W __P(( void )); +static void del_hns_X __P(( struct hns_X* )); +/* static void del_hns_P __P(( struct hns_P* )); */ +static void del_hns_I __P(( struct hns_I* )); +static void del_hns_W __P(( struct hns_W* )); +/* static void movehnsw __P(( losig_list*, losig_list* )); */ +static float stof __P(( char* )); +static losig_list* givelosigalias __P(( lofig_list*, chain_list*, int )); +static int compare_alias_join __P(( lofig_list*, chain_list*, chain_list** )); +static int traite_join __P(( lofig_list*, chain_list* )); +static void msg_err __P(( lofig_list*, chain_list* )); +/* static void debug __P(( lofig_list* )); */ + + +/******************************************************************************* +* hns_error : generic error routine for vtiloadlofig function * +*******************************************************************************/ +static void hns_error(type, name, line, string, parameter) +int type; +long line, parameter; +char *name, *string; +{ + (void)fflush(stdout); + (void)fprintf(stderr, "*** mbk error ***\n"); + switch (type) { + case SYNTAX_ERROR : + (void)fprintf(stderr, "syntax error"); + break; + case NET_ERROR : + (void)fprintf(stderr, "external connector %s on signal %ld", + string, parameter); + (void)fprintf(stderr, " is internally joined with an other"); + (void)fprintf(stderr, " external connector with an other name"); + break; + case OPEN_ERROR : + (void)fprintf(stderr, "can't open file : %s", name); + break; + case PARSE_ERROR : + (void)fprintf(stderr, "abnormal parsing for : %s", name); + break; + case CLOSE_ERROR : + (void)fprintf(stderr, "can't close file : %s", name); + break; + case NAME_ERROR : + (void)fprintf(stderr, "name syntax error"); + break; + case CON_SIGDIF : + (void)fprintf(stderr, "two connectors with the same name on two different signals"); + break; + case BAD_JOIN : + (void)fprintf(stderr, "join of signal %ld connected on two different external connectors %s",parameter,string); + break; + } + if (line) + (void)fprintf(stderr, "\nvtiloadlofig : parsing file %s.%s line %ld\n", + name, IN_LO, line); + else + (void)fprintf(stderr, "\nvtiloadlofig : parsing file %s.%s\n", + name, IN_LO); + EXIT(1); +} + +/******************************************************************************* +* vfgets: read a line of a file to a buffer, the line beeing size max or end * +* with a \n. In order to properly treat vti line breaks, the -\n pattern is * +* recognized and ignored * +*******************************************************************************/ +static char *vfgets(str, size, iob) +char *str; +int size; +FILE *iob; +{ +register char *cs; +register int c; + + cs = str; + while (--size > 0 && (c = getc(iob)) != EOF) { + if ((*(cs++) = c) == '-') { + if ((c = getc(iob)) == '\n') { + /* avant : *cs-- */ + cs--; + } else + (void)ungetc(c ,iob); + } else if (c == '\n') + break; + } + *cs = '\0'; + return (c == EOF && cs == str) ? (char *)NULL : str; +} + +/******************************************************************************* +* shift : shift a float 3 times to give a long in ascii * +*******************************************************************************/ +#define shift(pt) \ + if (*(pt + 1) == '\0') { \ + *pt = '0'; \ + *(pt + 1) = '0'; \ + *(pt + 2) = '0'; \ + *(pt + 3) = '\0'; \ + } else if (*(pt + 2) == '\0') { \ + *pt = *(pt + 1); \ + *(pt + 1) = '0'; \ + *(pt + 2) = '0'; \ + *(pt + 3) = '\0'; \ + } else if (*(pt + 3) == '\0') { \ + *pt = *(pt + 1); \ + *(pt + 1) = *(pt + 2); \ + *(pt + 2) = '0'; \ + *(pt + 3) = '\0'; \ + } else { \ + *pt = *(pt + 1); \ + *(pt + 1) = *(pt + 2); \ + *(pt + 2) = *(pt + 3); \ + *(pt + 3) = '\0'; \ + } + +/******************************************************************************* +* stol : convert a string to a long * +*******************************************************************************/ +static long stol(token) +char *token; +{ +register char *pt; + + if ((pt = strchr(token, '.')) == (char *)NULL) + return (long)(SCALE_X * atol(token)); + else { + shift(pt); + return (long)(SCALE_X * atol(token) / 1000); + } +} + +/******************************************************************************* +* stof : convert a string to a float * +*******************************************************************************/ +static float stof(token) +char *token; +{ + char *end; + double f; + f = strtod( token, &end ); + if( end == token ) + hns_error((int)SYNTAX_ERROR, NULL, (long)0, (char *)NULL, 0L); + return( (float)(f) ); +} + + +/******************************************************************************* +* checkname : check for busses * +*******************************************************************************/ +static char *checkname(name) +char *name; +{ +char *s, *t; + + s = t = name; + while (*t) { + if (*t == '[') + *t = ' '; + else if (*t == ']') + { + if (*(++t) == '\0') /* ok, it's finished */ + goto end; + else if (*t == '[') /* multiple array */ + continue; + } + *s++ = *t++; + } +end: + *s = '\0'; + return name; +} + +/******************************************************************************* +* function env() * +*******************************************************************************/ +static void env(tn, tp) +char *tn, *tp; +{ +char *s, *mbkgetenv(); + + s = mbkgetenv("MBK_VTI_TN"); + *tn = s ? *s : 'e'; + if (islower((int)*tn)) + *tn = toupper(*tn); + s = mbkgetenv("MBK_VTI_TP"); + *tp = s ? *s : 'p'; + if (islower((int)*tp)) + *tp = toupper(*tp); +} + + +/******************************************************************************* +* logical parser : vti2mbk * +*******************************************************************************/ +static int parse(fig, mode, in, fname) +lofig_list *fig; +char mode; +FILE *in; +char *fname; +{ +char line[LSIZE+1]; +char *t1, *t2, *t3, *t4, *t5; /* pointers to token on a line */ +char *t6, *t7, *t8, *t9, *t10, *t11; /* of vti file */ +char s[100]; /* intermediate string to process tokens */ +long l1, l2, l3, l4; /* results from strtol */ +float f; /* only used for capacitances */ +lofig_list *model = (lofig_list *)NULL; /* must be initialized */ +num_list *ylist = (num_list *)NULL; /* must be initialized */ +long i = 1L; /* line number */ +static char tn, tp; +losig_list *cursig = NULL; /* current signal for wire */ +ptype_list *ptl; +chain_list *head_join; +chain_list *head_sigalias; +losig_list *sigct1,*sigct2; + + head_join = head_sigalias = NULL; + + if (!tn) /* or tp, who cares? */ + env(&tn, &tp); + + while (1) { + i++; + if (vfgets(line, LSIZE, in) == (char *)NULL) + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + switch (line[0]) { + case '#' : /* comment */ + case '\{' : /* comment */ + case ' ' : /* empty line in vti file */ + case ';' : /* empty line in vti file */ + case 'A' : + case 'B' : + break; + case 'C' : /* C INT NOP NOP cap INT INT ; */ + if (mode != 'P') { + loctc_list *ptctc; + + t1 = strtok(line + 2, " \n\t\""); + l1 = atol(t1); + t2 = strtok((char *)NULL, " \n\t\""); + t3 = strtok((char *)NULL, " \n\t\""); + t4 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t4); + f = atof(s); + t5 = strtok((char *)NULL, " \n\t\""); + l3 = atol(t5); + t6 = strtok((char *)NULL, " \n\t\""); + l4 = atol(t6); + /* capacitance : + units are picofarads inside vti logical formats. + add capacitance on both signals. + 0 is a linear, wire, capacitance, + 1 is a grid capacitance, + 2-5 are sidewall and surface diffusion capacitances + 6 is diaphonic capacitances. */ + if (l1 != 1) { + + sigct1 = givelosigalias(fig, head_sigalias, (long)l3); + sigct2 = givelosigalias(fig, head_sigalias, (long)l4); + + if( !sigct1->PRCN ) + addlorcnet( sigct1 ); + + if( !sigct2->PRCN ) + addlorcnet( sigct2 ); + + if( ( ptctc = getloctc( sigct1, 0, sigct2, 0 ) ) ) + ptctc->CAPA = ptctc->CAPA + f; + else + addloctc( sigct1, 0, sigct2, 0, f ); + + addcapa( sigct1, f ); + addcapa( sigct2, f ); + } + } + break; + case 'E': /* E ; */ + { + locon_list *c1; + ptype_list *ptl; + num_list *pn; + lofig_list *ptmodel; + struct hns_X *effx; + struct hns_X *effscanx; + chain_list *scan_head_join; + losig_list *ptsig; + locon_list *ptcon; + + lofigchain( fig ); + + for (c1 = fig->LOCON; c1; c1 = c1->NEXT) { + ptl = getptype(c1->USER,HNSRCN); + ptl->DATA = reverse( ptl->DATA ); + } + + if( !compare_alias_join( fig, head_sigalias, &head_join ) ) { + hns_error((int)CON_SIGDIF, fname, (long)i, (char *)NULL, 0L); + } + + if( !traite_join( fig, head_join ) ) { + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + } + + /* Comme la fonction traite_join peut avoir deplacer des connecteurs ( passe d'un signal a un autre ), on refait un lofigchain + pour tout remettre a jour. Le lofigchain fait un nettoyage prealable, donc pas de problemes... */ + + lofigchain(fig); + + /* On nettoie les join */ + for( scan_head_join = head_join; scan_head_join; scan_head_join = scan_head_join->NEXT ) { + freechain( (chain_list*)(scan_head_join->DATA) ); + } + freechain( head_join ); + + /* destroy the trhu routes connectors and signals */ + for (pn = ylist; pn; pn = pn->NEXT) + { + ptsig = getlosig( fig, pn->DATA ); + ptl = getptype( ptsig->USER, LOFIGCHAIN ); + if( !ptl->DATA ) + dellosig( fig, pn->DATA ); + else + { + ptcon = (locon_list*)(((chain_list*)(ptl->DATA))->DATA); + if( !((chain_list*)(ptl->DATA))->NEXT && ptcon->ROOT == fig ) + { + if( (ptl = getptype( ptcon->USER, HNSRCN )) ) + { + freechain( (chain_list*)(ptl->DATA) ); + ptcon->USER = delptype( ptcon->USER, HNSRCN ); + } + dellocon( fig, ptcon->NAME ); + /* + for (delete = &fig->LOCON; *delete != NULL; ) + if ((*delete)->SIG->INDEX == pn->DATA) + { + c1 = (*delete)->NEXT; + if( (ptl = getptype( (*delete)->USER,HNSRCN ))) + { + freechain( (chain_list*)(ptl->DATA)); + (*delete)->USER = delptype( (*delete)->USER, HNSRCN ); + } + mbkfree((void *)*delete); + *delete = c1; + } + else + delete = &(*delete)->NEXT; + */ + + dellosig( fig, pn->DATA ); + } + else + { + fprintf( stderr, "*** mbkvti warning : Can't delete thru routes %ld.\n", ptsig->INDEX ); + } + } + } + + freenum(ylist); + + buildrcn(fig); + + for( ptmodel = model ; ptmodel; ptmodel = ptmodel->NEXT ) { + freechain( (chain_list*)( getptype(ptmodel->USER, HNSPHCON)->DATA ) ); + for(c1 = ptmodel->LOCON; c1; c1 = c1->NEXT ) { + effx = NULL; + for( effscanx = (struct hns_X*)( getptype( c1->USER,HNSRCN )->DATA ); + effscanx; effscanx = effscanx->NEXT ) { + if( effx ) + del_hns_X(effx); + effx = effscanx; + } + if( effx ) + del_hns_X(effx); + c1->USER = delptype(c1->USER, HNSRCN); + } + } + freelomodel(model); + + /* successfull exit */ + return 0; + } + case 'G' : /* G INT name ; */ + if (mode != 'P') { + losig_list *ptsig; + t1 = strtok(line + 2, " \n\t\"@"); + l1 = atol(t1); + t2 = strtok((char *)NULL, " \n\t\"@;"); + for (ptsig = fig->LOSIG; ptsig; ptsig = ptsig->NEXT) + if (ptsig->INDEX == (long)l1) { + ptsig->NAMECHAIN = addchain(ptsig->NAMECHAIN,(void *)namealloc(checkname(t2))); + break; + } + if (ptsig == (losig_list *)NULL) + (void)addlosig(fig, (long)l1, addchain((chain_list *)NULL, + (void *)t2), INTERNAL); + } + break; + case 'H' : /* H INT ; */ + break; + case 'I' : /* I name name name | numlist | numlist ; */ + if (mode != 'P') { + num_list *pnlist1 = (num_list *)NULL, *pnlist2 = (num_list *)NULL; + char s2[100]; + char s3[100]; + + if (strchr(line + 2, ';') != (char *)NULL) { + t1 = strtok(line + 2, " \n\t\"@"); + t2 = strtok((char *)NULL, " \n\t\"@"); + (void)strcpy(s2, t2); + t3 = strtok((char *)NULL, " \n\t\"@"); + (void)strcpy(s3, t3); + t4 = strtok((char *)NULL, " \n\t\"@"); + t5 = strtok((char *)NULL, " \n\t\"@"); + if (*t5 == '|') + pnlist1 = (num_list *)NULL; + else { + if (*t5 == '*') + pnlist1 = addnum((num_list *)NULL, 0L); + else + pnlist1 = addnum((num_list *)NULL, atol(t5)); + while (*(t5 = strtok((char *)NULL, " \n\t\"@")) != '|') { + if (*t5 == '*') + pnlist1 = addnum(pnlist1, 0L); + else + pnlist1 = addnum(pnlist1, atol(t5)); + } + } + t6 = strtok((char *)NULL, " \n\t\"@;"); + if (t6 == (char *)NULL) + pnlist2 = (num_list *)NULL; + else { + if (*t6 == '*') + pnlist2 = addnum((num_list *)NULL, 0L); + else + pnlist2 = addnum((num_list *)NULL, atol(t6)); + while ((t6 = strtok((char *)NULL, " \n\t\"@;")) + != (char *)NULL) { + if (*t6 == '*') + pnlist2 = addnum(pnlist2, 0L); + else + pnlist2 = addnum(pnlist2, atol(t6)); + } + } + } else + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + + { + lofig_list *ptmodel; + chain_list *phcon,*ch1,*ch2,*chainsig; + num_list *n1,*n2; + losig_list *ptsig; + locon_list *cm, *ci; + loins_list *ptins; + struct hns_X *scanx; + struct hns_I *newi; + chain_list *headi; + + ptmodel = getlomodel(model,s2); + phcon = (chain_list*)( (getptype(ptmodel->USER,HNSPHCON))->DATA ); + pnlist2 = (num_list*)reverse((chain_list*)pnlist2); + chainsig = NULL; + + for(ch1 = phcon, n1 = pnlist2; ch1 && n1; ch1 = ch1->NEXT, n1 = n1->NEXT ) { + /* Verify all signals on locon are the same */ + for(ch2 = ch1->NEXT, n2 = n1->NEXT ; ch2 && n2 ; ch2 = ch2->NEXT, n2 = n2->NEXT ) { + if( (ch1->DATA == ch2->DATA) && (n1->DATA != n2->DATA) ) + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char*)NULL, 0L); + } + /* Get one signal per locon */ + for(ch2 = phcon; ch2!=ch1; ch2 = ch2->NEXT ) { + if(ch2->DATA == ch1->DATA) + break; + } + if(ch1 == ch2) { + ptsig = givelosigalias( fig, head_sigalias, n1->DATA ); + chainsig = addchain(chainsig,(void*)ptsig); + } + } + /* On recupere la liste des signaux dans l'ordre inverse ou ils apparaissent dans le + fichier, mais dans l'ordre des connecteurs du modele */ + ptins = addloins(fig,s3,ptmodel,chainsig); + freenum(pnlist2); + freenum(pnlist1); /* no more parameters */ + + for( cm = ptmodel->LOCON; cm; cm = cm->NEXT) { + for( ci = ptins->LOCON; ci; ci = ci->NEXT ) { + if( ci->NAME == cm->NAME ) + break; + } + headi = NULL; + for(scanx=(struct hns_X*)( getptype(cm->USER,HNSRCN)->DATA ); + scanx; + scanx = scanx->NEXT) { + newi = givehnsi(fig, scanx->idx,ptins); + headi = addchain(headi,newi); + } + ci->USER = addptype(ci->USER,HNSRCN,headi); + } + } + } + break; + case 'J' : /* J INT INT ; */ + { + losig_list *s1, *s2; + chain_list *scan_head_join1; + chain_list *scan_head_join2; + chain_list *scan_join; + + t1 = strtok( line + 2, " \n\t\"@" ); + s1 = givelosig( fig, atol(t1) ); + + for( scan_head_join1 = head_join; scan_head_join1 ; scan_head_join1 = scan_head_join1->NEXT ) { + for( scan_join = (chain_list*)(scan_head_join1->DATA); scan_join; scan_join = scan_join->NEXT ) { + if( s1 == scan_join->DATA ) + break; + } + if( scan_join ) + break; + } + + if( ! scan_head_join1 ) { + head_join = addchain( head_join, addchain( NULL, s1 ) ); + scan_head_join1 = head_join; + } + /* scan_head_join1 est la liste qui contient le premier signal rencontre */ + + while( (t1 = strtok( NULL, " \n\t\"@" ) ) ) + { + if( strcmp(t1,";")==0 ) + break; + s2 = givelosig( fig, atol(t1) ); + + for( scan_head_join2 = head_join; scan_head_join2 ; scan_head_join2 = scan_head_join2->NEXT ) { + for( scan_join = (chain_list*)(scan_head_join2->DATA); scan_join; scan_join = scan_join->NEXT ) { + if( s2 == scan_join->DATA ) + break; + } + if( scan_join ) + break; + } + + if( !scan_head_join2 ) { + scan_head_join1->DATA = addchain( (chain_list*)(scan_head_join1->DATA), s2 ); + } + else + if( scan_head_join1 != scan_head_join2 ) { + for( scan_join = (chain_list*)(scan_head_join2->DATA); scan_join; scan_join = scan_join->NEXT ) { + scan_head_join1->DATA = addchain( (chain_list*)(scan_head_join1->DATA), scan_join->DATA ); + } + freechain( (chain_list*)(scan_head_join2->DATA) ); + head_join = delchain( head_join, scan_head_join2 ); + } + } + } + break; + case 'M' : /* M name name | strlist | strlist | numlist ; */ + if (mode != 'P') { + chain_list *slist2 = (chain_list *)NULL, *pt; + num_list *llist3 = NULL, *ptn; + chain_list *ptv; + locon_list *ptcon; + struct hns_X *headX; + + t1 = strtok(line + 2, " \n\t\"@"); + t2 = strtok((char *)NULL, " \n\t\"@"); + (void)strcpy(s, t2); + t3 = strtok((char *)NULL, " \n\t\"@"); /* the seperator | */ + + if (*t3 != '|') + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + + /* the first strlist is to be skipped */ + do { + t4 = strtok((char *)NULL, " \n\t\"@"); + if (t4 == (char *)NULL) + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + } while(*t4 != '|'); + + /* the second one contains the connectors name and order */ + t4 = strtok((char *)NULL, " \n\t\"@"); + while(*t4 != '|') { + if (t4 == (char *)NULL) + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + slist2 = addchain(slist2, (void *)namealloc(checkname(t4))); + t4 = strtok((char *)NULL, " \n\t\"@"); + } + + /* the third one contains the connectors ident */ + t4 = strtok((char *)NULL, " \n\t\"@"); + while(*t4 != ';') { + if (t4 == (char *)NULL) + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + llist3 = addnum(llist3,atol(t4)); + t4 = strtok((char *)NULL, " \n\t\"@"); + } + + model = addlomodel(model, s); + llist3 = (num_list*)reverse((chain_list*)llist3); + slist2 = reverse(slist2); + + for (pt = slist2, ptn = llist3; pt && ptn ; pt = pt->NEXT, ptn = ptn->NEXT) { + + headX = add_hns_X(); + headX->NEXT = NULL; + headX->idx = ptn->DATA; + headX->rcn = 0; + + for(ptv = slist2; ptv != pt; ptv = ptv->NEXT) { + if( pt->DATA == ptv->DATA ) + break; + } + if(pt == ptv) { + ptcon = addlocon(model, (char *)pt->DATA,(losig_list *)NULL, 'X'); + ptcon->USER = addptype(ptcon->USER, HNSRCN, headX); + } + else { + ptcon = getlocon(model,(char*)(pt->DATA)); + ptl = getptype(ptcon->USER,HNSRCN); + headX->NEXT = (struct hns_X*)( ptl->DATA ); + ptl->DATA = headX; + } + } + + if( pt || ptn ) + hns_error((int)PARSE_ERROR, fname, (long)i, (char *)NULL, 0L); + + freenum(llist3); + model->USER = addptype(model->USER,HNSPHCON,slist2); + } + break; + case 'N' : /* N INT name ; */ + if (mode != 'P') { + losig_list *ptsig; + t1 = strtok(line + 2, " \n\t\"@"); + l1 = atol(t1); + t2 = strtok((char *)NULL, " \n\t\"@;"); + ptsig = givelosigalias(fig, head_sigalias, (long)l1); + ptsig->NAMECHAIN = addchain(ptsig->NAMECHAIN,(void *)namealloc(checkname(t2))); + cursig = givelosig( fig, (long)l1 ); + } + break; + case 'P' : /* P INT name num ; */ + if (mode != 'C') { + t1 = strtok(line + 2, " \n\t\"@"); + t2 = strtok((char *)NULL, " \n\t\"@"); + t3 = strtok((char *)NULL, " \n\t\"@;"); + /* let's keep it, just in case ... */ + } + break; + + case 'T' : /* T name name name num num cap INT INT INT INT ; */ + if (mode != 'P') { + char type; + t1 = strtok(line + 2, " \n\t\"@"); + t2 = strtok((char *)NULL, " \n\t\"@["); + t3 = strtok((char *)NULL, " \n\t\"@[,"); + t4 = strtok((char *)NULL, " \n\t\"@,]"); + t5 = strtok((char *)NULL, " \n\t\"@]"); + t6 = strtok((char *)NULL, " \n\t\"@"); + t7 = strtok((char *)NULL, " \n\t\"@"); + t8 = strtok((char *)NULL, " \n\t\"@"); + t9 = strtok((char *)NULL, " \n\t\"@"); + if (islower((int)*t1)) + *t1 = toupper(*t1); + type = (*t1 == tn) ? TRANSN : TRANSP; + (void)strcpy(s, t3); + l1 = stol(s); + (void)strcpy(s, t4); + l2 = stol(s); + if ((t10 = strtok((char *)NULL, " \n\t\"@;")) == (char *)NULL) { + losig_list *ptgrid; + ptgrid = givelosigalias(fig, head_sigalias, atol(t6)); + (void)addlotrs(fig, type, 0L, 0L, + (unsigned short)l1, (unsigned short)l2, + 0, 0, 0, 0, + ptgrid, givelosigalias(fig, head_sigalias, atol(t7)), + givelosigalias(fig, head_sigalias, atol(t8)), givelosigalias(fig, head_sigalias, atol(t9) ), NULL); + /* do not add grid capacatance anymore + (void)addcapa(ptgrid, atof(t5)); + */ + } + else { /* T name name [num,num] num num cap INT INT INT INT; */ + losig_list *ptgrid; + t11 = strtok((char *)NULL, " \n\t\"@;"); + ptgrid = givelosigalias(fig, head_sigalias, atol(t8)); + (void)strcpy(s, t5); + l3 = stol(s); + (void)strcpy(s, t6); + l4 = stol(s); + (void)addlotrs(fig, type, l1, l2, + (unsigned short)l3, (unsigned short)l4, + 0, 0, 0, 0, + ptgrid, givelosigalias(fig, head_sigalias, atol(t9)), + givelosigalias(fig, head_sigalias, atol(t10)), givelosigalias(fig, head_sigalias, atol(t11) ), NULL); + /* do not add grid capacatance anymore + (void)addcapa(ptgrid, atof(t7)); + */ + } + } + break; + + case 'W' : /* W node1 node2 R C */ + if (mode != 'P') { + char *separ; + struct hns_X *pt_X; + struct hns_P *pt_P; + struct hns_I *pt_I; + struct hns_W *pt_W; + struct hns_W *head_W; + + separ=" \n\t\"@"; + ptl = getptype(cursig->USER,HNSRCN); + if(!ptl) { + cursig->USER = addptype(cursig->USER,HNSRCN,NULL); + ptl = cursig->USER; + } + head_W = ( struct hns_W* )( ptl->DATA ); + + pt_W = add_hns_W(); + + t1 = strtok(line + 2, separ); + if( strcasecmp(t1,"P")==0 ) { + t2 = strtok((char*)NULL,separ); + l1 = atol(t2); + pt_P = givehnsp(cursig, l1); + pt_W->flag = pt_W->flag | 4; + pt_W->node1 = pt_P; + } + else + if( strcasecmp(t1,"I")==0 ) { + t2 = strtok((char*)NULL,separ); + t3 = strtok((char*)NULL,separ); + l1 = atol(t3); + + pt_I = givehnsi(fig, l1,getloins(fig,t2)); + pt_W->flag = pt_W->flag | 2; + pt_W->node1 = pt_I; + } + else + if( strcasecmp(t1,"X")==0 ) { + t2 = strtok((char*)NULL,separ); + l1 = atol(t2); + + pt_X = givehnsx(fig, l1); + pt_W->flag = pt_W->flag | 1; + pt_W->node1 = pt_X; + } + else { + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + } + t1 = strtok((char*)NULL, separ); + if( strcasecmp(t1,"P")==0 ) { + t2 = strtok((char*)NULL,separ); + l1 = atol(t2); + + pt_P = givehnsp(cursig, l1); + pt_W->flag = pt_W->flag | 32; + pt_W->node2 = pt_P; + } + else + if( strcasecmp(t1,"I")==0 ) { + t2 = strtok((char*)NULL,separ); + t3 = strtok((char*)NULL,separ); + l1 = atol(t3); + + pt_I = givehnsi(fig, l1,getloins(fig,t2)); + pt_W->flag = pt_W->flag | 16; + pt_W->node2 = pt_I; + } + else + if( strcasecmp(t1,"X")==0 ) { + t2 = strtok((char*)NULL,separ); + l1 = atol(t2); + + pt_X = givehnsx(fig, l1); + pt_W->flag = pt_W->flag | 8; + pt_W->node2 = pt_X; + } + else { + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + } + + t1 = strtok( NULL, separ); + pt_W->r = stof(t1); + t1 = strtok( NULL, separ); + pt_W->c = stof(t1); + pt_W->NEXT = head_W; + head_W = pt_W; + ptl->DATA = head_W; + } + break; + + case 'X' : /* X INT bof name ; */ + { + locon_list *ptcon; + losig_list *ptsig; + losig_list *sig2; + char *conname; + struct hns_X *headX; + ptype_list *ptl; + chain_list *scan_head_sigalias, *scan_sigalias; + + t1 = strtok(line + 2, " \n\t\"@"); + l1 = atol(t1); + t2 = strtok((char *)NULL, " \n\t\"@"); + t3 = strtok((char *)NULL, " \n\t\"@;"); + + headX= givehnsx(fig, atol(t2)); + + conname = namealloc(checkname(t3)); + + /* Chaque locon possede un nom unique */ + + for(ptcon = fig->LOCON; ptcon; ptcon = ptcon->NEXT) { + if( ptcon->NAME == conname ) + break; + } + + if( ptcon ) { + if ( ptcon->SIG->INDEX != l1 ) { + sig2 = givelosig(fig, l1); + sig2->TYPE = EXTERNAL; + for( scan_head_sigalias = head_sigalias; scan_head_sigalias; scan_head_sigalias = scan_head_sigalias->NEXT ) { + for( scan_sigalias = (chain_list*)(scan_head_sigalias->DATA); scan_sigalias; scan_sigalias = scan_sigalias->NEXT ) { + if( (losig_list*)( scan_sigalias->DATA ) == ptcon->SIG ) + break; + } + if( scan_sigalias ) + break; + } + if( !scan_head_sigalias ) { + /* Attention : l'ordre est important : le signal qui existait avant doit etre + en fin de liste */ + head_sigalias = addchain( head_sigalias, addchain( addchain(NULL,ptcon->SIG), sig2 )); + } + else { + for( scan_sigalias = (chain_list*)(scan_head_sigalias->DATA); scan_sigalias; scan_sigalias = scan_sigalias->NEXT ) { + if( (losig_list*)( scan_sigalias->DATA ) == sig2 ) + break; + } + if( !scan_sigalias ) { + (chain_list*)(scan_head_sigalias->DATA) = addchain( (chain_list*)(scan_head_sigalias->DATA), sig2); + } + } + } + + /* Si on est en mode 'C', on peut se retrouver ici sans avoir de ptype */ + if( mode == 'C' ) + { + ptl = getptype(ptcon->USER,HNSRCN); + if( !ptl ) + { + /* C'est la 1ere fois qu'on tombe sur ce locon, on lui enleve tous les connecteurs physiques + * qu'il avait */ + while(ptcon->PNODE) + delloconnode( ptcon, ptcon->PNODE->DATA); + ptl = ptcon->USER = addptype( ptcon->USER, HNSRCN, NULL ); + } + } + else + ptl = getptype(ptcon->USER,HNSRCN); + + ptl->DATA = addchain( (chain_list*)(ptl->DATA),headX); + } + else { + /* Si c'est il existe deja un connecteur sur ce signal, le addlosig terminera le programme. */ + ptsig = addlosig(fig, (long)l1, addchain((chain_list *)NULL, + (void *)conname), EXTERNAL); + ptcon = addlocon( fig, conname, ptsig, 'X'); + ptcon->USER = addptype( ptcon->USER, HNSRCN, addchain(NULL,headX) ); + } + } + + break; + case 'Y' : /* Y INT INT [ num , num ] [ num , num ] ; */ + break; + t1 = strtok(line + 2, " \n\t\"@"); + t2 = strtok((char *)NULL, " \n\t\"@;"); + l2 = atol(t2); + ylist = addnum(ylist, l2); /* create a list of thru routes */ + break; + case 'Z' : /* Z INT name INT cap INT num num ; */ + break; + default : + hns_error((int)SYNTAX_ERROR, fname, (long)i, (char *)NULL, 0L); + break; + } + } +} + +/******************************************************************************* +* unique function accesible from this file * +*******************************************************************************/ +void vtiloadlofig(ptfig, figname, mode) +lofig_list *ptfig; +char *figname; +char mode; +{ +FILE *in; + + /* opening file */ + if ((in = mbkfopen(figname, IN_LO, READ_TEXT)) == (FILE *)NULL) + hns_error((int)OPEN_ERROR, figname, 0L, (char *)NULL, 0L); + + if (TRACE_MODE == 'Y') + (void)printf("\n--- mbk --- parsing file : %s.%s in mode %c\n", + figname, IN_LO, mode); + + /* parsing */ + if (parse(ptfig, mode, in, figname)) + hns_error((int)PARSE_ERROR, figname, 0L, (char *)NULL, 0L); + + if (fclose(in)) + hns_error((int)CLOSE_ERROR, figname, 0L, (char *)NULL, 0L); + + (void)strcpy(PARSER_INFO, "@(#)vti logical views parser version 4.04"); +} + +static struct hns_X* add_hns_X() +{ + struct hns_X *head; + int i; + + if(!HNS_X) + { + HNS_X = (struct hns_X*)mbkalloc(sizeof(struct hns_X)*64); + FREE_HNS = addchain(FREE_HNS,HNS_X); + + for(i=0;i<=62;i++) + HNS_X[i].NEXT=&(HNS_X[i+1]); + HNS_X[63].NEXT=NULL; + } + head = HNS_X; + HNS_X = HNS_X->NEXT; + + head->NEXT = NULL; + head->idx = 0; + head->rcn = 0; + + return(head); +} + +static void del_hns_X( ptx ) +struct hns_X *ptx; +{ + ptx->NEXT = HNS_X; + HNS_X = ptx; +} + +static struct hns_I* add_hns_I() +{ + struct hns_I *head; + int i; + + if(!HNS_I) + { + HNS_I = (struct hns_I*)mbkalloc(sizeof(struct hns_I)*64); + FREE_HNS = addchain(FREE_HNS,HNS_I); + + for(i=0;i<=62;i++) + HNS_I[i].NEXT=&(HNS_I[i+1]); + HNS_I[63].NEXT=NULL; + } + head = HNS_I; + HNS_I = HNS_I->NEXT; + + head->NEXT = NULL; + head->idx = 0; + head->rcn = 0; + head->ins = NULL; + + return(head); +} + +static void del_hns_I( pti ) +struct hns_I *pti; +{ + pti->NEXT = HNS_I; + HNS_I = pti; +} + +static struct hns_P* add_hns_P() +{ + struct hns_P *head; + int i; + + if(!HNS_P) + { + HNS_P = (struct hns_P*)mbkalloc(sizeof(struct hns_P)*64); + FREE_HNS = addchain(FREE_HNS,HNS_P); + + for(i=0;i<=62;i++) + HNS_P[i].NEXT=&(HNS_P[i+1]); + HNS_P[63].NEXT=NULL; + } + head = HNS_P; + HNS_P = HNS_P->NEXT; + + head->NEXT = NULL; + head->idx = 0; + head->sig = NULL; + head->rcn = 0; + + return(head); +} + +/* +static void del_hns_P( ptp ) +struct hns_P *ptp; +{ + ptp->NEXT = HNS_P; + HNS_P = ptp; +} +*/ + +static struct hns_W* add_hns_W() +{ + struct hns_W *head; + int i; + + if(!HNS_W) + { + HNS_W = (struct hns_W*)mbkalloc(sizeof(struct hns_W)*64); + FREE_HNS = addchain(FREE_HNS,HNS_W); + + for(i=0;i<=62;i++) + HNS_W[i].NEXT=&(HNS_W[i+1]); + HNS_W[63].NEXT=NULL; + } + head = HNS_W; + HNS_W = HNS_W->NEXT; + + head->NEXT = NULL; + head->flag = 0; + head->node1 = NULL; + head->node2 = NULL; + head->r = 0.0; + head->c = 0.0; + + return(head); +} + +static void del_hns_W( ptw ) +struct hns_W *ptw; +{ + ptw->NEXT = HNS_W; + HNS_W = ptw; +} + +static struct hns_P* givehnsp( ptsig, index ) +losig_list *ptsig; +int index; +{ + ptype_list *ptl; + struct hns_P *ptp; + struct hns_W *scanw; + + ptl = getptype(ptsig->USER, HNSRCN); + if( !ptl ) { + ptp = add_hns_P(); + ptp->idx = index; + ptp->sig = ptsig; + ptp->rcn = 0; + return(ptp); + } + + for(scanw = (struct hns_W*)( getptype( ptsig->USER, HNSRCN )->DATA ); scanw; scanw = scanw->NEXT ) { + if(scanw->flag & 4) { + ptp = (struct hns_P*)(scanw->node1); + if( ptp->idx == index && ptp->sig == ptsig ) + return(ptp); + } + if(scanw->flag & 32) { + ptp = (struct hns_P*)(scanw->node2); + if( ptp->idx == index && ptp->sig == ptsig ) + return(ptp); + } + } + ptp = add_hns_P(); + ptp->idx = index; + ptp->sig = ptsig; + ptp->rcn = 0; + return(ptp); +} + +static struct hns_X* givehnsx(ptfig, index) +lofig_list *ptfig; +int index; +{ + ptype_list *ptl; + struct hns_X *headx, *scanx; + + ptl = getptype( ptfig->USER, HNSRCNX ); + if( !ptl ) { + ptfig->USER = addptype( ptfig->USER, HNSRCNX, NULL ); + ptl = ptfig->USER; + } + headx = (struct hns_X*)(ptl->DATA); + + for( scanx = headx; scanx; scanx = scanx->NEXT ) { + if (scanx->idx == index ) + break; + } + + if(!scanx) { + scanx = add_hns_X(); + scanx->idx = index; + scanx->NEXT = headx; + scanx->rcn = 0; + headx = scanx; + (struct hns_X*)(ptl->DATA) = headx; + } + + return(scanx); +} + +static struct hns_I* givehnsi(ptfig, index, ptins) +lofig_list *ptfig; +int index; +loins_list *ptins; +{ + ptype_list *ptl; + struct hns_I *headi, *scani; + + ptl = getptype( ptfig->USER, HNSRCNI ); + if( !ptl ) { + ptfig->USER = addptype( ptfig->USER, HNSRCNI, NULL ); + ptl = ptfig->USER; + } + headi = (struct hns_I*)(ptl->DATA); + + for( scani = headi; scani; scani = scani->NEXT ) { + if (scani->idx == index && scani->ins == ptins) + break; + } + + if(!scani) { + scani = add_hns_I(); + scani->idx = index; + scani->NEXT = headi; + scani->ins = ptins; + scani->rcn = 0; + headi = scani; + (struct hns_I*)(ptl->DATA) = headi; + } + + return(scani); + +} + +static void buildrcn( ptfig ) +lofig_list *ptfig; +{ + int index; + losig_list *scanlosig; + ptype_list *ptl; + lorcnet_list *ptrcnet; + struct hns_W *headw; + struct hns_W *scanw; + struct hns_W *elem_w; + struct hns_X *elem_x; + struct hns_X *headx; + struct hns_X *scanx; + struct hns_I *elem_i; + struct hns_I *scani; + struct hns_I *headi; + struct hns_P *elem_p; + int n1=0,n2=0; + locon_list *ptcon; + chain_list *scan; + chain_list *head; + chain_list *scanchain; + locon_list *scanlocon; + loins_list *scanloins; + ptype_list *ptl_head; + + + /* On commence par remplir le champ RCN des structures */ + for( scanlosig = ptfig->LOSIG; scanlosig; scanlosig = scanlosig->NEXT ) { + + index = 1; + ptl = getptype( scanlosig->USER, HNSRCN ); + + /* Si on est en mode 'C', il se peut que certains signaux aient herites d'une vue + * RC dans les signaux cree pour les connecteurs */ + + headw = NULL; + + if( ptl ) { + + headw = (struct hns_W*)( ptl->DATA ); + + /* On ne cree les vues RC que si on a des resistances. Tant pis pour les noeuds sur les locons */ + if( !scanlosig->PRCN && headw ) + ptrcnet = addlorcnet(scanlosig); + + for( scanw = headw; scanw; scanw = scanw->NEXT ) { + + if( scanw->flag & 1 ) { + elem_x = (struct hns_X*)( scanw->node1 ); + if( elem_x->rcn == 0 ) + elem_x->rcn = index++; + n1 = elem_x->rcn; + } + else if( scanw->flag & 2 ) { + elem_i = (struct hns_I*)( scanw->node1 ); + if( elem_i->rcn == 0 ) + elem_i->rcn = index++; + n1 = elem_i->rcn; + } + else if( scanw->flag & 4 ) { + elem_p = (struct hns_P*)( scanw->node1 ); + if( elem_p->rcn == 0 ) + elem_p->rcn = index++; + n1 = elem_p->rcn; + } + + if( scanw->flag & 8 ) { + elem_x = (struct hns_X*)( scanw->node2 ); + if( elem_x->rcn == 0 ) + elem_x->rcn = index++; + n2 = elem_x->rcn; + } + else if( scanw->flag & 16 ) { + elem_i = (struct hns_I*)( scanw->node2 ); + if( elem_i->rcn == 0 ) + elem_i->rcn = index++; + n2 = elem_i->rcn; + } + else if( scanw->flag & 32 ) { + elem_p = (struct hns_P*)( scanw->node2 ); + if( elem_p->rcn == 0 ) + elem_p->rcn = index++; + n2 = elem_p->rcn; + } + + addlowire( scanlosig, RCN_WIRE_UNKNOW, 0, scanw->r, scanw->c, 0l, 0l, 0l, 0l, n1, n2 ); + addcapa( scanlosig, scanw->c ); + } + } + + ptl = getptype( scanlosig->USER, LOFIGCHAIN ); + + if( ptl && headw ) { + + for( scanchain = (chain_list*)( ptl->DATA ); scanchain; scanchain = scanchain->NEXT ) { + + ptcon = (locon_list*)( scanchain->DATA ); + ptl_head = getptype( ptcon->USER, HNSRCN ); + if( !ptl_head ) + continue; + + head = (chain_list*)( ptl_head->DATA ); + head = reverse(head); + + if( ptcon->ROOT == ptfig ) { + for(scan = head; scan; scan = scan->NEXT ) { + elem_x = (struct hns_X*)(scan->DATA); + if( elem_x->rcn == 0 ) + elem_x->rcn = index++; + setloconnode( ptcon, elem_x->rcn ); + } + } + else { + for(scan = head; scan; scan = scan->NEXT ) { + elem_i = (struct hns_I*)(scan->DATA); + if( elem_i->rcn == 0 ) + elem_i->rcn = index++; + setloconnode( ptcon, elem_i->rcn ); + } + } + head = reverse(head); + } + } + } + + /* Technicien de surface */ + + for(scanlosig = ptfig->LOSIG; scanlosig; scanlosig = scanlosig->NEXT ) { + ptl = getptype( scanlosig->USER, HNSRCN ); + if( ptl ) { + headw = (struct hns_W*)( ptl->DATA ); + elem_w = NULL; + for( scanw = headw; scanw; scanw = scanw->NEXT ) { + if( elem_w ) + del_hns_W( elem_w ); + } + if( elem_w ) + del_hns_W( elem_w ); + scanlosig->USER = delptype( scanlosig->USER, HNSRCN ); + } + } + + for(scanlocon = ptfig->LOCON; scanlocon; scanlocon = scanlocon->NEXT ) { + freechain( (chain_list*)( getptype(scanlocon->USER,HNSRCN)->DATA ) ); + scanlocon->USER = delptype( scanlocon->USER, HNSRCN ); + } + + for(scanloins = ptfig->LOINS; scanloins; scanloins = scanloins->NEXT ) { + for(scanlocon = scanloins->LOCON; scanlocon; scanlocon = scanlocon->NEXT ) { + freechain( (chain_list*)( getptype(scanlocon->USER,HNSRCN)->DATA ) ); + scanlocon->USER = delptype( scanlocon->USER, HNSRCN ); + } + } + + ptl = getptype( ptfig->USER, HNSRCNX ); + if(ptl) { + headx = (struct hns_X*)( ptl->DATA ); + elem_x = NULL; + for( scanx = headx; scanx; scanx = scanx->NEXT ) { + if( elem_x ) + del_hns_X( elem_x ); + elem_x = scanx; + } + if( elem_x ) + del_hns_X( elem_x ); + + ptfig->USER = delptype( ptfig->USER, HNSRCNX ); + } + + ptl = getptype( ptfig->USER, HNSRCNI ); + if(ptl) { + headi = (struct hns_I*)( ptl->DATA ); + elem_i = NULL; + for( scani = headi; scani; scani = scani->NEXT ) { + if( elem_i ) + del_hns_I( elem_i ); + elem_i = scani; + } + if( elem_i ) + del_hns_I( elem_i ); + + ptfig->USER = delptype( ptfig->USER, HNSRCNI ); + } +} + +/* +static void movehnsw( sig1, sig2) +losig_list *sig1; +losig_list *sig2; +{ + ptype_list *ptl; + struct hns_W *headw1; + struct hns_W *headw2; + + ptl = getptype( sig1->USER,HNSRCN ); + if (!ptl ) + headw1 = NULL; + else + headw1 = ( struct hns_W* )( ptl->DATA ); + + ptl = getptype( sig2->USER,HNSRCN ); + if (!ptl ) + headw2 = NULL; + else + headw2 = ( struct hns_W* )( ptl->DATA ); + + if( !headw2 ) + return; + + if( !headw1 ) { + sig1->USER = addptype( sig1->USER, HNSRCN, headw2 ); + } + else { + for( ; headw1->NEXT; headw1 = headw1->NEXT ) ; + headw1->NEXT = headw2; + } + sig2->USER = delptype( sig2->USER, HNSRCN ); +} +*/ +/* +void debug(ptfig) +lofig_list *ptfig; +{ + locon_list *scanlocon; + ptype_list *ptl; + chain_list *scanchain; + struct hns_X *elem_x; + + printf("##############################################################################################\n"); + for( scanlocon = ptfig->LOCON; scanlocon; scanlocon = scanlocon->NEXT ) { + printf("Connecteur %s :",scanlocon->NAME); + ptl = getptype(scanlocon->USER,HNSRCN); + if( ptl ) + { + for(scanchain = (chain_list*)(ptl->DATA); scanchain; scanchain = scanchain->NEXT ) { + elem_x = (struct hns_X*)(scanchain->DATA); + printf("%ld ", elem_x->idx); + } + } + printf("\n"); + } + printf("##############################################################################################\n"); +} +*/ + +static losig_list* givelosigalias( ptfig, head_sigalias, n ) +lofig_list *ptfig; +chain_list *head_sigalias; +int n; +{ + chain_list *scan_head_sigalias; + chain_list *scan_sigalias; + losig_list *ptsig; + losig_list *grpsig; + + for( scan_head_sigalias = head_sigalias; scan_head_sigalias; scan_head_sigalias = scan_head_sigalias->NEXT ) { + + for( scan_sigalias = (chain_list*)(scan_head_sigalias->DATA); scan_sigalias; scan_sigalias = scan_sigalias->NEXT ) { + + ptsig = (losig_list*)( scan_sigalias->DATA ); + + if( ptsig->INDEX == n ) { + for( ; scan_sigalias->NEXT ; scan_sigalias = scan_sigalias->NEXT ); + grpsig = (losig_list*)( scan_sigalias->DATA ); + return( grpsig ); + } + } + } + + return( givelosig( ptfig, n ) ); +} + +static int compare_alias_join( fig, head_sigalias, ext_join ) +lofig_list *fig; +chain_list *head_sigalias; +chain_list **ext_join; +{ + chain_list *scan_head_sigalias; + chain_list *scan_sigalias; + chain_list *scan_head_join; + chain_list *scan_join; + chain_list *scan_chain; + chain_list *head_new_join; + chain_list *add_to_head_join; + chain_list *head_join; + int manque; + int me; + + head_join = *ext_join; + + add_to_head_join = NULL; + + for( scan_head_sigalias = head_sigalias; scan_head_sigalias; scan_head_sigalias=scan_head_sigalias->NEXT) { + + manque = 0; + me=0; + + scan_sigalias = (chain_list*)( scan_head_sigalias ->DATA ); + + for( scan_head_join = head_join; scan_head_join ; scan_head_join = scan_head_join->NEXT ) { + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + if( scan_join->DATA == scan_sigalias->DATA ) { + break; + } + } + if( scan_join ) + break; + } + + if( !scan_head_join ) { + msg_err( fig, scan_head_sigalias->DATA ); + manque = 1; + me = 1; + /* + return(0); + */ + } + else { + + for( scan_sigalias = scan_sigalias->NEXT; scan_sigalias; scan_sigalias = scan_sigalias->NEXT ) { + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + if ( scan_join->DATA == scan_sigalias->DATA ) + break; + } + if( !scan_join ) + { + if( me ) + msg_err( fig, scan_head_sigalias->DATA ); + manque = 1; + me = 1; + /* + return(0); + */ + } + } + } + + if( manque ) { + /* Il manque un join pour regrouper des signaux */ + + head_new_join = NULL; + + for( scan_sigalias = ((chain_list*)(scan_head_sigalias->DATA)); + scan_sigalias; + scan_sigalias = scan_sigalias->NEXT ) { + head_new_join = addchain( head_new_join, scan_sigalias->DATA ); + } + + for( scan_head_join = head_join; scan_head_join ; scan_head_join = scan_head_join->NEXT ) { + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + for( scan_sigalias = ((chain_list*)(scan_head_sigalias->DATA)); scan_sigalias; + scan_sigalias = scan_sigalias->NEXT) { + if( scan_join->DATA == scan_sigalias->DATA ) { + break; + } + } + if( scan_sigalias ) + break; + } + + /* Si on a trouve au moins un element dans la liste join, on transfert toute la liste join vers la + nouvelle et on supprime l'originale */ + + if( scan_join ) { + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + for( scan_chain = head_new_join; scan_chain; scan_chain = scan_chain->NEXT ) { + if( scan_chain->DATA == scan_join->DATA ) + break; + } + if(!scan_chain) + head_new_join = addchain( head_new_join, scan_join->DATA ); + } + + freechain( (chain_list*)(scan_head_join->DATA) ); + scan_head_join->DATA = NULL; + } + } + + /* En creant le head_new_join, on a utilise addchain, ce qui inverse l'ordre des signaux */ + + add_to_head_join = addchain( add_to_head_join, head_new_join ); + } + } + + if( head_join ) { + for( scan_head_join = head_join; scan_head_join->NEXT ; scan_head_join = scan_head_join->NEXT ); + scan_head_join->NEXT = add_to_head_join; + } + else { + head_join = add_to_head_join; + } + + *ext_join = head_join; + return( 1 ); +} + +static void msg_err(fig, head) +lofig_list *fig; +chain_list *head; +{ + locon_list *ptcon = NULL; + losig_list *ptsig; + chain_list *scan,*slf; + ptype_list *ptl; + + for( scan = head; scan; scan = scan->NEXT ) { + + ptcon = NULL; + + ptsig = (losig_list*)(scan->DATA); + ptl = getptype( ptsig->USER, LOFIGCHAIN ); + + for( slf = (chain_list*)(ptl->DATA) ; slf; slf = slf->NEXT ) { + ptcon = (locon_list*)( slf->DATA ); + if(ptcon->ROOT == fig ) { + break; + } + } + + if(ptcon) + break; + } + + (void)fprintf(stderr,"\n*** mbk warning ***\n"); + (void)fprintf(stderr,"no join for signals connected on the connector %s\n\n",ptcon->NAME); +} + + +static int traite_join( fig, head_join ) +lofig_list *fig; +chain_list *head_join; +{ + chain_list *scan_head_join, *scan_join; + int trouve; + losig_list *ptsig; + losig_list *grpsig = NULL; + loins_list *scanloins; + lotrs_list *scanlotrs; + locon_list *scanlocon; + locon_list *oldlocon=NULL; + chain_list *scanchain; + ptype_list *ptlsrc; + ptype_list *ptldst; + ptype_list *ptl; + struct hns_W *scanw; + char errmes[256] ; + int externe; + chain_list *nom,*scnom; + loctc_list *ptctc; + losig_list *s1, *s2; + float f; + + for( scan_head_join = head_join; scan_head_join; scan_head_join = scan_head_join->NEXT ) { + if( !scan_head_join->DATA ) + continue; + + /* On commence par verifier qu'il n'y a seulement qu'un signal qui possede des connecteurs. + On en profite egalement pour retrouver le signal qui regroupera les autres ( le dernier + dans la liste des join ) */ + + trouve = 0; + externe = 0; + nom = NULL; + + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + + ptsig = (losig_list*)(scan_join->DATA); + ptl = getptype( ptsig->USER, LOFIGCHAIN ); + + if( ptsig->TYPE == EXTERNAL ) + externe = 1; + + for( scanchain = (chain_list*)(ptl->DATA); scanchain; scanchain = scanchain->NEXT ) { + + scanlocon = (locon_list*)( scanchain->DATA ); + + if( scanlocon->ROOT==fig ) { + if( trouve ) { + sprintf(errmes,"%s and %s",oldlocon->NAME,scanlocon->NAME) ; + hns_error((int)BAD_JOIN, fig->NAME, (long)0,errmes,ptsig->INDEX); + } + trouve = 1; + oldlocon = scanlocon ; + } + } + + if( !scan_join->NEXT ) + grpsig = ptsig; + } + + /* On fait remplace par ptsig tous les signaux de la figure qui apparaissent dans le join */ + + /* Les connecteurs sur les instances */ + + for( scanloins = fig->LOINS ; scanloins; scanloins = scanloins->NEXT ) { + + for( scanlocon = scanloins->LOCON; scanlocon; scanlocon = scanlocon->NEXT ) { + + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + + if( scan_join->DATA == scanlocon->SIG ) { + scanlocon->SIG = grpsig; + break; + } + } + } + } + + /* Les connecteurs de la figure */ + + for( scanlocon = fig->LOCON; scanlocon; scanlocon = scanlocon->NEXT ) { + + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + + if( scan_join->DATA == scanlocon->SIG ) { + + scanlocon->SIG = grpsig; + break; + } + } + } + + /* Les connecteurs sur les transistors */ + + for( scanlotrs = fig->LOTRS; scanlotrs; scanlotrs = scanlotrs->NEXT ) { + + for( scan_join = (chain_list*)(scan_head_join->DATA); scan_join; scan_join = scan_join->NEXT ) { + + if( scan_join->DATA == scanlotrs->GRID->SIG ) + scanlotrs->GRID->SIG = grpsig; + + if( scan_join->DATA == scanlotrs->SOURCE->SIG ) + scanlotrs->SOURCE->SIG = grpsig; + + if( scan_join->DATA == scanlotrs->DRAIN->SIG ) + scanlotrs->DRAIN->SIG = grpsig; + + if( scan_join->DATA == scanlotrs->BULK->SIG ) + scanlotrs->BULK->SIG = grpsig; + } + + } + + /* On efface les signaux devenus inutiles en transferant les vues RC */ + + for( scan_join = ((chain_list*)(scan_head_join->DATA)); scan_join; scan_join = scan_join->NEXT ) { + ptsig = (losig_list*)(scan_join->DATA); + if( ptsig != grpsig ) { + if ( ptsig->PRCN ) + { + if( !grpsig->PRCN ) + addlorcnet( grpsig ); + addcapa( grpsig, ptsig->PRCN->CAPA ); + } + + if( nom ) { + for( scnom = nom ; scnom->NEXT; scnom = scnom->NEXT ) ; + scnom->NEXT = ptsig->NAMECHAIN; + ptsig->NAMECHAIN = NULL; + } + else { + nom = ptsig->NAMECHAIN; + ptsig->NAMECHAIN = NULL; + } + + ptlsrc = getptype( ptsig->USER, HNSRCN ); + if( ptlsrc ) { + ptldst = getptype( grpsig->USER, HNSRCN ); + if( !ptldst ) { + grpsig->USER = addptype( grpsig->USER, HNSRCN, ptlsrc->DATA ); + } + else { + for( scanw= (struct hns_W*)( ptlsrc->DATA ); scanw->NEXT; scanw = scanw->NEXT ); + scanw->NEXT = (struct hns_W*)( ptldst->DATA ); + ptldst->DATA = ptlsrc->DATA; + } + ptsig->USER = delptype( ptsig->USER, HNSRCN ); + } + + if( ptsig->PRCN ) + while( ptsig->PRCN->PCTC ) + { + ptctc = (loctc_list*)(ptsig->PRCN->PCTC->DATA); + s1 = ptctc->SIG1 ; + s2 = ptctc->SIG2 ; + f = ptctc->CAPA ; + delloctc( s1, 0, s2, 0 ); + if( s1 == ptsig ) + s1 = grpsig; + if( s2 == ptsig ) + s2 = grpsig; + + if( s1 != s2 ) + { + ptctc = getloctc( s1, 0, s2, 0 ); + if( ptctc ) + ptctc->CAPA = ptctc->CAPA + f; + else + addloctc( s1, 0, s2, 0, f ); + } + } + dellosig( fig, ptsig->INDEX ); + } + } + + if( externe ) + grpsig->TYPE = EXTERNAL; + else + grpsig->TYPE = INTERNAL; + + if( grpsig->NAMECHAIN ) { + for( scnom = grpsig->NAMECHAIN ; scnom->NEXT; scnom = scnom->NEXT ) ; + scnom->NEXT = nom; + } + else { + grpsig->NAMECHAIN = nom; + } + } + + return( 1 ); +} diff --git a/alliance/src/mbkvti/src/parse_vti_p.c b/alliance/src/mbkvti/src/parse_vti_p.c new file mode 100644 index 00000000..95152442 --- /dev/null +++ b/alliance/src/mbkvti/src/parse_vti_p.c @@ -0,0 +1,1344 @@ +/* + * This file is part of the Alliance CAD System + * Copyright (C) Laboratoire LIP6 - Département ASIM + * Universite Pierre et Marie Curie + * + * Home page : http://www-asim.lip6.fr/alliance/ + * E-mail support : mailto:alliance-support@asim.lip6.fr + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * Alliance VLSI CAD System is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with the GNU C Library; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/******************************************************************************* +* mbk : vti parser for symbolic layout view : cp format v7r5 * +* * +* Based upon material provided by Alain Greiner in 1990, in lex and yacc * +* * +* version 0.0 written by Hichang Li in june 1991 under the supervision of * +* Frederic Petrot * +* version 1.0 is basically an update of version 0.0 written by Frederic * +* Petrot on september 1991 * +* * +* New versions are mostly bug corrections, or standardization matters and are * +* done by Frederic Petrot, since middle 1990. * +* * +* version : 3.06 * +* date : 03/08/92 * +*******************************************************************************/ + +/* + * $Log: parse_vti_p.c,v $ + * Revision 1.1 2002/03/08 14:17:47 fred + * Initial revision + * + * Revision 1.7 2001/02/21 15:37:40 fred + * New layers + * + * Revision 1.6 2000/02/22 14:00:12 syf + * IDEM + * + * Revision 1.5 2000/02/09 10:09:45 syf + * Hello world + * + * Revision 1.4 2000/02/07 16:55:36 syf + * BIGVIA TURNVIA et CALUx + * + * Revision 1.3 2000/01/12 10:00:47 syf + * Nouveau PHVIA + * + * Revision 1.2 1999/07/12 16:16:24 ludo + * Modif pour Franck + * + * Revision 1.1.1.1 1998/10/02 15:27:13 alliance + * Imported by czo + * + * Revision 5.1 1998/09/16 14:48:38 mbkvti + * rcs version number consistency + * + * Revision 5.0 1998/09/16 14:46:20 mbkvti + * rcs version number consistency + * + */ +#ident "$Id: parse_vti_p.c,v 1.1 2002/03/08 14:17:47 fred Exp $" + +#include +#include +#include +#include +#include MUT_H +#include MPH_H +#include MPU_H + +#define LSIZE 16384 /* max line size for fgets */ + +enum {CPPREF_ERROR, CPIREF_ERROR, CPCREF_ERROR, SYNTAX_ERROR, VIA_ERROR, + BIGVIA_ERROR, REF_ERROR, OPEN_ERROR, PARSE_ERROR, CLOSE_ERROR}; + + +/******************************************************************************* +* These macros are big but are supposed to speed up the whole thing * +* All arguments are passed per values, this is different from old versions * +*******************************************************************************/ + +/******************************************************************************* +* macro cppref() * +*******************************************************************************/ +#define cppref(px, py, refnum, lineno) \ +{ \ +point_list *ptpoint; \ + \ + for (ptpoint = head_point; ptpoint; ptpoint = ptpoint->NEXT) \ + if (ptpoint->INDEX == refnum) \ + break; \ + \ + if (ptpoint == (point_list *)NULL) \ + cp_error((int)CPPREF_ERROR, fname, lineno, refnum); \ + \ + px = ptpoint->X; \ + py = ptpoint->Y; \ +} + +/******************************************************************************* +* macro cpcref() * +*******************************************************************************/ +#define cpcref(px, py, refnum, lineno) \ +{ \ +phcon_list *ptcon; \ + \ + for (ptcon = figure->PHCON; ptcon; ptcon = ptcon->NEXT) \ + if (((int)(getptype(ptcon->USER, (long)VTIPARSER)->DATA)) == refnum) \ + break; \ + \ + if (ptcon == (phcon_list *)NULL) \ + cp_error((int)CPCREF_ERROR, fname, lineno, refnum); \ +\ + px = ptcon->XCON; \ + py = ptcon->YCON; \ +} + +/******************************************************************************* +* macro cpiref() * +*******************************************************************************/ +#define cpiref(px, py, insname, refnum, lineno) \ +{ \ +phfig_list *ptnewfig; \ +phcon_list *ptcon; \ +phins_list *ptins; \ + \ + ptins = getphins(figure, insname); \ + ptnewfig = getphfig(ptins->FIGNAME, 'P'); \ + for (ptcon = ptnewfig->PHCON; ptcon; ptcon = ptcon->NEXT) \ + if ((int)(getptype(ptcon->USER, (long)VTIPARSER)->DATA) == refnum) \ + break; \ + \ + if (ptcon == (phcon_list *)NULL) \ + cp_error((int)CPIREF_ERROR, fname, lineno, refnum); \ + \ + xyflat(&px, &py, ptcon->XCON, ptcon->YCON, ptins->XINS, ptins->YINS, \ + ptnewfig->XAB1, ptnewfig->YAB1, ptnewfig->XAB2, ptnewfig->YAB2, \ + ptins->TRANSF); \ +} +/******************************************************************************* +* macro used to add a point to the point list * +*******************************************************************************/ +#define addpoint(xp,yp) \ +{ \ +point_list *point; \ + point = (point_list *)mbkalloc(sizeof(point_list)); \ + point->INDEX = ++index; \ + point->X = xp; \ + point->Y = yp; \ + point->NEXT = head_point; \ + head_point = point; \ +} + +/******************************************************************************* +* cp_error : generic error routine for vtiloadphfig function * +*******************************************************************************/ +static void cp_error(type, name, line, parameter) +int type, line; +long parameter; +char *name; +{ + + (void)fflush(stdout); + (void)fprintf(stderr, "*** mbk error ***\n"); + switch (type) { + case CPPREF_ERROR : + (void)fprintf(stderr, + "illegal segment reference : point P %ld doesn't exist", + parameter); + break; + case CPCREF_ERROR : + (void)fprintf(stderr, + "illegal segment reference : connector C %ld doesn't exist", + parameter); + break; + case CPIREF_ERROR : + (void)fprintf(stderr, + "illegal segment reference : connector C %ld doesn't exist", + parameter); + break; + case SYNTAX_ERROR : + (void)fprintf(stderr, "syntax error"); + break; + case VIA_ERROR : + (void)fprintf(stderr, "D entry has unknown contact type"); + break; + case BIGVIA_ERROR : + (void)fprintf(stderr, "D entry has unimplement automatic generation of mega-contacts"); + break; + case REF_ERROR : + (void)fprintf(stderr, "unknown segment reference type"); + break; + case OPEN_ERROR : + (void)fprintf(stderr, "can't open file : %s", name); + break; + case PARSE_ERROR : + (void)fprintf(stderr, "abnormal parsing for : %s", name); + break; + case CLOSE_ERROR : + (void)fprintf(stderr, "can't close file : %s", name); + break; + } + if (!line) + (void)fprintf(stderr, "\nvtiloadphfig : parsing file %s.%s\n", + name, IN_PH); + else + (void)fprintf(stderr, "\nvtiloadphfig : parsing file %s.%s line %d\n", + name, IN_PH, line); + EXIT(1); +} + +#if 0 +/* Somehow unuseful right now that double are 64 bits long */ +/******************************************************************************* +* shift : shift a floating point number in order to x 1000 float approx failed * +*******************************************************************************/ +#define shift(pt) \ + if (*(pt + 1) == '\0') { \ + *pt = '0'; \ + *(pt + 1) = '0'; \ + *(pt + 2) = '0'; \ + *(pt + 3) = '\0'; \ + } else if (*(pt + 2) == '\0') { \ + *pt = *(pt + 1); \ + *(pt + 1) = '0'; \ + *(pt + 2) = '0'; \ + *(pt + 3) = '\0'; \ + } else if (*(pt + 3) == '\0') { \ + *pt = *(pt + 1); \ + *(pt + 1) = *(pt + 2); \ + *(pt + 2) = '0'; \ + *(pt + 3) = '\0'; \ + } else { \ + *pt = *(pt + 1); \ + *(pt + 1) = *(pt + 2); \ + *(pt + 2) = *(pt + 3); \ + *(pt + 3) = '\0'; \ + } +#endif + + +static void vti_addphseg(phfig_list * figure, char layer, + long l1, long x1, long y1, + long x2, long y2, char * sname) +{ + if ( ( x1 == x2 ) || ( y1 == y2 ) ) { + (void)addphseg(figure, layer, l1, x1, y1, x2, y2, sname); + } + else + fprintf(stderr, "WARNING : illegal segment layer=%d w=%ld" + " x1=%ld y1=%ld x2=%ld y2=%ld name=%s\n\n", + layer, l1/SCALE_X, x1/SCALE_X, y1/SCALE_X, + x2/SCALE_X, y2/SCALE_X, + ( sname != (char *)0 ) ? sname : "NULL" ); +} + +/******************************************************************************* +* stol : convert a string to a long * +*******************************************************************************/ +static long stol(tokenpt) +char *tokenpt; +{ +register char *pt; + + if ((pt = strchr(tokenpt, '.')) == (char *)NULL) + return (long)(SCALE_X * atol(tokenpt)); + else { +#if 0 + shift(pt); + return (long)(SCALE_X * atol(tokenpt) / 1000); +#endif + return (long)((double)SCALE_X * atof(tokenpt)); + } +} + +/******************************************************************************* +* fonction codelayer() * +*******************************************************************************/ +static char codelayer(layername) +char *layername; +{ + if (!strcmp(layername, "metal")) + return ALU1; + else if (!strcmp(layername, "metal2")) + return ALU2; + else if (!strcmp(layername, "metal3")) + return ALU3; + else if (!strcmp(layername, "metal4")) + return ALU4; + else if (!strcmp(layername, "metal5")) + return ALU5; + else if (!strcmp(layername, "metal6")) + return ALU6; + else if (!strcmp(layername, "metal7")) + return ALU7; + else if (!strcmp(layername, "metal8")) + return ALU8; + else if (!strcmp(layername, "metal9")) + return ALU9; + else if (!strcmp(layername, "allowM")) + return TALU1; + else if (!strcmp(layername, "allowM1")) + return TALU1; + else if (!strcmp(layername, "allowM2")) + return TALU2; + else if (!strcmp(layername, "allowM3")) + return TALU3; + else if (!strcmp(layername, "allowM4")) + return TALU4; + else if (!strcmp(layername, "allowM5")) + return TALU5; + else if (!strcmp(layername, "allowM6")) + return TALU6; + else if (!strcmp(layername, "allowM7")) + return TALU7; + else if (!strcmp(layername, "allowM8")) + return TALU8; + else if (!strcmp(layername, "allowM9")) + return TALU9; + else if (!strcmp(layername, "poly")) + return POLY; + else if (!strcmp(layername, "poly2")) + return POLY2; + else if (!strcmp(layername, "ndif")) + return NDIF; + else if (!strcmp(layername, "pdif")) + return PDIF; + else if (!strcmp(layername, "ntie")) + return NTIE; + else if (!strcmp(layername, "ptie")) + return PTIE; + else if (!strcmp(layername, "ntrans")) + return NTRANS; + else if (!strcmp(layername, "ptrans")) + return PTRANS; + else if (!strcmp(layername, "nwell")) + return NWELL; + else if (!strcmp(layername, "pwell")) + return PWELL; + return 255; +} + +/******************************************************************************* +* checkname : check for busses * +*******************************************************************************/ +static char *checkname(name) +char *name; +{ +char *s, *t; + + s = t = name; + while (*t) { + if (*t == '[') + *t = ' '; + else if (*t == ']') + if (*(++t) == '\0') /* ok, it's finished */ + goto end; + else if (*t == '[') /* multiple array */ + continue; + *s++ = *t++; + } +end: + *s = '\0'; + return name; +} + +/******************************************************************************* +* physical parser : vti2mbk * +*******************************************************************************/ +static int parse(figure, mode, in, fname) +phfig_list *figure; +char mode; +FILE *in; +char *fname; +{ +char line[LSIZE]; +char *t1, *t2, *t3, *t4, *t5; /* pointers for token on a line */ +char *t6, *t7, *t8, *t9, *t10; /* */ +char *t11; /* of vti file */ +char s[100]; /* intermediate buffer to process tokens */ +long l1, l2, l3, l4; /* results from string to long */ +long x1, x2, y1, y2; +point_list *head_point = (point_list *)NULL; +int index = 0; +char *sname = NULL; +int i = 1; /* file line number */ + + while (1) { + i++; + if (fgets(line, LSIZE, in) == (char *)NULL) + cp_error((int)SYNTAX_ERROR, fname, i, 0L); + switch (line[0]) { + case ' ' : /* comment */ + case '#' : /* comment */ + break; + case 'A' : + if (line[2] == '\\') /* comment */ + break; + if (strchr(line + 2, '*') == (char *)NULL) { /* A num num num num */ + t1 = strtok(line + 2, " \n\t\""); + (void)strcpy(s, t1); + l1 = stol(s); + t2 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t2); + l2 = stol(s); + t3 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t3); + l3 = stol(s); + t4 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t4); + l4 = stol(s); + t5 = strtok((char *)NULL, " \n\t\""); + if (t5 != (char *)NULL) + cp_error((int)SYNTAX_ERROR, fname, i, 0L); + defab(figure, l1, l2, l3, l4); + } + break; + case 'B' : /* doesn't care about bounding box */ + break; + case 'C' : /* C name num num name num num name name name name */ + if (mode != 'C') { + t1 = strtok(line + 2, " \n\t\""); + t2 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t2); + l1 = stol(s); + t3 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t3); + l2 = stol(s); + t4 = strtok((char *)NULL, " \n\t\""); + t5 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t5); + l3 = stol(s); + t6 = strtok((char *)NULL, " \n\t\""); + l4 = atol(t6); + t7 = strtok((char *)NULL, " \n\t\""); + t8 = strtok((char *)NULL, " \n\t\""); + t9 = strtok((char *)NULL, " \n\t\""); + t10 = strtok((char *)NULL, " \n\t\""); + t11 = strtok((char *)NULL, " \n\t\""); + if (t11 != (char *)NULL) + cp_error((int)SYNTAX_ERROR, fname, i, 0L); + { + char orient = '\0'; + if (!strcmp(t9, "NW")) + orient = WEST; + else if (*t9 == 'N' || *t9 == 'n') + orient = NORTH; + else if (*t9 == 'E' || *t9 == 'e') + orient = EAST; + else if (*t9 == 'S' || *t9 == 's') + orient = SOUTH; + else if (*t9 == 'W' || *t9 == 'w') + orient = WEST; + (void)addphcon(figure, orient, checkname(t10), l1, l2, + codelayer(t4), l3); + figure->PHCON->USER = (ptype_list *)addptype((ptype_list *)NULL, + (long)VTIPARSER, (void *)l4); + } + } + break; + case 'D' : /* D num num name name num num num */ + t1 = strtok(line + 2, " \n\t\""); + (void)strcpy(s, t1); + l1 = stol(s); + t2 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t2); + l2 = stol(s); + t3 = strtok((char *)NULL, " \n\t\""); + t4 = strtok((char *)NULL, " \n\t\""); + t5 = strtok((char *)NULL, " \n\t\""); + t6 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t6); + l3 = stol(s); + t7 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t7); + l4 = stol(s); + addpoint(l1, l2); + if (mode != 'P') { + if (isdigit(*t4)) /* for vti v8 compatibility */ + break; /* D num num name num num num */ + if (!strcmp(t4, "VIA")) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + } + else if (!strcmp(t4, "CONT")) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + } + else if (!strcmp(t4, "CONT2")) + { + (void)addphvia(figure, CONT_POLY2, l1, l2, l3, l4,NULL); + } + else if (!strcmp(t4, "VIA2")) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA01"))||(!strcmp(t4, "VI01"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA02"))||(!strcmp(t4, "VI02"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA03"))||(!strcmp(t4, "VI03"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA04"))||(!strcmp(t4, "VI04"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA05"))||(!strcmp(t4, "VI05"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA06"))||(!strcmp(t4, "VI06"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA07"))||(!strcmp(t4, "VI07"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA08"))||(!strcmp(t4, "VI08"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA09"))||(!strcmp(t4, "VI09"))) + { + (void)addphvia(figure, CONT_POLY, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA12"))||(!strcmp(t4, "VI12"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA13"))||(!strcmp(t4, "VI13"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA14"))||(!strcmp(t4, "VI14"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA15"))||(!strcmp(t4, "VI15"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA16"))||(!strcmp(t4, "VI16"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA17"))||(!strcmp(t4, "VI17"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA18"))||(!strcmp(t4, "VI18"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA19"))||(!strcmp(t4, "VI19"))) + { + (void)addphvia(figure, CONT_VIA, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + + else if ((!strcmp(t4, "VIA23"))||(!strcmp(t4, "VI23"))) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA24"))||(!strcmp(t4, "VI24"))) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA25"))||(!strcmp(t4, "VI25"))) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA26"))||(!strcmp(t4, "VI26"))) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA27"))||(!strcmp(t4, "VI27"))) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA28"))||(!strcmp(t4, "VI28"))) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA29"))||(!strcmp(t4, "VI29"))) + { + (void)addphvia(figure, CONT_VIA2, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA34"))||(!strcmp(t4, "VI34"))) + { + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA35"))||(!strcmp(t4, "VI35"))) + { + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA36"))||(!strcmp(t4, "VI36"))) + { + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA37"))||(!strcmp(t4, "VI37"))) + { + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA38"))||(!strcmp(t4, "VI38"))) + { + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA39"))||(!strcmp(t4, "VI39"))) + { + (void)addphvia(figure, CONT_VIA3, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA45"))||(!strcmp(t4, "VI45"))) + { + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA46"))||(!strcmp(t4, "VI46"))) + { + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA47"))||(!strcmp(t4, "VI47"))) + { + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA48"))||(!strcmp(t4, "VI48"))) + { + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA49"))||(!strcmp(t4, "VI49"))) + { + (void)addphvia(figure, CONT_VIA4, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA56"))||(!strcmp(t4, "VI56"))) + { + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA57"))||(!strcmp(t4, "VI57"))) + { + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA58"))||(!strcmp(t4, "VI58"))) + { + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA59"))||(!strcmp(t4, "VI59"))) + { + (void)addphvia(figure, CONT_VIA5, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA67"))||(!strcmp(t4, "VI67"))) + { + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA68"))||(!strcmp(t4, "VI68"))) + { + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA69"))||(!strcmp(t4, "VI69"))) + { + (void)addphvia(figure, CONT_VIA6, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA78"))||(!strcmp(t4, "VI78"))) + { + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA79"))||(!strcmp(t4, "VI79"))) + { + (void)addphvia(figure, CONT_VIA7, l1, l2, l3, l4,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + } + else if ((!strcmp(t4, "VIA89"))||(!strcmp(t4, "VI89"))) + (void)addphvia(figure, CONT_VIA8, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN1")) + (void)addphvia(figure, CONT_TURN1, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN2")) + (void)addphvia(figure, CONT_TURN2, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN3")) + (void)addphvia(figure, CONT_TURN3, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN4")) + (void)addphvia(figure, CONT_TURN4, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN5")) + (void)addphvia(figure, CONT_TURN5, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN6")) + (void)addphvia(figure, CONT_TURN6, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN7")) + (void)addphvia(figure, CONT_TURN7, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN8")) + (void)addphvia(figure, CONT_TURN8, l1, l2, l3, l4,NULL); + else if (!strcmp(t4, "TURN9")) + (void)addphvia(figure, CONT_TURN9, l1, l2, l3, l4,NULL); + else + cp_error((int)VIA_ERROR, fname, i, 0L); + } + break; + case 'E' : /* E */ + { + point_list *point; + phins_list *ins; + void *sav; + + for (point = head_point; point; point = (point_list *)sav) { + sav = (void *)point->NEXT; + mbkfree((void *)point); + } + if (mode == 'P') { + for (ins = figure->PHINS; ins; ins = (phins_list *)sav) { + sav = (void *)ins->NEXT; + mbkfree((void *)ins); + } + figure->PHINS = (phins_list *)NULL; + } + return 0; + } + case 'F': + break; + + case 'I' : /* I name num num num name name name name */ + t1 = strtok(line + 2, " \n\t\""); + t2 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t2); + l1 = stol(s); + t3 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t3); + l2 = stol(s); + t4 = strtok((char *)NULL, " \n\t\""); + l3 = atol(t4); + t5 = strtok((char *)NULL, " \n\t\""); + t6 = strtok((char *)NULL, " \n\t\""); + /* load what is referenced by .cp or .scp as .cp */ + if (*t6 == 'c' || *t6 == 's') { /* load instances for any mode */ + char symm; + switch ((int)l3) { + case 0 : + symm = NOSYM; + break; + case 1 : + symm = ROT_P; + break; + case 2 : + symm = SYMXY; + break; + case 3 : + symm = ROT_M; + break; + case 4 : + symm = SYM_X; + break; + case 5 : + symm = SY_RM; + break; + case 6 : + symm = SYM_Y; + break; + case 7 : + symm = SY_RP; + break; + default : + symm = -1; + } + (void)addphins(figure, t5, t1, symm, l1, l2); + } + if (mode != 'C') + if (*t6 == 'l' && !strncmp(t5, "ref_", 4)) + (void)addphref(figure, t5, checkname(t1), l1, l2); + if (mode != 'P') { + if (*t6 == 'l') { + if (!strcmp(t5, "cbn")) { + (void)addphvia(figure, CONT_BODY_N, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cbnv")) { + (void)addphvia(figure, CONT_BODY_N, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cbp")) { + (void)addphvia(figure, CONT_BODY_P, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cbpv")) { + (void)addphvia(figure, CONT_BODY_P, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cdn")) { + (void)addphvia(figure, CONT_DIF_N, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cdnv")) { + (void)addphvia(figure, CONT_DIF_N, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cdp")) { + (void)addphvia(figure, CONT_DIF_P, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cdpv")) { + (void)addphvia(figure, CONT_DIF_P, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cpf")) { + (void)addphvia(figure, CONT_POLY, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cpfv")) { + (void)addphvia(figure, CONT_POLY, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cpf2")) { + (void)addphvia(figure, CONT_POLY2, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cpf2v")) { + (void)addphvia(figure, CONT_POLY2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cvia")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cvia2")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cxn")) { + (void)addphvia(figure, C_X_N, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "cxp")) { + (void)addphvia(figure, C_X_P, l1, l2,0,0,NULL); + /* Bull specific: quite bright, insn't it ? */ + } else if (!strcmp(t5, "via12")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via13")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via14")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via15")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via16")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via17")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via18")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via19")) { + (void)addphvia(figure, CONT_VIA, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via23")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via24")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via25")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via26")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via27")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via28")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via29")) { + (void)addphvia(figure, CONT_VIA2, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via34")) { + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via35")) { + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via36")) { + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via37")) { + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via38")) { + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via39")) { + (void)addphvia(figure, CONT_VIA3, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via45")) { + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via46")) { + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via47")) { + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via48")) { + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via49")) { + (void)addphvia(figure, CONT_VIA4, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via56")) { + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via57")) { + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via58")) { + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via59")) { + (void)addphvia(figure, CONT_VIA5, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via67")) { + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via68")) { + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via69")) { + (void)addphvia(figure, CONT_VIA6, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via78")) { + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via79")) { + (void)addphvia(figure, CONT_VIA7, l1, l2,0,0,NULL); + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "via89")) { + (void)addphvia(figure, CONT_VIA8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn1")) { + (void)addphvia(figure, CONT_TURN1, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn2")) { + (void)addphvia(figure, CONT_TURN2, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn3")) { + (void)addphvia(figure, CONT_TURN3, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn4")) { + (void)addphvia(figure, CONT_TURN4, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn5")) { + (void)addphvia(figure, CONT_TURN5, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn6")) { + (void)addphvia(figure, CONT_TURN6, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn7")) { + (void)addphvia(figure, CONT_TURN7, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn8")) { + (void)addphvia(figure, CONT_TURN8, l1, l2,0,0,NULL); + } else if (!strcmp(t5, "turn9")) { + (void)addphvia(figure, CONT_TURN9, l1, l2,0,0,NULL); + } + } + } + break; + case 'J' : /* J num num name name */ + t1 = strtok(line + 2, " \n\t\""); + (void)strcpy(s, t1); + l1 = stol(s); + t2 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t2); + l2 = stol(s); + addpoint(l1, l2); + break; + case 'P' : /* P num num name name */ + t1 = strtok(line + 2, " \n\t\""); + (void)strcpy(s, t1); + l1 = stol(s); + t2 = strtok((char *)NULL, " \n\t\""); + (void)strcpy(s, t2); + l2 = stol(s); + addpoint(l1, l2); + break; + case 'S' : + t1 = strtok(line + 2, " \n\t\""); + (void)strcpy(s, t1); + l1 = stol(s); + t2 = strtok((char *)NULL, " \n\t\""); + t3 = strtok((char *)NULL, " \n\t\""); + t4 = strtok((char *)NULL, " \n\t\""); + t5 = strtok((char *)NULL, " \n\t\""); + t6 = strtok((char *)NULL, " \n\t\""); + t7 = strtok((char *)NULL, " \n\t\""); + t8 = strtok((char *)NULL, " \n\t\""); + t9 = strtok((char *)NULL, " \n\t\""); + { + char layer = codelayer(t3); + if (mode == 'A' + || (mode == 'P' && + ( + layer == TALU1 || layer == TALU2 || layer == TALU3 + || layer == TALU4 || layer == TALU5 || layer == TALU6 + || layer == TALU7 || layer == TALU8 || layer == TALU9 + || layer == CALU1 || layer == CALU2 || layer == CALU3 + || layer == CALU4 || layer == CALU5 || layer == CALU6 + || layer == CALU7 || layer == CALU8 || layer == CALU9 + )) + || (mode == 'C' && + ( layer != TALU1 && layer && TALU2 && layer != TALU3 + && layer != TALU4 && layer != TALU5 && layer != TALU6 + && layer != TALU7 && layer != TALU8 && layer != TALU9 + && layer != CALU1 && layer != CALU2 && layer != CALU3 + && layer != CALU4 && layer != CALU5 && layer != CALU6 + && layer != CALU7 && layer != CALU8 && layer != CALU9 + )) + ) { + switch (*t4) { + case 'p' : /* S num name name P_REF num P_REF num */ + *t4 = 'P'; + case 'P' : + switch (*t6) { + case 'p' : + *t6 = 'P'; + case 'P' : + l2 = atol(t5); + l3 = atol(t7); + cppref(x1, y1, l2, i); + cppref(x2, y2, l3, i); + (void)vti_addphseg(figure, layer, l1, x1, y1, + x2, y2, sname); + break; + case 'c' : /* S num name name P_REF num C_REF num */ + *t6 = 'C'; + case 'C' : + l2 = atol(t5); + l3 = atol(t7); + cppref(x1, y1, l2, i); + cpcref(x2, y2, l3, i); + (void)vti_addphseg(figure, layer, l1, + x1, y1, x2, y2, sname); + break; + case 'i' :/* S num name name P_REF num I_REF name num */ + *t6 = 'I'; + case 'I' : + l2 = atol(t5); + l3 = atol(t8); + cppref(x1, y1, l2, i); + cpiref(x2, y2, t7, l3, i); + (void)vti_addphseg(figure, layer, l1, x1, y1, + x2, y2, sname); + break; + + default : + cp_error((int)REF_ERROR, fname, i, 0L); + } + break; + + case 'c' : /* S num name name C_REF num P_REF num */ + *t4 = 'C'; + case 'C' : + switch (*t6) { + case 'p' : + *t6 = 'P'; + case 'P' : + l2 = atol(t5); + l3 = atol(t7); + cpcref(x1, y1, l2, i); + cppref(x2, y2, l3, i); + (void)vti_addphseg(figure, layer, (long)l1, + x1, y1, x2, y2, sname); + break; + case 'c' : /* S num name name C_REF num C_REF num */ + *t6 = 'C'; + case 'C' : + l2 = atol(t5); + l3 = atol(t7); + cpcref(x1, y1, l2, i); + cpcref(x2, y2, l3, i); + (void)vti_addphseg(figure, layer, l1, + x1, y1, x2, y2, sname); + break; + case 'i' : /* S num name name C_REF num I_REF name num */ + *t6 = 'I'; + case 'I' : + l2 = atol(t5); + l3 = atol(t8); + cpcref(x1, y1, l2, i); + cpiref(x2, y2, t7, l3, i); + (void)vti_addphseg(figure, layer, l1, x1, y1, + x2, y2, sname); + break; + default : + cp_error((int)REF_ERROR, fname, i, 0L); + } + break; + case 'i' : /* S num name name I_REF name num P_REF num */ + *t4 = 'I'; + case 'I' : + switch (*t7) { + case 'p' : + *t7 = 'P'; + case 'P' : + l2 = atol(t6); + l3 = atol(t8); + cppref(x2, y2, l3, i); + cpiref(x1, y1, t5, l2, i); + (void)vti_addphseg(figure, layer, l1, x1, y1, + x2, y2, sname); + break; + case 'c' : /* S num name name I_REF name num C_REF num */ + *t7 = 'C'; + case 'C' : + l2 = atol(t6); + l3 = atol(t8); + cpcref(x2, y2, l3, i); + cpiref(x1, y1, t5, l2, i); + (void)vti_addphseg(figure, layer, l1, x1, y1, + x2, y2, sname); + break; + case 'i' : /* S num name name I_REF name num I_REF name num */ + *t7 = 'I'; + case 'I' : + l2 = atol(t6); + l3 = atol(t9); + cpiref(x1, y1, t5, l2, i); + cpiref(x2, y2, t8, l3, i); + (void)vti_addphseg(figure, layer, l1, x1, y1, + x2, y2, sname); + break; + default: + cp_error((int)REF_ERROR, fname, i, 0L); + } + break; + default : + cp_error((int)REF_ERROR, fname, i, 0L); + } + } + } + break; + case 'V' : /* V num name num */ + break; + case 'W' : + t1 = strtok(line + 2, " \n\t\""); + t2 = strtok((char *)NULL, " \n\t\""); + t3 = strtok((char *)NULL, " \n\t\""); + t4 = strtok((char *)NULL, " \n\t\""); + t5 = strtok((char *)NULL, " \n\t\""); + if (t5 != (char *)NULL) /* W num num num num name */ + sname = namealloc(checkname(t5)); + else /* W num num num num */ + sname = (char *)NULL; + break; + default : + cp_error((int)SYNTAX_ERROR, fname, i, 0L); + } + } +} + +/******************************************************************************* +* This is the only function to be accesible from outside * +* Effective call the the cp parser * +*******************************************************************************/ +void vtiloadphfig(ptfig, figname, mode) +phfig_list *ptfig; +char *figname; +char mode; +{ +FILE *in; + + /* opening file */ + if ((in = mbkfopen(figname, IN_PH, READ_TEXT)) == (FILE *)NULL) + cp_error((int)OPEN_ERROR, figname, 0, 0L); + + if (TRACE_MODE == 'Y') + (void)printf("\n--- mbk --- parsing file %s.%s in mode %c\n", + figname, IN_PH, mode); + + /* parsing */ + if (parse(ptfig, mode, in, figname)) + cp_error((int)PARSE_ERROR, figname, 0, 0L); + + if (fclose(in)) + cp_error((int)CLOSE_ERROR, figname, 0, 0L); + + strcpy(PARSER_INFO, "@(#)vti symbolic layout view parser version 3.06"); +}