From bcc39ffd4acca361e75c178fdbdbfa55c505c0a5 Mon Sep 17 00:00:00 2001 From: Frederic Petrot Date: Tue, 12 Mar 2002 08:30:03 +0000 Subject: [PATCH] Importing MBKEDIF sources into the new CVS tree --- alliance/src/mbkedif/Makefile.am | 1 + alliance/src/mbkedif/configure.in | 54 + alliance/src/mbkedif/src/Makefile.am | 8 + alliance/src/mbkedif/src/driver.c | 885 ++++++++++++++ alliance/src/mbkedif/src/parser_l.l | 90 ++ alliance/src/mbkedif/src/parser_y.y | 1624 ++++++++++++++++++++++++++ alliance/src/mbkedif/src/time.c | 83 ++ 7 files changed, 2745 insertions(+) create mode 100644 alliance/src/mbkedif/Makefile.am create mode 100644 alliance/src/mbkedif/configure.in create mode 100644 alliance/src/mbkedif/src/Makefile.am create mode 100644 alliance/src/mbkedif/src/driver.c create mode 100644 alliance/src/mbkedif/src/parser_l.l create mode 100644 alliance/src/mbkedif/src/parser_y.y create mode 100644 alliance/src/mbkedif/src/time.c diff --git a/alliance/src/mbkedif/Makefile.am b/alliance/src/mbkedif/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/mbkedif/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/mbkedif/configure.in b/alliance/src/mbkedif/configure.in new file mode 100644 index 00000000..60fb5c70 --- /dev/null +++ b/alliance/src/mbkedif/configure.in @@ -0,0 +1,54 @@ +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/12 08:30:03 fred Exp $ +dnl +dnl +AC_INIT(src/time.c) +AM_INIT_AUTOMAKE(mbkedif, 4.9) +AC_PROG_INSTALL +AC_PROG_CC +AC_PROG_YACC +AM_PROG_LEX +AC_HEADER_STDC +AC_CHECK_HEADERS(strings.h unistd.h) +AC_C_CONST +AC_PROG_RANLIB + +changequote(,)dnl +INCLUDES=-I${ALLIANCE_TOP}/include +LDFLAGS=-L${ALLIANCE_TOP}/lib +changequote([,])dnl + +AC_SUBST(INCLUDES) +AC_SUBST(LDFLAGS) + + +AC_OUTPUT([ +Makefile +src/Makefile +]) diff --git a/alliance/src/mbkedif/src/Makefile.am b/alliance/src/mbkedif/src/Makefile.am new file mode 100644 index 00000000..65447f81 --- /dev/null +++ b/alliance/src/mbkedif/src/Makefile.am @@ -0,0 +1,8 @@ +lib_LIBRARIES = libMel.a +libMel_a_SOURCES = time.c driver.c parser_y.y parser_l.l +CLEANFILES = parser_y.c parser_y.h parser_l.c + +parser_y.c parser_y.h : $(srcdir)/parser_y.y + $(YACC) -d $(YFLAGS) $(srcdir)/parser_y.y && sed -e "s/yy/mvl_y_/g" -e "s/YY/MVL_Y_/g" y.tab.c > parser_y.c && sed -e "s/yy/mvl_y_/g" -e "s/YY/MVL_Y_/g" y.tab.h > parser_y.h +parser_l.c : $(srcdir)/parser_l.l parser_y.h + $(LEX) -t $(srcdir)/parser_l.l | sed -e "s/yy/mvl_y_/g" -e "s/YY/MVL_Y_/g" > parser_l.c diff --git a/alliance/src/mbkedif/src/driver.c b/alliance/src/mbkedif/src/driver.c new file mode 100644 index 00000000..647864be --- /dev/null +++ b/alliance/src/mbkedif/src/driver.c @@ -0,0 +1,885 @@ +/* + * 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 TO EDIF Driver */ +/*------------------------------------------------------------------------------*/ +/*version 1.0 : Implemented by Fred Petrot */ +/*version 1.1 : Extended by Mokhtar Hirech (January, 92) */ +/*version 1.2 : Extended by Olivier BEAURIN (September, 93) */ +/*version 1.2 : Extended by Olivier BEAURIN (November, 93) */ +/*------------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include + +/* defines */ +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#define SCHEMATIC "schematic" +#define SYMBOL "symbol" + +#define MBK_EDIF_LIBNAME "MBKEDIF_LIBNAME" +#define MBK_EDIF_SUFFIXES "MBKEDIF_SUFFIXES" +#define DEBUG_MBKEDIF "DEBUG_MBKEDIF" +#define DEFAULT_SUFFIXES "y=ScLib:dp=DpLib:fp=FpLib:sp=PadLib" + +/* Global variables*/ + +static int edif_debug = FALSE; +static FILE *edif_file; +static char *EDIF_LIBNAME; +static char *EDIF_SUFFIXES; +static int nb_lib = 0; +static char **suffixes = NULL; +static char **libraries = NULL; +static chain_list **cellules = NULL; +static chain_list *already_drived = NULL; + +/* Global Functions*/ + +static void port_ext ( ); +static void edit_sig ( ); +static void edit_ins ( ); +static void edit_con ( ); +static void connect ( ); +static void view ( ); +static void drive_cell ( ); +static void r_drive_cell ( ); +static int edif_busindex ( ); +static int drive_basic_cells( ); +static locon_list *edif_found_array ( ); +static void check_fig_portref( ); +static void r_found_suffixed_cells( ); +static void save_libraries_cells( ); + + char *edif_busname ( ); + +/*---------------------------------------------------------\ + ParseSuffixes +\---------------------------------------------------------*/ +int ParseSuffixes( fill ) +int fill; +{ + char *suf; + char *lib; + char *pt; + int index; + + if( fill ) + { + if( suffixes || libraries || cellules ) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : bugs in ParseSuffixes\n" ); + exit( 1 ); + } + suffixes = mbkalloc( nb_lib * sizeof( char * ) ); + libraries = mbkalloc( nb_lib * sizeof( char * ) ); + cellules = mbkalloc( nb_lib * sizeof( chain_list * ) ); + index = 0; + } + + suf = EDIF_SUFFIXES; + do + { + lib = strchr( suf, '=' ); + if( !lib ) + { + return FALSE; + } + pt = strchr( lib, ':' ); + if( pt && fill ) + { + *pt = '\0'; + } + if( fill ) + { + *lib = '\0'; + } + lib ++; + + if( !fill ) + { + nb_lib++; + } + else + { + suffixes[ index ] = suf; + libraries[ index ] = lib; + cellules[ index ] = NULL; + index ++; + } + + if( pt ) + { + suf = pt + 1; + } + } while( pt ); + + if( fill && edif_debug ) + { + fprintf( stdout, "\nMBKEDIF DEBUG : Libraries and suffixes used.\n\n"); + for( index = 0; index < nb_lib; index ++) + { + fprintf( stdout, "\t%s\t=>\t%s\n",suffixes[index], libraries[index] ); + } + fprintf( stdout, "\n"); + } + + return TRUE; +} /* end of ParseSuffixes */ + +/*---------------------------------------------------------\ + edifsavelofig +\---------------------------------------------------------*/ +void edifsavelofig( firstlofig ) +lofig_list *firstlofig; +{ + chain_list *chainl; + chain_list *chainp; + char filename[ 255 ]; + char *pc; + int index; + + edif_debug = mbkgetenv( DEBUG_MBKEDIF ) != NULL; + + EDIF_LIBNAME = mbkgetenv( MBK_EDIF_LIBNAME ); + if( !EDIF_LIBNAME ) + EDIF_LIBNAME = namealloc( "alliance" ); + + if( strcmp( EDIF_LIBNAME, "" ) == 0 ) + EDIF_LIBNAME = namealloc( "alliance" ); + + + for( pc = EDIF_LIBNAME; pc[0] != '\0'; pc ++ ) + { + if( ( pc[0] == '(' ) || ( pc[0] == ')' ) || ( pc[0] == ' ' ) ) + { + fprintf( stderr, "*** mbk error *** edifloadlofig : environment variable 'MBK_EDIF_LIBNAME' invalid.\n" ); + exit( 1 ); + } + } + + if( nb_lib == 0 ) + { + EDIF_SUFFIXES = mbkgetenv( MBK_EDIF_SUFFIXES ); + if( !EDIF_SUFFIXES ) + { + EDIF_SUFFIXES = mbkstrdup(DEFAULT_SUFFIXES); + } + if( !ParseSuffixes( FALSE ) ) + { + fprintf(stderr, "*** mbk warning *** edifsavelofig : %s invalid, using default value.\n", + MBK_EDIF_SUFFIXES ); + EDIF_SUFFIXES = mbkstrdup(DEFAULT_SUFFIXES); + if( !ParseSuffixes( FALSE ) ) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : Bugs with default %s value\n", + MBK_EDIF_SUFFIXES); + exit( 1 ); + } + } + ParseSuffixes( TRUE ); + } + else + { + for( index = 0; index < nb_lib; index ++) + { + cellules[index] = NULL; + } + } + + if (firstlofig == NULL) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : edif shall not drive a NULL figure\n"); + exit( 1 ); + } + + r_found_suffixed_cells( firstlofig ); + + sprintf( filename, "%s/%s.%s", WORK_LIB, firstlofig->NAME, OUT_LO ); + + if( ( edif_file = mbkfopen( firstlofig->NAME, OUT_LO, WRITE_TEXT ) ) == NULL ) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : the file %s cannot be opened\n", filename ); + exit( 1 ); + } + + fprintf( edif_file, "(edif RobiN_EDIF\n" ); + fprintf( edif_file, " (edifversion 2 0 0)\n" ); + fprintf( edif_file, " (ediflevel 0)\n" ); + fprintf( edif_file, " (keywordMap (keywordLevel 0))\n" ); + fprintf( edif_file, " (status\n" ); + fprintf( edif_file, " (written\n" ); + fprintf( edif_file, " (timeStamp %s)\n", EdifTime( ) ); + fprintf( edif_file, " (program \"Driver mbk2edif\")\n" ); + fprintf( edif_file, " (author \"FP & HM & OB for : %s\")\n", mbkgetenv( "USER" ) ? mbkgetenv( "USER" ) : "RobiN" ); + fprintf( edif_file, " (dataOrigin \"VLSI-CAD : Masi Lab. UPMC\")))" ); + + save_libraries_cells( ); + + fprintf( edif_file, "\n (library %s\n", EDIF_LIBNAME ); + fprintf( edif_file, " (ediflevel 0)\n" ); + fprintf( edif_file, " (technology (numberDefinition))" ); + + r_drive_cell( firstlofig ); + + fprintf( edif_file, "))\n"); + + if( fclose( edif_file ) !=0 ) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : Cannot close file '%s'\n", filename ); + exit( 1 ); + } + + freechain( already_drived ); + already_drived = (chain_list *)NULL; + +} /* end of edifsavelofig */ + +/*---------------------------------------------------------\ + save_libraries_cells +\---------------------------------------------------------*/ +static void save_libraries_cells( ) +{ + chain_list *ptchain; + int index; + + for( index = 0; index < nb_lib; index ++ ) + { + if( !cellules[index] ) + { + continue; + } + + fprintf( edif_file, "\n (library %s\n", libraries[index] ); + fprintf( edif_file, " (ediflevel 0)\n" ); + fprintf( edif_file, " (technology (numberDefinition))" ); + + ptchain = cellules[ index ]; + + while( ptchain ) + { + drive_cell(ptchain->DATA, incatalog(ptchain->DATA) ? 'I' : 'C'); + ptchain = ptchain->NEXT; + } + + fprintf( edif_file, ")"); + } +} /* end of save_libraries_cells */ + +/*---------------------------------------------------------\ + in_chain_list +\---------------------------------------------------------*/ +static char in_chain_list( ptchain, cell_name ) +chain_list *ptchain; +char *cell_name; +{ + chain_list *chainp; + + for(chainp = ptchain; chainp; chainp = chainp->NEXT) + if ((char *)chainp->DATA == cell_name) + return 1; + + return 0; +} /* end of in_chain_list */ + +/*---------------------------------------------------------\ + found_suffixed_cell +\---------------------------------------------------------*/ +static char *found_suffixed_cell( name, insert ) +char *name; +int insert; +{ + int index; + char *pt; + + pt = strrchr( name, '_' ); + if( !pt ) + { + return NULL; + } + pt++; + + for( index = 0; index < nb_lib; index ++ ) + { + if( strcmp( pt, suffixes[index] ) == 0 ) + { + if( (!insert) || ( in_chain_list( cellules[ index ], name ) ) ) + { + return libraries[ index ]; + } + if( edif_debug ) + { + fprintf(stdout, "Cellule %s in library %s\n",name,libraries[index]); + } + + cellules[index] = addchain(cellules[index],name ); + return NULL; + } + } + return NULL; +} /* end of found_suffixed_cell */ + +/*---------------------------------------------------------\ + r_found_suffixed_cells +\---------------------------------------------------------*/ +static void r_found_suffixed_cells( ptlofig ) +lofig_list *ptlofig; +{ + chain_list *ptchain; + lofig_list *ptlfig; + + for (ptchain = ptlofig->MODELCHAIN; ptchain; ptchain = ptchain->NEXT) + { + found_suffixed_cell(ptchain->DATA, TRUE); + } + for (ptchain = ptlofig->MODELCHAIN; ptchain; ptchain = ptchain->NEXT) + { + if (!incatalog(ptchain->DATA)) + { + r_found_suffixed_cells( getlofig( ptchain->DATA, 'A' ) ); + } + } +} /* end of r_found_suffixed_cells */ + +/*---------------------------------------------------------\ + r_drive_cell +\---------------------------------------------------------*/ +static void r_drive_cell(ptlofig) +lofig_list *ptlofig; +{ + chain_list *ptchain; + lofig_list *ptlfig; + + ptlofig->MODELCHAIN = (chain_list *)reverse((chain_list *)ptlofig->MODELCHAIN); + + drive_basic_cells(ptlofig); + + for (ptchain = ptlofig->MODELCHAIN; ptchain; ptchain = ptchain->NEXT) + { + if (!in_chain_list(already_drived, namealloc((char*)ptchain->DATA))) + { + ptlfig = getlofig((char *)ptchain->DATA, 'A'); + r_drive_cell(ptlfig); + } + } + + ptlofig->MODELCHAIN = (chain_list *)reverse((chain_list *)ptlofig->MODELCHAIN); + drive_cell(ptlofig->NAME, 'C'); +} /* end of r_drive_cell */ + + +/*---------------------------------------------------------\ + drive_basic_cells +\---------------------------------------------------------*/ +static int drive_basic_cells( ptlofig ) +lofig_list *ptlofig; +{ + chain_list *ptchain; + lofig_list *ptlfig; + char *cell_model_name; + + for (ptchain = ptlofig->MODELCHAIN; ptchain; ptchain = ptchain->NEXT) + { + cell_model_name = namealloc((char *)ptchain->DATA); + if (incatalog(cell_model_name)) + drive_cell(cell_model_name, 'I'); + } +} /* end of drive_basic_cells */ + +/*---------------------------------------------------------\ + drive_cell +\---------------------------------------------------------*/ +static void drive_cell(figname, c) +char *figname; +char c; +{ + chain_list *ptchain; + lofig_list *ptlofig; + + if (in_chain_list(already_drived, figname)) + return; + + already_drived = addchain(already_drived, figname); + + if (c == 'C') + { + view(figname, 'A'); + } + + view(figname, 'I'); +} + +/*---------------------------------------------------------\ + view +\---------------------------------------------------------*/ +static void view(figname, viewtype) +char *figname; +char viewtype; +{ + lofig_list *ptlofig; + char view[20]; + + fprintf(edif_file, "\n (cell %s (cellType GENERIC)", figname); + + strcpy(&view[0], (viewtype == 'A') ? SCHEMATIC: SYMBOL ); + + fprintf(edif_file, "\n (view %s (viewType NETLIST)", view); + fprintf(edif_file, "\n (interface"); + + ptlofig = getlofig(figname, 'P'); + + ptlofig->LOCON = (locon_list *)reverse((locon_list *)ptlofig->LOCON); + + edit_con(ptlofig->LOCON); + + fprintf(edif_file, ")"); + + if( viewtype == 'A' ) + { + fprintf(edif_file, "\n (contents"); + + ptlofig->LOINS = (loins_list *)reverse((loins_list *)ptlofig->LOINS); + edit_ins( ptlofig->LOINS ); + ptlofig->LOINS = (loins_list *)reverse((loins_list *)ptlofig->LOINS); + + ptlofig->LOSIG = (losig_list *)reverse((losig_list *)ptlofig->LOSIG); + edit_sig( ptlofig ); + ptlofig->LOSIG = (losig_list *)reverse((losig_list *)ptlofig->LOSIG); + + fprintf( edif_file, ")"); + } + + fprintf(edif_file, "))"); + + ptlofig->LOCON = (locon_list *)reverse((locon_list *)ptlofig->LOCON); + + return; +} /* end of view */ + +/*---------------------------------------------------------\ + connect +\---------------------------------------------------------*/ +static void connect(conn, index, instance) +locon_list *conn; +int index; +loins_list *instance; +{ + locon_list *ptcon; + locon_list *ptcon2; + losig_list *sig; + char *busname; + char *name; + char *pt; + int begin; + int end; + int myindex; + + ptcon = conn; + + for( ; ptcon != (locon_list *) NULL; ptcon = ptcon -> NEXT) + { + sig = ptcon->SIG; + if( sig->INDEX == index ) + { + name = mbkalloc( strlen( ptcon->NAME ) + 1 ); + strcpy( name, ptcon->NAME ); + for( pt = name; *pt; pt++ ) + { + if( *pt == '/' ) + { + *pt = '_'; + } + } + + busname = edif_busname( name ); + + if( !busname ) + fprintf( edif_file,"\n (portref %s ", name ); + else + { + myindex = edif_busindex( name ); + ptcon2 = conn; + do + { + ptcon2 = edif_found_array( ptcon2, busname, &begin, &end ); + } while( ( ( begin <= end ) && ( ( myindex < begin ) || ( end < myindex ) ) ) + ||( ( begin > end ) && ( ( myindex > begin ) || ( end > myindex ) ) ) ); + + if( begin != end ) + fprintf( edif_file,"\n (portref (member %s_60_%dTO%d_62 %d) ", + busname, begin, end, + ( begin <= end ) ? myindex - begin : begin - myindex ); + else + fprintf( edif_file,"\n (portref %s_%d_", + busname, begin ); + } + + mbkfree( name ); + + if( instance != (loins_list *) NULL ) + { + name = mbkalloc( strlen( instance->INSNAME ) + 1 ); + strcpy( name, instance->INSNAME ); + for( pt = name; *pt; pt++ ) + if( *pt == '/' ) + *pt = '_'; + + fprintf( edif_file, "(instanceref %s )", name ); + + mbkfree( name ); + } + + fprintf( edif_file, ")" ); + + } + } +} /* end of connect */ + +/*---------------------------------------------------------\ + edit_con +\---------------------------------------------------------*/ +static void edit_con( ptcon ) +locon_list *ptcon; +{ + char direction[ 7 ]; + char cadence_array_name[ 1000 ]; + char *array_name; + char *name; + char *pt; + int begin; + int end; + + while (ptcon != (locon_list *) NULL) + { + if( isvdd( ptcon->NAME ) || isvss( ptcon->NAME ) ) + { + ptcon = ptcon -> NEXT; + continue; + } + if( ptcon -> DIRECTION == IN ) + strcpy( direction, "INPUT" ); + else + if( ( ptcon -> DIRECTION == OUT ) || ( ptcon->DIRECTION == 'Z' ) ) + strcpy(direction, "OUTPUT"); + else + strcpy(direction, "INOUT"); + + name = mbkalloc( strlen( ptcon->NAME ) + 1 ); + strcpy( name, ptcon->NAME ); + for( pt = name; *pt; pt++ ) + if( *pt == '/' ) + *pt = '_'; + + if( !( array_name = edif_busname( name ) ) ) + { + fprintf(edif_file, "\n (port %s (direction %s))", name, direction); + ptcon = ptcon -> NEXT; + } + else + { + ptcon = edif_found_array( ptcon, array_name, &begin, &end ); + + if( end != begin ) + { + sprintf( cadence_array_name, "(rename %s_60_%dTO%d_62 \"%s<%d:%d>\")", + array_name, begin, end, + array_name, begin, end ); + fprintf(edif_file, "\n (port (array %s %d)", + cadence_array_name, abs( end - begin ) + 1); + fprintf(edif_file, "(direction %s))", direction ); + } + else + fprintf(edif_file, "\n (port (rename %s_60_%d_62 \"%s<%d>\") (direction %s))", + array_name, begin, array_name, begin, direction); + + if( ptcon == (locon_list *) NULL ) + break; + } + + mbkfree( name ); + } +} /* end of edit_con */ + +/*---------------------------------------------------------\ + edit_ins +\---------------------------------------------------------*/ +static void edit_ins(ptins) +loins_list *ptins; +{ + char cellref_type; + char *name; + char *pt; + + while (ptins != (loins_list *) NULL) + { + name = mbkalloc( strlen( ptins->INSNAME ) + 1 ); + strcpy( name, ptins->INSNAME ); + for( pt = name; *pt; pt++ ) + { + if( *pt == '/' ) + { + *pt = '_'; + } + } + + cellref_type = (incatalog(ptins->FIGNAME) ? 'I' : 'A'); + + pt = found_suffixed_cell( ptins->FIGNAME, FALSE ); + + fprintf(edif_file, "\n (instance %s (viewref %s (cellref %s (libraryref %s) )))", + name, +/* (cellref_type == 'I') ? SYMBOL : SCHEMATIC, */ + SYMBOL, + ptins->FIGNAME, + pt ? pt : EDIF_LIBNAME ); + ptins = ptins -> NEXT; + + mbkfree( name ); + } +} /* end of edit_ins */ + +/*---------------------------------------------------------\ + edit_sig +\---------------------------------------------------------*/ +static void edit_sig(ptlofig) +lofig_list *ptlofig; +{ + losig_list *ptsig; + loins_list *sig_ins; + int idx = 0; + long sig_index; + char *array_name = (char *) NULL; + char *name = (char *) NULL; + char *pt; + + for (ptsig = ptlofig->LOSIG; ptsig != (losig_list *) NULL; ptsig = ptsig->NEXT) + check_fig_portref( ptlofig->NAME, ptlofig->LOCON, ptsig->INDEX ); + + ptsig = ptlofig->LOSIG; + while( ptsig != (losig_list *) NULL ) + { + if( ptsig->TYPE != 'I' || ptlofig->LOINS ) + { + sig_index = ptsig -> INDEX; + + name = getsigname( ptsig ); + if( isvdd( name ) || isvss( name ) ) + { + ptsig = ptsig->NEXT; + continue; + } + for( pt = name; *pt; pt++ ) + { + if( *pt == '/' ) + { + *pt = '_'; + } + } + + if( ( array_name = edif_busname( name ) ) && ( ( idx = edif_busindex( name ) ) != -1 ) ) + { + fprintf( edif_file, "\n (net (rename %s_60_%d_62 \"%s<%d>\") (joined ", + array_name, idx, array_name, idx ); + } + else + { + if( !isdigit( name[0] ) ) + fprintf( edif_file, "\n (net %s (joined ", name ); + else + fprintf( edif_file, "\n (net &_%s (joined ", name ); + } + + if (ptsig->TYPE != 'I') + port_ext( ptlofig->LOCON, sig_index ); + + for( sig_ins = ptlofig->LOINS; sig_ins != NULL; sig_ins = sig_ins->NEXT ) + { + sig_ins->LOCON = (locon_list *)reverse((locon_list *)sig_ins->LOCON); + connect( sig_ins->LOCON, sig_index, sig_ins ); + sig_ins->LOCON = (locon_list *)reverse((locon_list *)sig_ins->LOCON); + } + + fprintf(edif_file, "))"); + } + + if( ptsig ) + { + ptsig = ptsig->NEXT; + } + } +} /* end of edit_sig */ + +/*---------------------------------------------------------\ + check_fig_portref +\---------------------------------------------------------*/ +static void check_fig_portref( lofig_name, ptcon, sig_index ) +char *lofig_name; +locon_list *ptcon; +int sig_index; +{ + int nb = 0; + + for (; (ptcon != (locon_list *) NULL) && (nb <= 1); ptcon = ptcon->NEXT) + if (ptcon->SIG->INDEX == sig_index) + nb++; + + if (nb > 1) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : Error in MBK Structure\n" ); + fprintf( stderr, " multiple (portref ..) to lofig '%s' not\n" ); + fprintf( stderr, " allowed on signal of type 'E' (cadence)\n", lofig_name ); + exit( 1 ); + } + +} /* end of check_fig_portref */ + +/*---------------------------------------------------------\ + port_ext +\---------------------------------------------------------*/ +static void port_ext( sig_con, sig_index ) +locon_list *sig_con; +int sig_index; +{ + losig_list *sig_con_sig; + locon_list *connector, *fig_con; + char *sig_con_name; + + connector = (locon_list *)NULL; + fig_con = sig_con; + sig_con_name = (char *)NULL; + + while (sig_con != (locon_list *)NULL) + { + sig_con_sig = sig_con -> SIG; + if (sig_con_sig -> INDEX == sig_index) + { + sig_con_name = sig_con -> NAME; + connector=sig_con; + break; + } + sig_con = sig_con -> NEXT; + } + + if (sig_con_name == NULL) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : Error in MBK Structure\n" ); + fprintf( stderr, " No Connector on Signal of type 'E'\n" ); + exit( 1 ); + } + + connect(fig_con, sig_index, (loins_list *)NULL); + +} /* end of port_ext */ + +/*---------------------------------------------------------\ + edif_found_array +\---------------------------------------------------------*/ +static locon_list *edif_found_array( ptcon, name, begin, end ) +locon_list *ptcon; +char *name; +int *begin; +int *end; +{ + locon_list *ptcon_first_bus; + char *array_name; + + *begin = 0; + *end = 0; + + while( ( ptcon ) && ( ( array_name = edif_busname( ptcon->NAME ) ) != name ) ) + ptcon = ptcon->NEXT; + + if( !ptcon ) + return NULL; + + *begin = edif_busindex( ptcon -> NAME ); + *end = *begin; + + ptcon_first_bus = ptcon; + + while( ( ptcon != (locon_list *) NULL ) && ( array_name == edif_busname( ptcon->NAME ) ) ) + { + if (ptcon->DIRECTION != ptcon_first_bus->DIRECTION) + { + fprintf( stderr, "*** mbk error *** edifsavelofig : Error in MBK Structure\n" ); + fprintf( stderr, " Connectors %s and %s of same bus must have same direction\n", + ptcon_first_bus->NAME, *ptcon->NAME); + exit( 1 ); + } + *end = edif_busindex( ptcon->NAME ); + ptcon = ptcon->NEXT; + } + + return ptcon; + +} /* fin de edif_found_array */ + +/*---------------------------------------------------------\ + edif_busindex +\---------------------------------------------------------*/ +static int edif_busindex(s) +char *s; +{ + char *t; + + if( !( t = strchr( s, ' ' ) ) ) + return -1; + + return atoi(t); + +} /* end of edif_busindex */ + +/*---------------------------------------------------------\ + edif_busname +\---------------------------------------------------------*/ +char *edif_busname( name ) +char *name; +{ + char *s; + char c[100]; + + if( !( s = strchr( name, ' ' ) ) ) + return (char *) NULL; + + strncpy( c, name, (int)(s - name) ); + c[ s - name ] = '\0'; + + for (s++; *s != '\0'; s++) + if( !isdigit( *s ) ) + return (char *) NULL; + + return namealloc( c ); +} /* end of edif_busname */ + diff --git a/alliance/src/mbkedif/src/parser_l.l b/alliance/src/mbkedif/src/parser_l.l new file mode 100644 index 00000000..9ff71f4d --- /dev/null +++ b/alliance/src/mbkedif/src/parser_l.l @@ -0,0 +1,90 @@ +%p 5000 +%k 1200 + +%{ +#include +#include "parser_y.h" + +#undef ECHO +#define ECHO {strcpy(yylval.sval, yytext);} +void yyJumpOver(); +int yylineno; +%} + +minus [a-z] +majus [A-Z] +digit [0-9] +spec_carac [\40-\57]|[\72-\100]|[\133-\140]|[\173-\176] +blank [ \t]* +newline [\n] +identif (\042|\056|\055|\137|\046|{minus}|{majus}|{digit})+ +identif_ren ({spec_carac}|{minus}|{majus}|{digit})+ +r [(]{blank} +views (SYMBOLIC|symbolic|BEHAVIOR|behavior|MASKLAYOUT|masklayout) + +%% + +{blank} { } +{newline} { yylineno ++; } +{r}[eE][dD][iI][fF] { ECHO return T_EDIF ; } +{r}[eE][dD][iI][fF][vV][eE][rR][sS][iI][oO][nN] { ECHO return T_EDIFVERSION ; } +{r}[eE][dD][iI][fF][lL][eE][vV][eE][lL] { ECHO return T_EDIFLEVEL ; } +{r}[lL][iI][bB][rR][aA][rR][yY] { ECHO return T_LIBRARY ; } +{r}[cC][eE][lL][lL] { ECHO return T_CELL ; } +{r}[eE][xX][tT][eE][rR][nN][aA][lL] { ECHO return T_EXTERNAL ; } +{r}[cC][eE][lL][lL][tT][yY][pP][eE] { ECHO return T_CELLTYPE ; } +[gG][eE][nN][eE][rR][iI][cC] { ECHO return T_CELLTYPE_GENERIC ; } +[tT][iI][eE] { ECHO return T_CELLTYPE_TIE ; } +[rR][iI][pP][pP][eE][rR] { ECHO return T_CELLTYPE_RIPPER ; } +{r}[pP][rR][oO][pP][eE][rR][tT][yY] { ECHO return T_PROPERTY ; } +{r}[vV][iI][eE][wW]{blank}{identif}{blank}{r}[vV][iI][eE][wW][Tt][yY][pP][eE]{blank}{views} {yyJumpOver(2);} +{r}[vV][iI][eE][wW] { ECHO return T_VIEW ; } +{r}[vV][iI][eE][wW][tT][yY][pP][eE] { ECHO return T_VIEWTYPE ; } +{r}[iI][nN][tT][eE][rR][fF][aA][cC][eE] { ECHO return T_INTERFACE ; } +{r}[cC][oO][nN][tT][eE][nN][tT][sS] { ECHO return T_CONTENTS ; } +{r}[nN][eE][tT] { ECHO return T_NET ; } +{r}[jJ][oO][iI][nN][eE][dD] { ECHO return T_JOINED ; } +{r}[iI][nN][sS][tT][aA][nN][cC][eE] { ECHO return T_INSTANCE ; } +{r}[pP][oO][rR][tT][iI][nN][sS][tT][aA][nN][cC][eE] { ECHO return T_PORTINSTANCE ; } +{r}[vV][iI][eE][wW][rR][eE][fF] { ECHO return T_VIEWREF ; } +{r}[cC][eE][lL][lL][rR][eE][fF] { ECHO return T_CELLREF ; } +{r}[lL][iI][bB][rR][aA][rR][yY][rR][eE][fF] { ECHO return T_LIBRARYREF ; } +{r}[pP][oO][rR][tT] { ECHO return T_PORT ; } +{r}[dD][iI][rR][eE][cC][tT][iI][oO][nN] { ECHO return T_DIRECTION ; } +[iI][nN][oO][uU][tT] { ECHO return T_INOUT ; } +[iI][nN][pP][uU][tT] { ECHO return T_INPUT; } +[oO][uU][tT][pP][uU][tT] { ECHO return T_OUTPUT ; } +{r}[pP][oO][rR][tT][rR][eE][fF] { ECHO return T_PORTREF ; } +{r}[pP][oO][rR][tT][lL][iI][sS][tT] { ECHO return T_PORTLIST ; } +{r}[iI][nN][sS][tT][aA][nN][cC][eE][rR][eE][fF] { ECHO return T_INSTANCEREF ; } +{r}[nN][aA][mM][eE] { ECHO return T_NAME ; } +{r}[mM][eE][mM][bB][eE][rR] { ECHO return T_MEMBER ;} +[nN][eE][tT][lL][iI][sS][tT] { ECHO return T_NETLIST ; } +{r}[rR][eE][nN][aA][mM][eE] { ECHO return T_RENAME ; } +{r}[aA][rR][rR][aA][yY] { ECHO return T_ARRAY ;} +{digit}+ { ECHO sscanf(yytext, "%ld", &(yylval.lval)); + return T_INTEGER ; + } +{r}{identif} { yyJumpOver(1); } +\"{identif_ren}\" { ECHO return T_RENAME_STRING ; } +\"{identif}\" { ECHO return T_STRING ; } +{identif} { ECHO return T_IDENT; } +")" { ECHO return ')';} + +%% + +void yyJumpOver (nParenthesis) +int nParenthesis; +{ + char cRead; + while(nParenthesis!=0) { + if((cRead=input())==0) break; + switch(cRead) { + case '\n': yylineno ++; break; + case '(' : nParenthesis ++; break; + case ')' : nParenthesis --; break; + } + } + if (nParenthesis > 0) puts("Not enought closing parentesis"); + else if(nParenthesis < 0) puts("Too many closing parentesis"); +} diff --git a/alliance/src/mbkedif/src/parser_y.y b/alliance/src/mbkedif/src/parser_y.y new file mode 100644 index 00000000..9a2cce9e --- /dev/null +++ b/alliance/src/mbkedif/src/parser_y.y @@ -0,0 +1,1624 @@ +%{ + +/*----------------------------------------------------------------------*/ +/* @(#) Edif Parser For MBK. */ +/*----------------------------------------------------------------------*/ +/* version 1.00: by Fred Petrot. */ +/* version 4.02: by Mokhtar Hirech (Jan. 92) */ +/* version 4.03: by Olivier BEAURIN (Aou. 93) */ +/* version 4.04: by Olivier BEAURIN (Sep. 93) */ +/* version 4.06: by Olivier BEAURIN (Nov. 93) */ +/*----------------------------------------------------------------------*/ + +#include +#include +#include + +/*---------------------------------------------------------\ + Les defines +\---------------------------------------------------------*/ +#define MAXSTRLEN 100 + +/*---------------------------------------------------------\ + Globals variables +\---------------------------------------------------------*/ +static lofig_list *YY_LOFIG = (lofig_list *) NULL; +static lofig_list *YY_PTFIG = (lofig_list *) NULL; +static losig_list *YY_PTSIG = (losig_list *) NULL; +static chain_list *YY_PORTLIST_SIG = (chain_list *) NULL; +static chain_list *YY_PORTLIST_SIG_TMP = (chain_list *) NULL; +static loins_list *YY_PTINS = (loins_list *) NULL; +static chain_list *YY_V_PORTINSTANCE = (chain_list *) NULL; + +static char *YY_RIPPER_IN = (char *)NULL; +static char *YY_RIPPER_OUT = (char *)NULL; + +static char YY_BLACKBOX = 'N'; +static int YY_BUS_WIDTH = 0; +static char YY_DIRECTION = UNKNOWN; +static int YY_INDEX = 0; +static char YY_SIGTYPE = 'Z'; /* Z=not alr. defined, I=interne, E=externe */ +static int YY_NOLOAD_LOCON = 0; +static int YY_NOLOAD_FIG = 0; + +static int YY_BASE_CELL; +static char *YY_FIGNAME; +static char *YY_INS_MODELNAME; +static char YY_ARRAYPORTNAME[MAXSTRLEN]; +static char YY_PORTLIST_NUM; +static char YY_PORTLIST; +static char *YY_RIPPER_CELL = (char *) NULL; + +/*---------------------------------------------------------\ + Functions +\---------------------------------------------------------*/ +static void REnamealloc ( ); +static void del_patch ( ); +static void sig_merge ( ); + +static char bus_nameref ( ); +static char CheckCadenceBusError( ); +static char *CheckCadenceNetError( ); +static lofig_list *get_figure_pt ( ); +static char is_portinstance ( ); +extern char *edif_busname ( ); + +extern int yylineno; + +%} + +%start r_edif + +%union + { + long lval; + char sval[100]; + } + +%token T_EDIF T_EDIFVERSION T_EDIFLEVEL +%token T_TECHNOLOGY T_CELLTYPE T_CELLTYPE_GENERIC +%token T_CELLTYPE_TIE T_CELLTYPE_RIPPER T_PROPERTY +%token T_VIEWTYPE T_INTERFACE T_CONTENTS +%token T_JOINED T_INSTANCE T_VIEWREF +%token T_PORT T_DIRECTION T_INOUT +%token T_PORTREF T_NETLIST T_KEYWORDMAP +%token T_KEYWORDLEVEL T_EXTERNAL T_LIBRARYREF +%token T_OUTPUT T_INSTANCEREF T_MEMBER +%token T_RENAME T_NAME T_STRING +%token T_PORTINSTANCE T_LIBRARY T_CELL +%token T_VIEW T_NET T_CELLREF +%token T_INPUT T_STATUS T_IDENT +%token T_ARRAY T_RENAME_STRING T_PORTLIST + +/* for FLEX */ +%type r_namedef r_libraryref r_name +%type r_external r_extinterface r_library +%type r_celltype r_property r_viewref +%type r_finextcell r_finextinterf r_fincell +%type r_extview r_port r_view +%type r_contents r_finnet r_finview +%type r_array_joined r_joined r_interface +%type r_portlist r_array_portref r_port_joined +%type r_fininterface r_finport r_direction +%type r_anything r_shorted_portref r_opt_property +%type l_anything r_finport_joined r_edif + +%token T_INTEGER + +/*----------------------------------------------------------------------* +* All identifiers starting with T_ are considered as (T)okens. * +* " " YY_ are (V)ariables for identifiers. * +* " " r_ are (R)ules * +* " " l_ are (L)ists of rules * +* " " l_fin.. : list of optional parameters * +* " " r_fin.. : rules for optional parameters * +* for previous rule: ... * +------------------------------------------------------------------------*/ + +%% + +r_edif : + T_EDIF r_namedef r_edifversion r_ediflevel l_externals l_finedif ')' + ; + +r_edifversion : + T_EDIFVERSION T_INTEGER T_INTEGER T_INTEGER ')' + { + if (($2 != 2) || ($3 != 0) || ($4 != 0)) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : unable to read this version of edif.\n"); + exit (1); + } + } + ; + +r_ediflevel : + T_EDIFLEVEL T_INTEGER ')' + { + if ($2 != 0) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : EdifLevel incorrect ( must be 0 ).\n"); + exit (1); + } + } + ; + +/*---------------------------------------------------------\ + EXTERNAL +\---------------------------------------------------------*/ +l_externals : + /* empty */ + | l_externals r_external + ; + +r_external : + T_EXTERNAL r_namedef r_ediflevel l_finexternal ')' + ; + +l_finexternal : + /* empty */ + | l_finexternal r_finexternal + ; + +r_finexternal : + r_extcell + ; + +r_extcell : + T_CELL r_namedef + { + lofig_list *ptf; + char *cell_name; + + + cell_name = namealloc($2); + + if( !( ptf = get_figure_pt( cell_name ) ) ) + { + YY_PTFIG = addlofig( cell_name ); + YY_NOLOAD_FIG = 0; + YY_NOLOAD_LOCON = 0; + } + else + { + if( cell_name == YY_FIGNAME ) + YY_PTFIG = YY_LOFIG; + else + YY_PTFIG = ptf; + + YY_BASE_CELL = incatalog( cell_name ); + + if( ptf->LOCON && YY_BASE_CELL || ptf->LOSIG ) + YY_NOLOAD_FIG = 1; + else + YY_NOLOAD_FIG = 0; + + YY_NOLOAD_LOCON = ( ptf->LOCON ) ? 1 : 0; + + } + YY_INDEX = 0; + } + r_celltype l_finextcell ')' + { + YY_PTFIG->MODE = 'A'; + } + ; + +l_finextcell : + /* empty */ + | l_finextcell r_finextcell + ; + +r_finextcell : + r_extview + | r_property + ; + +r_extview : + T_VIEW r_namedef T_VIEWTYPE T_NETLIST ')' r_extinterface ')' + { + if( YY_BASE_CELL && YY_PTFIG == YY_LOFIG ) + YY_BLACKBOX = 'Y'; + } + ; + +r_extinterface : + T_INTERFACE l_finextinterf ')' + ; + +l_finextinterf : + /* empty */ + | l_finextinterf r_finextinterf + ; + +r_finextinterf : + r_port + | r_property + ; + +/*---------------------------------------------------------\ + MAIN +\---------------------------------------------------------*/ +l_finedif : + /* empty */ + | l_finedif r_library + ; + +r_library : + T_LIBRARY r_namedef r_ediflevel l_finlibrary ')' + ; + +l_finlibrary : + /* empty */ + | l_finlibrary r_finlibrary + ; + +r_finlibrary : + r_cell + ; + +r_cell : + T_CELL r_namedef + { + lofig_list *ptf; + char *cell_name; + + cell_name = namealloc($2); + + YY_BASE_CELL = 0; + + if (!(ptf = get_figure_pt(cell_name))) + { + YY_PTFIG = addlofig ($2); + YY_NOLOAD_FIG = 0; + YY_NOLOAD_LOCON = 0; + } + else + { + if( cell_name == YY_FIGNAME ) + YY_PTFIG = YY_LOFIG; + else + YY_PTFIG = ptf; + + YY_BASE_CELL = incatalog( cell_name ); + + if( ptf->LOCON && YY_BASE_CELL || ptf->LOSIG ) + YY_NOLOAD_FIG = 1; + else + YY_NOLOAD_FIG = 0; + + YY_NOLOAD_LOCON = (ptf->LOCON) ? 1 : 0; + } + YY_INDEX = 0; + } + r_celltype l_fincell ')' + { + loins_list *inst_pt; + + if (YY_NOLOAD_FIG == 0) + { + char *array_cname; + char *array_sname; + locon_list *ptcon; + char new_sig_name[MAXSTRLEN]; + char end; + locon_list *YY_INS_PTCON = (locon_list *) NULL; + locon_list *YY_PTCON = (locon_list *) NULL; + losig_list *sigvss; + losig_list *sigvdd; + locon_list *ptlocon; + + for( ptlocon = YY_PTFIG->LOCON; ptlocon; ptlocon = ptlocon->NEXT ) + { + if( isvss( ptlocon->NAME ) || isvdd( ptlocon->NAME ) ) + { + break; + } + } + + if( !ptlocon ) + { + sigvss = addlosig (YY_PTFIG, + ++YY_INDEX, + addchain( NULL, namealloc( VSS ) ), + EXTERNAL ); + sigvdd = addlosig (YY_PTFIG, + ++YY_INDEX, + addchain( NULL, namealloc( VDD ) ), + EXTERNAL ); + addlocon( YY_PTFIG, namealloc( VDD ), sigvdd, IN ); + addlocon( YY_PTFIG, namealloc( VSS ), sigvss, IN ); + } + /* scan all instances */ + for( YY_PTINS = YY_PTFIG->LOINS; YY_PTINS; YY_PTINS=YY_PTINS->NEXT ) + { + if( YY_PTINS->FIGNAME != YY_RIPPER_CELL ) + { + for (YY_INS_PTCON = YY_PTINS->LOCON; + YY_INS_PTCON != (locon_list *) NULL; + YY_INS_PTCON = YY_INS_PTCON->NEXT) + { + if( isvss( YY_INS_PTCON->NAME ) ) + { + YY_INS_PTCON->SIG = sigvss; + } + if( isvdd( YY_INS_PTCON->NAME ) ) + { + YY_INS_PTCON->SIG = sigvdd; + } + if (YY_INS_PTCON->SIG == NULL) + { + sprintf(new_sig_name,"unused_%d",++YY_INDEX); + if ( YY_PTINS->USER == (struct ptype *) NULL || + !is_portinstance( YY_PTINS, YY_INS_PTCON->NAME ) ) + { + fprintf (stderr, "*** mbk warning *** edifloadlofig :\n"); + fprintf (stderr, "Connector '%s' ",YY_INS_PTCON->NAME); + fprintf (stderr, "of instance '%s' ",YY_PTINS->INSNAME); + fprintf (stderr, "has no signal in figure "); + fprintf (stderr, "'%s'.\n",YY_PTFIG->NAME); + fprintf(stderr, "==> Creation of signal '%s'\n", new_sig_name); + } + + YY_INS_PTCON->SIG = addlosig (YY_PTFIG, YY_INDEX, + addchain( NULL, namealloc( new_sig_name ) ), + INTERNAL ); + } + } + } + + + /* scan all figure's connectors */ + for (YY_PTCON = YY_PTFIG->LOCON; + YY_PTCON != (locon_list *) NULL; + YY_PTCON = YY_PTCON->NEXT) + { + if (YY_PTCON->SIG == NULL) + { + sprintf(new_sig_name,"unused_%d",++YY_INDEX); + + fprintf (stderr, "*** mbk warning *** "); + fprintf (stderr, "edifloadlofig : \n"); + fprintf (stderr, "connector '%s' ",YY_PTCON->NAME); + fprintf (stderr, "of figure '%s' ",YY_PTFIG->NAME); + fprintf (stderr, "has no signal\n"); + fprintf(stderr, "==> Creation of signal '%s'\n", new_sig_name); + + YY_PTCON->SIG = addlosig (YY_PTFIG, YY_INDEX, + addchain( NULL, namealloc( new_sig_name ) ), + EXTERNAL ); + + } + } + } + } + /* free all instance->USER that are filled with chain_list data */ + for( inst_pt = YY_PTFIG->LOINS; inst_pt; inst_pt=inst_pt->NEXT ) + { + if( inst_pt->USER != (struct ptype *)NULL ) + { + freechain( (chain_list *)inst_pt->USER ); + inst_pt->USER = (struct ptype *)NULL; + } + } + } + ; + +r_celltype : + T_CELLTYPE T_CELLTYPE_GENERIC ')' + | T_CELLTYPE T_CELLTYPE_TIE ')' + | T_CELLTYPE T_CELLTYPE_RIPPER ')' + { + YY_RIPPER_CELL = YY_PTFIG->NAME; + } + ; + +l_fincell : + /* empty */ + | l_fincell r_fincell + ; + +r_fincell : + r_view + | r_property + ; + +r_property : + T_PROPERTY l_anything ')' + ; + +r_opt_property : + { + } + | r_property + { + } + ; + +r_view : + T_VIEW r_namedef T_VIEWTYPE T_NETLIST ')' r_interface l_finview ')' + { + if( YY_BASE_CELL && YY_PTFIG == YY_LOFIG ) + YY_BLACKBOX = 'Y'; + } + ; + +l_finview : + /* empty */ + | l_finview r_finview + ; + +r_finview : + r_contents + | r_property + ; + +r_contents : + T_CONTENTS l_fincontents ')' + { + YY_PTFIG->MODE = 'A'; + } + ; + +l_fincontents : + /* empty */ + | l_fincontents r_fincontents + ; + +r_fincontents : + r_instance + | r_net + ; + +r_instance : + T_INSTANCE r_namedef r_viewref r_opt_property + { + if( YY_NOLOAD_FIG == 0 ) + { + lofig_list *YY_INS_PTMODEL = (lofig_list *) NULL; + chain_list *YY_INS_SIGCHAIN = (chain_list *) NULL; + locon_list *YY_INS_PTCON = (locon_list *) NULL; + + YY_INS_PTMODEL = getlofig( YY_INS_MODELNAME, 'P' ); + YY_INS_SIGCHAIN = NULL; + + for( YY_INS_PTCON = YY_INS_PTMODEL->LOCON; + YY_INS_PTCON != NULL; + YY_INS_PTCON = YY_INS_PTCON->NEXT) + YY_INS_SIGCHAIN = addchain( YY_INS_SIGCHAIN, NULL ); + + YY_PTINS = addloins( YY_PTFIG, $2, YY_INS_PTMODEL, YY_INS_SIGCHAIN ); + + YY_V_PORTINSTANCE = addchain(YY_V_PORTINSTANCE, NULL); + } + } + l_portinstance l_anything ')' + { + YY_PTINS->USER = (struct ptype *)YY_V_PORTINSTANCE->DATA; + } + ; + +r_viewref : + T_VIEWREF r_namedef ')' + | T_VIEWREF r_namedef r_cellref ')' + ; + +l_portinstance : + /* empty */ + | l_portinstance r_portinstance + ; + +r_portinstance : + T_PORTINSTANCE r_namedef l_anything ')' + { + YY_V_PORTINSTANCE->DATA = addchain( YY_V_PORTINSTANCE->DATA, (void *)namealloc( $2 ) ); + } + ; + +r_cellref : + T_CELLREF r_namedef ')' + { + YY_INS_MODELNAME = namealloc( $2 ); + } + | T_CELLREF r_namedef r_libraryref ')' + { + YY_INS_MODELNAME = namealloc( $2 ); + } + ; + +r_libraryref : + T_LIBRARYREF r_namedef ')' + ; + +r_net : + T_NET r_namedef + { + if (YY_NOLOAD_FIG == 0) + { + YY_PTSIG = addlosig (YY_PTFIG, ++YY_INDEX, addchain (NULL, CheckCadenceNetError( $2 ) ), 'Z'); + YY_SIGTYPE = INTERNAL; + } + YY_BUS_WIDTH = 1; + } + r_joined l_finnet ')' + { + if (YY_NOLOAD_FIG == 0) + { + YY_PTSIG->TYPE = YY_SIGTYPE; + } + } + | T_NET T_ARRAY r_namedef T_INTEGER ')' + { + if (YY_NOLOAD_FIG == 0) + { + int i; + int begin; + int end; + char net_name[MAXSTRLEN]; + losig_list *YY_SIG_TMP = (losig_list *) NULL; + + if( $4 <= 0 ) + { + fprintf(stderr, "*** mbk error *** edifloadlofig : Array width must be > 0\n"); + exit( 1 ); + } + + for (i=0; i < $4; i++) + { + if( (CheckCadenceBusError ($3, &begin, &end)) && (i <= abs( end - begin) ) ) + sprintf(&net_name[0], "%s %d", YY_ARRAYPORTNAME, ( begin <= end ) ? begin + i : begin - i); + else + sprintf(&net_name[0], "%s %d", $3, i); + + YY_PTSIG = addlosig (YY_PTFIG, ++YY_INDEX, addchain (NULL, namealloc (net_name)), 'Z'); + YY_SIGTYPE = INTERNAL; + YY_BUS_WIDTH = $4; + } + + YY_SIG_TMP = YY_PTSIG; + for (i=0; iNEXT; + } + YY_PTSIG = YY_SIG_TMP; + YY_PORTLIST_SIG_TMP = YY_PORTLIST_SIG; + } + } + r_array_joined l_finnet ')' + { + if (YY_NOLOAD_FIG == 0) + { + int i; + losig_list *ptsig; + + freechain( (chain_list *)YY_PORTLIST_SIG ); + YY_PORTLIST_SIG = (chain_list *)NULL; + + ptsig = YY_PTSIG; + for (i = YY_BUS_WIDTH - 1; i >= 0; i--) + { + ptsig->TYPE = YY_SIGTYPE; + ptsig = ptsig->NEXT; + } + } + } + ; + +l_finnet : + /* empty */ + | l_finnet r_finnet + ; + +r_finnet : + r_property + ; + +r_array_joined : + T_JOINED l_array_joined ')' + ; + +l_array_joined : + /* empty */ + | l_array_joined r_array_joined + ; + +r_array_joined : + r_array_portref + | r_portlist + ; + +r_portlist : + T_PORTLIST + { + YY_PORTLIST = 1; + YY_PORTLIST_NUM = 0; + YY_PORTLIST_SIG = YY_PORTLIST_SIG_TMP; + } + l_list_portref ')' + { + YY_PORTLIST = 0; + + if (YY_PORTLIST_NUM < YY_BUS_WIDTH) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : "); + fprintf (stderr, "PortList width < signal bus '%s' width ( line %d ).\n", + edif_busname( getsigname(YY_PTSIG)), yylineno ); + exit (1); + } + } + ; + +l_list_portref : + /* empty */ + | l_list_portref r_portref + ; + +r_array_portref : + T_PORTREF r_namedef ')' + { + if (YY_NOLOAD_FIG == 0) + { + int i; + losig_list *ptsig; + char port_name[MAXSTRLEN]; + int begin, end; + locon_list *YY_PTCON = (locon_list *) NULL; + + ptsig = YY_PTSIG; + if (bus_nameref(YY_PTFIG->LOCON, $2, YY_BUS_WIDTH)) + { + for (i = YY_BUS_WIDTH - 1; i >= 0; i--) + { + if ( (CheckCadenceBusError ($2, &begin, &end)) && (i <= abs( end - begin) ) ) + sprintf(&port_name[0], "%s %d", YY_ARRAYPORTNAME, (begin <= end) ? begin + i : begin - i); + else + sprintf(&port_name[0], "%s %d", $2, i); + + YY_PTCON = getlocon (YY_PTFIG, &port_name[0]); + YY_PTCON->SIG = ptsig; + ptsig = ptsig->NEXT; + } + YY_SIGTYPE = EXTERNAL; + } + else + { + fprintf (stderr, "*** mbk error *** edifloadlofig :\n"); + fprintf (stderr, "Connector '%s' in figure '%s' do not refer to an ARRAY construct", + $2, YY_PTFIG->NAME); + fprintf (stderr, "\n or it is a bus with incompatible width than Signal Bus\n"); + exit (1); + } + } + } + | T_PORTREF r_namedef T_INSTANCEREF r_namedef ')' ')' + { + if (YY_NOLOAD_FIG == 0) + { + int i; + char port_name[MAXSTRLEN]; + char *port_name_alloc; + losig_list *ptsig; + int begin, end; + locon_list *YY_PTCON = (locon_list *) NULL; + + ptsig = YY_PTSIG; + YY_PTINS = getloins (YY_PTFIG, $4); + + if( bus_nameref(YY_PTINS->LOCON, $2, YY_BUS_WIDTH)) + { + if( ( CheckCadenceBusError ($2, &begin, &end)) + &&( (YY_BUS_WIDTH - 1) == abs(end - begin) ) ) + sprintf(&port_name[0], "%s %d", YY_ARRAYPORTNAME, ( begin <= end ) ? end : begin ); + else + sprintf(&port_name[0], "%s %d", $2, YY_BUS_WIDTH - 1); + + port_name_alloc = namealloc( port_name ); + + for (YY_PTCON = YY_PTINS->LOCON; YY_PTCON; YY_PTCON = YY_PTCON->NEXT) + if( port_name_alloc == YY_PTCON->NAME) + break; + + if (YY_PTCON == (locon_list *) NULL) + { + fprintf (stderr, "*** mbk error *** edifloadlofig :"); + fprintf (stderr, " bus connector %s not found", $2); + fprintf (stderr, " in instance %s", $4); + fprintf (stderr, " of figure %s\n", YY_PTINS->FIGNAME); + exit( 1 ); + } + else + { + for (i = YY_BUS_WIDTH - 1; (i >= 0) && YY_PTCON; i--) + { + YY_PTCON->SIG = ptsig; + ptsig = ptsig->NEXT; + YY_PTCON = YY_PTCON->NEXT; + } + } + } + else + { + port_name_alloc = namealloc( CheckCadenceNetError( $2 ) ); + + for (YY_PTCON = YY_PTINS->LOCON; YY_PTCON; YY_PTCON = YY_PTCON->NEXT) + if( YY_PTCON->NAME == port_name_alloc ) + break; + fprintf (stderr, "*** mbk error *** edifloadlofig : "); + if (YY_PTCON) + { + fprintf (stderr, "Connector '%s' in instance '%s' of figure '%s' do not refer", + port_name_alloc, $4, YY_PTFIG->NAME); + fprintf (stderr, "\n to an ARRAY construct or it is a bus with" ); + fprintf (stderr, "incompatible width than Signal Bus/n"); + exit( 1 ); + } + else + { + fprintf (stderr, "Connector '%s' not found on instance '%s'\n", port_name_alloc, $4); + exit( 1 ); + } + } + } + } + ; + +r_joined : + T_JOINED l_finjoined ')' + ; + +l_finjoined : + /* empty */ + | l_finjoined r_finjoined + ; + +r_finjoined : + r_portref + ; + +r_portref : + T_PORTREF r_namedef ')' + { + if (YY_NOLOAD_FIG == 0) + { + locon_list *YY_PTCON = (locon_list *) NULL; + + YY_PTCON = getlocon( YY_PTFIG, CheckCadenceNetError( $2 ) ); + + if (!YY_PORTLIST) + YY_PTCON->SIG = YY_PTSIG; + else + YY_PTCON->SIG = (losig_list *)YY_PORTLIST_SIG->DATA; + + YY_SIGTYPE = EXTERNAL; + if (YY_PORTLIST) + { + if (++YY_PORTLIST_NUM < YY_BUS_WIDTH) + YY_PORTLIST_SIG = YY_PORTLIST_SIG->NEXT; + else + if (YY_PORTLIST_NUM > YY_BUS_WIDTH) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : "); + fprintf (stderr, "PortList width > signal bus '%s' width ( line %d ).\n", + edif_busname(getsigname(YY_PTCON->SIG)), yylineno ); + exit( 1 ); + } + } + } + } + | T_PORTREF r_namedef T_INSTANCEREF r_namedef ')' ')' + { + if (YY_NOLOAD_FIG == 0) + { + char *port_name_ref; + locon_list *YY_PTCON = (locon_list *) NULL; + + port_name_ref = namealloc( CheckCadenceNetError( $2 ) ); + + YY_PTINS = getloins (YY_PTFIG, $4); + for (YY_PTCON = YY_PTINS->LOCON; YY_PTCON; YY_PTCON = YY_PTCON->NEXT) + { + if ( port_name_ref == YY_PTCON->NAME) + { + if( !YY_PORTLIST ) + YY_PTCON->SIG = YY_PTSIG; + else + YY_PTCON->SIG = (losig_list *)YY_PORTLIST_SIG->DATA; + break; + } + } + + if (YY_PTCON == NULL) + { + fprintf (stderr, "*** mbk error *** edifloadlofig :"); + fprintf (stderr, " connector %s not found", $2); + fprintf (stderr, " in instance %s", $4); + fprintf (stderr, " of figure %s\n", YY_PTINS->FIGNAME); + exit( 1 ); + } + + if (YY_PORTLIST) + if (++YY_PORTLIST_NUM < YY_BUS_WIDTH) + YY_PORTLIST_SIG = YY_PORTLIST_SIG->NEXT; + else + if (YY_PORTLIST_NUM > YY_BUS_WIDTH) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : "); + fprintf (stderr, "PortList width > signal bus '%s' width ( line %d ).\n", + edif_busname(getsigname(YY_PTCON->SIG)), + yylineno ); + exit (1); + } + } + } + | T_PORTREF T_MEMBER r_namedef T_INTEGER ')' ')' + { + if (YY_NOLOAD_FIG == 0) + { + char port_name[MAXSTRLEN]; + int begin, end; + locon_list *YY_PTCON = (locon_list *) NULL; + + if ( (CheckCadenceBusError ($3, &begin, &end)) + && ($4 <= abs( begin - end ) ) ) + sprintf(&port_name[0], "%s %d", YY_ARRAYPORTNAME, ( begin <= end ) ? begin + $4 : begin - $4 ); + else + sprintf(&port_name[0], "%s %d", $3, $4); + + YY_PTCON = getlocon (YY_PTFIG, port_name); + if (!YY_PORTLIST) + YY_PTCON->SIG = YY_PTSIG; + else + YY_PTCON->SIG = (losig_list *)YY_PORTLIST_SIG->DATA; + + YY_SIGTYPE = EXTERNAL; + if (YY_PORTLIST) + if (++YY_PORTLIST_NUM < YY_BUS_WIDTH) + YY_PORTLIST_SIG = YY_PORTLIST_SIG->NEXT; + else + if (YY_PORTLIST_NUM > YY_BUS_WIDTH) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : "); + fprintf (stderr, "PortList width > signal bus '%s' width ( line %d ).\n", + edif_busname(getsigname(YY_PTCON->SIG)), + yylineno ); + exit (1); + } + } + } + | T_PORTREF T_MEMBER r_namedef T_INTEGER ')' T_INSTANCEREF r_namedef ')' ')' + { + + if (YY_NOLOAD_FIG == 0) + { + char port_name[MAXSTRLEN]; + int begin, end; + locon_list *YY_PTCON = (locon_list *) NULL; + char *YY_PORTNAME = (char *) NULL; + + YY_PTINS = getloins (YY_PTFIG, $7); + + if ( (CheckCadenceBusError ($3, &begin, &end) ) + && ($4 <= abs( begin - end ) ) ) + sprintf(&port_name[0], "%s %d", YY_ARRAYPORTNAME, ( begin <= end ) ? begin + $4 : begin - $4 ); + else + sprintf(&port_name[0], "%s %d", $3, $4); + + YY_PORTNAME = namealloc (&port_name[0]); + for (YY_PTCON = YY_PTINS->LOCON; YY_PTCON; YY_PTCON = YY_PTCON->NEXT) + { + if (YY_PORTNAME == YY_PTCON->NAME) + { + if (!YY_PORTLIST) + YY_PTCON->SIG = YY_PTSIG; + else + YY_PTCON->SIG = (losig_list *)YY_PORTLIST_SIG->DATA; + break; + } + } + + if (YY_PTCON == NULL) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : "); + fprintf (stderr, "connector %s not found ", port_name); + fprintf (stderr, " in instance %s", $7); + fprintf (stderr, " of figure %s\n", YY_PTINS->FIGNAME); + exit (1); + } + + if (YY_PORTLIST) + if (++YY_PORTLIST_NUM < YY_BUS_WIDTH) + YY_PORTLIST_SIG = YY_PORTLIST_SIG->NEXT; + else + if (YY_PORTLIST_NUM > YY_BUS_WIDTH) + { + fprintf (stderr, "*** mbk error *** edifloadlofig : "); + fprintf (stderr, "PortList width > signal bus '%s' width ( line %d ).\n", + edif_busname(getsigname(YY_PTCON->SIG)), + yylineno ); + exit (1); + } + } + } + ; + +r_interface : + T_INTERFACE l_fininterface ')' + ; + +l_fininterface : + /* empty */ + | l_fininterface r_fininterface + ; + +r_fininterface : + r_port + | r_port_joined + | r_property + ; + +r_port : + T_PORT r_namedef l_finport ')' + { + if (YY_NOLOAD_LOCON == 0) + { + addlocon( YY_PTFIG, CheckCadenceNetError( $2 ), NULL ,YY_DIRECTION ); + } + } + | T_PORT T_ARRAY r_namedef T_INTEGER ')' l_finport ')' + { + if (YY_NOLOAD_LOCON == 0) + { + char port_name [MAXSTRLEN]; + int i; + int begin; + int end; + + if( $4 <= 0 ) + { + fprintf(stderr, "*** mbk error *** edifloadlofig : Array width must be > 0\n"); + exit( 1 ); + } + + if ( (CheckCadenceBusError ($3, &begin, &end)) && ( (abs (end - begin) + 1) == $4) ) + { + for (i=0; i < $4; i++) + { + sprintf(&port_name[0], "%s %d", YY_ARRAYPORTNAME, ( begin <= end ) ? begin + i : begin - i ); + addlocon (YY_PTFIG, &port_name[0], NULL ,YY_DIRECTION); + } + } + else + { + for (i=0; i < $4; i++) + { + sprintf(&port_name[0], "%s %d", $3, i); + addlocon (YY_PTFIG, &port_name[0], NULL ,YY_DIRECTION); + } + } + } + } + ; + +l_finport : + /* empty */ + | l_finport r_finport + ; + +r_finport : + r_direction + | r_property + ; + +r_direction : + T_DIRECTION T_INOUT ')' + { + YY_DIRECTION = UNKNOWN; + } + | T_DIRECTION T_INPUT ')' + { + YY_DIRECTION = IN; + } + | T_DIRECTION T_OUTPUT ')' + { + YY_DIRECTION = OUT; + } + ; + +l_anything : + /* empty */ + { } + | l_anything r_anything + { } + ; + +r_anything : + l_anything ')' + | r_namedef + ; + +r_namedef : + T_IDENT + { + strcpy($$, $1); + } + | T_INTEGER + { + char YY_TMP [MAXSTRLEN]; + + sprintf(YY_TMP, "%ld", $1); + strcpy($$, YY_TMP); + } + | T_RENAME T_IDENT T_RENAME_STRING ')' + { + strcpy($$, $2); + } + | T_RENAME r_name T_RENAME_STRING ')' + { + strcpy($$, $2); + } + ; + +r_name : + T_NAME T_IDENT ')' + { + strcpy($$, $2); + } + ; + +r_port_joined : + T_JOINED l_finport_joined ')' + ; + +l_finport_joined : + /* empty */ + | l_finport_joined r_finport_joined + ; + +r_finport_joined : + r_shorted_portref + ; + +r_shorted_portref : + T_PORTREF r_namedef ')' + ; + +%% + +extern char yytext[]; +extern FILE *yyin; + + +/*----------------------------------------------------------------------*/ +/* bus_nameref: checks that name ref is bus name ref and with */ +/* the same width. It returns 1 if ok. */ +/* Do not forget that locon list is in reverse order. */ +/*----------------------------------------------------------------------*/ + +/*---------------------------------------------------------\ + bus_nameref +\---------------------------------------------------------*/ +static char bus_nameref( ptlocon, bnameref, bus_width ) +locon_list *ptlocon; +char *bnameref; +int bus_width; +{ + int i, n; + char port_name[MAXSTRLEN]; + char *pname; + locon_list *loconp; + int begin, end; + + bus_width --; + if ( (!CheckCadenceBusError( bnameref, &begin, &end ) ) || (bus_width != abs( end - begin ) ) ) + { + strcpy( YY_ARRAYPORTNAME, bnameref ); + end = bus_width; + } + + sprintf(&port_name[0], "%s %d", YY_ARRAYPORTNAME, end ); + + pname = namealloc( &port_name[0] ); + + for (loconp = ptlocon; loconp != (locon_list *) NULL; loconp = loconp->NEXT) + if (loconp->NAME == pname) + break; + + if (loconp == (locon_list *) NULL) + return 0; + + for( loconp = loconp->NEXT; loconp != (locon_list *) NULL; loconp = loconp->NEXT ) + { + sprintf( &port_name[0], "%s %d", YY_ARRAYPORTNAME, ( begin <= end ) ? --end : ++end ); + if ( ( loconp->NAME == namealloc( port_name ) ) && bus_width >= 0) + bus_width--; + else + break; + } + + return( bus_width == 0 ); + +} /* end of bus_nameref */ + +/*---------------------------------------------------------\ + edifloadlofig +\---------------------------------------------------------*/ +void edifloadlofig( ptfig, figname, mode ) +lofig_list *ptfig; +char *figname; +char mode; +{ + char filename[120]; + lofig_list *pt; + losig_list *ptsig; + losig_list *ptsignext; + loins_list *ptins; + loins_list *ptinsnext; + + static char Vierge = 1; /* first time */ + + yylineno = 0; + + YY_RIPPER_IN = (char *)NULL; + YY_RIPPER_OUT = (char *)NULL; + + YY_LOFIG = (lofig_list *) NULL; + YY_PTFIG = (lofig_list *) NULL; + YY_PTSIG = (losig_list *) NULL; + YY_PORTLIST_SIG = (chain_list *) NULL; + YY_PORTLIST_SIG_TMP = (chain_list *) NULL; + YY_PTINS = (loins_list *) NULL; + YY_V_PORTINSTANCE = (chain_list *) NULL; + YY_BLACKBOX = 'N'; + YY_BUS_WIDTH = 0; + YY_DIRECTION = UNKNOWN; + YY_INDEX = 0; + YY_SIGTYPE = 'Z'; + YY_NOLOAD_LOCON = 0; + YY_NOLOAD_FIG = 0; + YY_RIPPER_CELL = (char *) NULL; + + sprintf( filename, "%s/%s.%s", WORK_LIB, figname, IN_LO ); + if( ( yyin = mbkfopen( figname, IN_LO, READ_TEXT ) ) == NULL ) + { + fprintf( stderr, "*** mbk error *** edifloadlofig : can't open file %s\n", filename ); + exit( 1 ); + } + + if( Vierge == 0 ) + yyrestart( yyin ); + Vierge = 0; + + YY_LOFIG = ptfig; + YY_FIGNAME = figname; + YY_V_PORTINSTANCE = (chain_list *) NULL; + + if( yyparse() != 0 ) + { + fprintf( stderr, "*** mbk error *** edifloadlofig : abnormal parsing for %s\n", filename ); + exit( 1 ); + } + + if( fclose( yyin ) != 0 ) + { + fprintf(stderr, "*** mbk error *** edifloadlofig : can't close file %s\n", filename); + exit(1); + } + + if (YY_BLACKBOX == 'Y') + { + ptfig->MODE = 'A'; + for (pt = HEAD_LOFIG; pt != NULL; pt = pt->NEXT) + { + if (pt == ptfig) + break; + for (ptins = ptfig->LOINS; ptins != NULL; ptins = ptins->NEXT) + { + if( pt->NAME == ptins->FIGNAME ) + break; + } + if (ptins == NULL) + dellofig( pt->NAME ); + } + + for( pt = HEAD_LOFIG; pt != (lofig_list *) NULL; pt = pt->NEXT ) + { + if( pt != ptfig ) + { + for( ptsig = pt->LOSIG; ptsig != (losig_list *) NULL; ptsig = ptsig->NEXT ) + free( ptsig ); + pt->LOSIG = (losig_list *) NULL; + + for( ptins = pt->LOINS; ptins != (loins_list *) NULL; ptins = ptins->NEXT ) + delloins( pt , ptins->INSNAME ); + pt->MODE = 'P'; + } + } + } + + for (pt = HEAD_LOFIG; pt != NULL; pt = pt->NEXT) + if( pt != ptfig ) + pt->MODE = (pt->LOSIG == NULL) ? 'P' : 'A'; + else + pt->MODE = 'A'; + + REnamealloc( ); + + del_patch( ptfig, 1 ); + + +} /* end of edifloadlofig */ + +/*---------------------------------------------------------\ + yyerror +\---------------------------------------------------------*/ +int yyerror( String ) +char *String; +{ + fprintf( stderr, + "*** mbk error *** edifloadlofig : %s at ligne %d on '%s'\n", + String, yylineno + 1, yytext ); + exit( 1 ); +} /* end of yyerror */ + +/*---------------------------------------------------------\ + yywrap +\---------------------------------------------------------*/ +int yywrap() +{ + return 1; +} /* end of yywrap */ + +/*---------------------------------------------------------\ + get_figure_pt +\---------------------------------------------------------*/ +static lofig_list *get_figure_pt( Name ) +char *Name; +{ + lofig_list *pt; + + for( pt = HEAD_LOFIG; pt; pt = pt->NEXT ) + if( pt->NAME == Name ) + return pt; + + return (lofig_list *)NULL; + +} /* end of get_figure_pt */ + +/*---------------------------------------------------------\ + is_portinstance +\---------------------------------------------------------*/ +static char is_portinstance(inst_pt, Name) +loins_list *inst_pt; +char *Name; +{ + chain_list *chain_pt; + + chain_pt = (chain_list *)YY_PTINS->USER; + + while( chain_pt ) + { + if( Name == (char *)chain_pt->DATA ) + return 1; + chain_pt = chain_pt->NEXT; + } + + return 0; +} /* end of is_portinstance */ + +/*---------------------------------------------------------\ + CheckCadenceNetError +\---------------------------------------------------------*/ +static char *CheckCadenceNetError( Name ) +char *Name; +{ + char net_name[MAXSTRLEN]; + char *first; + char *second; + + strcpy (net_name, Name); + + first = net_name; + + while( first ) + { + if ( ( first = strchr( first, '_' ) ) != NULL ) + { + if( strncmp( first, "_60_", 4 ) != NULL ) + { + first++; + continue; + } + second = first + 4; + while( isdigit( *second ) ) second ++; + + if( strcmp( second, "_62" ) != NULL ) + { + *first = ' '; + first ++; + second = first + 3; + while( isdigit( *second ) ) + { + *first = *second; + second ++; + first ++; + } + first[ 0 ] = '\0'; + return namealloc( net_name ); + } + first ++; + } + else + { + return namealloc( Name ); + } + } + + return namealloc( Name ); + +} /* fin de CheckCadenceNetError */ + +/*---------------------------------------------------------\ + CheckCadenceBusError +\---------------------------------------------------------*/ +static char CheckCadenceBusError(PortName, Min, Max) +char *PortName; +int *Min; +int *Max; +{ + char *array; + char *first; + char *middle; + char save; + + strcpy (YY_ARRAYPORTNAME, PortName); + + first = YY_ARRAYPORTNAME; + + while (first) + { + if ( (first = strchr (first, '_') ) != NULL ) + { + if( strncmp( first, "_60_", 4 ) != NULL ) + { + first++; + continue; + } + first[0] = '\0'; + array = first + 4; + while ( isdigit (*array) ) array ++; + + if ( ( *array != 0 ) && ( strncasecmp (array, "TO", 2) == NULL ) ) + { + middle = array; + save = middle [0]; + middle [0] = '\0'; + array += 2; + while ( isdigit (*array) ) array ++; + + if ( strcmp( first, "_62" ) != NULL ) + { + array [0] = '\0'; + sscanf (first + 4, "%d", Min); + sscanf (middle + 2, "%d", Max); + return 1; + } + middle [0] = save; + } + first[0] = '_'; + first ++; + } + } + *Min = 0; + *Max = 0; + return 0; + +} /* end of CheckCadenceBusError */ + +/*---------------------------------------------------------\ + sig_merge +\---------------------------------------------------------*/ +static void sig_merge(pt_lofig, sig1, sig2) +lofig_list *pt_lofig; +long sig1; +long sig2; +{ + losig_list *ls1, *ls2; + locon_list *c; + loins_list *i; + lotrs_list *t; + + for (ls1 = pt_lofig->LOSIG; ls1; ls1 = ls1->NEXT) { + if (ls1->INDEX == sig1) + break; + } + + for (ls2 = pt_lofig->LOSIG; ls2; ls2 = ls2->NEXT) { + if (ls2->INDEX == sig2) + break; + } + + if (ls1 == NULL || ls2 == NULL) /* one of them not exists ! */ + { + return; + } + + if (ls1 == ls2) /* already joined!, just return */ + return; + + for (c = pt_lofig->LOCON; c; c = c->NEXT) + if (c->SIG == ls2) + c->SIG = ls1; + + for (i = pt_lofig->LOINS; i; i = i->NEXT) + for (c = i->LOCON; c; c = c->NEXT) + if (c->SIG == ls2) + c->SIG = ls1; + + for (t = pt_lofig->LOTRS; t; t = t->NEXT) { + if (t->GRID->SIG == ls2) + t->GRID->SIG = ls1; + if (t->DRAIN->SIG == ls2) + t->DRAIN->SIG = ls1; + if (t->SOURCE->SIG == ls2) + t->SOURCE->SIG = ls1; + } + + if(!ls1->PRCN) + addlorcnet( ls1 ); + (void)addcapa(ls1, getcapa(ls2)); + (void)dellosig(pt_lofig, ls2->INDEX); +} + +/*---------------------------------------------------------\ + find_ripper_con_name +\---------------------------------------------------------*/ +void find_ripper_con_name( lofig ) +lofig_list *lofig; +{ + locon_list *c1; + char save; + char *pt; + + for( c1 = lofig->LOCON; c1; c1 = c1->NEXT ) + { + if( isvss( c1->NAME ) || isvdd( c1->NAME ) ) + { + continue; + } + if( !YY_RIPPER_IN ) + { + if( ( pt = strrchr( c1->NAME, ' ' ) ) == NULL ) + { + fprintf( stderr, "*** mbk warning *** edifloadlofig : ripper connectors not valid (2)!!\n" ); + exit(1); + } + save = *pt; + *pt = '\0'; + YY_RIPPER_IN = namealloc ( c1->NAME ); + *pt = save; + } + else if( strncmp( YY_RIPPER_IN, c1->NAME, strlen( YY_RIPPER_IN ) ) != 0 ) + { + if( YY_RIPPER_OUT ) + { + if( strncmp( YY_RIPPER_OUT, c1->NAME, strlen( YY_RIPPER_OUT ) ) != 0 ) + { + fprintf( stderr, "*** mbk warning *** edifloadlofig : ripper connectors not valid (3)!!\n" ); + exit(1); + } + } + else + { + if( ( pt = strrchr( c1->NAME, ' ' ) ) == NULL ) + { + fprintf( stderr, "*** mbk warning *** edifloadlofig : ripper connectors not valid (4)!!\n" ); + exit(1); + } + save = *pt; + *pt = '\0'; + YY_RIPPER_OUT = namealloc ( c1->NAME ); + *pt = save; + } + } + } + +} /* end of find_ripper_con_name */ +/*---------------------------------------------------------\ + del_patch +\---------------------------------------------------------*/ +static void del_patch(pt_lofig, master) +lofig_list *pt_lofig; +char master; +{ + loins_list *i; + loins_list *k; + locon_list *c1, *c2; + chain_list *ptchain; + char *b; + long j; + long i1, i2; + char buf[MAXSTRLEN]; + + if( YY_RIPPER_CELL == (char *) NULL) + return; + + if( master == 1 ) + { + find_ripper_con_name( getlofig( YY_RIPPER_CELL, 'P' ) ); + } + + for (ptchain = pt_lofig->MODELCHAIN; ptchain != NULL; ptchain = ptchain->NEXT) + { + if ( YY_RIPPER_CELL != ptchain->DATA ) + del_patch( getlofig( ptchain->DATA, 'P'), 0 ); + } + + for (i = pt_lofig->LOINS; i; ) + { + if (YY_RIPPER_CELL == i->FIGNAME) + { + j = 0; + do + { + sprintf (buf, "%s %d", YY_RIPPER_IN, j); + b = namealloc (buf); + + for (c1 = i->LOCON; c1; c1 = c1->NEXT) + { + if ( (c1->NAME == b) && ( c1->SIG ) ) + { + i1 = c1->SIG->INDEX; + + sprintf (buf, "%s %d", YY_RIPPER_OUT, j); + b = namealloc (buf); + + for (c2 = i->LOCON; c2; c2 = c2->NEXT) + { + if ( (c2->NAME == b) && ( c2->SIG ) ) + { + i2 = c2->SIG->INDEX; + sig_merge(pt_lofig, i1, i2); + break; + } + } + + break; + } + } + + j++; + } while ( c1 ); + + k = i->NEXT; + delloins (pt_lofig, i->INSNAME); + i = k; + } + else + { + i = i->NEXT; + } + } + + if( master == 1 ) + dellofig( YY_RIPPER_CELL ); +} + +/*---------------------------------------------------------\ + REnamealloc +\---------------------------------------------------------*/ +static void REnamealloc( ) +{ + lofig_list *t; + char *te; + + for (t = YY_LOFIG; t; t = t->NEXT) + { + te = namealloc (t->NAME); + if( te != t->NAME ) + { + fprintf( stderr, "*** mbk warning *** edifloadlofig : instance name not namealloced !!!\n" ); + t->NAME = te; + } + } +} diff --git a/alliance/src/mbkedif/src/time.c b/alliance/src/mbkedif/src/time.c new file mode 100644 index 00000000..09c5298f --- /dev/null +++ b/alliance/src/mbkedif/src/time.c @@ -0,0 +1,83 @@ +/* + * 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. + */ + +/* + * gives time the format edif wants + */ + +#include +#include + +char *EdifTime() +{ +int EdifMonth(); +char *date; +long tim; +char day[6]; +int year; +int nday; +int hour; +int minute; +int second; +char month[6]; +int nmonth; + + time(&tim); + date = (char *)malloc(30); + strcpy(date, ctime(&tim)); + sscanf(date, "%s %s %d %d:%d:%d %d", + day,month,&nday,&hour,&minute,&second,&year); + sprintf(date, "%04d %02d %02d %02d %02d %02d", + year,EdifMonth(month),nday,hour,minute,second); + return date; +} + +int EdifMonth(month) +char *month; +{ + if (!strcmp(month, "Jan")) + return 1; + else if (!strcmp(month, "Feb")) + return 2; + else if (!strcmp(month, "Mar")) + return 3; + else if (!strcmp(month, "Apr")) + return 4; + else if (!strcmp(month, "May")) + return 5; + else if (!strcmp(month, "Jun")) + return 6; + else if (!strcmp(month, "Jul")) + return 7; + else if (!strcmp(month, "Aug")) + return 8; + else if (!strcmp(month, "Sep")) + return 9; + else if (!strcmp(month, "Oct")) + return 10; + else if (!strcmp(month, "Nov")) + return 11; + else if (!strcmp(month, "Dec")) + return 12; + else return 0; +}