Encore plus de fruits !

This commit is contained in:
Ludovic Jacomme 2002-04-16 13:30:58 +00:00
parent 33e32ba92e
commit fe367c577c
15 changed files with 480 additions and 230 deletions

View File

@ -110,6 +110,7 @@
# define FSM_MIXED_RTL_MASK (long)( 0x0001 )
# define FSM_MULTI_MASK (long)( 0x0002 )
# define FSM_MULTI_LEAF_MASK (long)( 0x0004 )
/*------------------------------------------------------\
| |
@ -164,6 +165,10 @@
# define SetFsmFigMulti( F ) ( (F)->FLAGS |= FSM_MULTI_MASK )
# define ClearFsmFigMulti( F ) ( (F)->FLAGS &= ~FSM_MULTI_MASK )
# define IsFsmFigMultiLeaf( F ) ( (F)->FLAGS & FSM_MULTI_LEAF_MASK )
# define SetFsmFigMultiLeaf( F ) ( (F)->FLAGS |= FSM_MULTI_LEAF_MASK )
# define ClearFsmFigMultiLeaf( F ) ( (F)->FLAGS &= ~FSM_MULTI_LEAF_MASK )
/*------------------------------------------------------\
| |
| Structures |
@ -297,6 +302,23 @@
} fsmstack_list;
/*------------------------------------------------------\
| |
| Fsm Pragma List |
| |
\------------------------------------------------------*/
typedef struct fsmpragma_list
{
struct fsmpragma_list *NEXT;
char *TYPE;
char *NAME;
char *VALUE;
long FLAGS;
void *USER;
} fsmpragma_list;
/*------------------------------------------------------\
| |
| Fsm Figure List |
@ -337,7 +359,7 @@
bddcircuit *CIRCUIT;
long FLAGS;
ptype_list *PRAGMA;
fsmpragma_list *PRAGMA;
chain_list *MULTI;
void *FIGURE;
@ -373,6 +395,7 @@
extern fsmlocout_list * allocfsmlocout __P(());
extern fsmout_list * allocfsmout __P(());
extern fsmin_list * allocfsmin __P(());
extern fsmpragma_list * allocfsmpragma __P(());
extern fsmport_list * allocfsmport __P(());
/*------------------------------------------------------\
@ -388,6 +411,7 @@
extern void freefsmlocout __P((fsmlocout_list *Locout));
extern void freefsmout __P((fsmout_list *Output));
extern void freefsmin __P((fsmin_list *Input));
extern void freefsmpragma __P((fsmpragma_list *Pragma));
extern void freefsmport __P((fsmport_list *Port));
/*------------------------------------------------------\
@ -403,6 +427,7 @@
extern fsmlocout_list * addfsmlocout __P((fsmstate_list *State, fsmout_list *Output, ablexpr *Equation, ablexpr *EquationDC));
extern fsmout_list * addfsmout __P((fsmfig_list *Figure, char *Name));
extern fsmin_list * addfsmin __P((fsmfig_list *Figure, char *Name));
extern fsmpragma_list * addfsmpragma __P((fsmfig_list *Figure, char *Type, char *Name, char *Value ));
extern fsmport_list * addfsmport __P((fsmfig_list *Figure, char *Name, char Dir, char Type));
/*------------------------------------------------------\

View File

@ -333,6 +333,36 @@ fsmlocout_list *addfsmlocout( State, Output, Equation, EquationDC )
return( Locout );
}
/*------------------------------------------------------------\
| |
| Fsm Add Pragma |
| |
\------------------------------------------------------------*/
fsmpragma_list *addfsmpragma( Figure, Type, Name, Value )
fsmfig_list *Figure;
char *Type;
char *Name;
char *Value;
{
fsmpragma_list *Pragma;
Type = namealloc( Type );
Name = namealloc( Name );
Value = namealloc( Value );
Pragma = allocfsmpragma();
Pragma->TYPE = namealloc( Type );
Pragma->NAME = namealloc( Name );
Pragma->VALUE = namealloc( Value );
Pragma->NEXT = Figure->PRAGMA;
Figure->PRAGMA = Pragma;
return( Pragma );
}
/*------------------------------------------------------------\
| |
| Fsm Add Output |

View File

@ -157,6 +157,18 @@ fsmlocout_list *allocfsmlocout()
return( (fsmlocout_list *)(autallocheap( sizeof( fsmlocout_list ) ) ) );
}
/*------------------------------------------------------------\
| |
| Fsm Alloc Pragma |
| |
\------------------------------------------------------------*/
fsmpragma_list *allocfsmpragma()
{
return( (fsmpragma_list *)(autallocblock( sizeof( fsmpragma_list ) ) ) );
}
/*------------------------------------------------------------\
| |
| Fsm Alloc Input |

View File

@ -102,6 +102,8 @@ int delfsmfig( Name )
fsmstack_list *DelStack;
fsmlocout_list *Locout;
fsmlocout_list *DelLocout;
fsmpragma_list *ScanPragma;
fsmpragma_list *DelPragma;
Name = namealloc( Name );
Previous = &HEAD_FSMFIG;
@ -200,9 +202,14 @@ int delfsmfig( Name )
freefsmstack( DelStack );
}
if ( Figure->PRAGMA != (ptype_list *)0 )
ScanPragma = Figure->PRAGMA;
while ( ScanPragma != (fsmpragma_list *)0 )
{
freeptype( Figure->PRAGMA );
DelPragma = ScanPragma;
ScanPragma = ScanPragma->NEXT;
freefsmpragma( DelPragma );
}
destroyauthtable( Figure->HASH_PORT );

View File

@ -170,6 +170,19 @@ void freefsmin( Input )
autfreeblock( (char *)Input );
}
/*------------------------------------------------------------\
| |
| Fsm Free Pragma |
| |
\------------------------------------------------------------*/
void freefsmpragma( Pragma )
fsmpragma_list *Pragma;
{
autfreeblock( (char *)Pragma );
}
/*------------------------------------------------------------\
| |
| Fsm Free Port |

View File

@ -207,6 +207,27 @@ void viewfsmtrans( Trans )
fprintf( stdout, "\n<-- Transition" );
}
/*------------------------------------------------------------\
| |
| Fsm View Pragma |
| |
\------------------------------------------------------------*/
void viewfsmpragma( Pragma )
fsmpragma_list *Pragma;
{
fprintf( stdout, "\n--> Pragma" );
fprintf( stdout, "\n\t\tFLAGS : %lx", Pragma->FLAGS );
fprintf( stdout, "\n\t\tUSER : %lx", (long)Pragma->USER );
fprintf( stdout, "\n\t\tTYPE : %s", Pragma->TYPE ? Pragma->TYPE : "NULL" );
fprintf( stdout, "\n\t\tNAME : %s", Pragma->NAME ? Pragma->NAME : "NULL" );
fprintf( stdout, "\n\t\tVALUE : %s", Pragma->VALUE ? Pragma->VALUE : "NULL" );
fprintf( stdout, "\n<-- Pragma" );
}
/*------------------------------------------------------------\
| |
| Fsm View Stack |
@ -320,12 +341,13 @@ void viewfsmfig( Figure )
fsmfig_list *Figure;
{
fsmstate_list *State;
fsmtrans_list *Trans;
fsmstack_list *Stack;
fsmin_list *Input;
fsmout_list *Output;
fsmport_list *Port;
fsmstate_list *State;
fsmtrans_list *Trans;
fsmstack_list *Stack;
fsmpragma_list *Pragma;
fsmin_list *Input;
fsmout_list *Output;
fsmport_list *Port;
fprintf( stdout, "\n--> Figure" );
fprintf( stdout, "\n\tNAME : %s", Figure->NAME );
@ -346,6 +368,16 @@ void viewfsmfig( Figure )
viewablexpr( Figure->CLOCK_ABL, ABL_VIEW_VHDL );
}
fprintf( stdout, "\n\tPRAGMA : " );
for ( Pragma = Figure->PRAGMA;
Pragma != (fsmpragma_list *)0;
Pragma = Pragma->NEXT )
{
viewfsmpragma( Pragma );
}
fprintf( stdout, "\n\tPORT : " );
for ( Port = Figure->PORT;

View File

@ -392,10 +392,7 @@ void FvhFbhTreatPragma( FbhFigure, FsmFigure, NumberProc )
ScanFigList->STACK_CONTROL[ FSM_CTRL_POP ] = ScanPragma->NAME;
}
/* SHOULD BE DONE BETTER !! */
FsmFigure->PRAGMA = addptype( FsmFigure->PRAGMA,
(long)ScanPragma->TYPE,
ScanPragma->NAME );
addfsmpragma( FsmFigure, ScanPragma->TYPE, ScanPragma->NAME, ScanPragma->VALUE );
}
}
@ -515,6 +512,8 @@ void FvhFbhTreatAux( FbhFigure, FsmFigure )
Figure = addfsmfig( ScanFigList->NAME );
ScanFigList->FSM_FIGURE = Figure;
FsmFigure->MULTI = addchain( FsmFigure->MULTI, (void *)Figure );
SetFsmFigMultiLeaf( Figure );
}
Figure->STAR_STATE = addfsmstate( Figure, "*" );
@ -1860,6 +1859,17 @@ void FvhFbhPostTreat( FsmFigure )
delablexpr( Equation );
}
if ( IsFsmFigMulti( FsmFigure ) )
{
Figure = ScanFigList->FSM_FIGURE;
addfsmpragma( Figure, FvhClockKeyword , ScanFigList->CLOCK , ScanFigList->NAME );
addfsmpragma( Figure, FvhCurrentStateKeyword, ScanFigList->CURRENT_STATE, ScanFigList->NAME );
addfsmpragma( Figure, FvhNextStateKeyword , ScanFigList->NEXT_STATE , ScanFigList->NAME );
addfsmpragma( Figure, FvhFirstStateKeyword , ScanFigList->FIRST_STATE , ScanFigList->NAME );
/* TO BE DONE for STACK */
}
}
}

View File

@ -200,71 +200,71 @@ void SyfFbhTreatPragma( FsmFigure )
fsmfig_list *FsmFigure;
{
ptype_list *ScanPragma;
syfinfo *SyfInfo;
char *PragmaType;
fsmpragma_list *ScanPragma;
syfinfo *SyfInfo;
char *PragmaType;
SyfInfo = FSM_SYF_INFO( FsmFigure );
for ( ScanPragma = FsmFigure->PRAGMA;
ScanPragma != (ptype_list *)0;
ScanPragma != (fsmpragma_list *)0;
ScanPragma = ScanPragma->NEXT )
{
PragmaType = (char *)ScanPragma->TYPE;
PragmaType = ScanPragma->TYPE;
if ( PragmaType == SyfCurrentStateKeyword )
{
SyfCurrentStateName = ScanPragma->DATA;
SyfCurrentStateName = ScanPragma->NAME;
}
else
if ( PragmaType == SyfNextStateKeyword )
{
SyfNextStateName = ScanPragma->DATA;
SyfNextStateName = ScanPragma->NAME;
}
else
if ( PragmaType == SyfReturnStateKeyword )
{
SyfReturnStateName = ScanPragma->DATA;
SyfReturnStateName = ScanPragma->NAME;
}
else
if ( PragmaType == SyfControlKeyword )
{
SyfControlName = ScanPragma->DATA;
SyfControlName = ScanPragma->NAME;
}
else
if ( PragmaType == SyfClockKeyword )
{
SyfClockName = ScanPragma->DATA;
SyfClockName = ScanPragma->NAME;
}
else
if ( PragmaType == SyfStackControlKeyword[ FSM_CTRL_NOP ] )
{
SyfStackControlName[ FSM_CTRL_NOP ] = ScanPragma->DATA;
SyfStackControlName[ FSM_CTRL_NOP ] = ScanPragma->NAME;
}
else
if ( PragmaType == SyfStackControlKeyword[ FSM_CTRL_PUSH ] )
{
SyfStackControlName[ FSM_CTRL_PUSH ] = ScanPragma->DATA;
SyfStackControlName[ FSM_CTRL_PUSH ] = ScanPragma->NAME;
}
else
if ( PragmaType == SyfStackControlKeyword[ FSM_CTRL_POP ] )
{
SyfStackControlName[ FSM_CTRL_POP ] = ScanPragma->DATA;
SyfStackControlName[ FSM_CTRL_POP ] = ScanPragma->NAME;
}
else
if ( PragmaType == SyfScanInKeyword )
{
SyfScanInName = ScanPragma->DATA;
SyfScanInName = ScanPragma->NAME;
}
else
if ( PragmaType == SyfScanOutKeyword )
{
SyfScanOutName = ScanPragma->DATA;
SyfScanOutName = ScanPragma->NAME;
}
else
if ( PragmaType == SyfScanTestKeyword )
{
SyfScanTestName = ScanPragma->DATA;
SyfScanTestName = ScanPragma->NAME;
}
}
@ -289,42 +289,66 @@ fsmfig_list *SyfFbhParse( Name, FlagScan )
char FlagScan;
{
fsmfig_list *FsmFigure;
fsmfig_list *ScanFigure;
chain_list *ScanChain;
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 )
if ( IsFsmFigMulti( FsmFigure ) )
{
*ScanState->PREV = ScanState->NEXT;
if ( ScanState->NEXT != (fsmstate_list *)0 )
for ( ScanChain = FsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
ScanState->NEXT->PREV = ScanState->PREV;
ScanFigure = (fsmfig_list *)ScanChain->DATA;
SyfInfo = Syfaddfsmsyfinfo( ScanFigure );
}
FsmFigure->NUMBER_STATE--;
}
else
{
FsmFigure->MULTI = addchain( (chain_list *)0, FsmFigure );
}
SyfInfo->STACK = ( FsmFigure->STACK_SIZE != 0 );
SyfFbhTreatPragma( FsmFigure );
SyfFbhTreatPort( FsmFigure );
for ( ScanState = FsmFigure->STATE;
ScanState != (fsmstate_list *)0;
ScanState = ScanState->NEXT )
for ( ScanChain = FsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
Syfaddfsmsyfstate( FsmFigure, ScanState );
ScanFigure = (fsmfig_list *)ScanChain->DATA;
SyfInfo = FSM_SYF_INFO( ScanFigure );
SyfInfo->SCAN_PATH = FlagScan;
ScanState = ScanFigure->STAR_STATE;
if ( ScanState != (fsmstate_list *)0 )
{
*ScanState->PREV = ScanState->NEXT;
if ( ScanState->NEXT != (fsmstate_list *)0 )
{
ScanState->NEXT->PREV = ScanState->PREV;
}
ScanFigure->NUMBER_STATE--;
}
SyfInfo->STACK = ( ScanFigure->STACK_SIZE != 0 );
SyfFbhTreatPragma( ScanFigure );
SyfFbhTreatPort( ScanFigure );
for ( ScanState = ScanFigure->STATE;
ScanState != (fsmstate_list *)0;
ScanState = ScanState->NEXT )
{
Syfaddfsmsyfstate( ScanFigure, ScanState );
}
}
return( FsmFigure );

View File

@ -152,5 +152,7 @@ fsmfig_list *SyfKissParse( Name, FlagScan )
Syfaddfsmsyfout( ScanOut );
}
FsmFigure->MULTI = addchain( (chain_list *)0, FsmFigure );
return( FsmFigure );
}

View File

@ -90,6 +90,8 @@ static void SyfRemoveStable( Expr )
ablexpr *Expr;
{
if ( Expr == (ablexpr *)0 ) return;
if ( ! ABL_ATOM( Expr ) )
{
if ( ABL_OPER( Expr ) == ABL_STABLE )
@ -125,7 +127,8 @@ fsmfig_list *SyfCompile( FileName, FlagScan, FlagSynopsys )
char FlagSynopsys;
{
fsmfig_list *FsmFigure;
syfinfo *SyfInfo;
fsmfig_list *ScanFigure;
chain_list *ScanChain;
if ( FSM_IN == FSM_VHDL_FORMAT )
{
@ -138,8 +141,16 @@ fsmfig_list *SyfCompile( FileName, FlagScan, FlagSynopsys )
if ( FlagSynopsys )
{
SyfInfo = FSM_SYF_INFO( FsmFigure );
SyfRemoveStable( FsmFigure->CLOCK_ABL );
for ( ScanChain = FsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
ScanFigure = (fsmfig_list *)ScanChain->DATA;
SyfRemoveStable( ScanFigure->CLOCK_ABL );
}
}
return( FsmFigure );

View File

@ -148,40 +148,24 @@ syfstate *Syfaddfsmsyfstate( Figure, State )
{
syfstate *SyfState;
syfinfo *SyfInfo;
char *Buffer;
int Length;
char Buffer[ 1024 ];
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 );
sprintf( Buffer, "%s_%s_%s", Figure->NAME, 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 );
sprintf( Buffer, "%s_%s_%s", Figure->NAME, 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 );
sprintf( Buffer, "%s_%s_%s", Figure->NAME, SyfInfo->NEXT_STATE, State->NAME );
SyfState->NEXT_NAME = namealloc( Buffer );
sprintf( Buffer, "%s_in_%s", SyfInfo->NEXT_STATE, State->NAME );
sprintf( Buffer, "%s_%s_in_%s", Figure->NAME, SyfInfo->NEXT_STATE, State->NAME );
SyfState->NEXT_IN_NAME = namealloc( Buffer );
autfreeblock( Buffer );
return( SyfState );
}

View File

@ -87,7 +87,6 @@ void SyfFsmTreatPort( FsmFigure, FbhFigure )
fsmfig_list *FsmFigure;
fbfig_list *FbhFigure;
{
syfinfo *SyfInfo;
fbpor_list *FbhPort;
fbrin_list *FbhRin;
fsmport_list *ScanPort;
@ -97,7 +96,6 @@ void SyfFsmTreatPort( FsmFigure, FbhFigure )
return;
}
SyfInfo = FSM_SYF_INFO( FsmFigure );
FbhPort = (fbpor_list *)0;
FbhRin = FbhFigure->BERIN;
@ -381,7 +379,9 @@ fbfig_list *SyfFsm2Fbh( FsmFigure )
fsmfig_list *FsmFigure;
{
fbfig_list *FbhFigure;
fsmfig_list *ScanFigure;
chain_list *ScanChain;
fbfig_list *FbhFigure;
if ( ! IsFsmFigMixedRtl( FsmFigure ) )
{
@ -393,9 +393,17 @@ fbfig_list *SyfFsm2Fbh( FsmFigure )
}
SyfFsmTreatPort( FsmFigure, FbhFigure );
SyfFsmTreatOutput( FsmFigure, FbhFigure );
SyfFsmTreatRegister( FsmFigure, FbhFigure );
SyfFsmTreatAux( FsmFigure, FbhFigure );
for ( ScanChain = FsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
ScanFigure = (fsmfig_list *)ScanChain->DATA;
SyfFsmTreatOutput( ScanFigure, FbhFigure );
SyfFsmTreatRegister( ScanFigure, FbhFigure );
SyfFsmTreatAux( ScanFigure, FbhFigure );
}
return( FbhFigure );
}

View File

@ -135,13 +135,15 @@ int main( argc, argv )
int argc;
char *argv[];
{
char *InputFileName;
char *OutputFileName;
char *FileName;
long Literals;
int Number;
int Index;
char Option;
chain_list *ScanChain;
fsmfig_list *FsmFigure;
char *InputFileName;
char *OutputFileName;
char *FileName;
long Literals;
int Number;
int Index;
char Option;
int FlagSave = 0;
int FlagScan = 0;
@ -254,8 +256,6 @@ int main( argc, argv )
SyfFsmFigure = SyfCompile( InputFileName, FlagScan, FlagFormat );
SyfFsmFigure->NAME = namealloc( OutputFileName );
if ( FlagInvPolar )
{
if ( FlagVerbose )
@ -263,7 +263,13 @@ int main( argc, argv )
fprintf( stdout, "\t\t--> Check FSM figure outputs\n" );
}
SyfFsmOutputPolarity( SyfFsmFigure );
for ( ScanChain = SyfFsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
FsmFigure = (fsmfig_list *)ScanChain->DATA;
SyfFsmOutputPolarity( FsmFigure );
}
}
if ( FlagVerbose )
@ -274,21 +280,39 @@ int main( argc, argv )
}
}
SyfFsmSimplify( SyfFsmFigure, FlagSimplify );
for ( ScanChain = SyfFsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
FsmFigure = (fsmfig_list *)ScanChain->DATA;
SyfFsmSimplify( FsmFigure, FlagSimplify );
}
if ( FlagVerbose )
{
fprintf( stdout, "\t\t--> Verify FSM figure\n" );
}
SyfFsmVerify( SyfFsmFigure, FlagCheck );
for ( ScanChain = SyfFsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
FsmFigure = (fsmfig_list *)ScanChain->DATA;
SyfFsmVerify( FsmFigure, FlagCheck );
}
if ( FlagVerbose )
{
fprintf( stdout, "\t\t--> Identify reset conditions\n" );
}
SyfFsmTreatReset( SyfFsmFigure );
for ( ScanChain = SyfFsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
FsmFigure = (fsmfig_list *)ScanChain->DATA;
SyfFsmTreatReset( FsmFigure );
}
if ( FlagVerbose )
{
@ -298,17 +322,33 @@ int main( argc, argv )
{
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" );
for ( ScanChain = SyfFsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
FsmFigure = (fsmfig_list *)ScanChain->DATA;
fprintf( stdout, "\t\t--> Name : %s\n" , FsmFigure->NAME );
fprintf( stdout, "\t\t--> States : %ld\n", FsmFigure->NUMBER_STATE );
fprintf( stdout, "\t\t--> Inputs : %ld\n", FsmFigure->NUMBER_IN );
fprintf( stdout, "\t\t--> Outputs : %ld\n", FsmFigure->NUMBER_OUT );
fprintf( stdout, "\t\t--> Edges : %ld\n", FsmFigure->NUMBER_TRANS );
fprintf( stdout, "\t\t--> Stacks : %ld\n", FsmFigure->NUMBER_STACK );
fprintf( stdout, "\n" );
}
fprintf( stdout, "\t\t--> Encode FSM figure\n" );
}
SyfFsmEncode( SyfFsmFigure, FlagCode, FlagVerbose,
FlagDc, FlagRegOut, FlagMustCost, InputFileName );
for ( ScanChain = SyfFsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
FsmFigure = (fsmfig_list *)ScanChain->DATA;
SyfFsmEncode( FsmFigure, FlagCode, FlagVerbose,
FlagDc, FlagRegOut, FlagMustCost, InputFileName );
}
if ( FlagSave )
{
@ -325,9 +365,15 @@ int main( argc, argv )
fprintf( stdout, "\t\t--> Translate FSM to BEH\n" );
}
SyfSynthFsmInit( SyfFsmFigure );
SyfSynthCode2Abl( SyfFsmFigure, FlagDc );
SyfSynthFsm2Abl( SyfFsmFigure );
for ( ScanChain = SyfFsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
FsmFigure = (fsmfig_list *)ScanChain->DATA;
SyfSynthFsmInit( FsmFigure );
SyfSynthCode2Abl( FsmFigure, FlagDc );
SyfSynthFsm2Abl( FsmFigure );
}
SyfFbhFigure = SyfFsm2Fbh( SyfFsmFigure );
@ -349,6 +395,8 @@ int main( argc, argv )
fprintf( stdout, "\t\t--> Save BEH file %s\n\n", OutputFileName );
SyfFbhFigure->NAME = namealloc( OutputFileName );
vhdlsavefbfig( SyfFbhFigure, OutputFileName, FlagFormat );
return( 0 );

View File

@ -1533,9 +1533,9 @@ void SyfSynthFsmInit( FsmFigure )
for ( Index = 0; Index < RegMax; Index++ )
{
sprintf( Buffer, "%s %ld", SyfInfo->CURRENT_STATE, Index );
sprintf( Buffer, "%s_%s %ld", FsmFigure->NAME, SyfInfo->CURRENT_STATE, Index );
RegArray[ Index ].NAME_OUT = namealloc( Buffer );
sprintf( Buffer, "%s %ld", SyfInfo->NEXT_STATE, Index );
sprintf( Buffer, "%s_%s %ld", FsmFigure->NAME, SyfInfo->NEXT_STATE, Index );
RegArray[ Index ].NAME_IN = namealloc( Buffer );
RegArray[ Index ].NAME_MASTER = RegArray[ Index ].NAME_OUT;
}
@ -1558,7 +1558,7 @@ void SyfSynthFsmInit( FsmFigure )
for ( Index = 0; Index < OutMax; Index++ )
{
sprintf( Buffer, "regouts_%ld", Index );
sprintf( Buffer, "%s_regouts_%ld", FsmFigure->NAME, Index );
OutArray[ Index ].NAME_OUT = namealloc( Buffer );
OutArray[ Index ].NAME_MASTER = OutArray[ Index ].NAME_OUT;
}
@ -1576,7 +1576,7 @@ void SyfSynthFsmInit( FsmFigure )
for ( Index = 0; Index < CtrlMax; Index++ )
{
sprintf( Buffer, "ctrl_%s", FSM_CTRL_NAME[ Index ] );
sprintf( Buffer, "%s_ctrl_%s", FsmFigure->NAME, FSM_CTRL_NAME[ Index ] );
CtrlArray[ Index ].NAME = namealloc( Buffer );
}
@ -1589,7 +1589,7 @@ void SyfSynthFsmInit( FsmFigure )
{
for ( ScanBit = 0; ScanBit < SyfInfo->NUMBER_REG; ScanBit++ )
{
sprintf( Buffer, "stacks_%ld_%ld", Stack, ScanBit );
sprintf( Buffer, "%s_stacks_%ld_%ld", FsmFigure->NAME, Stack, ScanBit );
StackArray[ Index ].NAME_OUT = namealloc( Buffer );
StackArray[ Index ].NAME_MASTER = StackArray[ Index ].NAME_OUT;

View File

@ -91,14 +91,15 @@ void SyfFsmUserSaveCode( FsmFigure, FileName )
fsmfig_list *FsmFigure;
char *FileName;
{
fsmfig_list *ScanFigure;
FILE *UserFile;
fsmstate_list *ScanState;
chain_list *ScanChain;
syfinfo *SyfInfo;
long Value;
long Bit;
char OneHot;
SyfInfo = FSM_SYF_INFO( FsmFigure );
UserFile = mbkfopen( FileName, "enc", "w" );
if ( UserFile == (FILE *)0 )
@ -106,38 +107,46 @@ void SyfFsmUserSaveCode( FsmFigure, FileName )
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 )
for ( ScanChain = FsmFigure->MULTI;
ScanChain != (chain_list *)0;
ScanChain = ScanChain->NEXT )
{
Value = FSM_SYF_STATE( ScanState )->CODE->VALUE;
fprintf( UserFile,"%s\t%lX", ScanState->NAME, Value );
if ( OneHot )
ScanFigure = (fsmfig_list *)ScanChain->DATA;
SyfInfo = FSM_SYF_INFO( ScanFigure );
fprintf( UserFile, "# Encoding figure \"%s\"\n", ScanFigure->NAME );
fprintf( UserFile, "-%s %c %ld\n" , ScanFigure->NAME, SyfInfo->ENCODE, SyfInfo->NUMBER_BIT );
OneHot = ( SyfInfo->ENCODE == SYF_ENCODE_ONE_HOT );
for ( ScanState = ScanFigure->STATE;
ScanState != (fsmstate_list *)0;
ScanState = ScanState->NEXT )
{
Bit = Value & 0x03;
fprintf( UserFile, "\t%lX", (long)( 1 << Bit ) );
Value = Value - Bit;
while ( Value > 0 )
Value = FSM_SYF_STATE( ScanState )->CODE->VALUE;
fprintf( UserFile,"%s\t%lX", ScanState->NAME, Value );
if ( OneHot )
{
Value = Value - 4;
fprintf( UserFile, "0" );
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" );
}
if ( IsFsmFirstState( ScanState ) ) fprintf( UserFile, "\tFirst state" );
fprintf( UserFile, "\n" );
}
fclose( UserFile );
@ -163,6 +172,8 @@ void SyfFsmUserEncode( FsmFigure, FileName )
authtable *HashTable;
authelem *Element;
char *StateName;
char *ScanName;
char *FigureName;
unsigned long StateCode;
long NumberState;
long NumberBit;
@ -170,6 +181,8 @@ void SyfFsmUserEncode( FsmFigure, FileName )
unsigned long CodeMax;
long Index;
long Error;
long Skip;
SyfInfo = FSM_SYF_INFO( FsmFigure );
CodeMax = SyfInfo->NUMBER_CODE;
@ -199,6 +212,7 @@ void SyfFsmUserEncode( FsmFigure, FileName )
CurrentLine = 1;
Error = 0;
Skip = 1;
while ( fgets( SyfUserBuffer,
SYF_USER_BUFFER_SIZE,
@ -213,112 +227,142 @@ void SyfFsmUserEncode( FsmFigure, FileName )
if ( ScanBuffer[ 0 ] == '-' )
{
if ( ScanBuffer[ 1 ] == SYF_ENCODE_ONE_HOT )
{
CodeMax = NumberState;
ScanBuffer = ScanBuffer + 1;
ScanName = strchr( ScanBuffer, ' ' );
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 )
if ( ScanName == (char *)0 )
{
Error = SYF_ERROR_SYNTAX; break;
}
if ( ( (long)StateCode < 0 ) ||
( StateCode >= CodeMax ) )
*ScanName = '\0';
FigureName = namealloc( ScanBuffer );
ScanBuffer = ScanName + 1;
if ( FigureName == FsmFigure->NAME )
{
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 )
if ( ScanBuffer[ 0 ] == SYF_ENCODE_ONE_HOT )
{
Error = SYF_ERROR_DUPLICATE_CODE; break;
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;
}
Skip = 0;
}
else
if ( ScanBuffer[ 0 ] == 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;
Skip = 0;
}
else
{
Error = SYF_ERROR_SYNTAX; break;
}
}
else
{
Skip = 0;
}
CodeArray[ StateCode ].USED = 1;
ScanSyfState->CODE = &CodeArray[ StateCode ];
}
else
{
CodeArray[ NumberState - 1 ].USED = 1;
CodeArray[ NumberState - 1 ].VALUE = StateCode;
ScanSyfState->CODE = &CodeArray[ NumberState - 1 ];
Skip = 1;
}
}
else
if ( ! Skip )
{
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--;
}
NumberState--;
}
CurrentLine++;