Parser de formules CTL

This commit is contained in:
Ludovic Jacomme 2002-05-02 13:37:03 +00:00
parent 1b8f467609
commit 7a75e75fa3
16 changed files with 4669 additions and 0 deletions

View File

@ -0,0 +1 @@
SUBDIRS = src

View File

@ -0,0 +1,47 @@
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 <Frederic.Petrot@lip6.fr>
dnl $Id: configure.in,v 1.1 2002/05/02 13:37:03 ludo Exp $
dnl
dnl
AC_INIT(src/ctp.h)
AM_INIT_AUTOMAKE(ctp, 1.1)
AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_YACC
AM_PROG_LEX
AC_HEADER_STDC
AC_C_CONST
AC_PROG_RANLIB
AM_ALLIANCE
AC_OUTPUT([
Makefile
src/Makefile
])

View File

@ -0,0 +1,22 @@
AM_CFLAGS = @ALLIANCE_CFLAGS@
lib_LIBRARIES = libCtp.a
include_HEADERS = ctp.h
libCtp_a_SOURCES = ctp_y.y ctp_l.l ctp.h \
ctp_bedef.h ctp_bspec.c ctp_byacc.h ctp_parse.c ctp_util.h \
ctp_blex.h ctp_bspec.h ctp_util.c ctp_utype.h
CLEANFILES = ctp_y.c ctp_y.h ctp_l.c
ctp_y.c ctp_y.h : $(srcdir)/ctp_y.y
$(YACC) -d $(YFLAGS) $(srcdir)/ctp_y.y && sed -e "s/yy/ctp_y_/g" -e "s/YY/CTL_Y_/g" y.tab.c > ctp_y.c && sed -e "s/yy/ctp_y_/g" -e "s/YY/CTL_Y_/g" y.tab.h > ctp_y.h
ctp_l.c : $(srcdir)/ctp_l.l ctp_y.h
$(LEX) -t $(srcdir)/ctp_l.l | sed -e "s/yy/ctp_y_/g" -e "s/YY/CTL_Y_/g" > ctp_l.c
EXTRA_PROGRAMS = ctptest
ctptest_LDADD = @ALLIANCE_LIBS@ \
$(top_builddir)/src/libCtp.a \
-lCtl -lVex -lAut -lMut
ctptest_SOURCES = main.c

View File

@ -0,0 +1,70 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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 __P
# if defined(__STDC__) || defined(__GNUC__)
# define __P(x) x
# else
# define __P(x) ()
# endif
#endif
/*------------------------------------------------------\
| |
| Title : Fonctions to parse a CTL file |
| |
| Date : 04.22.02 |
| |
| Author : Jacomme Ludovic |
| |
\------------------------------------------------------*/
# ifndef CTP_H
# define CTP_H
/*------------------------------------------------------\
| |
| Constants |
| |
\------------------------------------------------------*/
/*------------------------------------------------------\
| |
| Structures |
| |
\------------------------------------------------------*/
/*------------------------------------------------------\
| |
| Global Variables |
| |
\------------------------------------------------------*/
/*------------------------------------------------------\
| |
| Functions |
| |
\------------------------------------------------------*/
extern ctlfig_list *loadctlfig __P((char *InputFileName));
# endif

View File

@ -0,0 +1,96 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/* ###--------------------------------------------------------------### */
/* */
/* file : bvl_bedef.h */
/* date : Jun 15 1992 */
/* version : v102 */
/* author : P.BAZARGAN, M.HANAFI */
/* content : declaration of define used by yacc */
/* */
/* ###--------------------------------------------------------------### */
#define CTP_LG_MC 15
#define CTP_NB_MC ((tab_mc -1 + sizeof(tab_mc)/ (sizeof(tab_mc[0])) - tab_mc+1))
#define CTP_CSTDFN 1 /* constant */
#define CTP_TPEDFN 2 /* type */
#define CTP_FORDFN 3 /* formula */
#define CTP_VARDFN 4 /* variable */
#define CTP_LABDFN 5 /* label */
#define CTP_MODDFN 0 /* mod_val field of dct_recrd */
#define CTP_SYMDFN 1 /* sym_val field of dct_recrd */
#define CTP_TYPDFN 2 /* type_val field of dct_recrd */
#define CTP_SUNDFN 3 /* sign_val */
#define CTP_LBLDFN 4 /* lbl_val field of dct_recrd */
#define CTP_WMXDFN 5 /* wmx_val field of dct_recrd */
#define CTP_WMNDFN 6 /* wmn_val field of dct_recrd */
#define CTP_ATLDFN 7 /* attr_left_val */
#define CTP_ATRDFN 8 /* attr_left_val */
#define CTP_PNTDFN 9 /* pnt_val field of dct_recrd */
#define CTP_UPTDFN 1 /* direction is up */
#define CTP_DWTDFN 2 /* direction is down */
#define CTP_IDXDFN 3
#define CTP_EVENT 1
#define CTP_STABLE 2
#define CTP_LEFT 3
#define CTP_RIGHT 4
#define CTP_HIGH 5
#define CTP_LOW 6
#define CTP_LENGTH 7
#define CTP_RANGE 8
#define CTP_REV_RANGE 9
/* ###---------------------------------------------------------------### */
#define NE 109
#define EQ 110
#define GT 111
#define GE 112
#define LT 113
#define LE 114
#define NOPI 115
#define NOPS 116
#define ANDM 117
#define CONC 118
#define CONVRT 119
#define SUBVAR 120
#define EMPTYOP 121
#define CTP_UNGDFN 0
#define CTP_GRDDFN 1
/* ###---------------------------------------------------------------### */
#define CTP_INTDFN 0 /* int_val field of dtc_recrd */
#define CTP_ALODFN 60 /* nbr of allocations */
#define CTP_HSZDFN 97 /* size of dictionnary: entries */

View File

@ -0,0 +1,47 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/* ###--------------------------------------------------------------### */
/* */
/* file : bvl_blex.h */
/* date : Jun 15 1992 */
/* version : v102 */
/* author : TABUSSE L.A. */
/* content : declaration of functions and global variables used by */
/* lex */
/* */
/* ###--------------------------------------------------------------### */
#include "ctp_bedef.h"
extern long CTP_LINNUM; /* file's line number */
typedef struct
{ char nom[CTP_LG_MC];
int kval;
} el_mc;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/* ###--------------------------------------------------------------### */
/* */
/* file : bvl_bspec.h */
/* date : Jun 15 1992 */
/* author : TABUSSE L.A. */
/* content : declaration of functions and global variables used by */
/* bvl_bspec.c */
/* */
/* ###--------------------------------------------------------------### */
typedef struct ctp_expr
{
char *IDENT; /* identifier or constant name */
vexexpr *VEX; /* pointer on bvl_abllst list */
short TYPE;
int WIDTH; /* width of bit vector */
char SIGNED;
char AGGREG;
}
ctp_vexstr;
typedef struct
{
char *NAME; /* identifier name */
long LEFT; /* vector's left index */
long RIGHT; /* vector's right index */
char FLAG; /* scalar ('S') or array 'A' */
char TYPE; /* scalar ('S') or array 'A' */
char SIGNED;
}
ctp_name;
extern ctp_vexstr CTP_EMPSTR;
extern ctlfig_list *CTP_HEADFIG;
extern char *CTP_FILENAME;
extern ctp_vexstr ctp_crtvex ();
extern char *ctp_numtobin ();
extern char *ctp_enumbitstring();
extern int ctp_codeSize();
extern vexexpr *ctp_dynamicvexatom();
extern int ctp_intSize();
extern int ctp_vextonum();
extern ctltype_list *ctp_getbasetype();
extern void ctp_error();
extern int ctp_tobin();

View File

@ -0,0 +1,82 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/* ###--------------------------------------------------------------### */
/* */
/* file : ctp_byacc.h */
/* date : Jun 15 1992 */
/* version : v102 */
/* author : Pirouz BAZARGAN SABET */
/* content : declaration of external functions and global variables*/
/* used by yacc */
/* */
/* ###--------------------------------------------------------------### */
static struct dct_entry *addent ();
static struct dct_recrd *addrcd ();
static struct dct_entry **initab ();
static void addtab ();
static int chktab ();
static void fretab ();
static void *ctp_addstr ();
static ctltype_list *val_type();
static ctltype_list *get_type();
static struct ptype *reversetype();
extern char CTP_ERRFLG; /* set to 1 in case of error */
extern ctlfig_list *CTP_HEADFIG; /* head of vbfigs */
extern long CTP_LINNUM;
extern int CTP_NUMPTP;
extern char *CTP_MODNAM;
/*\
pNode CTP_BDDPNT;
\*/
/* BDD pointer */
ctp_vexstr CTP_SLCEXP; /* structure filled with the */
ctp_vexstr CTP_EMPSTR; /* empty structure used with NOT*/
static int CTP_NUMTYP = 0; /* nombre de type */
static struct chain *CTP_NM1LST = NULL; /* 1-st name liste */
static struct chain *CTP_NM2LST = NULL; /* 2-st name liste */
static struct chain *CTP_INSLST = NULL; /* 3-st name liste */
static struct chain *CTP_LINLST = NULL; /* list of line */
static struct chain *CTP_VALLST = NULL; /* list of waveforms (ABL) */
static struct ptype *CTP_PTYPE = NULL;
static struct dct_entry *CTP_DCEHED; /* free dct_entry's head */
static struct dct_recrd *CTP_DCRHED; /* free dct_recrd's head */
static struct dct_entry **hshtab;
extern ctp_vexstr ctp_crtvex();
extern ctp_vexstr ctp_cpyvexstr();
extern ctp_vexstr ctp_select();
extern char *ctp_stostr();
extern void ctp_error();

View File

@ -0,0 +1,220 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
%{
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "mut.h"
#include "aut.h"
#include "vex.h"
#include "ctl.h"
typedef struct ctp_expr
{
vexexpr *IDENT; /* identifier or constant name */
vexexpr *VEX; /* pointer on bvl_abllst list */
short WIDTH;
short TYPE;
}
ctp_vexstr;
typedef struct
{
char *NAME; /* identifier name */
long LEFT; /* vector's left index */
long RIGHT; /* vector's right index */
short WIDTH;
char FLAG;
}
ctp_name;
#include "ctp_y.h"
#include "ctp_bedef.h"
#include "ctp_blex.h"
static el_mc tab_mc []=
{
{"abs" ,ABS},
{"af" ,_AF},
{"ag" ,_AG},
{"and" ,_AND},
{"array" ,ARRAY},
{"au" ,_AU},
{"ax" ,_AX},
{"begin" ,_BEGIN},
{"constant" ,CONSTANT},
{"downto" ,DOWNTO},
{"ef" ,_EF},
{"eg" ,_EG},
{"end" ,_END},
{"error" ,ERROR},
{"eu" ,_EU},
{"event" ,_EVENT},
{"ex" ,_EX},
{"false" ,_FALSE},
{"high" ,_HIGH},
{"ift" ,_IFT},
{"is" ,IS},
{"left" ,_LEFT},
{"length" ,_LENGTH},
{"low" ,_LOW},
{"mod" ,MOD},
{"nand" ,_NAND},
{"nor" ,_NOR},
{"not" ,_NOT},
{"nxor" ,_NXOR},
{"of" ,OF},
{"or" ,_OR},
{"others" ,OTHERS},
{"range" ,_RANGE},
{"rem" ,REM},
{"reverse_range" ,_REV_RANGE},
{"right" ,_RIGHT},
{"stable" ,_STABLE},
{"subtype" ,SUBTYPE},
{"to" ,TO},
{"true" ,_TRUE },
{"type" ,_TYPE},
{"variable" ,_VARIABLE},
{"xnor" ,_NXOR},
{"xor" ,_XOR}
};
static int find_mc(s)
char *s;
{
char loc[512];
int l;
el_mc *pt;
l=strlen(s);
strcpy(loc,s);
while(l--) loc[l]=tolower(loc[l]); /* conversion en minuscules */
pt= (el_mc *) bsearch(loc, (char *)tab_mc,CTP_NB_MC,sizeof(el_mc),
(int (*)(const void *, const void *)) strcmp);
if (pt==NULL) return(-1);
return(pt->kval);
}
%}
upper_case_letter [A-Z]
digit [0-9]
special_character [\#\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\_\|]
space_character [ \t]
format_effector [\t\v\r\l\f]
end_of_line \n
lower_case_letter [a-z]
other_special_character [\!\$\@\?\[\\\]\^\`\{\}\~]
graphic_character ({basic_graphic_character}|{lower_case_letter}|{other_special_character})
basic_graphic_character ({upper_case_letter}|{digit}|{special_character}|{space_character})
letter ({upper_case_letter}|{lower_case_letter})
letter_or_digit ({letter}|{digit})
decimal_literal {integer}(\.{integer})?({exponent})?
integer {digit}(_?{digit})*
exponent ([eE][-+]?{integer})
base {integer}
based_integer {extended_digit}(_?{extended_digit})*
extended_digit ({digit}|[a-fA-F])
base_specifier (B|b|O|o|X|x)
%%
[ \t] ;
\& { return(Ampersand); }
\' { return(Apostrophe); }
\( { return(LeftParen); }
\) { return(RightParen); }
"<->" { return(Equiv); }
"->" { return(Imply); }
"**" { return(DoubleStar); }
\* { return(Star); }
\+ { return(Plus); }
\, { return(Comma); }
\- { return(Minus); }
":=" { return(VarAsgn); }
\: { return(Colon); }
\; { return(Semicolon); }
"<=" { return(_LESym); }
">=" { return(_GESym); }
\< { return(_LTSym); }
\> { return(_GTSym); }
= { return(_EQSym); }
\/= { return(_NESym); }
"=>" { return(Arrow); }
"<>" { return(Box); }
\| { return(Bar); }
! { return(Bar); }
\. { return(Dot); }
\/ { return(Slash); }
{letter}(_?{letter_or_digit})* {
int itoken;
itoken=find_mc(yytext);
if (itoken== -1)
{
yylval.text = namealloc(yytext);
return ( Identifier );
}
else
{
return ( itoken );
}
}
({decimal_literal})|({base}#{based_integer}(\.{based_integer})?#({exponent})?)|({base}:{based_integer}(\.{based_integer})?:({exponent})?) {
yylval.text = mbkalloc((unsigned int)strlen(yytext)+1);
strcpy(yylval.text,yytext);
return ( AbstractLit );
}
'({graphic_character}|\"|\%)' {
yylval.text = namealloc (yytext);
return ( CharacterLit );
}
(\"({graphic_character}|(\"\")|\%)*\")|(\%({graphic_character}|(\%\%)|\")*\%) {
yylval.text = namealloc (yytext);
return ( StringLit );
}
{base_specifier}((\"{extended_digit}(_?{extended_digit})*\")|(\%{extended_digit}(_?{extended_digit})*\%)) {
yylval.text = namealloc (yytext);
return ( BitStringLit );
}
\n {
CTP_LINNUM++;
}
\-\-.*$ {
/* comment */
/* nothing */
}
. {
return (*yytext);
}
%%

View File

@ -0,0 +1,114 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Tool : CTP |
| |
| File : ctp_parse.c |
| |
| Author : Jacomme Ludovic |
| |
| Date : 01.01.95 |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Include Files |
| |
\------------------------------------------------------------*/
# include "mut.h"
# include "aut.h"
# include "vex.h"
# include "ctl.h"
# include "ctp.h"
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
/*------------------------------------------------------------\
| |
| Constants |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Types |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Variables |
| |
\------------------------------------------------------------*/
extern FILE *ctp_y_in;
extern int ctp_y_parse();
extern char CTP_ERRFLG;
extern ctlfig_list *CTP_HEADFIG;
extern char *CTP_FILENAME;
/*------------------------------------------------------------\
| |
| vpnloadvpnfig |
| |
\------------------------------------------------------------*/
ctlfig_list *loadctlfig( InputFileName )
char *InputFileName;
{
int Value;
int Index;
fprintf( stdout, "loadctlfig InputFileName %s\n", InputFileName );
ctp_y_in = mbkfopen( InputFileName, "ctl", "r" );
if ( ctp_y_in == (FILE *)0 )
{
fprintf( stdout, "Error opening file %s\n", InputFileName );
autexit( 1 );
}
CTP_FILENAME = InputFileName;
Value = ctp_y_parse();
fclose( ctp_y_in );
if ( ( Value ) ||
( CTP_ERRFLG ) )
{
fprintf( stdout, "Error parsing file %s\n", InputFileName );
autexit( 1 );
}
return( CTP_HEADFIG );
}

View File

@ -0,0 +1,365 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/* ###--------------------------------------------------------------### */
/* */
/* file : ctp_util.c */
/* date : Sep 14 1992 */
/* version : v100 */
/* author : Pirouz BAZARGAN SABET, M.HANAFI */
/* description : This file contains some utility functions : */
/* ctp_error , ctp_y_error, ctp_toolbug, ctp_message, */
/* */
/* ###--------------------------------------------------------------### */
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <unistd.h>
#include "mut.h"
#include "aut.h"
#include "vex.h"
#include "ctl.h"
#include "ctp_utype.h"
#include "ctp_util.h"
char CTP_ERRFLG = 0; /* if = 1 no structure is made */
char *CTP_FILENAME = (char *)0;
long CTP_LINNUM = 1; /* file's line number */
int CTP_NUMPTP = 0; /* file's line number */
int CTP_NUMCHOICE = 0;
char *CTP_MODNAM = (char *)0;
ctlfig_list *CTP_HEADFIG = (ctlfig_list *)0;
char *ctp_func_std_logic_1164[] =
{
"to_bit",
"to_bitvector",
"to_stdulogic",
"to_stdlogicvector",
"to_stdulogicvector",
"to_x01",
"to_x01z",
"to_ux01",
"rising_edge",
"falling_edge",
"is_x",
NULL
};
char *ctp_func_std_logic_arith[] =
{
"abs",
"shl",
"shr",
"conv_integer",
"conv_unsigned",
"conv_signed",
"conv_std_logic_vector",
"ext",
"sxt",
NULL
};
char *ctp_func_std_numeric_std[] =
{
"shift_left",
"shift_right",
"rotate_left",
"rotate_right",
"resize",
"to_integer",
"to_unsigned",
"to_signed",
NULL
};
/* ###--------------------------------------------------------------### */
/* function : ctp_toolbug */
/* ###--------------------------------------------------------------### */
void ctp_toolbug (code,str1,str2,nbr1)
int code;
char *str1;
char *str2;
int nbr1;
{
(void) fprintf (stderr,"Fatal error %d executing `%s`: ", code,str1);
switch (code)
{
case 1:
(void) fprintf (stderr,"unknown operator\n");
break;
case 2:
(void) fprintf (stderr,"cannot create empty atom : %s\n",str2);
break;
case 3:
(void) fprintf (stderr,"cannot build NOT of empty expression\n");
break;
case 4:
(void) fprintf (stderr,"cannot combine empty expressions\n");
break;
case 5:
(void) fprintf (stderr,"cannot find terminal\n");
break;
case 6:
(void) fprintf (stderr,"cannot make BDD of empty expression\n");
break;
case 7:
(void) fprintf (stderr,"unknown type `%c` for IO `%s`\n",nbr1,str2);
break;
case 8:
(void) fprintf (stderr,"illegal signal value : hex `%x`\n",nbr1);
break;
case 9:
(void) fprintf (stderr,"unknown mode `%c` for IO `%s`\n",nbr1,str2);
break;
case 10:
(void) fprintf (stderr,"decompiler called on empty vbfig\n");
break;
case 12:
(void) fprintf (stderr,"illegal user value '%c' for IO\n",nbr1);
break;
case 13 :
(void) fprintf (stderr,"cannot find model of `%s`\n",str2);
break;
case 14 :
(void) fprintf (stderr,"cannot convert empty expression\n");
break;
case 15 :
(void) fprintf (stderr,"illegal bit string value : `%c`\n",nbr1);
break;
case 16 :
(void) fprintf (stderr,"the same expression cannot be used twice\n");
break;
case 17 :
(void) fprintf (stderr,"unknown base specifier : `%c`\n",nbr1);
break;
case 18:
(void) fprintf (stderr,"unknown mode `%c` for port `%s`\n",nbr1,str2);
break;
case 19:
(void) fprintf (stderr,"empty guard expression: `%s`\n",str2);
break;
case 20:
(void) fprintf (stderr,"empty waveform expression: `%s`\n",str2);
break;
case 21:
(void) fprintf (stderr,"cannot find structural level\n");
break;
case 22:
(void) fprintf (stderr,"`%s` : `%c` unknown resolution function\n",str2,nbr1);
break;
}
autexit (1);
}
/* ###--------------------------------------------------------------### */
/* function : ctp_message */
/* ###--------------------------------------------------------------### */
void ctp_message (code,str1,nmb1)
int code;
char *str1;
int nmb1;
{
switch (code)
{
case 1:
(void) fprintf(stderr,"USAGE is ctp [filename1],[filename2],.. \n\n\n");
break;
case 2:
(void) fprintf (stdout,"Initializing ...\n");
break;
case 3:
(void) fprintf (stdout,"Compiling `%s` (Behaviour) ...\n",str1);
break;
case 4:
(void) fprintf (stdout,"Compiling `%s` (Structural) ...\n\n",str1);
break;
case 5:
(void) fprintf (stdout,"Searching `%s` ...\n",str1);
break;
case 8:
(void) fprintf (stdout,"Compiling `%s` (Pattern) ...\n\n",str1);
break;
case 9:
(void) fprintf (stdout,"Linking ...\n");
break;
case 10:
(void) fprintf (stdout,"###----- processing pattern %d -----###\n",nmb1);
break;
case 11:
(void) fprintf (stdout,"Decompiling ...\n");
break;
case 12:
(void) fprintf (stdout,"Generating the file '%s' ...\n",str1);
break;
case 13:
(void) fprintf (stdout,"Saving '%s' in a vhdl file (vbe)\n",str1);
break;
case 14:
(void) fprintf (stdout,"File '%s' has been generated.\n",str1);
break;
case 15:
(void) fprintf (stdout,"Making Bdd ...\n\n");
break;
case 16:
(void) fprintf (stdout,"Restoring ...\n\n");
break;
case 17:
(void) fprintf (stdout,"Parsing the file %s .........\n\n",str1);
break;
case 18:
(void) fprintf (stderr,"ERROR: %s VHDL file does not exist !!! \n",str1);
(void) fprintf (stderr," Verify the file and restart \n");
break;
default:
(void) fprintf (stderr,"ctp_message : code %d unknown.\n",code);
}
}
/* ###--------------------------------------------------------------### */
/* function : ctp_error */
/* ###--------------------------------------------------------------### */
void ctp_error (code,str1)
int code;
char *str1;
{
CTP_ERRFLG++;
if (code < 100)
(void)fprintf (stderr,"Error %d line %ld in file %s :",code,CTP_LINNUM, CTP_FILENAME);
else
{
if (code < 200)
(void)fprintf (stderr,"Error %d :",code);
}
switch (code)
{
case 9:
(void) fprintf (stderr,"illegal declaration\n");
break;
case 10:
(void) fprintf (stderr,"symbol `%s` already declared\n",str1);
break;
case 18:
(void) fprintf (stderr,"illegal statement\n");
break;
case 32:
(void) fprintf (stderr,"null array not supported\n");
break;
case 33:
(void) fprintf (stderr,"incompatible constraint and type\n");
break;
case 35:
(void) fprintf (stderr,"illegal assignment of `%s` (widths mismatch)\n",str1);
break;
case 36:
(void) fprintf (stderr,"symbol `%s` used out of declared range\n",str1);
break;
case 38:
(void) fprintf (stderr,"width or/and type mismatch %s\n",str1);
break;
case 73:
(void) fprintf (stderr,"`%s` is not a bit string litteral\n",str1);
break;
case 78:
(void) fprintf (stderr,"illegal constant declaration\n");
break;
case 79:
(void) fprintf (stderr,"illegal use of attribute on `%s`\n",str1);
break;
case 80:
(void) fprintf (stderr,"variable `%s` already declared\n",str1);
break;
case 82:
(void) fprintf (stderr,"enumerate valu `%s` already declared\n",str1);
break;
case 83:
(void) fprintf (stderr,"'%s' illegal index subtype definition \n",str1);
break;
case 84:
(void) fprintf (stderr,"'%s' illegal type mark definition \n",str1);
break;
case 86:
(void) fprintf (stderr,"illegal variable declaration\n");
break;
case 87:
(void) fprintf (stderr,"illegal type declaration\n");
break;
case 97:
(void) fprintf (stderr,"width mismatch on signal initialisation\n");
break;
case 100:
(void) fprintf (stderr,"cannot find `%s`\n",str1);
break;
case 107:
(void) fprintf (stderr,"Cannot open result file\n");
break;
case 114:
(void) fprintf (stderr,"illegal aggregate\n");
break;
case 123:
(void) fprintf (stderr,"such array type definition is not supported\n");
break;
default:
(void) fprintf (stderr,"syntax error\n");
break;
}
if (CTP_ERRFLG > CTP_MXRDFN)
{
(void) fprintf (stderr,"Too many errors. Cannot continue further more\n");
(void) fprintf (stderr,"\n Have a nice day...\n");
EXIT (1);
}
autexit(1);
}
/* ###--------------------------------------------------------------### */
/* function : ctp_y_error */
/* ###--------------------------------------------------------------### */
void ctp_y_error (str)
char *str;
{
CTP_ERRFLG++;
(void)fprintf (stderr,"Error line %ld : %s\n",CTP_LINNUM,str);
}

View File

@ -0,0 +1,42 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/* ###--------------------------------------------------------------### */
/* */
/* file : ctp_util.h */
/* date : Jun 15 1992 */
/* version : v100 */
/* author : Pirouz BAZARGAN SABET */
/* description : This file contains declaration of global and external */
/* variables and, functions used in `ctp_util.c` */
/* */
/* ###--------------------------------------------------------------### */
#define CTP_MXRDFN 30
extern long CTP_LINNUM; /* file's line number */
extern char CTP_ERRFLG; /* Error flag */
extern char CTP_CURFIL[]; /* current file name */

View File

@ -0,0 +1,60 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/* ###--------------------------------------------------------------### */
/* */
/* file : ctp_utype.h */
/* date : Jun 15 1992 */
/* version : v100 */
/* author : P.BAZARGAN L.A.TABUSSE VUONG H.N. */
/* content : declaration of external functions and global variables */
/* used by yacc */
/* */
/* ###--------------------------------------------------------------### */
struct dct_entry
{
struct dct_entry *next;
struct dct_recrd *data;
char *key;
};
struct dct_recrd
{
struct dct_recrd *next;
char *key;
long fd0_val;
long fd1_val;
long fd2_val;
long fd3_val;
long fd4_val;
long fd5_val;
long fd6_val;
long fd7_val;
long fd8_val;
long pnt_val;
};

2120
alliance/src/ctp/src/ctp_y.y Normal file

File diff suppressed because it is too large Load Diff

145
alliance/src/ctp/src/main.c Normal file
View File

@ -0,0 +1,145 @@
/*------------------------------------------------------------\
| |
| This file is part of the Alliance CAD System Copyright |
| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie|
| |
| Home page : http://www-asim.lip6.fr/alliance/ |
| E-mail support : mailto:alliance-support@asim.lip6.fr |
| |
| This progam 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. |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Tool : CTP |
| |
| File : main.c |
| |
| Date : 04.24.02 |
| |
| Author : Jacomme Ludovic |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Include Files |
| |
\------------------------------------------------------------*/
# include <stdio.h>
# include <string.h>
# include "mut.h"
# include "aut.h"
# include "vex.h"
# include "ctl.h"
# include "ctp.h"
/*------------------------------------------------------------\
| |
| Constants |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Types |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Variables |
| |
\------------------------------------------------------------*/
/*------------------------------------------------------------\
| |
| Usage |
| |
\------------------------------------------------------------*/
void CtpUsage()
{
fprintf( stderr, "\t\tctptest [Options] Input_name\n\n" );
fprintf( stdout, "\t\tOptions : -V Sets Verbose mode on\n" );
fprintf( stdout, "\n" );
exit( 1 );
}
/*------------------------------------------------------------\
| |
| Functions |
| |
\------------------------------------------------------------*/
int main( argc, argv )
int argc;
char *argv[];
{
ctlfig_list *CtlFigure;
char *InputFileName;
int Number;
int Index;
char Option;
int FlagVerbose = 0;
int FlagSave = 0;
mbkenv();
autenv();
vexenv();
ctlenv();
InputFileName = (char *)0;
if ( argc < 2 ) CtpUsage();
for ( Number = 1; Number < argc; Number++ )
{
if ( argv[ Number ][ 0 ] == '-' )
{
for ( Index = 1; argv[ Number ][ Index ] != '\0'; Index++ )
{
Option = argv[ Number ][ Index ];
switch ( Option )
{
case 'V' : FlagVerbose = 1;
break;
default : CtpUsage();
}
}
}
else
if ( InputFileName == (char *)0 ) InputFileName = argv[ Number ];
else
CtpUsage();
}
if ( InputFileName == (char *)0 ) CtpUsage();
fprintf( stdout, "InputFileName %s\n", InputFileName );
CtlFigure = loadctlfig( InputFileName );
if ( FlagVerbose ) viewctlfig( CtlFigure );
delctlfig( CtlFigure->NAME );
return( 0 );
}