abc/src/aig/saig/saigSynch.c
/**Function*************************************************************

  Synopsis    [Creates SEC miter for two designs without initial state.]

  Description [The designs (pAig1 and pAig2) are assumed to have ternary 
  initial state. Determines synchronizing sequences using ternary simulation.
  Simulates the sequences on both designs to come up with equivalent binary 
  initial states. Create seq miter for the designs starting in these states.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Creates SEC miter for two designs without initial state.]

Description [The designs (pAig1 and pAig2) are assumed to have ternary
initial state. Determines synchronizing sequences using ternary simulation.
Simulates the sequences on both designs to come up with equivalent binary
initial states. Create seq miter for the designs starting in these states.]




Function Synopsis [ Creates SEC miter for two designs without initial state . ] Description [ The designs ( pAig1 and pAig2 ) are assumed to have ternary initial state . Determines synchronizing sequences using ternary simulation . Simulates the sequences on both designs to come up with equivalent binary initial states . Create seq miter for the designs starting in these states . ]
Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords, int fVerbose )
{
    Aig_Man_t * pAig1z, * pAig2z, * pMiter;
    Vec_Str_t * vSeq1, * vSeq2;
    Vec_Ptr_t * vSimInfo;
    int RetValue;
    abctime clk;
    if ( fVerbose )
    {
        printf( "Design 1: " );
        Aig_ManPrintStats( pAig1 );
        printf( "Design 2: " );
        Aig_ManPrintStats( pAig2 );
    }
    clk = Abc_Clock();
    vSeq1 = Saig_SynchSequence( pAig1, nWords );
    if ( vSeq1 == NULL )
        printf( "Design 1: Synchronizing sequence is not found. " );
    else if ( fVerbose )
        printf( "Design 1: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSeq1) / Saig_ManPiNum(pAig1) );
    if ( fVerbose )
    {
        ABC_PRT( "Time", Abc_Clock() - clk );
    }
    else
        printf( "\n" );
    clk = Abc_Clock();
    vSeq2 = Saig_SynchSequence( pAig2, nWords );
    if ( vSeq2 == NULL )
        printf( "Design 2: Synchronizing sequence is not found. " );
    else if ( fVerbose )
        printf( "Design 2: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSeq2) / Saig_ManPiNum(pAig2) );
    if ( fVerbose )
    {
        ABC_PRT( "Time", Abc_Clock() - clk );
    }
    else
        printf( "\n" );
    if ( vSeq1 == NULL || vSeq2 == NULL )
    {
        printf( "Quitting synchronization.\n" );
        if ( vSeq1 ) Vec_StrFree( vSeq1 );
        if ( vSeq2 ) Vec_StrFree( vSeq2 );
        return NULL;
    }
    clk = Abc_Clock();
    vSimInfo = Vec_PtrAllocSimInfo( Abc_MaxInt( Aig_ManObjNumMax(pAig1), Aig_ManObjNumMax(pAig2) ), 1 );
    RetValue = Saig_SynchSequenceRun( pAig1, vSimInfo, vSeq1, 1 );
    assert( RetValue == 0 );
    RetValue = Saig_SynchSequenceRun( pAig1, vSimInfo, vSeq2, 0 );
    assert( RetValue == 0 );
    RetValue = Saig_SynchSequenceRun( pAig2, vSimInfo, vSeq2, 1 );
    assert( RetValue == 0 );
    pAig1z = Saig_ManDupInitZero( pAig1 );
    pAig2z = Saig_ManDupInitZero( pAig2 );
    pMiter = Saig_ManCreateMiter( pAig1z, pAig2z, 0 );
    Aig_ManCleanup( pMiter );
    Aig_ManStop( pAig1z );
    Aig_ManStop( pAig2z );
    Vec_PtrFree( vSimInfo );
    Vec_StrFree( vSeq1 );
    Vec_StrFree( vSeq2 );
    Aig_ManCleanMarkA( pAig1 );
    Aig_ManCleanMarkA( pAig2 );
    if ( fVerbose )
    {
        printf( "Miter of the synchronized designs is constructed.         " );
        ABC_PRT( "Time", Abc_Clock() - clk );
    }
    return pMiter;
}
Aig_Man_t * Saig_Synchronize ( Aig_Man_t * pAig1 , Aig_Man_t * pAig2 , int nWords , int fVerbose ) { Aig_Man_t * pAig1z , * pAig2z , * pMiter ; Vec_Str_t * vSeq1 , * vSeq2 ; Vec_Ptr_t * vSimInfo ; int RetValue ; abctime clk ; if ( fVerbose ) { printf ( " " ) ; Aig_ManPrintStats ( pAig1 ) ; printf ( " " ) ; Aig_ManPrintStats ( pAig2 ) ; } clk = Abc_Clock ( ) ; vSeq1 = Saig_SynchSequence ( pAig1 , nWords ) ; if ( vSeq1 == NULL ) printf ( " " ) ; else if ( fVerbose ) printf ( " " , Vec_StrSize ( vSeq1 ) / Saig_ManPiNum ( pAig1 ) ) ; if ( fVerbose ) { ABC_PRT ( " " , Abc_Clock ( ) - clk ) ; } else printf ( " \n " ) ; clk = Abc_Clock ( ) ; vSeq2 = Saig_SynchSequence ( pAig2 , nWords ) ; if ( vSeq2 == NULL ) printf ( " " ) ; else if ( fVerbose ) printf ( " " , Vec_StrSize ( vSeq2 ) / Saig_ManPiNum ( pAig2 ) ) ; if ( fVerbose ) { ABC_PRT ( " " , Abc_Clock ( ) - clk ) ; } else printf ( " \n " ) ; if ( vSeq1 == NULL || vSeq2 == NULL ) { printf ( " \n " ) ; if ( vSeq1 ) Vec_StrFree ( vSeq1 ) ; if ( vSeq2 ) Vec_StrFree ( vSeq2 ) ; return NULL ; } clk = Abc_Clock ( ) ; vSimInfo = Vec_PtrAllocSimInfo ( Abc_MaxInt ( Aig_ManObjNumMax ( pAig1 ) , Aig_ManObjNumMax ( pAig2 ) ) , 1 ) ; RetValue = Saig_SynchSequenceRun ( pAig1 , vSimInfo , vSeq1 , 1 ) ; assert ( RetValue == 0 ) ; RetValue = Saig_SynchSequenceRun ( pAig1 , vSimInfo , vSeq2 , 0 ) ; assert ( RetValue == 0 ) ; RetValue = Saig_SynchSequenceRun ( pAig2 , vSimInfo , vSeq2 , 1 ) ; assert ( RetValue == 0 ) ; pAig1z = Saig_ManDupInitZero ( pAig1 ) ; pAig2z = Saig_ManDupInitZero ( pAig2 ) ; pMiter = Saig_ManCreateMiter ( pAig1z , pAig2z , 0 ) ; Aig_ManCleanup ( pMiter ) ; Aig_ManStop ( pAig1z ) ; Aig_ManStop ( pAig2z ) ; Vec_PtrFree ( vSimInfo ) ; Vec_StrFree ( vSeq1 ) ; Vec_StrFree ( vSeq2 ) ; Aig_ManCleanMarkA ( pAig1 ) ; Aig_ManCleanMarkA ( pAig2 ) ; if ( fVerbose ) { printf ( " " ) ; ABC_PRT ( " " , Abc_Clock ( ) - clk ) ; } return pMiter ; }
Function
Synopsis    [Creates SEC miter for two designs without initial state.]
Function Synopsis [ Creates SEC miter for two designs without initial state . ]
/*
    {
        unsigned u = Saig_SynchRandomTernary();
        unsigned w = Saig_SynchRandomTernary();
        unsigned x = Saig_SynchNot( u );
        unsigned y = Saig_SynchNot( w );
        unsigned z = Saig_SynchAnd( x, y );

        Extra_PrintBinary( stdout, &u, 32 );  printf( "\n" );
        Extra_PrintBinary( stdout, &w, 32 );  printf( "\n" );  printf( "\n" );
        Extra_PrintBinary( stdout, &x, 32 );  printf( "\n" );
        Extra_PrintBinary( stdout, &y, 32 );  printf( "\n" );  printf( "\n" );
        Extra_PrintBinary( stdout, &z, 32 );  printf( "\n" );
    }
*/ // report statistics // synchronize the first design // synchronize the first design // quit if one of the designs cannot be synchronized // process Design 1 // process Design 2 // duplicate designs // cleanup