diff --git a/alliance/src/syf/Makefile.am b/alliance/src/syf/Makefile.am new file mode 100644 index 00000000..5fcaa0d3 --- /dev/null +++ b/alliance/src/syf/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src man1 diff --git a/alliance/src/syf/man1/Makefile.am b/alliance/src/syf/man1/Makefile.am new file mode 100644 index 00000000..e97c86f6 --- /dev/null +++ b/alliance/src/syf/man1/Makefile.am @@ -0,0 +1,2 @@ +man_MANS = syf.1 +EXTRA_DIST = $(man_MANS) diff --git a/alliance/src/syf/man1/syf.1 b/alliance/src/syf/man1/syf.1 new file mode 100644 index 00000000..d6c5c68b --- /dev/null +++ b/alliance/src/syf/man1/syf.1 @@ -0,0 +1,119 @@ +.\" $Id: syf.1,v 1.1 2002/03/26 12:53:41 ludo Exp $ +.\" @(#)Labo.l 2.2 95/09/24 UPMC; Author: Jacomme L. +.pl -.4 +.TH SYF 1 "October 1, 1997" "ASIM/LIP6" "CAO\-VLSI Reference Manual" +.SH NAME +.TP +SYF \- Finite State Machine synthesizer. +.so man1/alc_origin.1 +.SH SYNOPSIS +.TP +\f4syf \-a|j|m|u|o|r [\-CDEOPRSTV] input_name [output_name] +.br +.SH DESCRIPTION +.br +\fBsyf\fp is a Finite State Machine synthesizer. +\fBsyf\fp allows a fast generation of VHDL Data Flow description (see \fBvbe\fP(5)) +from a VHDL Finite State Machine description (see \fBfsm\fP(5)). +The input FSM specification can use an internal STACK. +Both MOORE and MEALEY FSMs can be synthesized, with output registers if desired. +For a MOORE FSM, a timing\-optimized implementation that emulates a ROM with microsequencer +is possible. +A scan-path for the state registers can also be implemented. +.br + +.SH ENVIRONMENT VARIABLES +.br +.TP 10 +\f4MBK_WORK_LIB\fR(1) +indicates the path to the read/write directory for the session. +.br + +.SH OPTIONS +.TP 10 +\f4\-a\fP +Uses "Asp" as encoding algorithm. +.TP 10 +\f4\-j\fP +Uses "Jedi" as encoding algorithm. +.TP 10 +\f4\-m\fP +Uses "Mustang" as encoding algorithm. +.TP 10 +\f4\-u\fP +Uses an encoding given by user through .enc file. +In this file, a line started by a # character is a comment. +A valid line contains one state name followed by its hexadecimal code. +.TP 10 +\f4\-o\fP +Uses the one hot encoding algorithm. +.TP 10 +\f4\-r\fP +Uses distinct random numbers for state encoding. +.TP 10 +\f4\-C\fP +Checks the transition's consistency. +.TP 10 +\f4\-D\fP +With this option \fBsyf\fP doesn't optimize unused, i.e Don't Care, codes. +.TP 10 +\f4\-E\fP +Saves the encoding result in the .enc. +This file has the same syntax as .enc file which is used by \-u option. +.TP 10 +\f4\-O\fP +With this option \fBsyf\fp places registers on the outputs. +.TP 10 +\f4\-P\fP +Implements a scan-path for the state registers, stack registers and possibly output registers. Scan-path mechanism is directely included in states decoder. Users should use \fBscapin\fP(5) for a correct insertion of a scan-path in a netlist. +Please check \fBfsm\fP(5) for information about scan-path descriptions. +.TP 10 +\f4\-R\fP +This option is only available for MOORE FSM. With this option, \fBsyf\fP emulate +s a ROM with micro\-sequencer implementation : there is no combinatorial logic between +the state registers and the FSM outputs. +This can be mandatory for external timing constraints. +See \fBfsm\fP(5) and \fBgrog\fP(1) for more on ROM descriptions. +.TP 10 +\f4\-S\fP +With this option \fBsyf\fp doesn't take into account the cost of the transitions to compute +an encoding. +.TP 10 +\f4\-V\fP +Verbose mode on. +Each step of the FSM synthesis is displayed on the standard output, along with some statistics. +.ti 7 +.SH EXAMPLE +.br +Environment variables: +.br +.ti 7 +setenv MBK_WORK_LIB /alliance/tutorials/dlxm +.br +.ti 7 + +\fBsyf\fP is called as follow (the dlx_ctrl.fsm is already created in /alliance/tutorials/dlxm) : + +.ti 7 +\fBsyf\fP -sE dlx_ctrl + +Two files will be generated, a states encoding file dlx_ctrls.enc and a VHDL data flow file /alliance/tutorials/dlxm/dlx_ctrls.vbe +.SH SEE ALSO +.BR fsm (5), +.BR vbe (5), +.BR vhdl (5), +.BR boom (1), +.BR boog (1), +.BR loon (1), +.BR scapin (1), +.BR bop (1), +.BR glop (1), +.BR scmap (1), +.BR c4map (1), +.BR asimut (1), +.BR proof (1), +.BR MBK_WORK_LIB (1). + + +.so man1/alc_bug_report.1 + diff --git a/alliance/src/syf/src/Makefile.am b/alliance/src/syf/src/Makefile.am new file mode 100644 index 00000000..431d944d --- /dev/null +++ b/alliance/src/syf/src/Makefile.am @@ -0,0 +1,19 @@ +## Process this file with automake to produce Makefile.in + +bin_PROGRAMS = syf + +syf_LDADD = @LIBS@ \ + -lFtl -lFks -lFvh -lFsm \ + -lBdd -lAbl -lAut -lMut + + +syf_SOURCES = \ +fbh_parse.c syf_comp.h syf_error.c syf_main.h syf_synth.c \ +fbh_parse.h syf_cost.c syf_error.h syf_must.c syf_synth.h \ +kis_parse.c syf_cost.h syf_fsm.c syf_must.h syf_tools.c \ +kis_parse.h syf_dc.c syf_fsm.h syf_onehot.c syf_tools.h \ +syf_asp.c syf_dc.h syf_fsm2fbh.c syf_onehot.h syf_user.c \ +syf_asp.h syf_encod.c syf_fsm2fbh.h syf_random.c syf_user.h \ +syf_bdd.c syf_encod.h syf_jedi.c syf_random.h syf_verify.c \ +syf_bdd.h syf_env.c syf_jedi.h syf_simp.c syf_verify.h \ +syf_comp.c syf_env.h syf_main.c syf_simp.h diff --git a/alliance/src/syf/src/fbh_parse.c b/alliance/src/syf/src/fbh_parse.c new file mode 100644 index 00000000..ebbebf62 --- /dev/null +++ b/alliance/src/syf/src/fbh_parse.c @@ -0,0 +1,331 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : fbh_parse.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FTL_H + +# include +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "fbh_parse.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static char *SyfClockKeyword = (char *)0; + static char *SyfCurrentStateKeyword = (char *)0; + static char *SyfNextStateKeyword = (char *)0; + static char *SyfReturnStateKeyword = (char *)0; + static char *SyfControlKeyword = (char *)0; + static char *SyfToolsKeyword = (char *)0; + static char *SyfScanInKeyword = (char *)0; + static char *SyfScanOutKeyword = (char *)0; + static char *SyfScanTestKeyword = (char *)0; + + static char *SyfStackControlKeyword[ FSM_MAX_CTRL ]; + + static char *SyfClockName; + static char *SyfCurrentStateName; + static char *SyfNextStateName; + static char *SyfReturnStateName; + static char *SyfControlName; + static char *SyfScanInName; + static char *SyfScanOutName; + static char *SyfScanTestName; + static char *SyfStackControlName[ FSM_MAX_CTRL ]; + +/*------------------------------------------------------------\ +| | +| Privates | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void SyfInitializeKeyword() +{ + if ( SyfClockKeyword == (char *)0 ) + { + SyfClockKeyword = namealloc( "clock" ); + SyfCurrentStateKeyword = namealloc( "current_state" ); + SyfReturnStateKeyword = namealloc( "return_state" ); + SyfNextStateKeyword = namealloc( "next_state" ); + SyfControlKeyword = namealloc( "control" ); + SyfScanInKeyword = namealloc( "scan_in" ); + SyfScanOutKeyword = namealloc( "scan_out" ); + SyfScanTestKeyword = namealloc( "scan_test" ); + SyfToolsKeyword = namealloc( "syf" ); + + SyfStackControlKeyword[ FSM_CTRL_NOP ] = namealloc( "nop" ); + SyfStackControlKeyword[ FSM_CTRL_PUSH ] = namealloc( "push" ); + SyfStackControlKeyword[ FSM_CTRL_POP ] = namealloc( "pop" ); + } + + SyfClockName = SyfClockKeyword; + SyfCurrentStateName = SyfCurrentStateKeyword; + SyfReturnStateName = SyfReturnStateKeyword; + SyfNextStateName = SyfNextStateKeyword; + SyfControlName = SyfControlKeyword; + SyfScanInName = SyfScanInKeyword; + SyfScanOutName = SyfScanOutKeyword; + SyfScanTestName = SyfScanTestKeyword; + + SyfStackControlName[ FSM_CTRL_NOP ] = SyfStackControlKeyword[ FSM_CTRL_NOP ]; + SyfStackControlName[ FSM_CTRL_PUSH ] = SyfStackControlKeyword[ FSM_CTRL_PUSH ]; + SyfStackControlName[ FSM_CTRL_POP ] = SyfStackControlKeyword[ FSM_CTRL_POP ]; +} + +/*------------------------------------------------------------\ +| | +| SyfFbhTreatPort | +| | +\------------------------------------------------------------*/ + +void SyfFbhTreatPort( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmin_list *ScanIn; + fsmout_list *ScanOut; + syfinfo *SyfInfo; + char ScanOk; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + ScanOk = ( SyfInfo->SCAN_PATH ) ? 0x00 : 0x07; + + for ( ScanIn = FsmFigure->IN; + ScanIn != (fsmin_list *)0; + ScanIn = ScanIn->NEXT ) + { + if ( ScanIn->NAME == SyfScanInName ) + { + ScanOk |= 0x01; + } + else + if ( ScanIn->NAME == SyfScanTestName ) + { + ScanOk |= 0x02; + } + } + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + if ( ScanOut->NAME == SyfScanOutName ) + { + ScanOk |= 0x04; + } + + Syfaddfsmsyfout( ScanOut ); + } + + if ( ScanOk != 0x07 ) + { + SyfError( SYF_ERROR_MISSING_SCAN_PORT, FsmFigure->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfFbhTreatPragma | +| | +\------------------------------------------------------------*/ + +void SyfFbhTreatPragma( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + ptype_list *ScanPragma; + syfinfo *SyfInfo; + char *PragmaType; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + for ( ScanPragma = FsmFigure->PRAGMA; + ScanPragma != (ptype_list *)0; + ScanPragma = ScanPragma->NEXT ) + { + PragmaType = (char *)ScanPragma->TYPE; + + if ( PragmaType == SyfCurrentStateKeyword ) + { + SyfCurrentStateName = ScanPragma->DATA; + } + else + if ( PragmaType == SyfNextStateKeyword ) + { + SyfNextStateName = ScanPragma->DATA; + } + else + if ( PragmaType == SyfReturnStateKeyword ) + { + SyfReturnStateName = ScanPragma->DATA; + } + else + if ( PragmaType == SyfControlKeyword ) + { + SyfControlName = ScanPragma->DATA; + } + else + if ( PragmaType == SyfClockKeyword ) + { + SyfClockName = ScanPragma->DATA; + } + else + if ( PragmaType == SyfStackControlKeyword[ FSM_CTRL_NOP ] ) + { + SyfStackControlName[ FSM_CTRL_NOP ] = ScanPragma->DATA; + } + else + if ( PragmaType == SyfStackControlKeyword[ FSM_CTRL_PUSH ] ) + { + SyfStackControlName[ FSM_CTRL_PUSH ] = ScanPragma->DATA; + } + else + if ( PragmaType == SyfStackControlKeyword[ FSM_CTRL_POP ] ) + { + SyfStackControlName[ FSM_CTRL_POP ] = ScanPragma->DATA; + } + else + if ( PragmaType == SyfScanInKeyword ) + { + SyfScanInName = ScanPragma->DATA; + } + else + if ( PragmaType == SyfScanOutKeyword ) + { + SyfScanOutName = ScanPragma->DATA; + } + else + if ( PragmaType == SyfScanTestKeyword ) + { + SyfScanTestName = ScanPragma->DATA; + } + } + + SyfInfo->SCAN_IN = SyfScanInName; + SyfInfo->SCAN_OUT = SyfScanOutName; + SyfInfo->SCAN_TEST = SyfScanTestName; + SyfInfo->CURRENT_STATE = SyfCurrentStateName; + SyfInfo->NEXT_STATE = SyfNextStateName; + SyfInfo->RETURN_STATE = SyfReturnStateName; + SyfInfo->NUMBER_CTRL = FSM_MAX_CTRL; +} + +/*------------------------------------------------------------\ +| | +| SyfFbhParse | +| | +\------------------------------------------------------------*/ + +fsmfig_list *SyfFbhParse( Name, FlagScan ) + + char *Name; + char FlagScan; +{ + fsmfig_list *FsmFigure; + syfinfo *SyfInfo; + fsmstate_list *ScanState; + + SyfInitializeKeyword(); + + FsmFigure = Syfaddfsmfig( Name ); + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + SyfInfo->SCAN_PATH = FlagScan; + + loadfsmfig( FsmFigure, Name ); + + ScanState = FsmFigure->STAR_STATE; + + if ( ScanState != (fsmstate_list *)0 ) + { + *ScanState->PREV = ScanState->NEXT; + + if ( ScanState->NEXT != (fsmstate_list *)0 ) + { + ScanState->NEXT->PREV = ScanState->PREV; + } + + FsmFigure->NUMBER_STATE--; + } + + SyfInfo->STACK = ( FsmFigure->STACK_SIZE != 0 ); + + SyfFbhTreatPragma( FsmFigure ); + SyfFbhTreatPort( FsmFigure ); + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + Syfaddfsmsyfstate( FsmFigure, ScanState ); + } + + return( FsmFigure ); +} diff --git a/alliance/src/syf/src/fbh_parse.h b/alliance/src/syf/src/fbh_parse.h new file mode 100644 index 00000000..a5f3ef45 --- /dev/null +++ b/alliance/src/syf/src/fbh_parse.h @@ -0,0 +1,76 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : fbh_parse.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +# ifndef FBH_PARSE_H +# define FBH_PARSE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Keywords | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern fsmfig_list *SyfFbhParse(); + +# endif diff --git a/alliance/src/syf/src/kis_parse.c b/alliance/src/syf/src/kis_parse.c new file mode 100644 index 00000000..5f9f64b7 --- /dev/null +++ b/alliance/src/syf/src/kis_parse.c @@ -0,0 +1,156 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : kis_parse.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FTL_H + +# include +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "kis_parse.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Privates | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfKissParse | +| | +\------------------------------------------------------------*/ + +fsmfig_list *SyfKissParse( Name, FlagScan ) + + char *Name; + char FlagScan; +{ + fsmfig_list *FsmFigure; + syfinfo *SyfInfo; + fsmstate_list *ScanState; + fsmout_list *ScanOut; + + FsmFigure = Syfaddfsmfig( Name ); + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + SyfInfo->SCAN_PATH = FlagScan; + + SyfInfo->CURRENT_STATE = namealloc( "current_state" ); + SyfInfo->RETURN_STATE = namealloc( "return_state" ); + SyfInfo->NEXT_STATE = namealloc( "next_state" ); + SyfInfo->NUMBER_CTRL = FSM_MAX_CTRL; + + loadfsmfig( FsmFigure, Name ); + + ScanState = FsmFigure->STAR_STATE; + + if ( ScanState != (fsmstate_list *)0 ) + { + *ScanState->PREV = ScanState->NEXT; + + if ( ScanState->NEXT != (fsmstate_list *)0 ) + { + ScanState->NEXT->PREV = ScanState->PREV; + } + + FsmFigure->NUMBER_STATE--; + } + + if ( FlagScan ) + { + SyfInfo->SCAN_IN = namealloc( "scan_in" ); + SyfInfo->SCAN_OUT = namealloc( "scan_out" ); + SyfInfo->SCAN_TEST = namealloc( "scan_test" ); + + addfsmport( FsmFigure, SyfInfo->SCAN_IN , FSM_DIR_IN , FSM_TYPE_BIT ); + addfsmport( FsmFigure, SyfInfo->SCAN_TEST, FSM_DIR_IN , FSM_TYPE_BIT ); + addfsmport( FsmFigure, SyfInfo->SCAN_OUT , FSM_DIR_OUT, FSM_TYPE_BIT ); + + addfsmin( FsmFigure , SyfInfo->SCAN_TEST ); + addfsmin( FsmFigure , SyfInfo->SCAN_IN ); + addfsmout( FsmFigure, SyfInfo->SCAN_OUT ); + } + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + Syfaddfsmsyfstate( FsmFigure, ScanState ); + } + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + Syfaddfsmsyfout( ScanOut ); + } + + return( FsmFigure ); +} diff --git a/alliance/src/syf/src/kis_parse.h b/alliance/src/syf/src/kis_parse.h new file mode 100644 index 00000000..55557a08 --- /dev/null +++ b/alliance/src/syf/src/kis_parse.h @@ -0,0 +1,76 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : kis_parse.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +# ifndef KIS_PARSE_H +# define KIS_PARSE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Keywords | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern fsmfig_list *SyfKissParse(); + +# endif diff --git a/alliance/src/syf/src/syf_asp.c b/alliance/src/syf/src/syf_asp.c new file mode 100644 index 00000000..5a6e7a1e --- /dev/null +++ b/alliance/src/syf/src/syf_asp.c @@ -0,0 +1,447 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : Syf_asp.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_must.h" +# include "syf_asp.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmGetAspState | +| | +\------------------------------------------------------------*/ + +void SyfFsmGetAspState( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + long *StateWeightArray; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + long NumberState; + long IndexState; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + NumberState = FsmFigure->NUMBER_STATE; + + if ( SyfInfo->ASP_STATE == (long *)0 ) + { + StateWeightArray = + + (long *)autallocblock( sizeof( long ) * NumberState ); + + SyfInfo->ASP_STATE = StateWeightArray; + + IndexState = 0; + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + + ScanSyfState->INDEX = IndexState; + + StateWeightArray[ IndexState++ ] += getablexprnumatom( ScanSyfState->ABL_TRANS ); + } + } + else + { + StateWeightArray = SyfInfo->ASP_STATE; + + memset( StateWeightArray, 0, sizeof(long) * NumberState ); + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + + StateWeightArray[ ScanSyfState->INDEX ] += getablexprnumatom( ScanSyfState->ABL_TRANS ); + } + } + +# ifdef SYF_DEBUG + + SyfFsmViewAspState( FsmFigure ); + +# endif +} + +/*------------------------------------------------------------\ +| | +| SyfFsmAspEncode | +| | +\------------------------------------------------------------*/ + +void SyfFsmAspEncode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + + syfcode *CodeArray; + long *TransWeightArray; + long *OutWeightArray; + long *CtrlWeightArray; + long *StateWeightArray; + + long *WeightArray; + long *SumWeightArray; + long *SortGroupArray; + long *SortStateArray; + short *SelectArray; + long *ValueArray; + + long NumberState; + long NumberOut; + long NumberBit; + long NumberGroup; + long NumberCtrl; + + long CodeMax; + long CodeValue; + long CodeIndex; + + long BitSetMax; + long BitSetMask; + long BitSetCounter; + long RemainBit; + long RemainBitMax; + + long GroupIndex; + long GroupIndexCtrl; + long SortGroupIndex; + long LineGroup; + + long StateIndex; + long SortStateIndex; + long SumWeight; + long TransExist; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeMax = SyfInfo->NUMBER_CODE; + CodeArray = SyfInfo->CODE_ARRAY; + NumberBit = SyfInfo->NUMBER_BIT; + NumberState = FsmFigure->NUMBER_STATE; + NumberOut = FsmFigure->NUMBER_OUT; + NumberGroup = NumberState + NumberOut; + NumberCtrl = FSM_MAX_CTRL - 1; + + SyfFsmGetAspState( FsmFigure ); + SyfFsmGetMustangTrans( FsmFigure ); + SyfFsmGetMustangOut( FsmFigure ); + SyfFsmGetMustangCtrl( FsmFigure ); + + TransWeightArray = SyfInfo->MUSTANG_TRANS; + OutWeightArray = SyfInfo->MUSTANG_OUT; + CtrlWeightArray = SyfInfo->MUSTANG_CTRL; + StateWeightArray = SyfInfo->ASP_STATE; + + if ( CtrlWeightArray != (long *)0 ) + { + NumberGroup = NumberGroup + NumberCtrl; + } + + SumWeightArray = (long *)autallocblock( sizeof(long) * NumberGroup ); + SortGroupArray = (long *)autallocblock( sizeof(long) * NumberGroup ); + SortStateArray = (long *)autallocblock( sizeof(long) * NumberState ); + SelectArray = (short *)autallocblock( sizeof(short) * CodeMax ); + ValueArray = (long *)autallocblock( sizeof(long) * CodeMax ); + +/* +** Initialize possible code values +*/ + + for ( CodeIndex = 0; CodeIndex < CodeMax; CodeIndex++ ) + { + CodeArray[ CodeIndex ].VALUE = CodeIndex; + } + +/* +** Compute weight sum for all groups +*/ + +# ifdef SYF_DEBUG + + fprintf( stdout, "\nCompute weight sum for groups\n" ); + +# endif + + WeightArray = TransWeightArray; + LineGroup = 0; + GroupIndexCtrl = ( NumberState + NumberOut ); + + for ( GroupIndex = 0; GroupIndex < NumberGroup; GroupIndex++ ) + { + SumWeight = 0; + + if ( GroupIndex == NumberState ) + { + LineGroup = 0; + WeightArray = OutWeightArray; + } + else + if ( GroupIndex == GroupIndexCtrl ) + { + LineGroup = 0; + WeightArray = CtrlWeightArray; + } + + for ( StateIndex = 0; StateIndex < NumberState; StateIndex++ ) + { + TransExist = WeightArray[ StateIndex + LineGroup ]; + + if ( TransExist ) + { + SumWeight += StateWeightArray[ StateIndex ]; + } + } + + SumWeightArray[ GroupIndex ] = SumWeight; + +# ifdef SYF_DEBUG + + fprintf( stdout, "Sum %c%-3d: %d\n", + ( GroupIndex < NumberState ) ? 'E' : + ( GroupIndex < GroupIndexCtrl ) ? 'O' : 'C', + GroupIndex, SumWeight ); +# endif + + LineGroup += NumberState; + } + +/* +** Sort sum weight array index +*/ + + SyfFsmGetSortArray( SumWeightArray, SortGroupArray, NumberGroup ); + +/* +** Sort state weight array index +*/ + + SyfFsmGetSortArray( StateWeightArray, SortStateArray, NumberState ); + +/* +** Encode states bit by bit +*/ + + BitSetMax = 1 << ( NumberBit - 1 ); + + for ( RemainBit = NumberBit; RemainBit > 0; RemainBit-- ) + { + RemainBitMax = 1 << ( RemainBit - 1 ); + BitSetMask = 1 << ( NumberBit - RemainBit ); + BitSetCounter = 0; + + memset( SelectArray, 0, sizeof(short) * CodeMax ); + + for ( GroupIndex = 0; GroupIndex < NumberGroup; GroupIndex++ ) + { + SortGroupIndex = SortGroupArray[ GroupIndex ]; + + if ( SortGroupIndex < NumberState ) + { + WeightArray = TransWeightArray; + LineGroup = SortGroupIndex * NumberState; + } + else + if ( SortGroupIndex < GroupIndexCtrl ) + { + WeightArray = OutWeightArray; + LineGroup = ( SortGroupIndex - NumberState ) * NumberState; + } + else + { + WeightArray = CtrlWeightArray; + LineGroup = ( SortGroupIndex - GroupIndexCtrl ) * NumberState; + } + + for ( StateIndex = 0; StateIndex < NumberState; StateIndex++ ) + { + SortStateIndex = SortStateArray[ StateIndex ]; + + TransExist = WeightArray[ LineGroup + SortStateIndex ]; + + if ( TransExist ) + { + CodeValue = ValueArray[ SortStateIndex ]; +/* +** If the "BitSetMask" bit isn't currently set on this code and +** if less than "RemainBitMax" same code have been already selected +** then affect to this state code value the bit "BitSetMask" +*/ + if ( ( ! ( CodeValue & BitSetMask ) ) && + ( SelectArray[ CodeValue ] < RemainBitMax ) ) + { + ValueArray[ SortStateIndex ] |= BitSetMask; + SelectArray[ CodeValue ]++; + + BitSetCounter = BitSetCounter + 1; + + if ( BitSetCounter >= BitSetMax ) break; + } + } + } + + if ( BitSetCounter >= BitSetMax ) break; + } + } + + BitSetMask = ( 1 << NumberBit ) - 1; + +/* +** Assign code pointer's for states +*/ + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + StateIndex = ScanSyfState->INDEX; + CodeValue = ValueArray[ StateIndex ] ^ BitSetMask; + + CodeArray[ CodeValue ].USED = 1; + ScanSyfState->CODE = &CodeArray[ CodeValue ]; + } + + autfreeblock( SumWeightArray ); + autfreeblock( SortGroupArray ); + autfreeblock( SortStateArray ); + autfreeblock( ValueArray ); + autfreeblock( SelectArray ); + + autfreeblock( SyfInfo->MUSTANG_TRANS ); + autfreeblock( SyfInfo->MUSTANG_OUT ); + autfreeblock( SyfInfo->ASP_STATE ); + + if ( SyfInfo->MUSTANG_CTRL != (long *)0 ) + { + autfreeblock( SyfInfo->MUSTANG_CTRL ); + } + + SyfInfo->MUSTANG_TRANS = (long *)0; + SyfInfo->MUSTANG_OUT = (long *)0; + SyfInfo->MUSTANG_CTRL = (long *)0; + SyfInfo->ASP_STATE = (long *)0; +} + +# ifdef SYF_DEBUG + +/*------------------------------------------------------------\ +| | +| View Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Syf View Asp State | +| | +\------------------------------------------------------------*/ + +void SyfFsmViewAspState( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + long *StateWeightArray; + long NumberState; + long IndexLine; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + NumberState = FsmFigure->NUMBER_STATE; + StateWeightArray = SyfInfo->ASP_STATE; + + fprintf( stdout, "\n--> Asp state weight array" ); + + if ( StateWeightArray != (long *)0 ) + { + fprintf( stdout, "\n " ); + + for ( IndexLine = 0; IndexLine < NumberState; IndexLine++ ) + { + fprintf( stdout, "\nE%-3d %-3d", IndexLine, StateWeightArray[ IndexLine ] ); + } + } + + fprintf( stdout, "\n<-- Asp state weight array" ); +} + +# endif diff --git a/alliance/src/syf/src/syf_asp.h b/alliance/src/syf/src/syf_asp.h new file mode 100644 index 00000000..c2d0befa --- /dev/null +++ b/alliance/src/syf/src/syf_asp.h @@ -0,0 +1,85 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_asp.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_ASP_H +# define SYF_ASP_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmAspEncode(); + extern void SyfFsmGetAspState(); + +# ifdef SYF_DEBUG + +/*------------------------------------------------------------\ +| | +| View Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmViewAspState(); + +# endif + +# endif diff --git a/alliance/src/syf/src/syf_bdd.c b/alliance/src/syf/src/syf_bdd.c new file mode 100644 index 00000000..b2d028b9 --- /dev/null +++ b/alliance/src/syf/src/syf_bdd.c @@ -0,0 +1,117 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_bdd.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.03.95 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FVH_H + +# include +# include +# include +# include "syf_bdd.h" +# include "syf_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmMakeBddCircuit | +| | +\------------------------------------------------------------*/ + +bddcircuit *SyfFsmMakeBddCircuit( BddSystem, FsmFigure ) + + bddsystem *BddSystem; + fsmfig_list *FsmFigure; +{ + fsmin_list *ScanIn; + fsmout_list *ScanOut; + bddcircuit *BddCircuit; + + BddCircuit = createbddcircuit( FsmFigure->NAME, + FsmFigure->NUMBER_IN + FsmFigure->NUMBER_OUT, + FsmFigure->NUMBER_STATE, BddSystem ); + + for ( ScanIn = FsmFigure->IN; + ScanIn != (fsmin_list *)0; + ScanIn = ScanIn->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanIn->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanOut->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + FsmFigure->CIRCUIT = BddCircuit; + + makefsmbddnode( FsmFigure ); + + return( BddCircuit ); +} diff --git a/alliance/src/syf/src/syf_bdd.h b/alliance/src/syf/src/syf_bdd.h new file mode 100644 index 00000000..e33a8a58 --- /dev/null +++ b/alliance/src/syf/src/syf_bdd.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_bdd.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.03.95 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_BDD_H +# define SYF_BDD_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern bddcircuit *SyfFsmMakeBddCircuit(); + + +# endif diff --git a/alliance/src/syf/src/syf_comp.c b/alliance/src/syf/src/syf_comp.c new file mode 100644 index 00000000..ea5fe73e --- /dev/null +++ b/alliance/src/syf/src/syf_comp.c @@ -0,0 +1,146 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_comp.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FVH_H +# include FTL_H + + +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_comp.h" +# include "kis_parse.h" +# include "fbh_parse.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfRemoveStable | +| | +\------------------------------------------------------------*/ + +static void SyfRemoveStable( Expr ) + + ablexpr *Expr; +{ + if ( ! ABL_ATOM( Expr ) ) + { + if ( ABL_OPER( Expr ) == ABL_STABLE ) + { + freechain( ABL_CADR( Expr ) ); + freechain( ABL_CDR( Expr ) ); + freechain( ABL_CAR( Expr ) ); + + ABL_CDR( Expr ) = (ablexpr *)0; + ABL_ATOM_VALUE( Expr ) = getablatomzero(); + + return; + } + + while ( ( Expr = ABL_CDR( Expr ) ) != (ablexpr *)0 ) + { + SyfRemoveStable( ABL_CAR( Expr ) ); + } + } +} + + +/*------------------------------------------------------------\ +| | +| SyfCompile | +| | +\------------------------------------------------------------*/ + +fsmfig_list *SyfCompile( FileName, FlagScan, FlagSynopsys ) + + char *FileName; + char FlagScan; + char FlagSynopsys; +{ + fsmfig_list *FsmFigure; + syfinfo *SyfInfo; + + if ( FSM_IN == FSM_VHDL_FORMAT ) + { + FsmFigure = SyfFbhParse( FileName, FlagScan ); + } + else + { + FsmFigure = SyfKissParse( FileName, FlagScan ); + } + + if ( FlagSynopsys ) + { + SyfInfo = FSM_SYF_INFO( FsmFigure ); + SyfRemoveStable( FsmFigure->CLOCK_ABL ); + } + + return( FsmFigure ); +} diff --git a/alliance/src/syf/src/syf_comp.h b/alliance/src/syf/src/syf_comp.h new file mode 100644 index 00000000..0d967aa0 --- /dev/null +++ b/alliance/src/syf/src/syf_comp.h @@ -0,0 +1,73 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_comp.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_COMP_H +# define SYF_COMP_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern fsmfig_list *SyfCompileKiss(); + extern fsmfig_list *SyfCompile(); + +# endif diff --git a/alliance/src/syf/src/syf_cost.c b/alliance/src/syf/src/syf_cost.c new file mode 100644 index 00000000..e23201cb --- /dev/null +++ b/alliance/src/syf/src/syf_cost.c @@ -0,0 +1,187 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_cost.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FVH_H + +# include +# include +# include +# include +# include "syf_fsm.h" +# include "syf_env.h" +# include "syf_fsm2fbh.h" +# include "syf_synth.h" +# include "syf_bdd.h" +# include "syf_error.h" +# include "syf_cost.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFbhAblGiveCost | +| | +\------------------------------------------------------------*/ + +long SyfFbhAblGiveCost( FbhFigure ) + + fbfig_list *FbhFigure; +{ + long Cost; + fbout_list *FbhOut; + fbaux_list *FbhAux; + fbreg_list *FbhReg; + biabl_list *FbhBiAbl; + + Cost = 0; + + for ( FbhOut = FbhFigure->BEOUT; + FbhOut != (fbout_list *)0; + FbhOut = FbhOut->NEXT ) + { + if ( FbhOut->ABL != (chain_list *)0 ) + { + Cost += getablexprnumatom( FbhOut->ABL ); + } + } + + for ( FbhAux = FbhFigure->BEAUX; + FbhAux != (fbaux_list *)0; + FbhAux = FbhAux->NEXT ) + { + if ( FbhAux->ABL != (chain_list *)0 ) + { + Cost += getablexprnumatom( FbhAux->ABL ); + } + } + + for ( FbhReg = FbhFigure->BEREG; + FbhReg != (fbreg_list *)0; + FbhReg = FbhReg->NEXT ) + { + for ( FbhBiAbl = FbhReg->BIABL; + FbhBiAbl != (biabl_list *)0; + FbhBiAbl = FbhBiAbl->NEXT ) + { + if ( FbhBiAbl->VALABL != (chain_list *)0 ) + { + Cost += getablexprnumatom( FbhBiAbl->VALABL ); + } + + if ( FbhBiAbl->CNDABL != (chain_list *)0 ) + { + Cost += getablexprnumatom( FbhBiAbl->CNDABL ); + } + } + } + + return( Cost ); +} + +/*------------------------------------------------------------\ +| | +| SyfBddGiveCost | +| | +\------------------------------------------------------------*/ + +static long SyfBddGiveCost( BddNode ) + + bddnode *BddNode; +{ + bddnode *BddNot; + + if ( BddNode->INDEX >= BDD_INDEX_MIN ) + { + if ( ! ( BddNode->FLAG & SYF_BDD_COST_FLAG ) ) + { + if ( ( BddNode->HIGH->INDEX >= BDD_INDEX_MIN ) || + ( BddNode->LOW->INDEX >= BDD_INDEX_MIN ) ) + { + if ( BddNode->REF_INT > 1 ) + { + BddNode->FLAG |= SYF_BDD_COST_FLAG; + + BddNot = applybddnodenot( (bddsystem *)0, BddNode ); + + if ( BddNot->REF_INT > 1 ) + { + BddNot->FLAG |= SYF_BDD_COST_FLAG; + } + + delbddnode( (bddsystem *)0, decbddrefext( BddNot ) ); + } + + return( SyfBddGiveCost( BddNode->LOW ) + 1 + + SyfBddGiveCost( BddNode->HIGH ) ); + } + } + + return( 1 ); + } + + return( 0 ); +} diff --git a/alliance/src/syf/src/syf_cost.h b/alliance/src/syf/src/syf_cost.h new file mode 100644 index 00000000..53b6589c --- /dev/null +++ b/alliance/src/syf/src/syf_cost.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_cost.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + + +# ifndef SYF_COST_H +# define SYF_COST_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define SYF_BDD_COST_FLAG (bddflag)(0x0004) + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern long SyfFsmGiveCost(); + extern long SyfFbhAblGiveCost(); + extern long SyfFbhBddGiveCost(); + +# endif diff --git a/alliance/src/syf/src/syf_dc.c b/alliance/src/syf/src/syf_dc.c new file mode 100644 index 00000000..49b5a74a --- /dev/null +++ b/alliance/src/syf/src/syf_dc.c @@ -0,0 +1,243 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_synth.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_env.h" +# include "syf_dc.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfSynthCodeDc2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthCodeDc2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfcode *CodeArray; + syfregstate *RegArray; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + bddnode *BddNode; + bddnode *BddNodeDc; + bddnode *BddNodeOut; + bddnode *BddNodeOutDc; + bddnode *BddSimp; + bddnode *BddNot; + long NodeSize; + long SimpSize; + long Index; + long BitMask; + long ScanBit; + long NumberIn; + char DecodeOut; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeArray = SyfInfo->CODE_ARRAY; + RegArray = SyfInfo->REG_ARRAY; + DecodeOut = ( SyfInfo->REG_OUT ) && ( SyfInfo->STACK ); + NumberIn = SyfInfo->NUMBER_REG; + + if ( DecodeOut ) + { + NumberIn = NumberIn << 1; + } + + BddSystem = createbddsystem( SYF_BDD_VAR_NODE, SYF_BDD_OPER_NODE, NumberIn, SYF_BDD_MAX_NODE ); + BddCircuit = createbddcircuit( FsmFigure->NAME, NumberIn, 1, BddSystem ); + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + BddNode = addbddcircuitin( (bddcircuit *)0, RegArray[ ScanBit ].NAME_OUT, + (bddindex )0, BDD_IN_MODE_LAST ); + + RegArray[ ScanBit ].NODE_OUT = BddNode; + + if ( DecodeOut ) + { + BddNode = addbddcircuitin( (bddcircuit *)0, RegArray[ ScanBit ].NAME_IN, + (bddindex )0, BDD_IN_MODE_LAST ); + + RegArray[ ScanBit ].NODE_IN = BddNode; + } + } + + BddNodeDc = BddSystem->ZERO; + BddNodeOutDc = BddSystem->ZERO; + + for ( Index = 0; Index < SyfInfo->NUMBER_CODE; Index++ ) + { + BddNode = BddSystem->ONE; + BddNodeOut = BddSystem->ONE; + BitMask = 1; + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + if ( CodeArray[ Index ].VALUE & BitMask ) + { + BddNode = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddNode ), + RegArray[ ScanBit ].NODE_OUT ); + + if ( DecodeOut ) + { + BddNodeOut = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddNodeOut ), + RegArray[ ScanBit ].NODE_IN ); + } + } + else + { + BddNot = applybddnodenot( (bddsystem *)0, RegArray[ ScanBit ].NODE_OUT ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddNode ), + decbddrefext( BddNot ) ); + if ( DecodeOut ) + { + BddNot = applybddnodenot( (bddsystem *)0, RegArray[ ScanBit ].NODE_IN ); + BddNodeOut = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddNodeOut ), + decbddrefext( BddNot ) ); + } + } + + BitMask = BitMask << 1; + } + + if ( ! CodeArray[ Index ].USED ) + { + BddNodeDc = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddNodeDc ), BddNode ); + + if ( DecodeOut ) + { + BddNodeOutDc = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddNodeOutDc ), BddNodeOut ); + } + } + else + { + CodeArray[ Index ].ABL = (chain_list *)BddNode; + + if ( DecodeOut ) + { + CodeArray[ Index ].ABL_OUT = (chain_list *)BddNodeOut; + } + } + } + + for ( Index = 0; Index < SyfInfo->NUMBER_CODE; Index++ ) + { + if ( CodeArray[ Index ].USED ) + { + BddNode = (bddnode *)CodeArray[ Index ].ABL; + BddSimp = simpbddnodedcoff( (bddsystem *)0, BddNode, BddNodeDc ); + + SimpSize = getbddnodesize( (bddsystem *)0, BddSimp ); + NodeSize = getbddnodesize( (bddsystem *)0, BddNode ); + + if ( SimpSize < NodeSize ) + { + BddNode = BddSimp; + } + + CodeArray[ Index ].ABL = + + convertbddcircuitabl( (bddcircuit *)0, BddNode ); + + if ( DecodeOut ) + { + BddNodeOut = (bddnode *)CodeArray[ Index ].ABL_OUT; + BddSimp = simpbddnodedcoff( (bddsystem *)0, BddNodeOut, BddNodeOutDc ); + + SimpSize = getbddnodesize( (bddsystem *)0, BddSimp ); + NodeSize = getbddnodesize( (bddsystem *)0, BddNodeOut ); + + if ( SimpSize < NodeSize ) + { + BddNodeOut = BddSimp; + } + + CodeArray[ Index ].ABL_OUT = + + convertbddcircuitabl( (bddcircuit *)0, BddNodeOut ); + } + } + } + + destroybddcircuit( BddCircuit ); + destroybddsystem( BddSystem ); +} diff --git a/alliance/src/syf/src/syf_dc.h b/alliance/src/syf/src/syf_dc.h new file mode 100644 index 00000000..cfb7f29d --- /dev/null +++ b/alliance/src/syf/src/syf_dc.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_dc.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_DC_H +# define SYF_DC_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfSynthCodeDc2Abl(); + +# endif diff --git a/alliance/src/syf/src/syf_encod.c b/alliance/src/syf/src/syf_encod.c new file mode 100644 index 00000000..9476690d --- /dev/null +++ b/alliance/src/syf/src/syf_encod.c @@ -0,0 +1,189 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_encod.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include + +# include "syf_env.h" +# include "syf_fsm.h" +# include "syf_tools.h" +# include "syf_error.h" +# include "syf_encod.h" +# include "syf_asp.h" +# include "syf_random.h" +# include "syf_user.h" +# include "syf_must.h" +# include "syf_jedi.h" +# include "syf_onehot.h" +# include "syf_synth.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmEncode | +| | +\------------------------------------------------------------*/ + +void SyfFsmEncode( FsmFigure, Encode, Verbose, + TreatDc, RegOut, MustCost, FileName ) + + fsmfig_list *FsmFigure; + int Encode; + int Verbose; + int TreatDc; + int RegOut; + int MustCost; + char *FileName; +{ + syfinfo *SyfInfo; + syfcode *CodeArray; + long CodeMax; + long NumberBit; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + SyfInfo->REG_OUT = RegOut; + + if ( Encode != SYF_ENCODE_ONE_HOT ) + { + NumberBit = SyfGetNumberBit( FsmFigure->NUMBER_STATE - 1 ); + CodeMax = ( 1 << NumberBit ); + } + else + { + CodeMax = NumberBit = FsmFigure->NUMBER_STATE; + } + + CodeArray = (syfcode *)autallocblock( sizeof( syfcode ) * CodeMax ); + + SyfInfo->CODE_ARRAY = CodeArray; + SyfInfo->NUMBER_CODE = CodeMax; + SyfInfo->NUMBER_BIT = NumberBit; + SyfInfo->ENCODE = Encode; + + switch( Encode ) + { + case SYF_ENCODE_RANDOM : + + if ( Verbose ) fprintf( stdout, "\t\t--> Random encoding\n" ); + SyfFsmRandomEncode( FsmFigure ); + + break; + + case SYF_ENCODE_USER : + + if ( Verbose ) fprintf( stdout, "\t\t--> User encoding\n" ); + SyfFsmUserEncode( FsmFigure, FileName ); + + break; + + case SYF_ENCODE_MUSTANG : + + if ( Verbose ) fprintf( stdout, "\t\t--> Mustang encoding\n" ); + SyfFsmMustangEncode( FsmFigure ); + + break; + + case SYF_ENCODE_ASP : + + if ( Verbose ) fprintf( stdout, "\t\t--> Asp encoding\n" ); + + SyfSynthTrans2Abl( FsmFigure ); + SyfFsmAspEncode( FsmFigure ); + SyfSynthFreeTransAbl( FsmFigure ); + + break; + + case SYF_ENCODE_JEDI : + + if ( Verbose ) fprintf( stdout, "\t\t--> Jedi encoding\n" ); + SyfFsmJediEncode( FsmFigure ); + + break; + + case SYF_ENCODE_ONE_HOT : + + if ( Verbose ) fprintf( stdout, "\t\t--> One hot encoding\n" ); + SyfFsmOneHotEncode( FsmFigure ); + + break; + + default : + + SyfError( SYF_ERROR_UNKNOWN_ENCODE_TYPE, Encode ); + } + + if ( ( MustCost ) && + ( Verbose ) ) + { + fprintf( stdout, "\t\t--> Mustang cost %ld\n", + SyfFsmGetMustangCost( FsmFigure ) ); + } +} diff --git a/alliance/src/syf/src/syf_encod.h b/alliance/src/syf/src/syf_encod.h new file mode 100644 index 00000000..3b85ada7 --- /dev/null +++ b/alliance/src/syf/src/syf_encod.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_encod.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_ENCOD_H +# define SYF_ENCOD_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmUserSaveCode(); + extern void SyfFsmEncode(); + +# endif diff --git a/alliance/src/syf/src/syf_env.c b/alliance/src/syf/src/syf_env.c new file mode 100644 index 00000000..8b3e2446 --- /dev/null +++ b/alliance/src/syf/src/syf_env.c @@ -0,0 +1,170 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_env.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.03.95 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FVH_H + +# include +# include +# include +# include "syf_env.h" +# include "syf_fsm.h" +# include "syf_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + long SYF_BDD_MAX_NODE = 900000; + long SYF_BDD_VAR_NODE = 50; + long SYF_BDD_OPER_NODE = 10000; + long SYF_BDD_REORDER_NODE = 100000; + long SYF_BDD_REORDER_RATIO = 50; + void (*SYF_BDD_REORDER_FUNC)() = reorderbddsystemsimple; + + int SYF_MUSTANG_JEDI_ATOM = 1; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void SyfEnv( Trace ) + + int Trace; +{ + char *Variable; + char ReorderFunc; + + Variable = mbkgetenv( "SYF_BDD_VAR_NODE" ); + if ( Variable != (char *)0 ) + { + SYF_BDD_VAR_NODE = atoi( Variable ); + } + + Variable = mbkgetenv( "SYF_BDD_MAX_NODE" ); + if ( Variable != (char *)0 ) + { + SYF_BDD_MAX_NODE = atoi( Variable ); + } + + Variable = mbkgetenv( "SYF_BDD_OPER_NODE" ); + if ( Variable != (char *)0 ) + { + SYF_BDD_OPER_NODE = atoi( Variable ); + } + + Variable = mbkgetenv( "SYF_BDD_REORDER_NODE" ); + if ( Variable != (char *)0 ) + { + SYF_BDD_REORDER_NODE = atoi( Variable ); + } + + Variable = mbkgetenv( "SYF_BDD_REORDER_RATIO" ); + if ( Variable != (char *)0 ) + { + SYF_BDD_REORDER_RATIO = atoi( Variable ); + } + + Variable = mbkgetenv( "SYF_BDD_REORDER_FUNC" ); + if ( Variable != (char *)0 ) + { + ReorderFunc = Variable[ 0 ]; + + switch( ReorderFunc ) + { + case 's' : SYF_BDD_REORDER_FUNC = reorderbddsystemsimple; + break; + + case 'w' : SYF_BDD_REORDER_FUNC = reorderbddsystemwindow; + break; + + case 'g' : SYF_BDD_REORDER_FUNC = garbagebddsystem; + break; + + default : SYF_BDD_REORDER_FUNC = (void *)0; + } + } + else + { + ReorderFunc = 's'; + } + + Variable = mbkgetenv( "SYF_MUSTANG_JEDI_ATOM" ); + if ( Variable != (char *)0 ) + { + SYF_MUSTANG_JEDI_ATOM = atoi( Variable ); + } + + if ( Trace ) + { + fprintf( stdout, "\t\t--> Bdd environement\n\n" ); + fprintf( stdout, "\t\t\tSYF_BDD_VAR_NODE : %ld\n", SYF_BDD_VAR_NODE ); + fprintf( stdout, "\t\t\tSYF_BDD_MAX_NODE : %ld\n", SYF_BDD_MAX_NODE ); + fprintf( stdout, "\t\t\tSYF_BDD_OPER_NODE : %ld\n", SYF_BDD_OPER_NODE ); + fprintf( stdout, "\t\t\tSYF_BDD_REORDER_NODE : %ld\n", SYF_BDD_REORDER_NODE ); + fprintf( stdout, "\t\t\tSYF_BDD_REORDER_RATIO : %ld\n", SYF_BDD_REORDER_RATIO ); + fprintf( stdout, "\t\t\tSYF_BDD_REORDER_FUNC : %c\n", ReorderFunc ); + + fprintf( stdout, "\n\t\t--> Mustang and Jedi environement\n\n" ); + fprintf( stdout, "\t\t\tSYF_MUSTANG_JEDI_ATOM : %d\n", SYF_MUSTANG_JEDI_ATOM ); + fprintf( stdout, "\n" ); + } +} diff --git a/alliance/src/syf/src/syf_env.h b/alliance/src/syf/src/syf_env.h new file mode 100644 index 00000000..9d0a6751 --- /dev/null +++ b/alliance/src/syf/src/syf_env.h @@ -0,0 +1,80 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_env.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 06.03.95 | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_ENV_H +# define SYF_ENV_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern long SYF_BDD_VAR_NODE; + extern long SYF_BDD_MAX_NODE; + extern long SYF_BDD_OPER_NODE; + extern long SYF_BDD_REORDER_NODE; + extern long SYF_BDD_REORDER_RATIO; + extern void (*SYF_BDD_REORDER_FUNC)(); + + extern int SYF_MUSTANG_JEDI_ATOM; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfEnv(); + +# endif diff --git a/alliance/src/syf/src/syf_error.c b/alliance/src/syf/src/syf_error.c new file mode 100644 index 00000000..aa995548 --- /dev/null +++ b/alliance/src/syf/src/syf_error.c @@ -0,0 +1,218 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_error.c | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H + +# include +# include + +# include "syf_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfDisplayError | +| | +\------------------------------------------------------------*/ + +void SyfDisplayError( File, Line, Error, Text ) + + char *File; + int Line; + int Error; + char *Text; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%d ", Name, Line ); + + switch( Error ) + { + case SYF_ERROR_OPEN_FILE : + fprintf( stderr, "Unable to open file \"%s\"\n", Text ); + break; + case SYF_ERROR_MISSING_SCAN_PORT : + fprintf( stderr, "Missing scan-port declaration in figure \"%s\"\n", Text ); + break; + case SYF_ERROR_UNKNOWN_ENCODE_TYPE : + fprintf( stderr, "Unknown encode type \"%c\"\n", (int)Text ); + break; + case SYF_ERROR_BAD_STACK_NO_PUSH : + fprintf( stderr, "Bad stack, no \"push\" in figure \"%s\"\n", Text ); + break; + case SYF_ERROR_BAD_STACK_NO_POP : + fprintf( stderr, "Bad stack, no \"pop\" in figure \"%s\"\n", Text ); + break; + case SYF_ERROR_SYNTAX : + fprintf( stderr, "Syntax error %s\n", Text ); + break; + case SYF_ERROR_UNEXPECTED_EOF : + fprintf( stderr, "Unexpected end of file error %s\n", Text ); + break; + case SYF_ERROR_UNKNOWN_STATE : + fprintf( stderr, "Unknown state %s\n", Text ); + break; + case SYF_ERROR_DUPLICATE_CODE : + fprintf( stderr, "Duplicate state code %s\n", Text ); + break; + case SYF_ERROR_WRONG_CODE : + fprintf( stderr, "Bad state code %s\n", Text ); + break; + case SYF_ERROR_BDD_ATOM_UNKNOWN : + fprintf( stderr, "Unknown atom %s, unable to make BDD\n", Text ); + break; + case SYF_ERROR_BDD_OPER : + fprintf( stderr, "Illegal oper %ld, unable to make BDD\n", (long)Text ); + break; + case SYF_ERROR_BDD_EXPR_NULL : + fprintf( stderr, "Expression NULL, unable to make BDD\n" ); + break; + case SYF_ERROR_BDD_LOOP : + fprintf( stderr, "Loop on %s, unable to make BDD\n", Text ); + break; + case SYF_ERROR_ORDER_ATOM_UNKNOWN : + fprintf( stderr, "Unknown atom %s, unable to order BDD\n", Text ); + break; + case SYF_ERROR_ORDER_OPER : + fprintf( stderr, "Illegal oper %ld, unable to order BDD\n", (long)Text ); + break; + case SYF_ERROR_ORDER_EXPR_NULL : + fprintf( stderr, "Expression NULL, unable to order BDD\n" ); + break; + case SYF_ERROR_ORDER_LOOP : + fprintf( stderr, "Loop on %s, unable to order BDD\n", Text ); + break; + + default : + fprintf( stderr, "Internal error number %d\n", Error ); + + } + + autexit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| SyfDisplayWarning | +| | +\------------------------------------------------------------*/ + +void SyfDisplayWarning( File, Line, Warning, Text1, Text2 ) + + char *File; + int Line; + int Warning; + char *Text1; + char *Text2; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%d ", Name, Line ); + + switch ( Warning ) + { + case SYF_WARNING_NO_TRANS_TO : + fprintf( stderr, "No transition to \"%s\"\n", Text1 ); + break; + case SYF_WARNING_NO_TRANS_FROM : + fprintf( stderr, "No transition from \"%s\"\n", Text1 ); + break; + case SYF_WARNING_REMOVE_UNUSED_STACK : + fprintf( stderr, "Remove unused stack in figure \"%s\"\n", Text1 ); + break; + case SYF_WARNING_REMOVE_STACK : + fprintf( stderr, "Remove stack in state \"%s\"\n", Text1 ); + break; + case SYF_WARNING_REMOVE_LOCOUT : + fprintf( stderr, "Remove local output in state \"%s\"\n", Text1 ); + break; + case SYF_WARNING_REMOVE_TRANS : + fprintf( stderr, "Remove transition from \"%s\" to \"%s\"\n", Text1, Text2 ); + break; + case SYF_WARNING_SUM_TRANS : + fprintf( stderr, "All the possible combinations in \"%s\" are not evaluated\n", Text1 ); + break; + case SYF_WARNING_INTER_TRANS : + fprintf( stderr, "Intersection of all transitions leaving \"%s\" is non-empty\n", Text1 ); + break; + case SYF_WARNING_OUTPUT_NOT_ASSIGNED : + fprintf( stderr, "Output \"%s\" is assigned by only %ld states\n", Text1, (long)Text2 ); + break; + case SYF_WARNING_MODIFY_POLARITY : + fprintf( stderr, "Inverse the polarity of the output \"%s\"\n", Text1 ); + break; + default : + fprintf( stderr, "Internal warning number %d\n", Warning ); + } +} diff --git a/alliance/src/syf/src/syf_error.h b/alliance/src/syf/src/syf_error.h new file mode 100644 index 00000000..327063e8 --- /dev/null +++ b/alliance/src/syf/src/syf_error.h @@ -0,0 +1,127 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_error.h | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_ERROR_H +# define SYF_ERROR_H + +/*------------------------------------------------------------\ +| | +| Errors | +| | +\------------------------------------------------------------*/ + +# define SYF_ERROR_OPEN_FILE 1 +# define SYF_ERROR_MISSING_SCAN_PORT 2 +# define SYF_ERROR_UNKNOWN_ENCODE_TYPE 4 +# define SYF_ERROR_BAD_STACK_NO_PUSH 5 +# define SYF_ERROR_BAD_STACK_NO_POP 6 +# define SYF_ERROR_SYNTAX 7 +# define SYF_ERROR_UNEXPECTED_EOF 8 +# define SYF_ERROR_UNKNOWN_STATE 9 +# define SYF_ERROR_DUPLICATE_CODE 10 +# define SYF_ERROR_WRONG_CODE 11 +# define SYF_ERROR_ILLEGAL_FSM_TYPE 12 +# define SYF_ERROR_BDD_ATOM_UNKNOWN 13 +# define SYF_ERROR_BDD_OPER 14 +# define SYF_ERROR_BDD_EXPR_NULL 15 +# define SYF_ERROR_BDD_LOOP 16 +# define SYF_ERROR_ORDER_ATOM_UNKNOWN 17 +# define SYF_ERROR_ORDER_OPER 18 +# define SYF_ERROR_ORDER_EXPR_NULL 19 +# define SYF_ERROR_ORDER_LOOP 20 + +/*------------------------------------------------------------\ +| | +| Warnings | +| | +\------------------------------------------------------------*/ + +# define SYF_WARNING_NO_TRANS_TO 0 +# define SYF_WARNING_NO_TRANS_FROM 1 +# define SYF_WARNING_REMOVE_UNUSED_STACK 2 +# define SYF_WARNING_REMOVE_STACK 3 +# define SYF_WARNING_REMOVE_LOCOUT 4 +# define SYF_WARNING_REMOVE_TRANS 5 +# define SYF_WARNING_INTER_TRANS 6 +# define SYF_WARNING_SUM_TRANS 7 +# define SYF_WARNING_OUTPUT_NOT_ASSIGNED 8 +# define SYF_WARNING_MODIFY_POLARITY 9 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define SyfError( ERROR, TEXT ) \ + \ + SyfDisplayError( __FILE__, __LINE__, (ERROR), (TEXT) ) + +# define SyfWarning( WARNING, T1, T2 ) \ + \ + SyfDisplayWarning( __FILE__, __LINE__, (WARNING), (T1), (T2) ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern char SyfDebugMode; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfDisplayError(); + extern void SyfDisplayWarning(); + +# endif diff --git a/alliance/src/syf/src/syf_fsm.c b/alliance/src/syf/src/syf_fsm.c new file mode 100644 index 00000000..b5ca41c7 --- /dev/null +++ b/alliance/src/syf/src/syf_fsm.c @@ -0,0 +1,187 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_fsm.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include +# include "syf_fsm.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + char *SYF_FSM_TYPE_NAME[ SYF_FSM_MAX_TYPE ] = { "MOORE", "MEALY" }; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Add Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Syfaddfsmsyfinfo | +| | +\------------------------------------------------------------*/ + +syfinfo *Syfaddfsmsyfinfo( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + + SyfInfo = (void *)autallocblock( sizeof( syfinfo ) ); + FsmFigure->USER = (void *)SyfInfo; + + return( SyfInfo ); +} + +/*------------------------------------------------------------\ +| | +| Syfaddfsmfig | +| | +\------------------------------------------------------------*/ + +fsmfig_list *Syfaddfsmfig( Name ) + + char *Name; +{ + fsmfig_list *Figure; + + Figure = addfsmfig( Name ); + Syfaddfsmsyfinfo( Figure ); + + return( Figure ); +} + +/*------------------------------------------------------------\ +| | +| Syfaddfsmsyfout | +| | +\------------------------------------------------------------*/ + +syfout *Syfaddfsmsyfout( Output ) + + fsmout_list *Output; +{ + syfout *SyfOut; + + SyfOut = (syfout *)autallocblock( sizeof( syfout ) ); + Output->USER = (void *)SyfOut; + + return( SyfOut ); +} + +/*------------------------------------------------------------\ +| | +| Syfaddfsmsyfstate | +| | +\------------------------------------------------------------*/ + +syfstate *Syfaddfsmsyfstate( Figure, State ) + + fsmfig_list *Figure; + fsmstate_list *State; +{ + syfstate *SyfState; + syfinfo *SyfInfo; + char *Buffer; + int Length; + + SyfInfo = FSM_SYF_INFO( Figure ); + + SyfState = (void *)autallocblock( sizeof( syfstate ) ); + State->USER = (void *)SyfState; + + Length = strlen( State->NAME ) + strlen( SyfInfo->CURRENT_STATE ); + Buffer = autallocblock( Length + 2 ); + + sprintf( Buffer, "%s_%s", SyfInfo->CURRENT_STATE, State->NAME ); + SyfState->CURRENT_NAME = namealloc( Buffer ); + + autfreeblock( Buffer ); + + Length = strlen( State->NAME ) + strlen( SyfInfo->RETURN_STATE ); + Buffer = autallocblock( Length + 2 ); + + sprintf( Buffer, "%s_%s", SyfInfo->RETURN_STATE, State->NAME ); + SyfState->RETURN_NAME = namealloc( Buffer ); + + autfreeblock( Buffer ); + + Length = strlen( State->NAME ) + strlen( SyfInfo->NEXT_STATE ); + Buffer = autallocblock( Length + 5 ); + + sprintf( Buffer, "%s_%s", SyfInfo->NEXT_STATE, State->NAME ); + SyfState->NEXT_NAME = namealloc( Buffer ); + + sprintf( Buffer, "%s_in_%s", SyfInfo->NEXT_STATE, State->NAME ); + SyfState->NEXT_IN_NAME = namealloc( Buffer ); + + autfreeblock( Buffer ); + + return( SyfState ); +} diff --git a/alliance/src/syf/src/syf_fsm.h b/alliance/src/syf/src/syf_fsm.h new file mode 100644 index 00000000..b6eed689 --- /dev/null +++ b/alliance/src/syf/src/syf_fsm.h @@ -0,0 +1,260 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_fsm.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_FSM_H +# define SYF_FSM_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define SYF_FSM_TYPE_MOORE 0 +# define SYF_FSM_TYPE_MEALY 1 +# define SYF_FSM_MAX_TYPE 2 + +/*------------------------------------------------------------\ +| | +| Encode Type | +| | +\------------------------------------------------------------*/ + +# define SYF_ENCODE_RANDOM 'r' +# define SYF_ENCODE_CHAKER 'c' +# define SYF_ENCODE_ANNEAL 's' +# define SYF_ENCODE_USER 'u' +# define SYF_ENCODE_MUSTANG 'm' +# define SYF_ENCODE_ASP 'a' +# define SYF_ENCODE_JEDI 'j' +# define SYF_ENCODE_ONE_HOT 'o' +# define SYF_ENCODE_FRANCK 'f' + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define FSM_SYF_INFO( Figure ) ( (syfinfo *)( ( Figure )->USER ) ) +# define FSM_SYF_STATE( State ) ( (syfstate *)( ( State )->USER ) ) +# define FSM_SYF_OUT( Out ) ( (syfout *)( ( Out )->USER ) ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Syf Control Structure | +| | +\------------------------------------------------------------*/ + + typedef struct syfctrl + { + char *NAME; + chain_list *ABL; + + } syfctrl; + +/*------------------------------------------------------------\ +| | +| Syf Output Structure | +| | +\------------------------------------------------------------*/ + + typedef struct syfout + { + long INDEX; + long NUMBER_ZERO; + long NUMBER_ONE; + long NUMBER_ASSIGN; + long POLARITY; + chain_list *ABL; + + } syfout; + +/*------------------------------------------------------------\ +| | +| Syf Code Structure | +| | +\------------------------------------------------------------*/ + + typedef struct syfcode + { + long VALUE; + long USED; + chain_list *ABL; + chain_list *ABL_OUT; + + } syfcode; + +/*------------------------------------------------------------\ +| | +| Syf State Structure | +| | +\------------------------------------------------------------*/ + + typedef struct syfstate + { + char *CURRENT_NAME; + char *RETURN_NAME; + char *NEXT_NAME; + char *NEXT_IN_NAME; + long INDEX; + syfcode *CODE; + chain_list *ABL_TRANS; + chain_list *ABL_RETURN; + + } syfstate; + +/*------------------------------------------------------------\ +| | +| Syf Register Structure | +| | +\------------------------------------------------------------*/ + + typedef struct syfregout + { + char *NAME_MASTER; + char *NAME_OUT; + chain_list *ABL; + + } syfregout; + + typedef struct syfregstate + { + char *NAME_IN; + bddnode *NODE_IN; + char *NAME_MASTER; + char *NAME_OUT; + bddnode *NODE_OUT; + chain_list *ABL_IN; + chain_list *ABL_SET; + chain_list *ABL_RESET; + chain_list *ABL; + + } syfregstate; + + typedef struct syfregstack + { + char *NAME_MASTER; + char *NAME_OUT; + chain_list *ABL; + long FLAGS; + + } syfregstack; + +/*------------------------------------------------------------\ +| | +| Syf Info Structure | +| | +\------------------------------------------------------------*/ + + typedef struct syfinfo + { + char *CURRENT_STATE; + char *NEXT_STATE; + char *RETURN_STATE; + char *SCAN_IN; + char *SCAN_OUT; + char *SCAN_TEST; + char *SCAN_STACK; + + char STACK; + char SCAN_PATH; + char REG_OUT; + + long STACK_MASK; + long STACK_CSTE; + + char FSM_TYPE; + char ENCODE; + + long NUMBER_BIT; + long NUMBER_REG; + syfregstate *REG_ARRAY; + + long NUMBER_OUT; + syfregout *OUT_ARRAY; + + long NUMBER_STACK; + syfregstack *STACK_ARRAY; + + long NUMBER_CTRL; + syfctrl *CTRL_ARRAY; + + long NUMBER_CODE; + syfcode *CODE_ARRAY; + + long *MUSTANG_OUT; + long *MUSTANG_TRANS; + long *MUSTANG_CTRL; + long *MUSTANG_EDGE; + + long *ASP_STATE; + + } syfinfo; + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern char *SYF_FSM_TYPE_NAME[ SYF_FSM_MAX_TYPE ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Add Functions | +| | +\------------------------------------------------------------*/ + + extern fsmfig_list *Syfaddfsmfig(); + extern syfinfo *Syfaddfsmsyfinfo(); + extern syfout *Syfaddfsmsyfout(); + extern syfstate *Syfaddfsmsyfstate(); + +# endif diff --git a/alliance/src/syf/src/syf_fsm2fbh.c b/alliance/src/syf/src/syf_fsm2fbh.c new file mode 100644 index 00000000..9751f4db --- /dev/null +++ b/alliance/src/syf/src/syf_fsm2fbh.c @@ -0,0 +1,401 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_fsm2fbh.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FVH_H + +# include +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_fsm2fbh.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmTreatPort | +| | +\------------------------------------------------------------*/ + +void SyfFsmTreatPort( FsmFigure, FbhFigure ) + + fsmfig_list *FsmFigure; + fbfig_list *FbhFigure; +{ + syfinfo *SyfInfo; + fbpor_list *FbhPort; + fbrin_list *FbhRin; + fsmport_list *ScanPort; + + if ( IsFsmFigMixedRtl( FsmFigure ) ) + { + return; + } + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + FbhPort = (fbpor_list *)0; + FbhRin = FbhFigure->BERIN; + + for ( ScanPort = FsmFigure->PORT; + ScanPort != (fsmport_list *)0; + ScanPort = ScanPort->NEXT ) + { + FbhPort = fbh_addfbpor( FbhPort, ScanPort->NAME, + ScanPort->DIR, ScanPort->TYPE ); + + if ( ScanPort->DIR != FSM_DIR_OUT ) + { + FbhRin = fbh_addfbrin( FbhRin, ScanPort->NAME ); + } + } + + FbhFigure->BERIN = FbhRin; + FbhFigure->BEPOR = FbhPort; +} + +/*------------------------------------------------------------\ +| | +| SyfFsmTreatOutput | +| | +\------------------------------------------------------------*/ + +void SyfFsmTreatOutput( FsmFigure, FbhFigure ) + + fsmfig_list *FsmFigure; + fbfig_list *FbhFigure; +{ + syfinfo *SyfInfo; + fsmout_list *ScanOut; + syfout *ScanSyfOut; + syfregout *OutArray; + fbout_list *FbhOut; + fbrin_list *FbhRin; + fbreg_list *FbhReg; + biabl_list *FbhBiAbl; + binode_list *FbhBiNode; + ablexpr *Equation; + ablexpr *AblExpr; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + OutArray = SyfInfo->OUT_ARRAY; + + FbhOut = FbhFigure->BEOUT; + FbhRin = FbhFigure->BERIN; + FbhReg = FbhFigure->BEREG; + + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + ScanSyfOut = FSM_SYF_OUT( ScanOut ); + + if ( ScanSyfOut->ABL != (chain_list *)0 ) + { + AblExpr = dupablexpr( ScanSyfOut->ABL ); + + if ( ScanSyfOut->POLARITY ) + { + if ( ! SyfInfo->REG_OUT ) + { + AblExpr = optimablnotexpr( AblExpr ); + } + else + { + Equation = OutArray[ ScanSyfOut->INDEX ].ABL; + Equation = optimablnotexpr( Equation ); + OutArray[ ScanSyfOut->INDEX ].ABL = Equation; + } + } + + FbhOut = fbh_addfbout( FbhOut, ScanOut->NAME, AblExpr, (bddnode *)0, 0 ); + } + } + + if ( SyfInfo->REG_OUT ) + { + for ( Index = 0; Index < SyfInfo->NUMBER_OUT; Index++ ) + { + if ( OutArray[ Index ].ABL == (chain_list *)0 ) continue; + + Equation = dupablexpr( FsmFigure->CLOCK_ABL ); + AblExpr = dupablexpr( OutArray[ Index ].ABL ); + + FbhBiAbl = fbh_addbiabl( (biabl_list *)0, + OutArray[ Index ].NAME_MASTER, Equation, AblExpr ); + + FbhBiNode = fbh_addbinode( (binode_list *)0, + (bddnode *)0, + (bddnode *)0 ); + + FbhReg = fbh_addfbreg( FbhReg, OutArray[ Index ].NAME_MASTER, + FbhBiAbl, FbhBiNode ); + + FbhRin = fbh_addfbrin( FbhRin, OutArray[ Index ].NAME_MASTER ); + } + + FbhFigure->BEREG = FbhReg; + } + + FbhFigure->BERIN = FbhRin; + FbhFigure->BEOUT = FbhOut; +} + +/*------------------------------------------------------------\ +| | +| SyfFsmTreatRegister | +| | +\------------------------------------------------------------*/ + +void SyfFsmTreatRegister( FsmFigure, FbhFigure ) + + fsmfig_list *FsmFigure; + fbfig_list *FbhFigure; +{ + syfinfo *SyfInfo; + syfregstate *RegArray; + syfregstack *StackArray; + int Index; + fbreg_list *FbhReg; + fbrin_list *FbhRin; + biabl_list *FbhBiAbl; + binode_list *FbhBiNode; + chain_list *Equation; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + RegArray = SyfInfo->REG_ARRAY; + FbhReg = FbhFigure->BEREG; + FbhRin = FbhFigure->BERIN; + + for ( Index = SyfInfo->NUMBER_REG - 1; Index >= 0; Index-- ) + { + Equation = dupablexpr( FsmFigure->CLOCK_ABL ); + FbhBiAbl = fbh_addbiabl( (biabl_list *)0, + RegArray[ Index ].NAME_MASTER, + Equation, + dupablexpr( RegArray[ Index ].ABL_IN ) ); + + FbhBiNode = fbh_addbinode( (binode_list *)0, (bddnode *)0, (bddnode *)0 ); + + FbhReg = fbh_addfbreg( FbhReg, RegArray[ Index ].NAME_MASTER, + FbhBiAbl, FbhBiNode ); + + FbhRin = fbh_addfbrin( FbhRin, RegArray[ Index ].NAME_MASTER ); + } + + if ( SyfInfo->STACK ) + { + StackArray = SyfInfo->STACK_ARRAY; + + for ( Index = SyfInfo->NUMBER_STACK -1; Index >= 0; Index-- ) + { + if ( ! StackArray[ Index ].FLAGS ) + { + Equation = dupablexpr( FsmFigure->CLOCK_ABL ); + FbhBiAbl = fbh_addbiabl( (biabl_list *)0, + StackArray[ Index ].NAME_MASTER, + Equation, + dupablexpr( StackArray[ Index ].ABL ) ); + + FbhBiNode = fbh_addbinode( (binode_list *)0, + (bddnode *)0, + (bddnode *)0 ); + + FbhReg = fbh_addfbreg( FbhReg, StackArray[ Index ].NAME_MASTER, + FbhBiAbl, FbhBiNode ); + + FbhRin = fbh_addfbrin( FbhRin, StackArray[ Index ].NAME_MASTER ); + } + } + } + + FbhFigure->BERIN = FbhRin; + FbhFigure->BEREG = FbhReg; +} + +/*------------------------------------------------------------\ +| | +| SyfFsmTreatAux | +| | +\------------------------------------------------------------*/ + +void SyfFsmTreatAux( FsmFigure, FbhFigure ) + + fsmfig_list *FsmFigure; + fbfig_list *FbhFigure; +{ + syfinfo *SyfInfo; + fbaux_list *FbhAux; + fbrin_list *FbhRin; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + syfctrl *CtrlArray; + syfregstack *StackArray; + syfregstate *RegArray; + int Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + FbhAux = FbhFigure->BEAUX; + FbhRin = FbhFigure->BERIN; + + if ( SyfInfo->STACK ) + { + StackArray = SyfInfo->STACK_ARRAY; + + for ( Index = SyfInfo->NUMBER_REG - 1; Index >= 0; Index-- ) + { + if ( StackArray[ Index ].FLAGS ) + { + FbhAux = fbh_addfbaux( FbhAux, StackArray[ Index ].NAME_OUT, + dupablexpr( StackArray[ Index ].ABL ), (bddnode *)0, 0 ); + } + } + + CtrlArray = SyfInfo->CTRL_ARRAY; + + for ( Index = 0; Index < SyfInfo->NUMBER_CTRL; Index++ ) + { + FbhAux = fbh_addfbaux( FbhAux, CtrlArray[ Index ].NAME, + dupablexpr( CtrlArray[ Index ].ABL ), (bddnode *)0, 0 ); + + FbhRin = fbh_addfbrin( FbhRin, CtrlArray[ Index ].NAME ); + } + } + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + + if ( ( SyfInfo->STACK ) && + ( SyfInfo->REG_OUT ) ) + { + FbhAux = fbh_addfbaux( FbhAux, ScanSyfState->NEXT_IN_NAME, + dupablexpr( ScanSyfState->CODE->ABL_OUT ), (bddnode *)0, 0 ); + FbhRin = fbh_addfbrin( FbhRin, ScanSyfState->NEXT_IN_NAME ); + } + + FbhAux = fbh_addfbaux( FbhAux, ScanSyfState->CURRENT_NAME, + dupablexpr( ScanSyfState->CODE->ABL ), (bddnode *)0, 0 ); + FbhRin = fbh_addfbrin( FbhRin, ScanSyfState->CURRENT_NAME ); + + FbhAux = fbh_addfbaux( FbhAux, ScanSyfState->NEXT_NAME, + dupablexpr( ScanSyfState->ABL_TRANS ), (bddnode *)0, 0 ); + FbhRin = fbh_addfbrin( FbhRin, ScanSyfState->NEXT_NAME ); + + if ( ScanSyfState->ABL_RETURN != (chain_list *)0 ) + { + FbhAux = fbh_addfbaux( FbhAux, ScanSyfState->RETURN_NAME, + dupablexpr( ScanSyfState->ABL_RETURN ), (bddnode *)0, 0 ); + FbhRin = fbh_addfbrin( FbhRin, ScanSyfState->RETURN_NAME ); + } + } + + RegArray = SyfInfo->REG_ARRAY; + + for ( Index = SyfInfo->NUMBER_REG - 1; Index >= 0; Index-- ) + { + FbhAux = fbh_addfbaux( FbhAux, RegArray[ Index ].NAME_IN, + dupablexpr( RegArray[ Index ].ABL ), (bddnode *)0, 0 ); + FbhRin = fbh_addfbrin( FbhRin, RegArray[ Index ].NAME_IN ); + } + + FbhFigure->BERIN = FbhRin; + FbhFigure->BEAUX = FbhAux; +} + +/*------------------------------------------------------------\ +| | +| SyfFsm2Fbh | +| | +\------------------------------------------------------------*/ + +fbfig_list *SyfFsm2Fbh( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fbfig_list *FbhFigure; + + if ( ! IsFsmFigMixedRtl( FsmFigure ) ) + { + FbhFigure = fbh_addfbfig( (fbfig_list *)0, FsmFigure->NAME ); + } + else + { + FbhFigure = (fbfig_list *)FsmFigure->FIGURE; + } + + SyfFsmTreatPort( FsmFigure, FbhFigure ); + SyfFsmTreatOutput( FsmFigure, FbhFigure ); + SyfFsmTreatRegister( FsmFigure, FbhFigure ); + SyfFsmTreatAux( FsmFigure, FbhFigure ); + + return( FbhFigure ); +} diff --git a/alliance/src/syf/src/syf_fsm2fbh.h b/alliance/src/syf/src/syf_fsm2fbh.h new file mode 100644 index 00000000..9a19488a --- /dev/null +++ b/alliance/src/syf/src/syf_fsm2fbh.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_fsm2fbh.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_FSM2FBH_H +# define SYF_FSM2FBH_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern fbfig_list *SyfFsm2Fbh(); + +# endif diff --git a/alliance/src/syf/src/syf_jedi.c b/alliance/src/syf/src/syf_jedi.c new file mode 100644 index 00000000..055bc272 --- /dev/null +++ b/alliance/src/syf/src/syf_jedi.c @@ -0,0 +1,285 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : Syf_jedi.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include "syf_fsm.h" +# include "syf_tools.h" +# include "syf_error.h" +# include "syf_must.h" +# include "syf_jedi.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmJediEncode | +| | +\------------------------------------------------------------*/ + +void SyfFsmJediEncode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + syfcode *CodeArray; + long *EdgeWeightArray; + + short *DoneArray; + long *SortArray; + long *ValueArray; + + long StateCounter; + long BestState; + long SortState; + long DoneState; + + long SumWeightMax; + long SumWeight; + long SumCostMin; + long SumCost; + + long LineState; + long LineBest; + + + long SortIndex; + long StateIndex; + long ValueIndex; + + long EdgeWeight; + long Distance; + + long BestCode; + long StateCode; + long CodeValue; + + long NumberState; + long NumberBit; + long CodeMax; + long ValueMax; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeMax = SyfInfo->NUMBER_CODE; + ValueMax = CodeMax; + CodeArray = SyfInfo->CODE_ARRAY; + NumberState = FsmFigure->NUMBER_STATE; + NumberBit = SyfInfo->NUMBER_BIT; + + SyfFsmGetMustangEdge( FsmFigure ); + + autfreeblock( SyfInfo->MUSTANG_TRANS ); + autfreeblock( SyfInfo->MUSTANG_OUT ); + + if ( SyfInfo->MUSTANG_CTRL != (long *)0 ) + { + autfreeblock( SyfInfo->MUSTANG_CTRL ); + } + + EdgeWeightArray = SyfInfo->MUSTANG_EDGE; + + ValueArray = (long *)autallocblock( sizeof(long) * CodeMax ); + DoneArray = (short *)autallocblock( sizeof(short) * NumberState ); + SortArray = (long *)autallocblock( sizeof(long) * NumberState ); + +/* +** Initialize possible code values +*/ + for ( ValueIndex = 0; ValueIndex < ValueMax; ValueIndex++ ) + { + ValueArray[ ValueIndex ] = ValueIndex; + } + +/* +** Assign code pointer for states +*/ + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + + ScanSyfState->CODE = &CodeArray[ ScanSyfState->INDEX ]; + } + + for ( StateCounter = 0; StateCounter < NumberState; StateCounter++ ) + { +/* +** Look for a "best" state +*/ + LineState = 0; + SumWeightMax = -1; + + for ( StateIndex = 0; StateIndex < NumberState; StateIndex++ ) + { + if ( ! DoneArray[ StateIndex ] ) + { + SumWeight = 0; + + if ( StateCounter == 0 ) + { + for ( SortState = 0; SortState < NumberState; SortState++ ) + { + SumWeight += EdgeWeightArray[ LineState + SortState ]; + } + } + else + { + for ( SortIndex = 0; SortIndex < StateCounter; SortIndex++ ) + { + SortState = SortArray[ SortIndex ]; + SumWeight += EdgeWeightArray[ LineState + SortState ]; + } + } + + if ( SumWeight > SumWeightMax ) + { + BestState = StateIndex; + LineBest = LineState; + SumWeightMax = SumWeight; + } + } + + LineState = LineState + NumberState; + } +/* +** Get unused code for the "best" state +*/ + SortArray[ StateCounter ] = BestState; + DoneArray[ BestState ] = 1; + + if ( StateCounter == 0 ) + { + BestCode = 0; + } + else + { + SumCostMin = -1; + + for ( ValueIndex = 0; ValueIndex < ValueMax; ValueIndex++ ) + { + SumCost = 0; + CodeValue = ValueArray[ ValueIndex ]; + + for ( SortIndex = 0; SortIndex < StateCounter; SortIndex++ ) + { + DoneState = SortArray[ SortIndex ]; + EdgeWeight = EdgeWeightArray[ LineBest + DoneState ]; + + if ( EdgeWeight != 0 ) + { + Distance = SyfGetHamingDistance( CodeArray[ DoneState ].VALUE, + CodeValue, NumberBit ); + + SumCost += Distance * EdgeWeight; + } + } + + if ( ( SumCost < SumCostMin ) || + ( SumCostMin == -1 ) ) + { + SumCostMin = SumCost; + BestCode = ValueIndex; + } + } + } + + ValueMax = ValueMax - 1; + StateCode = ValueArray[ BestCode ]; + + if ( ValueMax != BestCode ) + { + ValueArray[ BestCode ] = ValueArray[ ValueMax ]; + ValueArray[ ValueMax ] = StateCode; + } + + CodeArray[ BestState ].USED = 1; + CodeArray[ BestState ].VALUE = StateCode; + } + + for ( ValueIndex = 0; ValueIndex < ValueMax; ValueIndex++ ) + { + CodeArray[ NumberState + ValueIndex ].VALUE = ValueArray[ ValueIndex ]; + } + + autfreeblock( SortArray ); + autfreeblock( DoneArray ); + autfreeblock( ValueArray ); + + autfreeblock( SyfInfo->MUSTANG_EDGE ); + + SyfInfo->MUSTANG_TRANS = (long *)0; + SyfInfo->MUSTANG_OUT = (long *)0; + SyfInfo->MUSTANG_CTRL = (long *)0; + SyfInfo->MUSTANG_EDGE = (long *)0; +} diff --git a/alliance/src/syf/src/syf_jedi.h b/alliance/src/syf/src/syf_jedi.h new file mode 100644 index 00000000..fd7afe74 --- /dev/null +++ b/alliance/src/syf/src/syf_jedi.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_jedi.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_JEDI_H +# define SYF_JEDI_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmJediEncode(); + +# endif diff --git a/alliance/src/syf/src/syf_main.c b/alliance/src/syf/src/syf_main.c new file mode 100644 index 00000000..ac3cc932 --- /dev/null +++ b/alliance/src/syf/src/syf_main.c @@ -0,0 +1,355 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_main.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FVH_H +# include FTL_H + +# include +# include +# include +# include "syf_main.h" +# include "syf_error.h" +# include "syf_env.h" +# include "syf_fsm.h" +# include "syf_comp.h" +# include "syf_fsm2fbh.h" +# include "syf_cost.h" +# include "syf_verify.h" +# include "syf_synth.h" +# include "syf_dc.h" +# include "syf_encod.h" +# include "syf_simp.h" +# include "syf_bdd.h" +# include "syf_verify.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + fsmfig_list *SyfFsmFigure = (fsmfig_list *)0; + fbfig_list *SyfFbhFigure = (fbfig_list *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Syf Usage | +| | +\------------------------------------------------------------*/ + +void SyfUsage() +{ + fprintf( stdout, "\t\tsyf Encoding [Options] Input_name [Output_name]\n\n" ); + + fprintf( stdout, "\t\tEncoding : -a Asp encoding\n" ); + fprintf( stdout, "\t\t -j Jedi encoding\n" ); + fprintf( stdout, "\t\t -m Mustang encoding\n" ); + fprintf( stdout, "\t\t -u User 'Input_name'.enc file\n" ); + fprintf( stdout, "\t\t -o One hot encoding\n" ); + fprintf( stdout, "\t\t -r Random encoding\n\n" ); + + fprintf( stdout, "\t\tOptions : -C Checks FSM transitions\n" ); + fprintf( stdout, "\t\t -D Doesn't treat unused codes as DC\n" ); + fprintf( stdout, "\t\t -E Saves 'Output_name'.enc file\n" ); + fprintf( stdout, "\t\t -O Uses registers for outputs\n" ); + fprintf( stdout, "\t\t -P Uses a scan-path for registers\n" ); + fprintf( stdout, "\t\t -I Doesn't inverse outputs polarity \n" ); + fprintf( stdout, "\t\t -S Doesn't simplify FSM equations\n" ); + fprintf( stdout, "\t\t -T Sets Trace mode on\n" ); + fprintf( stdout, "\t\t -V Sets Verbose mode on\n" ); + fprintf( stdout, "\t\t -F Sets synopsys output Format\n" ); + fprintf( stdout, "\n" ); + + exit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| Main | +| | +\------------------------------------------------------------*/ + +int main( argc, argv ) + + int argc; + char *argv[]; +{ + char *InputFileName; + char *OutputFileName; + char *FileName; + long Literals; + int Number; + int Index; + char Option; + + int FlagSave = 0; + int FlagScan = 0; + int FlagCode = -1; + int FlagVerbose = 0; + int FlagTrace = 0; + int FlagRegOut = 0; + int FlagDc = 1; + int FlagCheck = 0; + int FlagSimplify = 1; + int FlagInvPolar = 1; + int FlagMustCost = 0; + int FlagFormat = 0; + + alliancebanner_with_authors( + "SYF", SYF_VERSION, "FSM Synthesizer", "1995", + ALLIANCE_VERSION, "Ludovic Jacomme and Chaker Sarwary" ); + + mbkenv(); + autenv(); + ablenv(); + bddenv(); + fsmenv(); + + if ( argc < 3 ) SyfUsage(); + + OutputFileName = (char *)0; + InputFileName = (char *)0; + + 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 'C' : FlagCheck = 1; + break; + case 'D' : FlagDc = 0; + break; + case 'E' : FlagSave = 1; + break; + case 'F' : FlagFormat = 1; + break; + case 'O' : FlagRegOut = 1; + break; + case 'P' : FlagScan = 1; + break; + case 'S' : FlagSimplify = 0; + break; + case 'T' : FlagTrace = 1; + break; + case 'V' : FlagVerbose = 1; + break; + case 'M' : FlagMustCost = 1; + break; + case 'I' : FlagInvPolar = 0; + break; + case 'r' : FlagCode = SYF_ENCODE_RANDOM; + break; + case 'c' : FlagCode = SYF_ENCODE_CHAKER; + break; + case 'u' : FlagCode = SYF_ENCODE_USER; + break; + case 'm' : FlagCode = SYF_ENCODE_MUSTANG; + break; + case 'a' : FlagCode = SYF_ENCODE_ASP; + break; + case 'j' : FlagCode = SYF_ENCODE_JEDI; + break; + case 'o' : FlagCode = SYF_ENCODE_ONE_HOT; + break; + default : SyfUsage(); + } + } + } + else + if ( InputFileName == (char *)0 ) InputFileName = argv[ Number ]; + else + if ( OutputFileName == (char *)0 ) OutputFileName = argv[ Number ]; + else + SyfUsage(); + } + + if ( ( InputFileName == (char *)0 ) || + ( FlagCode == -1 ) ) SyfUsage(); + + InputFileName = autbasename( InputFileName, FSM_IN ); + + FileName = autallocblock( strlen( InputFileName ) + 7 ); + strcpy( FileName, InputFileName ); + InputFileName = FileName; + + if ( OutputFileName == (char *)0 ) + { + OutputFileName = autallocblock( strlen( InputFileName ) + 2 ); + sprintf( OutputFileName, "%s%c", InputFileName, FlagCode ); + } + else + { + OutputFileName = autbasename( OutputFileName, FSM_OUT ); + } + + SyfEnv( FlagTrace ); + + fprintf( stdout, "\t\t--> Compile FSM file %s\n", InputFileName ); + + SyfFsmFigure = SyfCompile( InputFileName, FlagScan, FlagFormat ); + + SyfFsmFigure->NAME = namealloc( OutputFileName ); + + if ( FlagInvPolar ) + { + if ( FlagVerbose ) + { + fprintf( stdout, "\t\t--> Check FSM figure outputs\n" ); + } + + SyfFsmOutputPolarity( SyfFsmFigure ); + } + + if ( FlagVerbose ) + { + if ( FlagSimplify ) + { + fprintf( stdout, "\t\t--> Simplify FSM figure\n" ); + } + } + + SyfFsmSimplify( SyfFsmFigure, FlagSimplify ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\t\t--> Verify FSM figure\n" ); + } + + SyfFsmVerify( SyfFsmFigure, FlagCheck ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\t\t--> Identify reset conditions\n" ); + } + + SyfFsmTreatReset( SyfFsmFigure ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\n" ); + + if ( IsFsmFigMixedRtl( SyfFsmFigure ) ) + { + fprintf( stdout, "\t\t--> Mixed DataFlow / Fsm\n\n" ); + } + fprintf( stdout, "\t\t--> States : %ld\n", SyfFsmFigure->NUMBER_STATE ); + fprintf( stdout, "\t\t--> Inputs : %ld\n", SyfFsmFigure->NUMBER_IN ); + fprintf( stdout, "\t\t--> Outputs : %ld\n", SyfFsmFigure->NUMBER_OUT ); + fprintf( stdout, "\t\t--> Edges : %ld\n", SyfFsmFigure->NUMBER_TRANS ); + fprintf( stdout, "\t\t--> Stacks : %ld\n", SyfFsmFigure->NUMBER_STACK ); + fprintf( stdout, "\n" ); + fprintf( stdout, "\t\t--> Encode FSM figure\n" ); + } + + SyfFsmEncode( SyfFsmFigure, FlagCode, FlagVerbose, + FlagDc, FlagRegOut, FlagMustCost, InputFileName ); + + if ( FlagSave ) + { + if ( FlagVerbose ) + { + fprintf( stdout, "\t\t--> Save FSM codes\n" ); + } + + SyfFsmUserSaveCode( SyfFsmFigure, OutputFileName ); + } + + if ( FlagVerbose ) + { + fprintf( stdout, "\t\t--> Translate FSM to BEH\n" ); + } + + SyfSynthFsmInit( SyfFsmFigure ); + SyfSynthCode2Abl( SyfFsmFigure, FlagDc ); + SyfSynthFsm2Abl( SyfFsmFigure ); + + SyfFbhFigure = SyfFsm2Fbh( SyfFsmFigure ); + + if ( FlagVerbose ) + { + fprintf( stdout, "\t\t--> Simplify BEH figure\n" ); + } + + SyfFbhSimplify( SyfFbhFigure ); + + if ( FlagVerbose ) + { + Literals = SyfFbhAblGiveCost( SyfFbhFigure ); + + fprintf( stdout, "\n" ); + fprintf( stdout, "\t\t--> Literals : %ld\n", Literals ); + fprintf( stdout, "\n" ); + } + + fprintf( stdout, "\t\t--> Save BEH file %s\n\n", OutputFileName ); + + vhdlsavefbfig( SyfFbhFigure, OutputFileName, FlagFormat ); + + return( 0 ); +} diff --git a/alliance/src/syf/src/syf_main.h b/alliance/src/syf/src/syf_main.h new file mode 100644 index 00000000..f9a5df14 --- /dev/null +++ b/alliance/src/syf/src/syf_main.h @@ -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 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 : SYF | +| | +| File : syf_main.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_MAIN_H +# define SYF_MAIN_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/syf/src/syf_must.c b/alliance/src/syf/src/syf_must.c new file mode 100644 index 00000000..6d3d5c7e --- /dev/null +++ b/alliance/src/syf/src/syf_must.c @@ -0,0 +1,908 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : Syf_must.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include "syf_env.h" +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_tools.h" +# include "syf_must.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmGetMustangCtrl | +| | +\------------------------------------------------------------*/ + +void SyfFsmGetMustangCtrl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstack_list *ScanStack; + long *CtrlWeightArray; + long NumberCtrl; + long NumberState; + long StateIndex; + long LineCtrl; + long Control; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + NumberState = FsmFigure->NUMBER_STATE; + NumberCtrl = FSM_MAX_CTRL - 1; + + if ( ! SyfInfo->STACK ) return; + + if ( SyfInfo->MUSTANG_CTRL == (long*)0 ) + { + CtrlWeightArray = + + (long*)autallocblock( sizeof(long) * NumberState * NumberCtrl ); + + SyfInfo->MUSTANG_CTRL = CtrlWeightArray; + } + else + { + CtrlWeightArray = SyfInfo->MUSTANG_CTRL; + + memset( CtrlWeightArray, 0, sizeof(long) * NumberState * NumberCtrl ); + } + + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( IsFsmStarStack( ScanStack ) ) continue; + + Control = ScanStack->CTRL; + + if ( Control != FSM_CTRL_NOP ) + { + LineCtrl = ( Control - 1 ) * NumberState; + StateIndex = FSM_SYF_STATE( ScanStack->CURRENT )->INDEX; + + if ( SYF_MUSTANG_JEDI_ATOM ) + { + CtrlWeightArray[ LineCtrl + StateIndex ] += + + getablexprnumatom( ScanStack->ABL ); + } + else + { + CtrlWeightArray[ LineCtrl + StateIndex ]++; + } + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmGetMustangOut | +| | +\------------------------------------------------------------*/ + +void SyfFsmGetMustangOut( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + long *OutWeightArray; + fsmout_list *ScanOut; + fsmstate_list *ScanState; + fsmlocout_list *ScanLocout; + long NumberState; + long NumberOut; + long IndexState; + long IndexOut; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + NumberState = FsmFigure->NUMBER_STATE; + NumberOut = FsmFigure->NUMBER_OUT; + OutWeightArray = SyfInfo->MUSTANG_OUT; + + if ( OutWeightArray == (long *)0 ) + { + OutWeightArray = + + (long *)autallocblock( sizeof(long) * NumberState * NumberOut ); + + SyfInfo->MUSTANG_OUT = OutWeightArray; + + IndexOut = 0; + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + FSM_SYF_OUT( ScanOut )->INDEX = IndexOut++; + } + } + else + { + memset( OutWeightArray, 0, sizeof(long) * NumberState * NumberOut ); + } + + IndexState = 0; + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + IndexOut = FSM_SYF_OUT( ScanLocout->OUT )->INDEX; + + if ( SYF_MUSTANG_JEDI_ATOM ) + { + if ( ScanLocout->ABL != (chain_list *)0 ) + { + OutWeightArray[ ( IndexOut * NumberState ) + IndexState ] += + + getablexprnumatom( ScanLocout->ABL ); + } + } + else + { + OutWeightArray[ ( IndexOut * NumberState ) + IndexState ]++; + } + } + + FSM_SYF_STATE( ScanState )->INDEX = IndexState++; + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmGetMustangTrans | +| | +\------------------------------------------------------------*/ + +void SyfFsmGetMustangTrans( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + long *TransWeightArray; + fsmstate_list *ScanState; + fsmtrans_list *ScanTrans; + long NumberState; + long Index; + long IndexTo; + long IndexFrom; + long IndexState; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + NumberState = FsmFigure->NUMBER_STATE; + TransWeightArray = SyfInfo->MUSTANG_TRANS; + + if ( TransWeightArray == (long *)0 ) + { + TransWeightArray = + + (long *)autallocblock( sizeof(long) * NumberState * NumberState ); + + SyfInfo->MUSTANG_TRANS = TransWeightArray; + + IndexState = 0; + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + FSM_SYF_STATE( ScanState )->INDEX = IndexState++; + } + } + else + { + memset( TransWeightArray, 0, sizeof(long) * NumberState * NumberState ); + } + + for ( ScanTrans = FsmFigure->TRANS; + ScanTrans != (fsmtrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + if ( IsFsmStarTrans( ScanTrans ) ) continue; + + IndexTo = FSM_SYF_STATE( ScanTrans->TO )->INDEX; + IndexFrom = FSM_SYF_STATE( ScanTrans->FROM )->INDEX; + Index = ( IndexTo * NumberState ) + IndexFrom; + + if ( SYF_MUSTANG_JEDI_ATOM ) + { + TransWeightArray[ Index ] += getablexprnumatom( ScanTrans->ABL ); + } + else + { + TransWeightArray[ Index ]++; + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmGetMustangEdge | +| | +\------------------------------------------------------------*/ + +void SyfFsmGetMustangEdge( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + long NumberState; + long NumberOut; + long NumberBit; + long NumberCtrl; + long *EdgeWeightArray; + long *OutWeightArray; + long *TransWeightArray; + long *CtrlWeightArray; + long StateIKWeight; + long StateJKWeight; + long CtrlIKWeight; + long CtrlJKWeight; + long OutIKWeight; + long OutJKWeight; + long LineStateI; + long LineStateJ; + long LineCtrlK; + long LineOutK; + long StateIJ; + long StateI; + long StateJ; + long StateK; + long OutK; + long CtrlK; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + NumberState = FsmFigure->NUMBER_STATE; + NumberOut = FsmFigure->NUMBER_OUT; + NumberBit = SyfInfo->NUMBER_BIT; + NumberCtrl = FSM_MAX_CTRL - 1; + EdgeWeightArray = SyfInfo->MUSTANG_EDGE; + + if ( SyfInfo->MUSTANG_OUT == (long *)0 ) + { + SyfFsmGetMustangOut( FsmFigure ); + } + + if ( SyfInfo->MUSTANG_TRANS == (long *)0 ) + { + SyfFsmGetMustangTrans( FsmFigure ); + } + + if ( SyfInfo->MUSTANG_CTRL == (long *)0 ) + { + SyfFsmGetMustangCtrl( FsmFigure ); + } + + if ( EdgeWeightArray == (long *)0 ) + { + EdgeWeightArray = + + (long *)autallocblock( sizeof(long) * NumberState * NumberState ); + + SyfInfo->MUSTANG_EDGE = EdgeWeightArray; + } + else + { + memset( EdgeWeightArray, 0, sizeof(long) * NumberState * NumberState ); + } + + EdgeWeightArray = SyfInfo->MUSTANG_EDGE; + OutWeightArray = SyfInfo->MUSTANG_OUT; + CtrlWeightArray = SyfInfo->MUSTANG_CTRL; + TransWeightArray = SyfInfo->MUSTANG_TRANS; + + LineStateI = 0; + + for ( StateI = 0; StateI < NumberState; StateI++ ) + { + LineStateJ = 0; + + for ( StateJ = 0; StateJ < NumberState; StateJ++ ) + { + StateIJ = LineStateI + StateJ; + + if ( StateI != StateJ ) + { + for ( StateK = 0; StateK < NumberState; StateK++ ) + { + StateIKWeight = TransWeightArray[ LineStateI + StateK ]; + StateJKWeight = TransWeightArray[ LineStateJ + StateK ]; + + if ( ( StateIKWeight != 0 ) && + ( StateJKWeight != 0 ) ) + { + EdgeWeightArray[ StateIJ ] += StateIKWeight * StateJKWeight; + } + } + + EdgeWeightArray[ StateIJ ] *= NumberBit; + + if ( CtrlWeightArray != (long *)0 ) + { + LineCtrlK = 0; + + for ( CtrlK = 0; CtrlK < NumberCtrl; CtrlK++ ) + { + CtrlIKWeight = CtrlWeightArray[ LineCtrlK + StateI ]; + CtrlJKWeight = CtrlWeightArray[ LineCtrlK + StateJ ]; + + if ( ( CtrlIKWeight != 0 ) && + ( CtrlJKWeight != 0 ) ) + { + EdgeWeightArray[ StateIJ ] += CtrlIKWeight * CtrlJKWeight; + } + + LineCtrlK = LineCtrlK + NumberState; + } + } + + LineOutK = 0; + + for ( OutK = 0; OutK < NumberOut; OutK++ ) + { + OutIKWeight = OutWeightArray[ LineOutK + StateI ]; + OutJKWeight = OutWeightArray[ LineOutK + StateJ ]; + + if ( ( OutIKWeight != 0 ) && + ( OutJKWeight != 0 ) ) + { + EdgeWeightArray[ StateIJ ] += OutIKWeight * OutJKWeight; + } + + LineOutK = LineOutK + NumberState; + } + } + + LineStateJ = LineStateJ + NumberState; + } + + LineStateI = LineStateI + NumberState; + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmGetMustangCost | +| | +\------------------------------------------------------------*/ + +long SyfFsmGetMustangCost( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + long NumberState; + long NumberBit; + long *EdgeWeightArray; + long *CodeArray; + long StateI; + long StateJ; + long LineStateI; + long Distance; + long Weight; + char FreeEdge; + long EdgeCost; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + NumberState = FsmFigure->NUMBER_STATE; + NumberBit = SyfInfo->NUMBER_BIT; + + if ( SyfInfo->CODE_ARRAY == (syfcode *)0 ) + { + return( 0 ); + } + + if ( SyfInfo->MUSTANG_EDGE == (long *)0 ) + { + SyfFsmGetMustangEdge( FsmFigure ); + + autfreeblock( SyfInfo->MUSTANG_TRANS ); + autfreeblock( SyfInfo->MUSTANG_OUT ); + + if ( SyfInfo->MUSTANG_CTRL != (long *)0 ) + { + autfreeblock( SyfInfo->MUSTANG_CTRL ); + } + + SyfInfo->MUSTANG_TRANS = (long *)0; + SyfInfo->MUSTANG_OUT = (long *)0; + SyfInfo->MUSTANG_CTRL = (long *)0; + + FreeEdge = 1; + } + else + { + FreeEdge = 0; + } + + EdgeWeightArray = SyfInfo->MUSTANG_EDGE; + + CodeArray = (long *)autallocblock( sizeof(long) * NumberState ); + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + + CodeArray[ ScanSyfState->INDEX ] = ScanSyfState->CODE->VALUE; + } + + EdgeCost = 0; + LineStateI = 0; + + for ( StateI = 0; StateI < NumberState; StateI++ ) + { + for ( StateJ = 0; StateJ < NumberState; StateJ++ ) + { + if ( StateJ != StateI ) + { + Weight = EdgeWeightArray[ StateJ + LineStateI ]; + + if ( Weight != 0 ) + { + Distance = + + SyfGetHamingDistance( CodeArray[ StateI ], CodeArray[ StateJ ], NumberBit ); + + EdgeCost = EdgeCost + ( Distance * Weight ); + } + } + } + + LineStateI = LineStateI + NumberState; + } + + autfreeblock( CodeArray ); + + if ( FreeEdge ) + { + autfreeblock( SyfInfo->MUSTANG_EDGE ); + + SyfInfo->MUSTANG_EDGE = (long *)0; + } + + return( EdgeCost ); +} + +/*------------------------------------------------------------\ +| | +| SyfFsmGetSortArray | +| | +\------------------------------------------------------------*/ + +void SyfFsmGetSortArray( ValueArray, IndexArray, ArraySize ) + + long *ValueArray; + long *IndexArray; + long ArraySize; +{ + long Node; + long NodeIndex; + long LastNode; + long Father; + long FatherIndex; + long LeftChild; + long LeftIndex; + long RightChild; + long RightIndex; + long Child; + long ChildIndex; + + for ( LastNode = 0; LastNode < ArraySize; LastNode++ ) + { + IndexArray[ LastNode ] = LastNode; + + NodeIndex = LastNode; + Node = LastNode; + + do + { + Father = HEAP_FATHER( Node ); + + if ( Father != -1 ) + { + FatherIndex = IndexArray[ Father ]; + + if ( ValueArray[ FatherIndex ] > ValueArray[ NodeIndex ] ) + { + IndexArray[ Father ] = NodeIndex; + IndexArray[ Node ] = FatherIndex; + + Node = Father; + } + } + } + while ( Node == Father ); + } + + for ( LastNode = ArraySize - 1; LastNode >= 0; LastNode-- ) + { + Node = 0; + + NodeIndex = IndexArray[ LastNode ]; + IndexArray[ LastNode ] = IndexArray[ 0 ]; + IndexArray[ 0 ] = NodeIndex; + + do + { + LeftChild = HEAP_LEFT_CHILD( Node ); + RightChild = HEAP_RIGHT_CHILD( Node ); + + if ( LeftChild < LastNode ) + { + LeftIndex = IndexArray[ LeftChild ]; + RightIndex = IndexArray[ RightChild ]; + + if ( ( RightChild < LastNode ) && + ( ValueArray[ RightIndex ] < ValueArray[ LeftIndex ] ) ) + { + Child = RightChild; + ChildIndex = RightIndex; + } + else + { + Child = LeftChild; + ChildIndex = LeftIndex; + } + + if ( ValueArray[ NodeIndex ] > ValueArray[ ChildIndex ] ) + { + IndexArray[ Child ] = NodeIndex; + IndexArray[ Node ] = ChildIndex; + + Node = Child; + } + else + { + LeftChild = LastNode; + } + } + } + while ( LeftChild < LastNode ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmMustangEncode | +| | +\------------------------------------------------------------*/ + +void SyfFsmMustangEncode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + syfcode *CodeArray; + long *EdgeArray; + + short *DoneArray; + long *SortArray; + long *ValueArray; + + long NearCounter; + long NearCounterMax; + long StateCounter; + + long NearState; + long BestState; + long SortState; + + long SumWeightMax; + long SumWeight; + long EdgeWeight; + + long SortIndex; + long StateIndex; + long ValueIndex; + long BestIndex; + + long LineState; + long LineSort; + + long StateCode; + long NearCode; + + long BestDistance; + long Distance; + + long BitSet; + long BestBitSet; + + long NumberState; + long NumberBit; + long CodeMax; + long ValueMax; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeMax = SyfInfo->NUMBER_CODE; + ValueMax = CodeMax; + CodeArray = SyfInfo->CODE_ARRAY; + NumberState = FsmFigure->NUMBER_STATE; + NumberBit = SyfInfo->NUMBER_BIT; + + SyfFsmGetMustangEdge( FsmFigure); + + autfreeblock( SyfInfo->MUSTANG_TRANS ); + autfreeblock( SyfInfo->MUSTANG_OUT ); + + if ( SyfInfo->MUSTANG_CTRL != (long *)0 ) + { + autfreeblock( SyfInfo->MUSTANG_CTRL ); + } + + EdgeArray = SyfInfo->MUSTANG_EDGE; + + ValueArray = (long *)autallocblock( sizeof(long) * CodeMax ); + DoneArray = (short *)autallocblock( sizeof(short) * NumberState ); + SortArray = (long *)autallocblock( sizeof(long) * NumberState + * NumberState ); +/* +** Initialize possible code values +*/ + for ( ValueIndex = 0; ValueIndex < ValueMax; ValueIndex++ ) + { + ValueArray[ ValueIndex ] = ValueIndex; + } + +/* +** Assign code pointer for states +*/ + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + + ScanSyfState->CODE = &CodeArray[ ScanSyfState->INDEX ]; + } + +/* +** Sort states index from edge weight values +*/ + LineState = 0; + + for ( StateIndex = 0; StateIndex < NumberState; StateIndex++ ) + { + SyfFsmGetSortArray( EdgeArray + LineState, + SortArray + LineState, NumberState ); + + LineState = LineState + NumberState; + } + + StateCounter = 0; + + while ( StateCounter < NumberState ) + { +/* +** Look for a "best" state, and a maximum of NumberBit "near" states +*/ + SumWeightMax = -1; + BestState = -1; + LineSort = 0; + NearCounterMax = 0; + + for ( StateIndex = 0; StateIndex < NumberState; StateIndex++ ) + { + if ( ! DoneArray[ StateIndex ] ) + { + SumWeight = 0; + NearCounter = 0; + + for ( SortIndex = 0; SortIndex < NumberState; SortIndex++ ) + { + SortState = SortArray[ LineSort + SortIndex ]; + + if ( ! DoneArray[ SortState ] ) + { + EdgeWeight = EdgeArray[ LineSort + SortState ]; + + if ( EdgeWeight == 0 ) break; + + SumWeight = SumWeight + EdgeWeight; + + NearCounter++; + + if ( NearCounter >= NumberBit ) break; + } + } + + if ( SumWeight > SumWeightMax ) + { + BestState = StateIndex; + LineState = LineSort; + SumWeightMax = SumWeight; + NearCounterMax = NearCounter; + } + } + + LineSort = LineSort + NumberState; + } +/* +** Get unused code for the "best" state +*/ + DoneArray[ BestState ] = 1; + + if ( ! CodeArray[ BestState ].USED ) + { + ValueMax = ValueMax - 1; + StateCode = ValueArray[ 0 ]; + + if ( ValueMax != 0 ) + { + ValueArray[ 0 ] = ValueArray[ ValueMax ]; + ValueArray[ ValueMax ] = StateCode; + } + + CodeArray[ BestState ].USED = 1; + CodeArray[ BestState ].VALUE = StateCode; + + StateCounter++; + } + else + { + StateCode = CodeArray[ BestState ].VALUE; + } +/* +** Get nearest code for the "near" states +*/ + NearCounter = 0; + LineSort = LineState; + + for ( SortIndex = 0; SortIndex < NumberState; SortIndex++ ) + { + NearState = SortArray[ LineSort + SortIndex ]; + + if ( DoneArray[ NearState ] ) continue; + + if ( ! CodeArray[ NearState ].USED ) + { + BestIndex = 0; + BestDistance = NumberBit; + BestBitSet = NumberBit; +/* +** Search the nearest code in the possible code array +*/ + for ( ValueIndex = 0; ValueIndex < ValueMax; ValueIndex++ ) + { + Distance = + + SyfGetHamingDistance( StateCode, ValueArray[ ValueIndex ], NumberBit ); + + BitSet = + + SyfGetNumberBitSet( ValueArray[ ValueIndex ], NumberBit ); + + if ( BestDistance > Distance ) + { + BestDistance = Distance; + BestBitSet = BitSet; + BestIndex = ValueIndex; + } + else + if ( ( BestDistance == Distance ) && + ( BitSet < BestBitSet ) ) + { + BestBitSet = BitSet; + BestIndex = ValueIndex; + } + } + + ValueMax = ValueMax - 1; + NearCode = ValueArray[ BestIndex ]; + + if ( BestIndex != ValueMax ) + { + ValueArray[ BestIndex ] = ValueArray[ ValueMax ]; + ValueArray[ ValueMax ] = NearCode; + } + + CodeArray[ NearState ].USED = 1; + CodeArray[ NearState ].VALUE = NearCode; + + StateCounter++; + } + + NearCounter++; + + if ( NearCounter >= NearCounterMax ) break; + } + } + + for ( ValueIndex = 0; ValueIndex < ValueMax; ValueIndex++ ) + { + CodeArray[ NumberState + ValueIndex ].VALUE = ValueArray[ ValueIndex ]; + } + + autfreeblock( SortArray ); + autfreeblock( DoneArray ); + autfreeblock( ValueArray ); + + autfreeblock( SyfInfo->MUSTANG_EDGE ); + + SyfInfo->MUSTANG_TRANS = (long *)0; + SyfInfo->MUSTANG_OUT = (long *)0; + SyfInfo->MUSTANG_CTRL = (long *)0; + SyfInfo->MUSTANG_EDGE = (long *)0; +} diff --git a/alliance/src/syf/src/syf_must.h b/alliance/src/syf/src/syf_must.h new file mode 100644 index 00000000..bddbc633 --- /dev/null +++ b/alliance/src/syf/src/syf_must.h @@ -0,0 +1,100 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_must.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_MUSTANG_H +# define SYF_MUSTANG_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define HEAP_FATHER( Node ) ( ( ( ( Node ) + 1 ) >> 1 ) - 1 ) +# define HEAP_LEFT_CHILD( Node ) ( ( ( ( Node ) + 1 ) << 1 ) - 1 ) +# define HEAP_RIGHT_CHILD( Node ) ( ( ( Node ) + 1 ) << 1 ) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmMustangEncode(); + extern void SyfFsmGetMustangTrans(); + extern void SyfFsmGetMustangOut(); + extern void SyfFsmGetMustangCtrl(); + extern void SyfFsmGetMustangEdge(); + extern long SyfFsmGetMustangCost(); + + extern void SyfFsmGetSortArray(); + + +# ifdef SYF_DEBUG + +/*------------------------------------------------------------\ +| | +| View Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmViewMustangOut(); + extern void SyfFsmViewMustangTrans(); + extern void SyfFsmViewMustangCtrl(); + extern void SyfFsmViewMustangEdge(); + +# endif + +# endif diff --git a/alliance/src/syf/src/syf_onehot.c b/alliance/src/syf/src/syf_onehot.c new file mode 100644 index 00000000..53e9c474 --- /dev/null +++ b/alliance/src/syf/src/syf_onehot.c @@ -0,0 +1,111 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : Syf_must.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_onehot.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmOneHotEncode | +| | +\------------------------------------------------------------*/ + +void SyfFsmOneHotEncode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + syfcode *CodeArray; + long CodeMax; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeMax = SyfInfo->NUMBER_CODE; + CodeArray = SyfInfo->CODE_ARRAY; + + ScanState = FsmFigure->STATE; + + for ( Index = 0; Index < CodeMax; Index++ ) + { + FSM_SYF_STATE( ScanState )->CODE = &CodeArray[ Index ]; + + CodeArray[ Index ].VALUE = Index; + CodeArray[ Index ].USED = 1; + + ScanState = ScanState->NEXT; + } +} diff --git a/alliance/src/syf/src/syf_onehot.h b/alliance/src/syf/src/syf_onehot.h new file mode 100644 index 00000000..f6edac03 --- /dev/null +++ b/alliance/src/syf/src/syf_onehot.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_onehot.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_ONEHOT_H +# define SYF_ONEHOT_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmOneHotEncode(); + +# endif diff --git a/alliance/src/syf/src/syf_random.c b/alliance/src/syf/src/syf_random.c new file mode 100644 index 00000000..b0eaae8c --- /dev/null +++ b/alliance/src/syf/src/syf_random.c @@ -0,0 +1,150 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : random.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ +# include +# include +# include +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_random.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static char SyfInitializedRandom = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfInitializeRandom | +| | +\------------------------------------------------------------*/ + +void SyfInitializeRandom() +{ + if ( ! SyfInitializedRandom ) + { + SyfInitializedRandom = 1; + + srand( getpid() ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfRandomEncode | +| | +\------------------------------------------------------------*/ + +void SyfFsmRandomEncode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + syfcode *CodeArray; + long CodeMax; + int Index; + int Swap; + int Scan; + + SyfInitializeRandom(); + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeMax = SyfInfo->NUMBER_CODE; + CodeArray = SyfInfo->CODE_ARRAY; + + for ( Index = 0; Index < CodeMax; Index++ ) + { + CodeArray[ Index ].VALUE = Index; + } + + ScanState = FsmFigure->STATE; + + while ( ScanState != (fsmstate_list *)0 ) + { + Scan = ( rand() >> 8 ) % CodeMax; + + CodeMax = CodeMax - 1; + + FSM_SYF_STATE( ScanState )->CODE = &CodeArray[ CodeMax ]; + + CodeArray[ CodeMax ].USED = 1; + + if ( Scan != CodeMax ) + { + Swap = CodeArray[ CodeMax ].VALUE; + CodeArray[ CodeMax ].VALUE = CodeArray[ Scan ].VALUE; + CodeArray[ Scan ].VALUE = Swap; + } + + ScanState = ScanState->NEXT; + } +} diff --git a/alliance/src/syf/src/syf_random.h b/alliance/src/syf/src/syf_random.h new file mode 100644 index 00000000..89b42f20 --- /dev/null +++ b/alliance/src/syf/src/syf_random.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : random.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_RANDOM_H +# define SYF_RANDOM_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmRandomEncode(); + extern void SyfInitializeRandom(); + +# endif diff --git a/alliance/src/syf/src/syf_simp.c b/alliance/src/syf/src/syf_simp.c new file mode 100644 index 00000000..679fee12 --- /dev/null +++ b/alliance/src/syf/src/syf_simp.c @@ -0,0 +1,134 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_simp.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H +# include FVH_H + +# include +# include +# include +# include "syf_fsm.h" +# include "syf_tools.h" +# include "syf_bdd.h" +# include "syf_simp.h" +# include "syf_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFbhSimplify | +| | +\------------------------------------------------------------*/ + + +void SyfFbhSimplify( FbhFigure ) + + fbfig_list *FbhFigure; +{ + fbout_list *FbOut; + fbreg_list *FbReg; + biabl_list *FbBiabl; + fbaux_list *FbAux; + + for ( FbAux = FbhFigure->BEAUX; + FbAux != (fbaux_list *)0; + FbAux = FbAux->NEXT ) + { + if ( FbAux->ABL != (chain_list *)0 ) + { + FbAux->ABL = simpablexpr( FbAux->ABL ); + } + } + + for ( FbOut = FbhFigure->BEOUT; + FbOut != (fbout_list *)0; + FbOut = FbOut->NEXT ) + { + if ( FbOut->ABL != (chain_list *)0 ) + { + FbOut->ABL = simpablexpr( FbOut->ABL ); + } + } + + for ( FbReg = FbhFigure->BEREG; + FbReg != (fbreg_list *)0; + FbReg = FbReg->NEXT ) + { + for ( FbBiabl = FbReg->BIABL; + FbBiabl != (biabl_list *)0; + FbBiabl = FbBiabl->NEXT ) + { + if ( ( FbBiabl->CNDABL != (chain_list *)0 ) && + ( FbBiabl->VALABL != (chain_list *)0 ) ) + { + FbBiabl->CNDABL = simpablexpr( FbBiabl->CNDABL ); + FbBiabl->VALABL = simpablexpr( FbBiabl->VALABL ); + } + } + } +} diff --git a/alliance/src/syf/src/syf_simp.h b/alliance/src/syf/src/syf_simp.h new file mode 100644 index 00000000..33af15ba --- /dev/null +++ b/alliance/src/syf/src/syf_simp.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_simp.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_SIMP_H +# define SYF_SIMP_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFbhSimplify(); + +# endif diff --git a/alliance/src/syf/src/syf_synth.c b/alliance/src/syf/src/syf_synth.c new file mode 100644 index 00000000..84258b6e --- /dev/null +++ b/alliance/src/syf/src/syf_synth.c @@ -0,0 +1,1603 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_synth.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_dc.h" +# include "syf_synth.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfSynthReturn2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthReturn2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstack_list *ScanStack; + syfstate *ReturnSyfState; + syfstate *CurrentSyfState; + syfinfo *SyfInfo; + ablexpr *Equation; + ablexpr *Atom; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + if ( ! SyfInfo->STACK ) return; + + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ReturnSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + + if ( IsFsmStarStack( ScanStack ) ) + { + Equation = dupablexpr( ScanStack->ABL ); + } + else + { + CurrentSyfState = FSM_SYF_STATE( ScanStack->CURRENT ); + + Atom = createablatom( CurrentSyfState->CURRENT_NAME ); + Equation = optimablbinexpr( ABL_AND, + dupablexpr( ScanStack->ABL ), + Atom ); + } + + if ( ReturnSyfState->ABL_RETURN == (ablexpr *)0 ) + { + ReturnSyfState->ABL_RETURN = createabloper( ABL_OR ); + } + + addablhexpr( ReturnSyfState->ABL_RETURN, Equation ); + } + } + + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ReturnSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + Equation = ReturnSyfState->ABL_RETURN; + + if ( ( Equation != (ablexpr *)0 ) && + ( ABL_CDDR( Equation ) == (ablexpr *)0 ) ) + { + Atom = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + ReturnSyfState->ABL_RETURN = Atom; + } + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeReturnAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeReturnAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfstate *ReturnSyfState; + fsmstack_list *ScanStack; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + if ( SyfInfo->STACK ) + { + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ReturnSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + + if ( ReturnSyfState->ABL_RETURN != (ablexpr *)0 ) + { + delablexpr( ReturnSyfState->ABL_RETURN ); + ReturnSyfState->ABL_RETURN = (ablexpr *)0; + } + } + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthStack2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthStack2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstack_list *ScanStack; + syfstate *ReturnSyfState; + syfinfo *SyfInfo; + syfregstack *StackArray; + syfregstack *StackNextArray; + syfregstack *StackPrevArray; + syfregstate *RegArray; + syfctrl *CtrlArray; + long Constant; + long StackMask; + long StackNewMask; + long StackCste; + long StackNewCste; + long ScanBit; + long BitMask; + long Index; + ablexpr *Stack; + ablexpr *Equation; + ablexpr *ScanPath; + ablexpr *Atom; + char *PrevStack; + char Encode; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + Encode = SyfInfo->ENCODE; + + if ( ! SyfInfo->STACK ) return; + + RegArray = SyfInfo->REG_ARRAY; + CtrlArray = SyfInfo->CTRL_ARRAY; + StackArray = SyfInfo->STACK_ARRAY; + StackCste = -1; + StackMask = 0; + + if ( Encode != SYF_ENCODE_ONE_HOT ) + { + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ReturnSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + StackNewCste = ReturnSyfState->CODE->VALUE; + + if ( StackCste == -1 ) + { + StackCste = StackNewCste; + StackMask = -1; + } + else + { + StackNewMask = ~(StackCste ^ StackNewCste); + StackMask = StackMask & StackNewMask; + } + } + } + +/* +** Push state in Stack_0 equation +*/ + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + StackArray[ ScanBit ].ABL = createabloper( ABL_OR ); + } + + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ReturnSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + StackNewCste = ReturnSyfState->CODE->VALUE; + + BitMask = 1; + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + if ( BitMask & StackNewCste ) + { + Atom = createablatom( ReturnSyfState->RETURN_NAME ); + + addablhexpr( StackArray[ ScanBit ].ABL, Atom ); + } + + BitMask = BitMask << 1; + } + } + } + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + Equation = StackArray[ ScanBit ].ABL; + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { + delablexpr( Equation ); + StackArray[ ScanBit ].ABL = createablatomzero(); + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { + Atom = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + StackArray[ ScanBit ].ABL = Atom; + } + } + } + else + { +/* +** Push state in Stack_0 equation +*/ + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ReturnSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + ScanBit = ReturnSyfState->CODE->VALUE; + + StackArray[ ScanBit ].ABL = createablatom( ReturnSyfState->RETURN_NAME ); + } + } + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + Equation = StackArray[ ScanBit ].ABL; + + if ( Equation == (ablexpr *)0 ) + { + StackArray[ ScanBit ].ABL = createablatomzero(); + StackArray[ ScanBit ].FLAGS = 1; + } + } + } + + SyfInfo->STACK_MASK = StackMask; + SyfInfo->STACK_CSTE = StackCste & StackMask; + + StackPrevArray = (syfregstack *)0; + + for ( Index = 0; Index < FsmFigure->STACK_SIZE; Index++ ) + { + if ( Index + 1 < FsmFigure->STACK_SIZE ) + { + StackNextArray = SyfInfo->STACK_ARRAY + ( SyfInfo->NUMBER_REG * ( Index + 1 ) ); + } + + BitMask = 1; + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + if ( Encode == SYF_ENCODE_ONE_HOT ) + { + Constant = SyfInfo->STACK_ARRAY[ ScanBit ].FLAGS; + } + else + { + Constant = ( BitMask & StackMask ); + } +/* +** Special case for constants +*/ + if ( Constant ) + { + StackArray[ ScanBit ].FLAGS = 1; + + if ( Encode != SYF_ENCODE_ONE_HOT ) + { +/* +** Constant equation only for Stack_0 +*/ + if ( Index == 0 ) + { + delablexpr( StackArray[ ScanBit ].ABL ); + + if ( StackCste & BitMask ) + { + StackArray[ ScanBit ].ABL = createablatomone(); + } + else + { + StackArray[ ScanBit ].ABL = createablatomzero(); + } + } + } + } + else + { +/* +** Generates Stack register equation +*/ + Stack = createabloper( ABL_OR ); + Atom = createablatom( CtrlArray[ FSM_CTRL_NOP ].NAME ); + + Equation = createablatom( StackArray[ ScanBit ].NAME_OUT ); + Equation = optimablbinexpr( ABL_AND, Equation, Atom ); + + addablhexpr( Stack, Equation ); + + Atom = createablatom( CtrlArray[ FSM_CTRL_PUSH ].NAME ); + + if ( Index == 0 ) + { + Equation = StackArray[ ScanBit ].ABL; + } + else + { + Equation = createablatom( StackPrevArray[ ScanBit ].NAME_OUT ); + } + + Equation = optimablbinexpr( ABL_AND, Equation, Atom ); + + addablhexpr( Stack, Equation ); + + if ( Index + 1 < FsmFigure->STACK_SIZE ) + { + Atom = createablatom( CtrlArray[ FSM_CTRL_POP ].NAME ); + + Equation = createablatom( StackNextArray[ ScanBit ].NAME_OUT ); + Equation = optimablbinexpr( ABL_AND, Equation, Atom ); + + addablhexpr( Stack, Equation ); + } + + StackArray[ ScanBit ].ABL = Stack; + } + + BitMask = BitMask << 1; + } + + StackPrevArray = StackArray; + StackArray = StackNextArray; + } + + if ( SyfInfo->SCAN_PATH ) + { + StackArray = SyfInfo->STACK_ARRAY; + PrevStack = SyfInfo->SCAN_IN; + + for ( Index = 0; Index < SyfInfo->NUMBER_STACK; Index++ ) + { + if ( ! StackArray[ Index ].FLAGS ) + { + ScanPath = optimablbinexpr( ABL_AND, + createablatom( PrevStack ), + createablatom( SyfInfo->SCAN_TEST ) ); + + Equation = optimablbinexpr( ABL_AND, + StackArray[ Index ].ABL, + optimablnotexpr( createablatom( SyfInfo->SCAN_TEST ) ) ); + + StackArray[ Index ].ABL = optimablbinexpr( ABL_OR, Equation, ScanPath ); + + PrevStack = StackArray[ Index ].NAME_OUT; + } + } + + SyfInfo->SCAN_STACK = PrevStack; + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeStackAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeStackAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfregstack *StackArray; + syfstate *ReturnSyfState; + fsmstack_list *ScanStack; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + if ( SyfInfo->STACK ) + { + StackArray = SyfInfo->STACK_ARRAY; + + for ( Index = 0; Index < SyfInfo->NUMBER_STACK; Index++ ) + { + StackArray[ Index ].FLAGS = 0; + + if ( StackArray[ Index ].ABL != (ablexpr *)0 ) + { + delablexpr( StackArray[ Index ].ABL ); + StackArray[ Index ].ABL = (ablexpr *)0; + } + } + + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ReturnSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + + if ( ReturnSyfState->ABL_RETURN != (ablexpr *)0 ) + { + delablexpr( ReturnSyfState->ABL_RETURN ); + ReturnSyfState->ABL_RETURN = (ablexpr *)0; + } + } + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthCtrl2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthCtrl2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstack_list *ScanStack; + syfstate *ScanSyfState; + syfinfo *SyfInfo; + syfctrl *CtrlArray; + ablexpr *Equation; + ablexpr *CtrlNop; + ablexpr *Atom; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CtrlArray = SyfInfo->CTRL_ARRAY; + + if ( ! SyfInfo->STACK ) return; + + for ( Index = 0; Index < SyfInfo->NUMBER_CTRL; Index++ ) + { + if ( Index != FSM_CTRL_NOP ) + { + CtrlArray[ Index ].ABL = createabloper( ABL_OR ); + } + } + + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL != FSM_CTRL_NOP ) + { + if ( IsFsmStarStack( ScanStack ) ) + { + Equation = dupablexpr( ScanStack->ABL ); + } + else + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + ScanSyfState = FSM_SYF_STATE( ScanStack->RETURN ); + Equation = createablatom( ScanSyfState->RETURN_NAME ); + } + else + { + ScanSyfState = FSM_SYF_STATE( ScanStack->CURRENT ); + Atom = createablatom( ScanSyfState->CURRENT_NAME ); + + Equation = optimablbinexpr( ABL_AND, + dupablexpr( ScanStack->ABL ), + Atom ); + } + } + + addablhexpr( CtrlArray[ ScanStack->CTRL ].ABL, Equation ); + } + } + + CtrlNop = createabloper( ABL_OR ); + + for ( Index = 0; Index < SyfInfo->NUMBER_CTRL; Index++ ) + { + if ( Index != FSM_CTRL_NOP ) + { + Equation = CtrlArray[ Index ].ABL; + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { + Atom = createablatomzero(); + delablexpr( Equation ); + CtrlArray[ Index ].ABL = Atom; + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { + Atom = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + CtrlArray[ Index ].ABL = Atom; + } + + Atom = createablatom( CtrlArray[ Index ].NAME ); + + addablhexpr( CtrlNop, Atom ); + } + } + + CtrlArray[ FSM_CTRL_NOP ].ABL = optimablnotexpr( CtrlNop ); +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeCtrlAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeCtrlAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfctrl *CtrlArray; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CtrlArray = SyfInfo->CTRL_ARRAY; + + if ( SyfInfo->STACK ) + { + for ( Index = 0; Index < SyfInfo->NUMBER_CTRL; Index++ ) + { + if ( CtrlArray[ Index ].ABL != (ablexpr *)0 ) + { + delablexpr( CtrlArray[ Index ].ABL ); + CtrlArray[ Index ].ABL = (ablexpr *)0; + } + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthOut2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthOut2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfregout *OutArray; + fsmout_list *ScanOutput; + fsmout_list *ScanOut; + fsmstate_list *ScanState; + fsmlocout_list *ScanLocout; + syfout *ScanSyfOut; + syfstate *ScanSyfState; + syfcode *ScanSyfCode; + ablexpr *Equation; + ablexpr *ScanPath; + ablexpr *Atom; + char *PrevScan; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + OutArray = SyfInfo->OUT_ARRAY; + ScanOut = (fsmout_list *)0; + + for ( ScanOutput = FsmFigure->OUT; + ScanOutput != (fsmout_list *)0; + ScanOutput = ScanOutput->NEXT ) + { + ScanSyfOut = FSM_SYF_OUT( ScanOutput ); + + if ( SyfInfo->SCAN_OUT == ScanOutput->NAME ) + { + ScanOut = ScanOutput; + } + + ScanSyfOut->ABL = createabloper( ABL_OR ); + } + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + ScanSyfCode = ScanSyfState->CODE; + + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + ScanSyfOut = FSM_SYF_OUT( ScanLocout->OUT ); + + if ( SyfInfo->REG_OUT ) + { + if ( SyfInfo->STACK ) + { + Atom = createablatom( ScanSyfState->NEXT_IN_NAME ); + } + else + { + Atom = createablatom( ScanSyfState->NEXT_NAME ); + } + } + else + { + Atom = createablatom( ScanSyfState->CURRENT_NAME ); + } + + if ( ScanLocout->ABL_DC != (ablexpr *)0 ) + { + Equation = optimablbinexpr( ABL_AND, + dupablexpr( ScanLocout->ABL_DC ), + createablatom( ABL_ATOM_NAME_DC ) ); + } + + if ( ScanLocout->ABL != (ablexpr *)0 ) + { + if ( ScanLocout->ABL_DC != (ablexpr *)0 ) + { + Equation = optimablbinexpr( ABL_OR, + dupablexpr( ScanLocout->ABL ), + Equation ); + } + else + { + Equation = dupablexpr( ScanLocout->ABL ); + } + } + + Equation = optimablbinexpr( ABL_AND, Atom, Equation ); + + addablhexpr( ScanSyfOut->ABL, Equation ); + } + } + + ScanState = FsmFigure->STAR_STATE; + + if ( ScanState != (fsmstate_list *)0 ) + { + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + ScanSyfOut = FSM_SYF_OUT( ScanLocout->OUT ); + + if ( ScanLocout->ABL_DC != (ablexpr *)0 ) + { + Equation = optimablbinexpr( ABL_AND, + dupablexpr( ScanLocout->ABL_DC ), + createablatom( ABL_ATOM_NAME_DC ) ); + } + + if ( ScanLocout->ABL != (ablexpr *)0 ) + { + if ( ScanLocout->ABL_DC != (ablexpr *)0 ) + { + Equation = optimablbinexpr( ABL_OR, + dupablexpr( ScanLocout->ABL ), + Equation ); + } + else + { + Equation = dupablexpr( ScanLocout->ABL ); + } + } + + addablhexpr( ScanSyfOut->ABL, Equation ); + } + } + + for ( ScanOutput = FsmFigure->OUT; + ScanOutput != (fsmout_list *)0; + ScanOutput = ScanOutput->NEXT ) + { + ScanSyfOut = FSM_SYF_OUT( ScanOutput ); + + Equation = ScanSyfOut->ABL; + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { +/* +** Out(i) = OR Null -> Out(i) = 0 +*/ + if ( ScanOutput != ScanOut ) + { + Atom = createablatomzero(); + } + else + { + Atom = createablatom( SyfInfo->SCAN_IN ); + } + + delablexpr( Equation ); + ScanSyfOut->ABL = Atom; + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { +/* +** Out(i) = OR Locout(j) -> Out(i) = Locout(j) +*/ + Atom = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + ScanSyfOut->ABL = Atom; + } + } + + if ( SyfInfo->REG_OUT ) + { + Index = 0; + + for ( ScanOutput = FsmFigure->OUT; + ScanOutput != (fsmout_list *)0; + ScanOutput = ScanOutput->NEXT ) + { + if ( ScanOutput != ScanOut ) + { + ScanSyfOut = FSM_SYF_OUT( ScanOutput ); + + if ( ! ABL_ATOM( ScanSyfOut->ABL ) ) + { + OutArray[ Index ].ABL = ScanSyfOut->ABL; + ScanSyfOut->ABL = createablatom( OutArray[ Index ].NAME_OUT ); + } + + Index = Index + 1; + } + } + } + + if ( SyfInfo->SCAN_PATH ) + { + PrevScan = SyfInfo->REG_ARRAY[ SyfInfo->NUMBER_REG - 1 ].NAME_OUT; + + if ( SyfInfo->REG_OUT ) + { + for ( Index = 0; Index < SyfInfo->NUMBER_OUT; Index++ ) + { + if ( OutArray[ Index ].ABL == (ablexpr *)0 ) continue; + + ScanPath = optimablbinexpr( ABL_AND, + createablatom( PrevScan ), + createablatom( SyfInfo->SCAN_TEST ) ); + + Equation = optimablbinexpr( ABL_AND, + OutArray[ Index ].ABL, + optimablnotexpr( createablatom( SyfInfo->SCAN_TEST ) ) ); + + OutArray[ Index ].ABL = optimablbinexpr( ABL_OR, Equation, ScanPath ); + + PrevScan = OutArray[ Index ].NAME_OUT; + } + } + + ScanSyfOut = FSM_SYF_OUT( ScanOut ); + ScanSyfOut->ABL = createablatom( PrevScan ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeOutAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeOutAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfregout *OutArray; + fsmout_list *ScanOutput; + syfout *ScanSyfOut; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + for ( ScanOutput = FsmFigure->OUT; + ScanOutput != (fsmout_list *)0; + ScanOutput = ScanOutput->NEXT ) + { + ScanSyfOut = FSM_SYF_OUT( ScanOutput ); + + if ( ScanSyfOut->ABL != (ablexpr *)0 ) + { + delablexpr( ScanSyfOut->ABL ); + ScanSyfOut->ABL = (ablexpr *)0; + } + } + + if ( SyfInfo->REG_OUT ) + { + OutArray = SyfInfo->OUT_ARRAY; + + for ( Index = 0; Index < SyfInfo->NUMBER_OUT; Index++ ) + { + if ( OutArray[ Index ].ABL != (ablexpr *)0 ) + { + delablexpr( OutArray[ Index ].ABL ); + OutArray[ Index ].ABL = (ablexpr *)0; + } + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthReg2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthReg2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + fsmstate_list *StarState; + fsmtrans_list *StarTrans; + chain_list *ScanChain; + ablexpr *Equation; + ablexpr *ScanPath; + ablexpr *Stack; + ablexpr *Atom; + ablexpr *AblReset; + ablexpr *AblSet; + syfstate *ScanSyfState; + syfcode *ScanCode; + syfregstate *RegArray; + syfctrl *CtrlArray; + syfregstack *StackArray; + char *PrevScan; + long Index; + long BitMask; + long ScanBit; + char Encode; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + RegArray = SyfInfo->REG_ARRAY; + StackArray = SyfInfo->STACK_ARRAY; + CtrlArray = SyfInfo->CTRL_ARRAY; + Encode = SyfInfo->ENCODE; + + for ( Index = 0; Index < SyfInfo->NUMBER_REG; Index++ ) + { + RegArray[ Index ].ABL = createabloper( ABL_OR ); + RegArray[ Index ].ABL_SET = createabloper( ABL_OR ); + RegArray[ Index ].ABL_RESET = createabloper( ABL_OR ); + } + +/* +** If Code[i] of E(j), Reg(i) <- Reg(i) OR E(j) +*/ + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + ScanCode = ScanSyfState->CODE; + + if ( Encode == SYF_ENCODE_ONE_HOT ) + { + Atom = createablatom( ScanSyfState->NEXT_NAME ); + + addablhexpr( RegArray[ ScanCode->VALUE ].ABL, Atom ); + } + else + { + BitMask = 1; + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + if ( ScanCode->VALUE & BitMask ) + { + Atom = createablatom( ScanSyfState->NEXT_NAME ); + + addablhexpr( RegArray[ ScanBit ].ABL, Atom ); + } + + BitMask = BitMask << 1; + } + } + } + + for ( Index = 0; Index < SyfInfo->NUMBER_REG; Index++ ) + { + Equation = RegArray[ Index ].ABL; + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { +/* +** Reg(i) = OR Null -> Reg(i) = 0 +*/ + Atom = createablatomzero(); + delablexpr( Equation ); + RegArray[ Index ].ABL = Atom; + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { +/* +** Reg(i) = OR E(j) -> Reg(i) = E(j) +*/ + Atom = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + RegArray[ Index ].ABL = Atom; + } + + if ( SyfInfo->STACK ) + { + Atom = createablatom( CtrlArray[ FSM_CTRL_POP ].NAME ); + + Equation = createablatom( StackArray[ Index ].NAME_OUT ); + Stack = optimablbinexpr( ABL_AND, Equation, dupablexpr( Atom ) ); + + Equation = optimablbinexpr( ABL_AND, + RegArray[ Index ].ABL, + optimablnotexpr( Atom ) ); + + RegArray[ Index ].ABL = optimablbinexpr( ABL_OR, Stack, Equation ); + } + } +/* +** Compute the Set and Reset conditions +*/ + StarState = FsmFigure->STAR_STATE; + + if ( StarState != (fsmstate_list *)0 ) + { + for ( ScanChain = StarState->FROM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + StarTrans = (fsmtrans_list *)ScanChain->DATA; + ScanState = StarTrans->TO; + + ScanSyfState = FSM_SYF_STATE( ScanState ); + ScanCode = ScanSyfState->CODE; + + if ( Encode == SYF_ENCODE_ONE_HOT ) + { + Atom = createablatom( ScanSyfState->NEXT_NAME ); + + addablhexpr( RegArray[ ScanCode->VALUE ].ABL_SET, dupablexpr( StarTrans->ABL ) ); + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + if ( ScanBit == ScanCode->VALUE ) continue; + + addablhexpr( RegArray[ ScanBit ].ABL_RESET, dupablexpr( StarTrans->ABL ) ); + } + } + else + { + BitMask = 1; + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + if ( ScanCode->VALUE & BitMask ) + { + addablhexpr( RegArray[ ScanBit ].ABL_SET, dupablexpr( StarTrans->ABL ) ); + } + else + { + addablhexpr( RegArray[ ScanBit ].ABL_RESET, dupablexpr( StarTrans->ABL ) ); + } + + BitMask = BitMask << 1; + } + } + } + } + +/* +** Add Reset and Set conditions +*/ + for ( Index = 0; Index < SyfInfo->NUMBER_REG; Index++ ) + { + Equation = RegArray[ Index ].ABL_SET; + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { + freeablexpr( Equation ); + RegArray[ Index ].ABL_SET = (chain_list *)0; + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { + Atom = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + RegArray[ Index ].ABL_SET = Atom; + } + + Equation = RegArray[ Index ].ABL_RESET; + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { + freeablexpr( Equation ); + RegArray[ Index ].ABL_RESET = (chain_list *)0; + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { + Atom = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + RegArray[ Index ].ABL_RESET = Atom; + } + } + + for ( Index = 0; Index < SyfInfo->NUMBER_REG; Index++ ) + { + AblSet = RegArray[ Index ].ABL_SET; + AblReset = RegArray[ Index ].ABL_RESET; + + RegArray[ Index ].ABL_SET = (ablexpr *)0; + RegArray[ Index ].ABL_RESET = (ablexpr *)0; + + Equation = createablatom( RegArray[ Index ].NAME_IN ); + + if ( AblReset != (ablexpr *)0 ) + { + AblReset = optimablnotexpr( AblReset ); + Equation = optimablbinexpr( ABL_AND, Equation, AblReset ); + } + + if ( AblSet != (ablexpr *)0 ) + { + Equation = optimablbinexpr( ABL_OR, Equation, AblSet ); + } + + RegArray[ Index ].ABL_IN = Equation; + } +/* +** Add a scan path +*/ + if ( SyfInfo->SCAN_PATH ) + { + if ( SyfInfo->STACK ) + { + PrevScan = SyfInfo->SCAN_STACK; + } + else + { + PrevScan = SyfInfo->SCAN_IN; + } + + for ( Index = 0; Index < SyfInfo->NUMBER_REG; Index++ ) + { + ScanPath = optimablbinexpr( ABL_AND, + createablatom( PrevScan ), + createablatom( SyfInfo->SCAN_TEST ) ); + + Equation = optimablbinexpr( ABL_AND, + RegArray[ Index ].ABL_IN, + optimablnotexpr( createablatom( SyfInfo->SCAN_TEST ) ) ); + + RegArray[ Index ].ABL_IN = optimablbinexpr( ABL_OR, Equation, ScanPath ); + + PrevScan = RegArray[ Index ].NAME_OUT; + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeRegAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeRegAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfregstate *RegArray; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + RegArray = SyfInfo->REG_ARRAY; + + for ( Index = 0; Index < SyfInfo->NUMBER_REG; Index++ ) + { + if ( RegArray[ Index ].ABL != (ablexpr *)0 ) + { + delablexpr( RegArray[ Index ].ABL ); + RegArray[ Index ].ABL = (ablexpr *)0; + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthCode2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthCode2Abl( FsmFigure, FlagDc ) + + fsmfig_list *FsmFigure; + int FlagDc; +{ + syfinfo *SyfInfo; + syfcode *CodeArray; + syfregstate *RegArray; + ablexpr *Equation; + ablexpr *EquationOut; + long Index; + long BitMask; + long ScanBit; + char DecodeOut; + char Encode; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + Encode = SyfInfo->ENCODE; + + if ( ( Encode != SYF_ENCODE_ONE_HOT ) && + ( Encode != SYF_ENCODE_FRANCK ) && + ( FlagDc ) ) + { + SyfSynthCodeDc2Abl( FsmFigure ); return; + } + + CodeArray = SyfInfo->CODE_ARRAY; + RegArray = SyfInfo->REG_ARRAY; + DecodeOut = ( SyfInfo->REG_OUT ) && ( SyfInfo->STACK ); + + for ( Index = 0; Index < SyfInfo->NUMBER_CODE; Index++ ) + { + if ( Encode == SYF_ENCODE_ONE_HOT ) + { + Equation = createablatom( RegArray[ Index ].NAME_OUT ); + + if ( DecodeOut ) + { + EquationOut = createablatom( RegArray[ Index ].NAME_IN ); + } + } + else + if ( SyfInfo->NUMBER_BIT < 2 ) + { + Equation = createablatom( RegArray[ 0 ].NAME_OUT ); + + if ( DecodeOut ) + { + EquationOut = createablatom( RegArray[ 0 ].NAME_IN ); + } + + if ( ! CodeArray[ Index ].VALUE ) + { + Equation = optimablnotexpr( Equation ); + + if ( DecodeOut ) + { + EquationOut = optimablnotexpr( EquationOut ); + } + } + } + else + { + Equation = createabloper( ABL_AND ); + BitMask = 1; + + if ( DecodeOut ) + { + EquationOut = createabloper( ABL_AND ); + } + + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + if ( CodeArray[ Index ].VALUE & BitMask ) + { + addablhexpr( Equation, + createablatom( RegArray[ ScanBit ].NAME_OUT ) ); + + if ( DecodeOut ) + { + addablhexpr( EquationOut, + createablatom( RegArray[ ScanBit ].NAME_IN ) ); + } + } + else + { + addablhexpr( Equation, + optimablnotexpr( createablatom( RegArray[ ScanBit ].NAME_OUT ) ) ); + + if ( DecodeOut ) + { + addablhexpr( EquationOut, + optimablnotexpr( createablatom( RegArray[ ScanBit ].NAME_IN ) ) ); + + } + } + + BitMask = BitMask << 1; + } + } + + CodeArray[ Index ].ABL = Equation; + + if ( DecodeOut ) + { + CodeArray[ Index ].ABL_OUT = EquationOut; + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeCodeAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeCodeAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + syfcode *CodeArray; + long Index; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeArray = SyfInfo->CODE_ARRAY; + + for ( Index = 0; Index < SyfInfo->NUMBER_CODE; Index++ ) + { + if ( CodeArray[ Index ].ABL != (ablexpr *)0 ) + { + delablexpr( CodeArray[ Index ].ABL ); + CodeArray[ Index ].ABL = (ablexpr *)0; + } + + if ( CodeArray[ Index ].ABL_OUT != (ablexpr *)0 ) + { + delablexpr( CodeArray[ Index ].ABL_OUT ); + CodeArray[ Index ].ABL_OUT = (ablexpr *)0; + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthTrans2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthTrans2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + syfstate *FromSyfState; + ablexpr *ScanChain; + ablexpr *Atom; + fsmtrans_list *ScanTrans; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanChain = ScanState->TO; + ScanSyfState = FSM_SYF_STATE( ScanState ); + + if ( ScanChain == (ablexpr *)0 ) + { +/* +** No transition to E(i) +*/ + ScanSyfState->ABL_TRANS = createablatomzero(); + } + else + if ( ScanChain->NEXT == (ablexpr *)0 ) + { +/* +** One transition to E(i) +*/ + ScanTrans = (fsmtrans_list *)( ScanChain->DATA ); + + if ( IsFsmStarTrans( ScanTrans ) ) + { + ScanSyfState->ABL_TRANS = createablatomzero(); + } + else + { + FromSyfState = FSM_SYF_STATE( ScanTrans->FROM ); + + Atom = createablatom( FromSyfState->CURRENT_NAME ); + + ScanSyfState->ABL_TRANS = + + optimablbinexpr( ABL_AND, Atom, dupablexpr( ScanTrans->ABL ) ); + } + } + else + { +/* +** More than one transition to E(i) +*/ + ScanSyfState->ABL_TRANS = createabloper( ABL_OR ); + + while ( ScanChain != (ablexpr *)0 ) + { + ScanTrans = (fsmtrans_list *)( ScanChain->DATA ); + + if ( IsFsmStarTrans( ScanTrans ) ) + { + addablhexpr( ScanSyfState->ABL_TRANS, createablatomzero() ); + } + else + { + FromSyfState = FSM_SYF_STATE( ScanTrans->FROM ); + + Atom = createablatom( FromSyfState->CURRENT_NAME ); + + addablhexpr( ScanSyfState->ABL_TRANS, + optimablbinexpr( ABL_AND, + Atom, dupablexpr( ScanTrans->ABL ) ) ); + + } + + ScanChain = ScanChain->NEXT; + } + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeTransAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeTransAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstate_list *ScanState; + syfstate *ScanSyfState; + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanSyfState = FSM_SYF_STATE( ScanState ); + + if ( ScanSyfState->ABL_TRANS != (ablexpr *)0 ) + { + delablexpr( ScanSyfState->ABL_TRANS ); + ScanSyfState->ABL_TRANS = (ablexpr *)0; + } + } +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFsm2Abl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFsm2Abl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + SyfSynthTrans2Abl( FsmFigure ); + SyfSynthReturn2Abl( FsmFigure ); + SyfSynthOut2Abl( FsmFigure ); + SyfSynthCtrl2Abl( FsmFigure ); + SyfSynthStack2Abl( FsmFigure ); + SyfSynthReg2Abl( FsmFigure ); +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFreeFsmAbl | +| | +\------------------------------------------------------------*/ + +void SyfSynthFreeFsmAbl( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + SyfSynthFreeTransAbl( FsmFigure ); + SyfSynthFreeReturnAbl( FsmFigure ); + SyfSynthFreeOutAbl( FsmFigure ); + SyfSynthFreeCtrlAbl( FsmFigure ); + SyfSynthFreeStackAbl( FsmFigure ); + SyfSynthFreeRegAbl( FsmFigure ); +} + +/*------------------------------------------------------------\ +| | +| SyfSynthFsmInit | +| | +\------------------------------------------------------------*/ + +void SyfSynthFsmInit( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + syfinfo *SyfInfo; + char Buffer[ 25 ]; + syfregstate *RegArray; + long RegMax; + syfregout *OutArray; + long OutMax; + syfregstack *StackArray; + long StackMax; + syfctrl *CtrlArray; + long CtrlMax; + long Index; + long Stack; + long ScanBit; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + RegMax = SyfInfo->NUMBER_BIT; + RegArray = (syfregstate *)autallocblock( sizeof( syfregstate ) * RegMax ); + + for ( Index = 0; Index < RegMax; Index++ ) + { + sprintf( Buffer, "%s %ld", SyfInfo->CURRENT_STATE, Index ); + RegArray[ Index ].NAME_OUT = namealloc( Buffer ); + sprintf( Buffer, "%s %ld", SyfInfo->NEXT_STATE, Index ); + RegArray[ Index ].NAME_IN = namealloc( Buffer ); + RegArray[ Index ].NAME_MASTER = RegArray[ Index ].NAME_OUT; + } + + SyfInfo->REG_ARRAY = RegArray; + SyfInfo->NUMBER_REG = RegMax; + + if ( SyfInfo->REG_OUT ) + { + if ( SyfInfo->SCAN_PATH ) + { + OutMax = FsmFigure->NUMBER_OUT - 1; + } + else + { + OutMax = FsmFigure->NUMBER_OUT; + } + + OutArray = (syfregout *)autallocblock( sizeof( syfregout ) * OutMax ); + + for ( Index = 0; Index < OutMax; Index++ ) + { + sprintf( Buffer, "regouts_%ld", Index ); + OutArray[ Index ].NAME_OUT = namealloc( Buffer ); + OutArray[ Index ].NAME_MASTER = OutArray[ Index ].NAME_OUT; + } + + SyfInfo->OUT_ARRAY = OutArray; + SyfInfo->NUMBER_OUT = OutMax; + } + + if ( SyfInfo->STACK ) + { + CtrlMax = FSM_MAX_CTRL; + StackMax = FsmFigure->STACK_SIZE * SyfInfo->NUMBER_REG; + CtrlArray = (syfctrl *)autallocblock( sizeof( syfctrl ) * CtrlMax ); + StackArray = (syfregstack *)autallocblock( sizeof( syfregstack ) * StackMax ); + + for ( Index = 0; Index < CtrlMax; Index++ ) + { + sprintf( Buffer, "ctrl_%s", FSM_CTRL_NAME[ Index ] ); + CtrlArray[ Index ].NAME = namealloc( Buffer ); + } + + SyfInfo->NUMBER_CTRL = CtrlMax; + SyfInfo->CTRL_ARRAY = CtrlArray; + + Index = 0; + + for ( Stack = 0; Stack < FsmFigure->STACK_SIZE; Stack++ ) + { + for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ ) + { + sprintf( Buffer, "stacks_%ld_%ld", Stack, ScanBit ); + StackArray[ Index ].NAME_OUT = namealloc( Buffer ); + StackArray[ Index ].NAME_MASTER = StackArray[ Index ].NAME_OUT; + + Index = Index + 1; + } + } + + SyfInfo->NUMBER_STACK = StackMax; + SyfInfo->STACK_ARRAY = StackArray; + } +} diff --git a/alliance/src/syf/src/syf_synth.h b/alliance/src/syf/src/syf_synth.h new file mode 100644 index 00000000..f78cbfbd --- /dev/null +++ b/alliance/src/syf/src/syf_synth.h @@ -0,0 +1,88 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_synth.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_SYNTH_H +# define SYF_SYNTH_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfSynthStack2Abl(); + extern void SyfSynthCtrl2Abl(); + extern void SyfSynthOut2Abl(); + extern void SyfSynthReg2Abl(); + extern void SyfSynthCode2Abl(); + extern void SyfSynthTrans2Abl(); + extern void SyfSynthFsm2Abl(); + + extern void SyfSynthFreeStackAbl(); + extern void SyfSynthFreeCtrlAbl(); + extern void SyfSynthFreeOutAbl(); + extern void SyfSynthFreeRegAbl(); + extern void SyfSynthFreeCodeAbl(); + extern void SyfSynthFreeTransAbl(); + extern void SyfSynthFreeFsmAbl(); + + extern void SyfSynthFsmInit(); + +# endif diff --git a/alliance/src/syf/src/syf_tools.c b/alliance/src/syf/src/syf_tools.c new file mode 100644 index 00000000..612aea40 --- /dev/null +++ b/alliance/src/syf/src/syf_tools.c @@ -0,0 +1,159 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_tools.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include +# include "syf_tools.h" +# include "syf_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfGetNumberBit | +| | +\------------------------------------------------------------*/ + +int SyfGetNumberBit( Value ) + + long Value; +{ + long Mask; + int NumberBit; + + Mask = 1 << 31; + + for ( NumberBit = 32; NumberBit > 0; NumberBit-- ) + { + if ( Mask & Value ) return( NumberBit ); + + Mask = Mask >> 1; + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| SyfGetHamingDistance | +| | +\------------------------------------------------------------*/ + +int SyfGetHamingDistance( First, Second, Bits ) + + int First; + int Second; + int Bits; +{ + register int Mask; + register int Counter; + register int Distance; + + First = First ^ Second; + Distance = 0; + Mask = 1; + + for( Counter = 0; Counter < Bits; Counter++ ) + { + if( Mask & First ) Distance++; + + Mask = Mask << 1; + } + + return( Distance ); +} + +/*------------------------------------------------------------\ +| | +| SyfGetNumberBitSet | +| | +\------------------------------------------------------------*/ + +int SyfGetNumberBitSet( Number, Bits ) + + int Number; + int Bits; +{ + int Mask; + int Counter; + int BitSet; + + Mask = 1; + BitSet = 0; + + for( Counter = 0; Counter < Bits; Counter++ ) + { + if( Mask & Number ) BitSet++; + + Mask = Mask << 1; + } + + return( BitSet ); +} diff --git a/alliance/src/syf/src/syf_tools.h b/alliance/src/syf/src/syf_tools.h new file mode 100644 index 00000000..3916407a --- /dev/null +++ b/alliance/src/syf/src/syf_tools.h @@ -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 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 : SYF | +| | +| File : syf_tools.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_TOOLS_H +# define SYF_TOOLS_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern int SyfGetHamingDistance(); + extern int SyfGetNumberBit(); + extern int SyfGetNumberBitSet(); + +# endif diff --git a/alliance/src/syf/src/syf_user.c b/alliance/src/syf/src/syf_user.c new file mode 100644 index 00000000..093fe006 --- /dev/null +++ b/alliance/src/syf/src/syf_user.c @@ -0,0 +1,339 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_user.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include +# include + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include "syf_fsm.h" +# include "syf_error.h" +# include "syf_user.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static char SyfUserBuffer[ SYF_USER_BUFFER_SIZE ]; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmUserSaveCode | +| | +\------------------------------------------------------------*/ + +void SyfFsmUserSaveCode( FsmFigure, FileName ) + + fsmfig_list *FsmFigure; + char *FileName; +{ + FILE *UserFile; + fsmstate_list *ScanState; + syfinfo *SyfInfo; + long Value; + long Bit; + char OneHot; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + UserFile = mbkfopen( FileName, "enc", "w" ); + + if ( UserFile == (FILE *)0 ) + { + SyfError( SYF_ERROR_OPEN_FILE, FileName ); + } + + fprintf( UserFile, "# Encoding figure \"%s\"\n", FsmFigure->NAME ); + fprintf( UserFile, "-%c %ld\n" , SyfInfo->ENCODE, SyfInfo->NUMBER_BIT ); + + OneHot = ( SyfInfo->ENCODE == SYF_ENCODE_ONE_HOT ); + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + Value = FSM_SYF_STATE( ScanState )->CODE->VALUE; + + fprintf( UserFile,"%s\t%lX", ScanState->NAME, Value ); + + if ( OneHot ) + { + Bit = Value & 0x03; + + fprintf( UserFile, "\t%lX", (long)( 1 << Bit ) ); + + Value = Value - Bit; + + while ( Value > 0 ) + { + Value = Value - 4; + + fprintf( UserFile, "0" ); + } + } + + if ( IsFsmFirstState( ScanState ) ) fprintf( UserFile, "\tFirst state" ); + + fprintf( UserFile, "\n" ); + } + + fclose( UserFile ); +} + +/*------------------------------------------------------------\ +| | +| SyfFsmUserEncode | +| | +\------------------------------------------------------------*/ + +void SyfFsmUserEncode( FsmFigure, FileName ) + + fsmfig_list *FsmFigure; + char *FileName; +{ + FILE *UserFile; + syfinfo *SyfInfo; + syfcode *CodeArray; + fsmstate_list *ScanState; + syfstate *ScanSyfState; + char *ScanBuffer; + authtable *HashTable; + authelem *Element; + char *StateName; + unsigned long StateCode; + long NumberState; + long NumberBit; + long CurrentLine; + unsigned long CodeMax; + long Index; + long Error; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + CodeMax = SyfInfo->NUMBER_CODE; + CodeArray = SyfInfo->CODE_ARRAY; + NumberState = FsmFigure->NUMBER_STATE; + + for ( Index = 0; Index < CodeMax; Index++ ) + { + CodeArray[ Index ].VALUE = Index; + } + + HashTable = createauthtable( NumberState << 1 ); + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + addauthelem( HashTable, ScanState->NAME, (long)ScanState ); + } + + UserFile = mbkfopen( FileName, "enc", "r" ); + + if ( UserFile == (FILE *)0 ) + { + SyfError( SYF_ERROR_OPEN_FILE, FileName ); + } + + CurrentLine = 1; + Error = 0; + + while ( fgets( SyfUserBuffer, + SYF_USER_BUFFER_SIZE, + UserFile ) != (char *)0 ) + { + for ( Index = 0; SyfUserBuffer[ Index ] != '\0'; Index++ ) + { + if ( ! isspace( SyfUserBuffer[ Index ] ) ) break; + } + + ScanBuffer = SyfUserBuffer + Index; + + if ( ScanBuffer[ 0 ] == '-' ) + { + if ( ScanBuffer[ 1 ] == SYF_ENCODE_ONE_HOT ) + { + CodeMax = NumberState; + + autfreeblock( (char *)CodeArray ); + CodeArray = (syfcode *)autallocblock( sizeof( syfcode ) * CodeMax ); + + SyfInfo->CODE_ARRAY = CodeArray; + SyfInfo->NUMBER_CODE = CodeMax; + SyfInfo->NUMBER_BIT = CodeMax; + SyfInfo->ENCODE = SYF_ENCODE_ONE_HOT; + + for ( Index = 0; Index < CodeMax; Index++ ) + { + CodeArray[ Index ].VALUE = Index; + } + } + else + if ( ScanBuffer[ 1 ] == SYF_ENCODE_FRANCK ) + { + NumberBit = atoi( &ScanBuffer[ 2 ] ); + + if ( ( NumberBit > SyfInfo->NUMBER_BIT ) && + ( NumberBit < 32 ) ) + { + CodeMax = 1 << NumberBit; + + autfreeblock( (char *)CodeArray ); + CodeArray = (syfcode *)autallocblock( sizeof( syfcode ) * NumberState ); + + SyfInfo->CODE_ARRAY = CodeArray; + SyfInfo->NUMBER_CODE = NumberState; + SyfInfo->NUMBER_BIT = NumberBit; + SyfInfo->ENCODE = SYF_ENCODE_FRANCK; + } + else + { + Error = SYF_ERROR_SYNTAX; break; + } + } + } + else + if ( ( ScanBuffer[ 0 ] != '#' ) && + ( ScanBuffer[ 0 ] != '\0' ) ) + { + StateCode = -1; + StateName = (char *)0; + + for ( Index = 0; ScanBuffer[ Index ] != '\0'; Index++ ) + { + if ( ( isspace( ScanBuffer[ Index ] ) ) && + ( ScanBuffer[ Index + 1 ] != '\0' ) ) + { + StateName = ScanBuffer; + ScanBuffer[ Index ] = '\0'; + sscanf( ScanBuffer + Index + 1, "%lx", &StateCode ); + + break; + } + } + + if ( StateName == (char *)0 ) + { + Error = SYF_ERROR_SYNTAX; break; + } + + if ( ( (long)StateCode < 0 ) || + ( StateCode >= CodeMax ) ) + { + Error = SYF_ERROR_WRONG_CODE; break; + } + + StateName = namealloc( StateName ); + Element = searchauthelem( HashTable, StateName ); + + if ( Element == (authelem *)0 ) + { + Error = SYF_ERROR_UNKNOWN_STATE; break; + } + + ScanState = (fsmstate_list *)Element->VALUE; + ScanSyfState = FSM_SYF_STATE( ScanState ); + + if ( ScanSyfState->CODE != (syfcode *)0 ) + { + Error = SYF_ERROR_DUPLICATE_CODE; break; + } + + if ( SyfInfo->ENCODE != SYF_ENCODE_FRANCK ) + { + if ( CodeArray[ StateCode ].USED ) + { + Error = SYF_ERROR_DUPLICATE_CODE; break; + } + + CodeArray[ StateCode ].USED = 1; + ScanSyfState->CODE = &CodeArray[ StateCode ]; + } + else + { + CodeArray[ NumberState - 1 ].USED = 1; + CodeArray[ NumberState - 1 ].VALUE = StateCode; + ScanSyfState->CODE = &CodeArray[ NumberState - 1 ]; + } + + NumberState--; + } + + CurrentLine++; + } + + if ( ( ! Error ) && + ( NumberState != 0 ) ) Error = SYF_ERROR_UNEXPECTED_EOF; + + if ( Error ) + { + sprintf( SyfUserBuffer, "line %ld in file \"%s.enc\"", CurrentLine, FileName ); + SyfError( Error, SyfUserBuffer ); + } + + destroyauthtable( HashTable ); + + fclose( UserFile ); +} diff --git a/alliance/src/syf/src/syf_user.h b/alliance/src/syf/src/syf_user.h new file mode 100644 index 00000000..479cc291 --- /dev/null +++ b/alliance/src/syf/src/syf_user.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_user.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_USER_H +# define SYF_USER_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define SYF_USER_BUFFER_SIZE 512 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmUserEncode(); + extern void SyfFsmUserSaveCode(); + +# endif diff --git a/alliance/src/syf/src/syf_verify.c b/alliance/src/syf/src/syf_verify.c new file mode 100644 index 00000000..007d75df --- /dev/null +++ b/alliance/src/syf/src/syf_verify.c @@ -0,0 +1,957 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_verify.c | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include ABL_H +# include BDD_H +# include FSM_H + +# include +# include +# include +# include "syf_fsm.h" +# include "syf_env.h" +# include "syf_bdd.h" +# include "syf_tools.h" +# include "syf_verify.h" +# include "syf_error.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| SyfFsmVerifyMooreExpr | +| | +\------------------------------------------------------------*/ + +int SyfFsmVerifyMooreExpr( FsmFigure, Equation ) + + fsmfig_list *FsmFigure; + chain_list *Equation; +{ + char *Value; + + if ( Equation == (chain_list *)0 ) + { + return( 0 ); + } + + if ( ABL_ATOM( Equation ) ) + { + Value = ABL_ATOM_VALUE( Equation ); + + if ( ( Value != ABL_ATOM_NAME_ZERO ) && + ( Value != ABL_ATOM_NAME_ONE ) && + ( Value != ABL_ATOM_NAME_DC ) ) + { + if ( searchfsmin( FsmFigure, Value ) ) + { + return( 1 ); + } + } + } + else + { + while ( ( Equation = ABL_CDR( Equation ) ) != (ablexpr *)0 ) + { + if ( SyfFsmVerifyMooreExpr( FsmFigure, ABL_CAR( Equation ) ) ) + { + return( 1 ); + } + } + } + + return( 0 ); +} + +/*------------------------------------------------------------\ +| | +| SyfVerifyExclusivity | +| | +\------------------------------------------------------------*/ + +static void SyfVerifyExclusivity( ScanState, StarState ) + + fsmstate_list *ScanState; + fsmstate_list *StarState; +{ + chain_list *ScanChain; + chain_list *ScanNext; + fsmtrans_list *ScanTrans; + fsmtrans_list *NextTrans; + fsmstack_list *ScanStack; + fsmstack_list *NextStack; + bddnode *TransCond; + bddnode *NextCond; + bddnode *ProductCond; + char Counter; + char NextCounter; + + Counter = 0; + ScanChain = ScanState->FROM; + + while ( Counter < 4 ) + { + while ( ScanChain != (chain_list *)0 ) + { + if ( Counter & 0x1 ) + { + ScanStack = (fsmstack_list *)ScanChain->DATA; + TransCond = ScanStack->BDD; + + if ( ScanStack->CTRL != FSM_CTRL_POP ) + { + ScanChain = ScanChain->NEXT; continue; + } + } + else + { + ScanTrans = (fsmtrans_list *)ScanChain->DATA; + TransCond = ScanTrans->BDD; + } + + NextCounter = Counter; + ScanNext = ScanChain->NEXT; + + while ( NextCounter < 4 ) + { + while ( ScanNext != (chain_list *)0 ) + { + if ( NextCounter & 0x1 ) + { + NextStack = (fsmstack_list *)ScanNext->DATA; + NextCond = NextStack->BDD; + + if ( NextStack->CTRL != FSM_CTRL_POP ) + { + ScanNext = ScanNext->NEXT; continue; + } + } + else + { + NextTrans = (fsmtrans_list *)ScanNext->DATA; + NextCond = NextTrans->BDD; + } + + ProductCond = applybddnode( (bddsystem *)0, ABL_AND, NextCond, TransCond ); + + if ( ProductCond != BddLocalSystem->ZERO ) + { + SyfWarning( SYF_WARNING_INTER_TRANS, ScanState->NAME, NULL ); + } + + ScanNext = ScanNext->NEXT; + } + + NextCounter = NextCounter + 1; + + if ( ( NextCounter > 1 ) && + ( StarState == (fsmstate_list *)0 ) ) break; + + if ( NextCounter == 1 ) ScanNext = ScanState->STACK; + else + if ( NextCounter == 2 ) ScanNext = StarState->FROM; + else ScanNext = StarState->STACK; + } + + ScanChain = ScanChain->NEXT; + } + + Counter = Counter + 1; + + + if ( ( Counter > 1 ) && + ( StarState == (fsmstate_list *)0 ) ) break; + + if ( Counter == 1 ) ScanChain = ScanState->STACK; + else + if ( Counter == 2 ) ScanChain = StarState->FROM; + else ScanChain = StarState->STACK; + } +} + +/*------------------------------------------------------------\ +| | +| SyfVerifyCompletly | +| | +\------------------------------------------------------------*/ + +static void SyfVerifyCompletly( ScanState, SumStar ) + + fsmstate_list *ScanState; + bddnode *SumStar; +{ + chain_list *ScanChain; + fsmtrans_list *ScanTrans; + fsmstack_list *ScanStack; + bddnode *TransCond; + bddnode *SumCond; + char Stack; + + SumCond = SumStar; + Stack = 0; + ScanChain = ScanState->FROM; + + while ( Stack < 2 ) + { + while ( ScanChain != (chain_list *)0 ) + { + if ( ! Stack ) + { + ScanTrans = (fsmtrans_list *)ScanChain->DATA; + TransCond = ScanTrans->BDD; + } + else + { + ScanStack = (fsmstack_list *)ScanChain->DATA; + TransCond = ScanStack->BDD; + + if ( ScanStack->CTRL != FSM_CTRL_POP ) + { + ScanChain = ScanChain->NEXT; + + continue; + } + } + + SumCond = applybddnode( (bddsystem *)0, ABL_OR, SumCond, TransCond ); + ScanChain = ScanChain->NEXT; + } + + ScanChain = ScanState->STACK; + Stack = Stack + 1; + } + + if ( SumCond != BddLocalSystem->ONE ) + { + SyfWarning( SYF_WARNING_SUM_TRANS, ScanState->NAME, NULL ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfVerifyTransistion | +| | +\------------------------------------------------------------*/ + +static void SyfVerifyTransition( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + bddsystem *BddSystem; + bddcircuit *BddCircuit; + fsmstate_list *ScanState; + fsmstate_list *StarState; + chain_list *ScanChain; + fsmtrans_list *StarTrans; + fsmstack_list *StarStack; + bddnode *TransCond; + bddnode *SumStar; + char Stack; + + if ( FsmFigure->CIRCUIT == (bddcircuit *)0 ) + { + BddSystem = createbddsystem( SYF_BDD_VAR_NODE, SYF_BDD_OPER_NODE, 1000, SYF_BDD_MAX_NODE ); + reorderbddsystemdynamic( BddSystem, SYF_BDD_REORDER_FUNC, + SYF_BDD_REORDER_NODE, SYF_BDD_REORDER_RATIO ); + BddCircuit = SyfFsmMakeBddCircuit( BddSystem, FsmFigure ); + reorderbddsystemsimple( BddSystem ); + } + else + { + BddCircuit = FsmFigure->CIRCUIT; + BddSystem = BddCircuit->BDD_SYSTEM; + + setbddlocalcircuit( BddCircuit ); + setbddlocalsystem( BddSystem ); + } +/* +** Compute Sum Star Transitions +*/ + SumStar = BddLocalSystem->ZERO; + StarState = FsmFigure->STAR_STATE; + + if ( StarState != (fsmstate_list *)0 ) + { + Stack = 0; + ScanChain = StarState->FROM; + + while ( Stack < 2 ) + { + while ( ScanChain != (chain_list *)0 ) + { + if ( ! Stack ) + { + StarTrans = (fsmtrans_list *)ScanChain->DATA; + TransCond = StarTrans->BDD; + } + else + { + StarStack = (fsmstack_list *)ScanChain->DATA; + TransCond = StarStack->BDD; + + if ( StarStack->CTRL != FSM_CTRL_POP ) + { + ScanChain = ScanChain->NEXT; continue; + } + } + + decbddrefext( SumStar ); + SumStar = applybddnode( (bddsystem *)0, ABL_OR, SumStar, TransCond ); + ScanChain = ScanChain->NEXT; + } + + ScanChain = StarState->STACK; + Stack = Stack + 1; + } + } + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + SyfVerifyCompletly( ScanState, SumStar ); + SyfVerifyExclusivity( ScanState, StarState ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmVerify | +| | +\------------------------------------------------------------*/ + +void SyfFsmVerify( FsmFigure, FlagVerify ) + + fsmfig_list *FsmFigure; + int FlagVerify; +{ + syfinfo *SyfInfo; + fsmstate_list *ScanState; + fsmstack_list *ScanStack; + fsmlocout_list *ScanLocout; + chain_list *ScanChain; + char TypeMoore; + int NumberPush; + int NumberPop; + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + if ( SyfInfo->STACK ) + { + NumberPush = 0; + NumberPop = 0; + + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) NumberPush++; + else + if ( ScanStack->CTRL == FSM_CTRL_POP ) NumberPop++; + } + + if ( ( NumberPush == 0 ) && + ( NumberPop == 0 ) ) + { + FsmFigure->STACK_SIZE = 0; + + while ( FsmFigure->STACK != (fsmstack_list *)0 ) + { + delfsmstack( FsmFigure, FsmFigure->STACK ); + } + + SyfWarning( SYF_WARNING_REMOVE_UNUSED_STACK, FsmFigure->NAME, NULL ); + } + else + if ( NumberPop == 0 ) + { + SyfError( SYF_ERROR_BAD_STACK_NO_POP, FsmFigure->NAME ); + } + else + if ( NumberPush == 0 ) + { + SyfError( SYF_ERROR_BAD_STACK_NO_PUSH, FsmFigure->NAME ); + } + } + + TypeMoore = 1; + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + if ( IsFsmStarState( ScanState ) ) continue; + + if ( ScanState->TO == (chain_list *)0 ) + { +/* +** No transition to E(i) +*/ + if ( SyfInfo->STACK ) + { + for ( ScanStack = FsmFigure->STACK; + ScanStack != (fsmstack_list *)0; + ScanStack = ScanStack->NEXT ) + { + if ( ( ScanStack->CTRL == FSM_CTRL_PUSH ) && + ( ScanStack->RETURN == ScanState ) ) + { + break; + } + } +/* +** No stack transition to E(i) +*/ + if ( ScanStack == (fsmstack_list *)0 ) + { + SyfWarning( SYF_WARNING_NO_TRANS_TO, ScanState->NAME, NULL ); + } + } + else + { + SyfWarning( SYF_WARNING_NO_TRANS_TO, ScanState->NAME, NULL ); + } + } + + if ( ScanState->FROM == (chain_list *)0 ) + { +/* +** No transition from E(i) +*/ + if ( SyfInfo->STACK ) + { + for ( ScanChain = ScanState->STACK; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + ScanStack = (fsmstack_list *)(ScanChain->DATA); + + if ( ScanStack->CTRL == FSM_CTRL_POP ) + { + break; + } + } +/* +** No stack transition from E(i) +*/ + if ( ScanChain == (chain_list *)0 ) + { + SyfWarning( SYF_WARNING_NO_TRANS_FROM, ScanState->NAME, NULL ); + } + } + else + { + SyfWarning( SYF_WARNING_NO_TRANS_FROM, ScanState->NAME, NULL ); + } + } + + if ( TypeMoore ) + { + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + if ( SyfFsmVerifyMooreExpr( FsmFigure, ScanLocout->ABL ) ) + { + TypeMoore = 0; + } + } + } + } + + if ( TypeMoore ) + { + SyfInfo->FSM_TYPE = SYF_FSM_TYPE_MOORE; + } + else + { + SyfInfo->FSM_TYPE = SYF_FSM_TYPE_MEALY; + } + + if ( FlagVerify ) + { + SyfVerifyTransition( FsmFigure ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmOutputPolarity | +| | +\------------------------------------------------------------*/ + +void SyfFsmOutputPolarity( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstate_list *ScanState; + fsmstate_list *StarState; + chain_list *ScanChain; + fsmtrans_list *ScanTrans; + fsmlocout_list *ScanLocout; + fsmout_list *ScanOut; + syfout *SyfOut; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + bddnode *BddOne; + bddnode *BddZero; + bddnode *BddNode; + + if ( FsmFigure->CIRCUIT == (bddcircuit *)0 ) + { + BddSystem = createbddsystem( SYF_BDD_VAR_NODE, SYF_BDD_OPER_NODE, 1000, SYF_BDD_MAX_NODE ); + reorderbddsystemdynamic( BddSystem, SYF_BDD_REORDER_FUNC, + SYF_BDD_REORDER_NODE, SYF_BDD_REORDER_RATIO ); + BddCircuit = SyfFsmMakeBddCircuit( BddSystem, FsmFigure ); + reorderbddsystemsimple( BddSystem ); + } + else + { + BddCircuit = FsmFigure->CIRCUIT; + BddSystem = BddCircuit->BDD_SYSTEM; + + setbddlocalcircuit( BddCircuit ); + setbddlocalsystem( BddSystem ); + } + + StarState = FsmFigure->STAR_STATE; + BddOne = BddSystem->ONE; + BddZero = BddSystem->ZERO; + + if ( StarState != (fsmstate_list *)0 ) + { + BddOne = BddSystem->ZERO; + + for ( ScanChain = StarState->FROM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + ScanTrans = (fsmtrans_list *)ScanChain->DATA; + BddOne = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddOne ), ScanTrans->BDD ); + } + + if ( StarState->FROM == (chain_list *)0 ) + { + StarState = (fsmstate_list *)0; + } + + BddOne = applybddnodenot( (bddsystem *)0, decbddrefext( BddOne ) ); + } + + if ( StarState != (fsmstate_list *)0 ) + { + ScanState = StarState; + ScanState->NEXT = FsmFigure->STATE; + } + else + { + ScanState = FsmFigure->STATE; + } + + while ( ScanState != (fsmstate_list *)0 ) + { + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + if ( ScanLocout->ABL == (ablexpr *)0 ) continue; + + if ( ScanLocout->BDD == (bddnode *)0 ) + { + ScanLocout->BDD = addbddcircuitabl( BddCircuit, ScanLocout->ABL ); + } + + ScanOut = ScanLocout->OUT; + SyfOut = FSM_SYF_OUT( ScanOut ); + + SyfOut->NUMBER_ASSIGN++; + + if ( ScanState != StarState ) + { + if ( ScanLocout->BDD == BddOne ) SyfOut->NUMBER_ONE++; + else + if ( ScanLocout->BDD == BddZero ) SyfOut->NUMBER_ZERO++; + } + } + + ScanState = ScanState->NEXT; + } + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + SyfOut = FSM_SYF_OUT( ScanOut ); + + if ( ( SyfOut->NUMBER_ASSIGN < FsmFigure->NUMBER_STATE ) && + ( SyfOut->NUMBER_ASSIGN != 0 ) ) + { + SyfWarning( SYF_WARNING_OUTPUT_NOT_ASSIGNED, ScanOut->NAME, SyfOut->NUMBER_ASSIGN ); + } + + if ( SyfOut->NUMBER_ONE > SyfOut->NUMBER_ZERO ) + { + SyfOut->POLARITY = 1; + SyfWarning( SYF_WARNING_MODIFY_POLARITY, ScanOut->NAME, NULL ); + } + } + + if ( StarState != (fsmstate_list *)0 ) ScanState = StarState; + else ScanState = FsmFigure->STATE; + + while ( ScanState != (fsmstate_list *)0 ) + { + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + ScanOut = ScanLocout->OUT; + SyfOut = FSM_SYF_OUT( ScanOut ); + + if ( SyfOut->POLARITY ) + { + if ( ScanState == StarState ) + { + BddNode = ScanLocout->BDD; + BddNode = applybddnode( (bddsystem *)0, ABL_NOR, BddNode, BddOne ); + } + else + { + BddNode = ScanLocout->BDD; + BddNode = applybddnodenot( (bddsystem *)0, BddNode ); + BddNode = applybddnode( (bddsystem *)0, ABL_AND, decbddrefext( BddNode ), BddOne ); + } + + freeablexpr( ScanLocout->ABL ); + ScanLocout->ABL = convertbddcircuitabl( (bddcircuit *)0, BddNode ); + + decbddrefext( ScanLocout->BDD ); + ScanLocout->BDD = BddNode; + + freeablexpr( ScanLocout->ABL_DC ); + ScanLocout->ABL_DC = (ablexpr *)0; + } + } + + ScanState = ScanState->NEXT; + } + + decbddrefext( BddOne ); + decbddrefext( BddZero ); + + if ( StarState != (fsmstate_list *)0 ) + { + StarState->NEXT = (fsmstate_list *)0; + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmSimplify | +| | +\------------------------------------------------------------*/ + +void SyfFsmSimplify( FsmFigure, FlagSimplify ) + + fsmfig_list *FsmFigure; + int FlagSimplify; +{ + bddsystem *BddSystem; + bddcircuit *BddCircuit; + syfinfo *SyfInfo; + fsmstate_list *ScanState; + fsmstack_list *ScanStack; + fsmstack_list *DelStack; + fsmlocout_list *ScanLocout; + fsmlocout_list *DelLocout; + fsmtrans_list *ScanTrans; + fsmtrans_list *DelTrans; + + if ( FlagSimplify ) + { + if ( FsmFigure->CIRCUIT == (bddcircuit *)0 ) + { + BddSystem = createbddsystem( SYF_BDD_VAR_NODE, SYF_BDD_OPER_NODE, 1000, SYF_BDD_MAX_NODE ); + reorderbddsystemdynamic( BddSystem, SYF_BDD_REORDER_FUNC, + SYF_BDD_REORDER_NODE, SYF_BDD_REORDER_RATIO ); + BddCircuit = SyfFsmMakeBddCircuit( BddSystem, FsmFigure ); + reorderbddsystemsimple( BddSystem ); + } + + convertfsmbddnodeabl( FsmFigure ); + } + + SyfInfo = FSM_SYF_INFO( FsmFigure ); + + if ( SyfInfo->STACK ) + { + ScanStack = FsmFigure->STACK; + + while ( ScanStack != (fsmstack_list *)0 ) + { + ScanStack->ABL = simpablexpr( ScanStack->ABL ); + + if ( ( ABL_ATOM( ScanStack->ABL ) ) && + ( ABL_ATOM_VALUE( ScanStack->ABL ) == ABL_ATOM_NAME_ZERO ) ) + { + DelStack = ScanStack; + ScanStack = ScanStack->NEXT; + + SyfWarning( SYF_WARNING_REMOVE_STACK, DelStack->CURRENT->NAME, NULL ); + + delfsmstack( FsmFigure, DelStack ); + } + else + { + ScanStack = ScanStack->NEXT; + } + } + } + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + ScanLocout = ScanState->LOCOUT; + + while ( ScanLocout != (fsmlocout_list *)0 ) + { + if ( ScanLocout->ABL != (chain_list *)0 ) + { + ScanLocout->ABL = simpablexpr( ScanLocout->ABL ); + + if ( ( ABL_ATOM( ScanLocout->ABL ) ) && + ( ABL_ATOM_VALUE( ScanLocout->ABL ) == ABL_ATOM_NAME_ZERO ) ) + { + freeablexpr( ScanLocout->ABL ); + ScanLocout->ABL = (chain_list *)0; + } + } + + if ( ScanLocout->ABL_DC != (chain_list *)0 ) + { + ScanLocout->ABL_DC = simpablexpr( ScanLocout->ABL_DC ); + + if ( ( ABL_ATOM( ScanLocout->ABL_DC ) ) && + ( ABL_ATOM_VALUE( ScanLocout->ABL_DC ) == ABL_ATOM_NAME_ZERO ) ) + { + freeablexpr( ScanLocout->ABL_DC ); + ScanLocout->ABL_DC = (chain_list *)0; + } + } + + if ( ( ScanLocout->ABL == (chain_list *)0 ) && + ( ScanLocout->ABL_DC == (chain_list *)0 ) ) + { + DelLocout = ScanLocout; + ScanLocout = ScanLocout->NEXT; + + delfsmlocout( ScanState, DelLocout ); + } + else + { + ScanLocout = ScanLocout->NEXT; + } + } + } + + ScanTrans = FsmFigure->TRANS; + + while ( ScanTrans != (fsmtrans_list *)0 ) + { + ScanTrans->ABL = simpablexpr( ScanTrans->ABL ); + + if ( ( ABL_ATOM( ScanTrans->ABL ) ) && + ( ABL_ATOM_VALUE( ScanTrans->ABL ) == ABL_ATOM_NAME_ZERO ) ) + { + DelTrans = ScanTrans; + ScanTrans = ScanTrans->NEXT; + + SyfWarning( SYF_WARNING_REMOVE_TRANS, + DelTrans->FROM->NAME, DelTrans->TO->NAME ); + + delfsmtrans( FsmFigure, DelTrans ); + } + else + { + ScanTrans = ScanTrans->NEXT; + } + } + + if ( FsmFigure->CLOCK_ABL != (chain_list *)0 ) + { + FsmFigure->CLOCK_ABL = simpablexpr( FsmFigure->CLOCK_ABL ); + } +} + +/*------------------------------------------------------------\ +| | +| SyfFsmTreatReset | +| | +\------------------------------------------------------------*/ + +void SyfFsmTreatReset( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + bddsystem *BddSystem; + bddcircuit *BddCircuit; + bddassoc *BddAssoc; + bddnode *SumStar; + bddnode *TransCond; + bddnode *BddNode; + bddvar BddVar; + fsmstate_list *StarState; + fsmtrans_list *ScanTrans; + chain_list *ScanChain; + chain_list *Support; + + StarState = FsmFigure->STAR_STATE; + + if ( ( StarState == (fsmstate_list *)0 ) || + ( StarState->FROM == (chain_list *)0 ) ) return; + + if ( FsmFigure->CIRCUIT == (bddcircuit *)0 ) + { + BddSystem = createbddsystem( SYF_BDD_VAR_NODE, SYF_BDD_OPER_NODE, 1000, SYF_BDD_MAX_NODE ); + reorderbddsystemdynamic( BddSystem, SYF_BDD_REORDER_FUNC, + SYF_BDD_REORDER_NODE, SYF_BDD_REORDER_RATIO ); + BddCircuit = SyfFsmMakeBddCircuit( BddSystem, FsmFigure ); + reorderbddsystemsimple( BddSystem ); + } + +/* +** Compute Sum Star Transitions +*/ + SumStar = BddLocalSystem->ZERO; + + for ( ScanChain = StarState->FROM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + ScanTrans = (fsmtrans_list *)ScanChain->DATA; + TransCond = ScanTrans->BDD; + + decbddrefext( SumStar ); + SumStar = applybddnode( (bddsystem *)0, ABL_OR, SumStar, TransCond ); + } + + decbddrefext( SumStar ); + SumStar = applybddnodenot( (bddsystem *)0, SumStar ); + + BddAssoc = addbddassoc( (bddsystem *)0 ); + Support = getbddnodesupportchain( (bddsystem *)0, SumStar ); + + for ( ScanChain = Support; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + BddNode = (bddnode *)ScanChain->DATA; + BddVar = getbddvarbyindex( (bddsystem *)0, BddNode->INDEX ); + addbddnodeassoc( (bddsystem *)0, BddAssoc, BddVar, BddNode ); + } + + freechain( Support); + + for ( ScanTrans = FsmFigure->TRANS; + ScanTrans != (fsmtrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + if ( IsFsmStarTrans( ScanTrans ) ) continue; + + TransCond = ScanTrans->BDD; + TransCond = existbddnodeassoc( (bddsystem *)0, TransCond, BddAssoc ); +/* +** Verify the correctness of the solution +*/ + BddNode = applybddnode( (bddsystem *)0, ABL_AND, TransCond, SumStar ); + decbddrefext( BddNode ); + + if ( BddNode != ScanTrans->BDD ) + { + decbddrefext( TransCond ); + TransCond = ScanTrans->BDD; + TransCond = cofactorbddnode( (bddsystem *)0, TransCond, SumStar ); + } + + decbddrefext( ScanTrans->BDD ); + ScanTrans->BDD = TransCond; + } + + delbddassoc( (bddsystem *)0, BddAssoc ); + + convertfsmbddnodeabl( FsmFigure ); + + if ( FsmFigure->CIRCUIT != (bddcircuit *)0 ) + { + BddCircuit = FsmFigure->CIRCUIT; + BddSystem = BddCircuit->BDD_SYSTEM; + + destroybddsystem( BddSystem ); + destroybddcircuit( BddCircuit ); + + FsmFigure->CIRCUIT = (bddcircuit *)0; + } +} diff --git a/alliance/src/syf/src/syf_verify.h b/alliance/src/syf/src/syf_verify.h new file mode 100644 index 00000000..a4741b6a --- /dev/null +++ b/alliance/src/syf/src/syf_verify.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| 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 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 : SYF | +| | +| File : syf_verify.h | +| | +| Authors : C. Sarwary | +| Modified by Jacomme Ludovic | +| | +| Date : 01.11.94 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef SYF_VERIFY_H +# define SYF_VERIFY_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void SyfFsmOutputPolarity(); + extern void SyfFsmVerify(); + extern void SyfFsmSimplify(); + extern void SyfFsmTreatReset(); + +# endif