src/opt/sim/simSymSat.c File Reference

#include "abc.h"
#include "sim.h"
#include "fraig.h"
Include dependency graph for simSymSat.c:

Go to the source code of this file.

Functions

static int Sim_SymmsSatProveOne (Sym_Man_t *p, int Out, int Var1, int Var2, unsigned *pPattern)
int Sim_SymmsGetPatternUsingSat (Sym_Man_t *p, unsigned *pPattern)

Function Documentation

int Sim_SymmsGetPatternUsingSat ( Sym_Man_t p,
unsigned *  pPattern 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Tries to prove the remaining pairs using SAT.]

Description [Continues to prove as long as it encounters symmetric pairs. Returns 1 if a non-symmetric pair is found (which gives a counter-example). Returns 0 if it finishes considering all pairs for all outputs.]

SideEffects []

SeeAlso []

Definition at line 48 of file simSymSat.c.

00049 {
00050     Vec_Int_t * vSupport;
00051     Extra_BitMat_t * pMatSym, * pMatNonSym;
00052     int Index1, Index2, Index3, IndexU, IndexV;
00053     int v, u, i, k, b, out;
00054 
00055     // iterate through outputs
00056     for ( out = p->iOutput; out < p->nOutputs; out++ )
00057     {
00058         pMatSym    = Vec_PtrEntry( p->vMatrSymms,    out );
00059         pMatNonSym = Vec_PtrEntry( p->vMatrNonSymms, out );
00060 
00061         // go through the remaining variable pairs
00062         vSupport = Vec_VecEntry( p->vSupports, out );
00063         Vec_IntForEachEntry( vSupport, v, Index1 )
00064         Vec_IntForEachEntryStart( vSupport, u, Index2, Index1+1 )
00065         {
00066             if ( Extra_BitMatrixLookup1( pMatSym, v, u ) || Extra_BitMatrixLookup1( pMatNonSym, v, u ) )
00067                 continue;
00068             p->nSatRuns++;
00069 
00070             // collect the support variables that are symmetric with u and v
00071             Vec_IntClear( p->vVarsU );
00072             Vec_IntClear( p->vVarsV );
00073             Vec_IntForEachEntry( vSupport, b, Index3 )
00074             {
00075                 if ( Extra_BitMatrixLookup1( pMatSym, u, b ) )
00076                     Vec_IntPush( p->vVarsU, b );
00077                 if ( Extra_BitMatrixLookup1( pMatSym, v, b ) )
00078                     Vec_IntPush( p->vVarsV, b );
00079             }
00080 
00081             if ( Sim_SymmsSatProveOne( p, out, v, u, pPattern ) )
00082             { // update the symmetric variable info            
00083                 p->nSatRunsUnsat++;
00084                 Vec_IntForEachEntry( p->vVarsU, i, IndexU )
00085                 Vec_IntForEachEntry( p->vVarsV, k, IndexV )
00086                 {
00087                     Extra_BitMatrixInsert1( pMatSym,  i, k );  // Theorem 1
00088                     Extra_BitMatrixInsert2( pMatSym,  i, k );  // Theorem 1
00089                     Extra_BitMatrixOrTwo( pMatNonSym, i, k );  // Theorem 2
00090                 }
00091             }
00092             else
00093             { // update the assymmetric variable info
00094                 p->nSatRunsSat++;
00095                 Vec_IntForEachEntry( p->vVarsU, i, IndexU )
00096                 Vec_IntForEachEntry( p->vVarsV, k, IndexV )
00097                 {
00098                     Extra_BitMatrixInsert1( pMatNonSym, i, k );   // Theorem 3
00099                     Extra_BitMatrixInsert2( pMatNonSym, i, k );   // Theorem 3
00100                 }
00101 
00102                 // remember the out
00103                 p->iOutput = out;
00104                 p->iVar1Old = p->iVar1;
00105                 p->iVar2Old = p->iVar2;
00106                 p->iVar1 = v;
00107                 p->iVar2 = u;
00108                 return 1;
00109 
00110             }
00111         }
00112         // make sure that the symmetry matrix contains only cliques
00113         assert( Extra_BitMatrixIsClique( pMatSym ) );
00114     }
00115 
00116     // mark that we finished all outputs
00117     p->iOutput = p->nOutputs;
00118     return 0;
00119 }

int Sim_SymmsSatProveOne ( Sym_Man_t p,
int  Out,
int  Var1,
int  Var2,
unsigned *  pPattern 
) [static]

CFile****************************************************************

FileName [simSymSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Satisfiability to determine two variable symmetries.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
simSymSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS ///

Function*************************************************************

Synopsis [Returns 1 if the variables are symmetric; 0 otherwise.]

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file simSymSat.c.

00133 {
00134     Fraig_Params_t Params;
00135     Fraig_Man_t * pMan;
00136     Abc_Ntk_t * pMiter;
00137     int RetValue, i, clk;
00138     int * pModel;
00139 
00140     // get the miter for this problem
00141     pMiter = Abc_NtkMiterForCofactors( p->pNtk, Out, Var1, Var2 );
00142     // transform the miter into a fraig
00143     Fraig_ParamsSetDefault( &Params );
00144     Params.fInternal = 1;
00145     Params.nPatsRand = 512;
00146     Params.nPatsDyna = 512;
00147     Params.nSeconds = ABC_INFINITY;
00148 
00149 clk = clock();
00150     pMan = Abc_NtkToFraig( pMiter, &Params, 0, 0 ); 
00151 p->timeFraig += clock() - clk;
00152 clk = clock();
00153     Fraig_ManProveMiter( pMan );
00154 p->timeSat += clock() - clk;
00155 
00156     // analyze the result
00157     RetValue = Fraig_ManCheckMiter( pMan );
00158 //    assert( RetValue >= 0 );
00159     // save the pattern
00160     if ( RetValue == 0 )
00161     {
00162         // get the pattern
00163         pModel = Fraig_ManReadModel( pMan );
00164         assert( pModel != NULL );
00165 //printf( "Disproved by SAT: out = %d  pair = (%d, %d)\n", Out, Var1, Var2 );
00166         // transfer the model into the pattern
00167         for ( i = 0; i < p->nSimWords; i++ )
00168             pPattern[i] = 0;
00169         for ( i = 0; i < p->nInputs; i++ )
00170             if ( pModel[i] )
00171                 Sim_SetBit( pPattern, i );
00172         // make sure these variables have the same value (1)
00173         Sim_SetBit( pPattern, Var1 );
00174         Sim_SetBit( pPattern, Var2 );
00175     }
00176     else if ( RetValue == -1 )
00177     {
00178         // this should never happen; if it happens, such is life
00179         // we are conservative and assume that there is no symmetry
00180 //printf( "STRANGE THING: out = %d %s  pair = (%d %s, %d %s)\n", 
00181 //                        Out, Abc_ObjName(Abc_NtkCo(p->pNtk,Out)), 
00182 //                        Var1, Abc_ObjName(Abc_NtkCi(p->pNtk,Var1)), 
00183 //                        Var2, Abc_ObjName(Abc_NtkCi(p->pNtk,Var2)) );
00184         memset( pPattern, 0, sizeof(unsigned) * p->nSimWords );
00185         RetValue = 0;
00186     }
00187     // delete the fraig manager
00188     Fraig_ManFree( pMan );
00189     // delete the miter
00190     Abc_NtkDelete( pMiter );
00191     return RetValue;
00192 }


Generated on Tue Jan 5 12:19:36 2010 for abc70930 by  doxygen 1.6.1