00001
00019 #include "fraigInt.h"
00020
00024
00028
00040 Fraig_NodeVec_t * Fraig_ManReadVecInputs( Fraig_Man_t * p ) { return p->vInputs; }
00041 Fraig_NodeVec_t * Fraig_ManReadVecOutputs( Fraig_Man_t * p ) { return p->vOutputs; }
00042 Fraig_NodeVec_t * Fraig_ManReadVecNodes( Fraig_Man_t * p ) { return p->vNodes; }
00043 Fraig_Node_t ** Fraig_ManReadInputs ( Fraig_Man_t * p ) { return p->vInputs->pArray; }
00044 Fraig_Node_t ** Fraig_ManReadOutputs( Fraig_Man_t * p ) { return p->vOutputs->pArray; }
00045 Fraig_Node_t ** Fraig_ManReadNodes( Fraig_Man_t * p ) { return p->vNodes->pArray; }
00046 int Fraig_ManReadInputNum ( Fraig_Man_t * p ) { return p->vInputs->nSize; }
00047 int Fraig_ManReadOutputNum( Fraig_Man_t * p ) { return p->vOutputs->nSize; }
00048 int Fraig_ManReadNodeNum( Fraig_Man_t * p ) { return p->vNodes->nSize; }
00049 Fraig_Node_t * Fraig_ManReadConst1 ( Fraig_Man_t * p ) { return p->pConst1; }
00050 Fraig_Node_t * Fraig_ManReadIthNode( Fraig_Man_t * p, int i ) { assert ( i < p->vNodes->nSize ); return p->vNodes->pArray[i]; }
00051 char ** Fraig_ManReadInputNames( Fraig_Man_t * p ) { return p->ppInputNames; }
00052 char ** Fraig_ManReadOutputNames( Fraig_Man_t * p ) { return p->ppOutputNames; }
00053 char * Fraig_ManReadVarsInt( Fraig_Man_t * p ) { return (char *)p->vVarsInt; }
00054 char * Fraig_ManReadSat( Fraig_Man_t * p ) { return (char *)p->pSat; }
00055 int Fraig_ManReadFuncRed( Fraig_Man_t * p ) { return p->fFuncRed; }
00056 int Fraig_ManReadFeedBack( Fraig_Man_t * p ) { return p->fFeedBack; }
00057 int Fraig_ManReadDoSparse( Fraig_Man_t * p ) { return p->fDoSparse; }
00058 int Fraig_ManReadChoicing( Fraig_Man_t * p ) { return p->fChoicing; }
00059 int Fraig_ManReadVerbose( Fraig_Man_t * p ) { return p->fVerbose; }
00060 int * Fraig_ManReadModel( Fraig_Man_t * p ) { return p->pModel; }
00061
00062 int Fraig_ManReadPatternNumRandom( Fraig_Man_t * p ) { return p->nWordsRand * 32; }
00063
00064 int Fraig_ManReadPatternNumDynamic( Fraig_Man_t * p ) { return p->iWordStart * 32; }
00065
00066 int Fraig_ManReadPatternNumDynamicFiltered( Fraig_Man_t * p ) { return p->iPatsPerm; }
00067
00068 int Fraig_ManReadSatFails( Fraig_Man_t * p ) { return p->nSatFailsReal; }
00069
00070 int Fraig_ManReadConflicts( Fraig_Man_t * p ) { return p->pSat? Msat_SolverReadBackTracks(p->pSat) : 0; }
00071
00072 int Fraig_ManReadInspects( Fraig_Man_t * p ) { return p->pSat? Msat_SolverReadInspects(p->pSat) : 0; }
00073
00085 void Fraig_ManSetFuncRed( Fraig_Man_t * p, int fFuncRed ) { p->fFuncRed = fFuncRed; }
00086 void Fraig_ManSetFeedBack( Fraig_Man_t * p, int fFeedBack ) { p->fFeedBack = fFeedBack; }
00087 void Fraig_ManSetDoSparse( Fraig_Man_t * p, int fDoSparse ) { p->fDoSparse = fDoSparse; }
00088 void Fraig_ManSetChoicing( Fraig_Man_t * p, int fChoicing ) { p->fChoicing = fChoicing; }
00089 void Fraig_ManSetTryProve( Fraig_Man_t * p, int fTryProve ) { p->fTryProve = fTryProve; }
00090 void Fraig_ManSetVerbose( Fraig_Man_t * p, int fVerbose ) { p->fVerbose = fVerbose; }
00091 void Fraig_ManSetTimeToGraph( Fraig_Man_t * p, int Time ) { p->timeToAig = Time; }
00092 void Fraig_ManSetTimeToNet( Fraig_Man_t * p, int Time ) { p->timeToNet = Time; }
00093 void Fraig_ManSetTimeTotal( Fraig_Man_t * p, int Time ) { p->timeTotal = Time; }
00094 void Fraig_ManSetOutputNames( Fraig_Man_t * p, char ** ppNames ) { p->ppOutputNames = ppNames; }
00095 void Fraig_ManSetInputNames( Fraig_Man_t * p, char ** ppNames ) { p->ppInputNames = ppNames; }
00096
00108 Fraig_Node_t * Fraig_NodeReadData0( Fraig_Node_t * p ) { return p->pData0; }
00109 Fraig_Node_t * Fraig_NodeReadData1( Fraig_Node_t * p ) { return p->pData1; }
00110 int Fraig_NodeReadNum( Fraig_Node_t * p ) { return p->Num; }
00111 Fraig_Node_t * Fraig_NodeReadOne( Fraig_Node_t * p ) { assert (!Fraig_IsComplement(p)); return p->p1; }
00112 Fraig_Node_t * Fraig_NodeReadTwo( Fraig_Node_t * p ) { assert (!Fraig_IsComplement(p)); return p->p2; }
00113 Fraig_Node_t * Fraig_NodeReadNextE( Fraig_Node_t * p ) { return p->pNextE; }
00114 Fraig_Node_t * Fraig_NodeReadRepr( Fraig_Node_t * p ) { return p->pRepr; }
00115 int Fraig_NodeReadNumRefs( Fraig_Node_t * p ) { return p->nRefs; }
00116 int Fraig_NodeReadNumFanouts( Fraig_Node_t * p ) { return p->nFanouts; }
00117 int Fraig_NodeReadSimInv( Fraig_Node_t * p ) { return p->fInv; }
00118 int Fraig_NodeReadNumOnes( Fraig_Node_t * p ) { return p->nOnes; }
00119
00120
00121 unsigned * Fraig_NodeReadPatternsRandom( Fraig_Node_t * p ) { return p->puSimR; }
00122
00123
00124 unsigned * Fraig_NodeReadPatternsDynamic( Fraig_Node_t * p ) { return p->puSimD; }
00125
00137 void Fraig_NodeSetData0( Fraig_Node_t * p, Fraig_Node_t * pData ) { p->pData0 = pData; }
00138 void Fraig_NodeSetData1( Fraig_Node_t * p, Fraig_Node_t * pData ) { p->pData1 = pData; }
00139
00151 int Fraig_NodeIsConst( Fraig_Node_t * p ) { return (Fraig_Regular(p))->Num == 0; }
00152 int Fraig_NodeIsVar( Fraig_Node_t * p ) { return (Fraig_Regular(p))->NumPi >= 0; }
00153 int Fraig_NodeIsAnd( Fraig_Node_t * p ) { return (Fraig_Regular(p))->NumPi < 0 && (Fraig_Regular(p))->Num > 0; }
00154 int Fraig_NodeComparePhase( Fraig_Node_t * p1, Fraig_Node_t * p2 ) { assert( !Fraig_IsComplement(p1) ); assert( !Fraig_IsComplement(p2) ); return p1->fInv ^ p2->fInv; }
00155
00168 Fraig_Node_t * Fraig_ManReadIthVar( Fraig_Man_t * p, int i )
00169 {
00170 int k;
00171 if ( i < 0 )
00172 {
00173 printf( "Requesting a PI with a negative number\n" );
00174 return NULL;
00175 }
00176
00177 if ( i >= p->vInputs->nSize )
00178 for ( k = p->vInputs->nSize; k <= i; k++ )
00179 Fraig_NodeCreatePi( p );
00180 return p->vInputs->pArray[i];
00181 }
00182
00194 void Fraig_ManSetPo( Fraig_Man_t * p, Fraig_Node_t * pNode )
00195 {
00196
00197 Fraig_Regular(pNode)->fNodePo = 1;
00198 Fraig_NodeVecPush( p->vOutputs, pNode );
00199 }
00200
00212 Fraig_Node_t * Fraig_NodeAnd( Fraig_Man_t * p, Fraig_Node_t * p1, Fraig_Node_t * p2 )
00213 {
00214 return Fraig_NodeAndCanon( p, p1, p2 );
00215 }
00216
00228 Fraig_Node_t * Fraig_NodeOr( Fraig_Man_t * p, Fraig_Node_t * p1, Fraig_Node_t * p2 )
00229 {
00230 return Fraig_Not( Fraig_NodeAndCanon( p, Fraig_Not(p1), Fraig_Not(p2) ) );
00231 }
00232
00244 Fraig_Node_t * Fraig_NodeExor( Fraig_Man_t * p, Fraig_Node_t * p1, Fraig_Node_t * p2 )
00245 {
00246 return Fraig_NodeMux( p, p1, Fraig_Not(p2), p2 );
00247 }
00248
00260 Fraig_Node_t * Fraig_NodeMux( Fraig_Man_t * p, Fraig_Node_t * pC, Fraig_Node_t * pT, Fraig_Node_t * pE )
00261 {
00262 Fraig_Node_t * pAnd1, * pAnd2, * pRes;
00263 pAnd1 = Fraig_NodeAndCanon( p, pC, pT ); Fraig_Ref( pAnd1 );
00264 pAnd2 = Fraig_NodeAndCanon( p, Fraig_Not(pC), pE ); Fraig_Ref( pAnd2 );
00265 pRes = Fraig_NodeOr( p, pAnd1, pAnd2 );
00266 Fraig_RecursiveDeref( p, pAnd1 );
00267 Fraig_RecursiveDeref( p, pAnd2 );
00268 Fraig_Deref( pRes );
00269 return pRes;
00270 }
00271
00272
00285 void Fraig_NodeSetChoice( Fraig_Man_t * pMan, Fraig_Node_t * pNodeOld, Fraig_Node_t * pNodeNew )
00286 {
00287
00288 pNodeNew->pNextE = pNodeOld->pNextE;
00289 pNodeOld->pNextE = pNodeNew;
00290 pNodeNew->pRepr = pNodeOld;
00291 }
00292
00296
00297