summaryrefslogtreecommitdiffstats
path: root/src/aig
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2009-02-15 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2009-02-15 08:01:00 -0800
commit0871bffae307e0553e0c5186336189e8b55cf6a6 (patch)
tree4571d1563fe33a53a57fea1c35fb668b9d33265f /src/aig
parentf936cc0680c98ffe51b3a1716c996072d5dbf76c (diff)
downloadabc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.gz
abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.bz2
abc-0871bffae307e0553e0c5186336189e8b55cf6a6.zip
Version abc90215
Diffstat (limited to 'src/aig')
-rw-r--r--src/aig/aig/aig.h39
-rw-r--r--src/aig/aig/aigCanon.c14
-rw-r--r--src/aig/aig/aigCuts.c16
-rw-r--r--src/aig/aig/aigDup.c12
-rw-r--r--src/aig/aig/aigFanout.c6
-rw-r--r--src/aig/aig/aigFrames.c4
-rw-r--r--src/aig/aig/aigInter.c6
-rw-r--r--src/aig/aig/aigMan.c30
-rw-r--r--src/aig/aig/aigMem.c80
-rw-r--r--src/aig/aig/aigOrder.c6
-rw-r--r--src/aig/aig/aigPart.c42
-rw-r--r--src/aig/aig/aigPartReg.c22
-rw-r--r--src/aig/aig/aigPartSat.c8
-rw-r--r--src/aig/aig/aigRepr.c8
-rw-r--r--src/aig/aig/aigRet.c20
-rw-r--r--src/aig/aig/aigScl.c11
-rw-r--r--src/aig/aig/aigTable.c8
-rw-r--r--src/aig/aig/aigTsim.c8
-rw-r--r--src/aig/aig/aigUtil.c38
-rw-r--r--src/aig/bar/bar.c5
-rw-r--r--src/aig/bar/bar.h8
-rw-r--r--src/aig/bbr/bbr.h8
-rw-r--r--src/aig/bbr/bbrCex.c8
-rw-r--r--src/aig/bbr/bbrImage.c78
-rw-r--r--src/aig/bbr/bbrReach.c26
-rw-r--r--src/aig/bdc/bdc.h16
-rw-r--r--src/aig/bdc/bdcCore.c26
-rw-r--r--src/aig/bdc/bdcInt.h8
-rw-r--r--src/aig/cec/cec.c48
-rw-r--r--src/aig/cec/cec.h22
-rw-r--r--src/aig/cec/cecClass.c841
-rw-r--r--src/aig/cec/cecCore.c234
-rw-r--r--src/aig/cec/cecInt.h221
-rw-r--r--src/aig/cec/cecMan.c175
-rw-r--r--src/aig/cec/cecPat.c493
-rw-r--r--src/aig/cec/cecSolve.c537
-rw-r--r--src/aig/cec/module.make9
-rw-r--r--src/aig/cec2/cec.h104
-rw-r--r--src/aig/cec2/cecAig.c (renamed from src/aig/cec/cecAig.c)45
-rw-r--r--src/aig/cec2/cecClass.c571
-rw-r--r--src/aig/cec2/cecCnf.c (renamed from src/aig/cec/cecCnf.c)4
-rw-r--r--src/aig/cec2/cecCore.c245
-rw-r--r--src/aig/cec2/cecInt.h208
-rw-r--r--src/aig/cec2/cecMan.c59
-rw-r--r--src/aig/cec2/cecSat.c (renamed from src/aig/cec/cecSat.c)10
-rw-r--r--src/aig/cec2/cecSat2.c284
-rw-r--r--src/aig/cec2/cecSim.c (renamed from src/aig/cec/cecSim.c)372
-rw-r--r--src/aig/cec2/cecStatus.c (renamed from src/aig/cec/cecStatus.c)0
-rw-r--r--src/aig/cec2/cecSweep.c582
-rw-r--r--src/aig/cec2/module.make9
-rw-r--r--src/aig/cgt/cgt.h8
-rw-r--r--src/aig/cgt/cgtCore.c2
-rw-r--r--src/aig/cgt/cgtDecide.c4
-rw-r--r--src/aig/cgt/cgtInt.h8
-rw-r--r--src/aig/cgt/cgtMan.c22
-rw-r--r--src/aig/cgt/cgtSat.c2
-rw-r--r--src/aig/cnf/cnf.h8
-rw-r--r--src/aig/cnf/cnfCore.c10
-rw-r--r--src/aig/cnf/cnfData.c6
-rw-r--r--src/aig/cnf/cnfMan.c40
-rw-r--r--src/aig/cnf/cnfMap.c4
-rw-r--r--src/aig/cnf/cnfWrite.c24
-rw-r--r--src/aig/csw/csw.h8
-rw-r--r--src/aig/csw/cswCut.c2
-rw-r--r--src/aig/csw/cswInt.h8
-rw-r--r--src/aig/csw/cswMan.c32
-rw-r--r--src/aig/dar/dar.h9
-rw-r--r--src/aig/dar/darCore.c23
-rw-r--r--src/aig/dar/darCut.c17
-rw-r--r--src/aig/dar/darData.c4
-rw-r--r--src/aig/dar/darInt.h12
-rw-r--r--src/aig/dar/darLib.c58
-rw-r--r--src/aig/dar/darMan.c21
-rw-r--r--src/aig/dar/darPrec.c32
-rw-r--r--src/aig/dar/darRefact.c12
-rw-r--r--src/aig/dar/darScript.c8
-rw-r--r--src/aig/dch/dch.h8
-rw-r--r--src/aig/dch/dchChoice.c6
-rw-r--r--src/aig/dch/dchClass.c24
-rw-r--r--src/aig/dch/dchCnf.c4
-rw-r--r--src/aig/dch/dchCore.c2
-rw-r--r--src/aig/dch/dchInt.h8
-rw-r--r--src/aig/dch/dchMan.c32
-rw-r--r--src/aig/dch/dchSat.c4
-rw-r--r--src/aig/dch/dchSweep.c2
-rw-r--r--src/aig/deco/deco.h22
-rw-r--r--src/aig/fra/fra.h16
-rw-r--r--src/aig/fra/fraBmc.c28
-rw-r--r--src/aig/fra/fraCec.c36
-rw-r--r--src/aig/fra/fraClass.c36
-rw-r--r--src/aig/fra/fraClau.c20
-rw-r--r--src/aig/fra/fraClaus.c78
-rw-r--r--src/aig/fra/fraCnf.c4
-rw-r--r--src/aig/fra/fraHot.c2
-rw-r--r--src/aig/fra/fraImp.c33
-rw-r--r--src/aig/fra/fraInd.c18
-rw-r--r--src/aig/fra/fraIndVer.c2
-rw-r--r--src/aig/fra/fraLcr.c38
-rw-r--r--src/aig/fra/fraMan.c46
-rw-r--r--src/aig/fra/fraPart.c20
-rw-r--r--src/aig/fra/fraSat.c14
-rw-r--r--src/aig/fra/fraSec.c60
-rw-r--r--src/aig/fra/fraSim.c13
-rw-r--r--src/aig/fsim/fsim.h8
-rw-r--r--src/aig/fsim/fsimFront.c30
-rw-r--r--src/aig/fsim/fsimInt.h8
-rw-r--r--src/aig/fsim/fsimMan.c30
-rw-r--r--src/aig/fsim/fsimSim.c41
-rw-r--r--src/aig/fsim/fsimSwitch.c553
-rw-r--r--src/aig/fsim/fsimTsim.c22
-rw-r--r--src/aig/gia/gia.c47
-rw-r--r--src/aig/gia/gia.h423
-rw-r--r--src/aig/gia/giaAig.c214
-rw-r--r--src/aig/gia/giaAiger.c553
-rw-r--r--src/aig/gia/giaCof.c688
-rw-r--r--src/aig/gia/giaConstr.c47
-rw-r--r--src/aig/gia/giaDfs.c243
-rw-r--r--src/aig/gia/giaDup.c698
-rw-r--r--src/aig/gia/giaFanout.c197
-rw-r--r--src/aig/gia/giaForce.c164
-rw-r--r--src/aig/gia/giaFrames.c346
-rw-r--r--src/aig/gia/giaFront.c248
-rw-r--r--src/aig/gia/giaGlitch.c743
-rw-r--r--src/aig/gia/giaHash.c541
-rw-r--r--src/aig/gia/giaLogic.c725
-rw-r--r--src/aig/gia/giaMan.c203
-rw-r--r--src/aig/gia/giaProp.c171
-rw-r--r--src/aig/gia/giaSat.c421
-rw-r--r--src/aig/gia/giaScl.c240
-rw-r--r--src/aig/gia/giaSim.c437
-rw-r--r--src/aig/gia/giaSolver.c490
-rw-r--r--src/aig/gia/giaSolver_cnf.c103
-rw-r--r--src/aig/gia/giaSwitch.c673
-rw-r--r--src/aig/gia/giaTsim.c708
-rw-r--r--src/aig/gia/giaUtil.c518
-rw-r--r--src/aig/gia/module.make19
-rw-r--r--src/aig/hop/cudd2.h8
-rw-r--r--src/aig/hop/hop.h34
-rw-r--r--src/aig/hop/hopDfs.c8
-rw-r--r--src/aig/hop/hopMan.c12
-rw-r--r--src/aig/hop/hopMem.c6
-rw-r--r--src/aig/hop/hopObj.c2
-rw-r--r--src/aig/hop/hopTable.c6
-rw-r--r--src/aig/hop/hopUtil.c24
-rw-r--r--src/aig/int/int.h8
-rw-r--r--src/aig/int/intContain.c4
-rw-r--r--src/aig/int/intCore.c4
-rw-r--r--src/aig/int/intCtrex.c8
-rw-r--r--src/aig/int/intDup.c4
-rw-r--r--src/aig/int/intInt.h8
-rw-r--r--src/aig/int/intM114.c6
-rw-r--r--src/aig/int/intMan.c18
-rw-r--r--src/aig/int/intUtil.c8
-rw-r--r--src/aig/ioa/ioa.h8
-rw-r--r--src/aig/ioa/ioaReadAig.c7
-rw-r--r--src/aig/ioa/ioaWriteAig.c12
-rw-r--r--src/aig/ivy/attr.h8
-rw-r--r--src/aig/ivy/ivy.h18
-rw-r--r--src/aig/ivy/ivyCut.c2
-rw-r--r--src/aig/ivy/ivyCutTrav.c2
-rw-r--r--src/aig/ivy/ivyFastMap.c10
-rw-r--r--src/aig/ivy/ivyFraig.c112
-rw-r--r--src/aig/ivy/ivyHaig.c2
-rw-r--r--src/aig/ivy/ivyMan.c16
-rw-r--r--src/aig/ivy/ivyMem.c6
-rw-r--r--src/aig/ivy/ivyObj.c2
-rw-r--r--src/aig/ivy/ivyResyn.c28
-rw-r--r--src/aig/ivy/ivySeq.c2
-rw-r--r--src/aig/ivy/ivyTable.c6
-rw-r--r--src/aig/kit/cloud.c34
-rw-r--r--src/aig/kit/cloud.h39
-rw-r--r--src/aig/kit/kit.h33
-rw-r--r--src/aig/kit/kitDsd.c42
-rw-r--r--src/aig/kit/kitFactor.c2
-rw-r--r--src/aig/kit/kitGraph.c14
-rw-r--r--src/aig/kit/kitSop.c6
-rw-r--r--src/aig/mem/mem.c81
-rw-r--r--src/aig/mfx/mfx.h8
-rw-r--r--src/aig/mfx/mfxCore.c4
-rw-r--r--src/aig/mfx/mfxInt.h8
-rw-r--r--src/aig/mfx/mfxInter.c4
-rw-r--r--src/aig/mfx/mfxMan.c18
-rw-r--r--src/aig/mfx/mfxResub.c2
-rw-r--r--src/aig/mfx/mfxSat.c2
-rw-r--r--src/aig/ntl/ntl.h19
-rw-r--r--src/aig/ntl/ntlFraig.c10
-rw-r--r--src/aig/ntl/ntlMan.c18
-rw-r--r--src/aig/ntl/ntlMap.c4
-rw-r--r--src/aig/ntl/ntlReadBlif.c26
-rw-r--r--src/aig/ntl/ntlTable.c12
-rw-r--r--src/aig/ntl/ntlTime.c2
-rw-r--r--src/aig/ntl/ntlUtil.c6
-rw-r--r--src/aig/ntl/ntlWriteBlif.c12
-rw-r--r--src/aig/nwk/nwk.h21
-rw-r--r--src/aig/nwk/nwkBidec.c2
-rw-r--r--src/aig/nwk/nwkFlow.c4
-rw-r--r--src/aig/nwk/nwkMan.c16
-rw-r--r--src/aig/nwk/nwkMap.c4
-rw-r--r--src/aig/nwk/nwkMerge.c38
-rw-r--r--src/aig/nwk/nwkMerge.h8
-rw-r--r--src/aig/nwk/nwkSpeedup.c6
-rw-r--r--src/aig/nwk/nwkTiming.c4
-rw-r--r--src/aig/nwk2/nwk.h8
-rw-r--r--src/aig/nwk2/nwkMerge.h8
-rw-r--r--src/aig/rwt/rwt.h16
-rw-r--r--src/aig/rwt/rwtDec.c2
-rw-r--r--src/aig/rwt/rwtMan.c38
-rw-r--r--src/aig/rwt/rwtUtil.c4
-rw-r--r--src/aig/saig/saig.h10
-rw-r--r--src/aig/saig/saigAbs.c26
-rw-r--r--src/aig/saig/saigBmc.c14
-rw-r--r--src/aig/saig/saigBmc2.c12
-rw-r--r--src/aig/saig/saigHaig.c24
-rw-r--r--src/aig/saig/saigInd.c4
-rw-r--r--src/aig/saig/saigIoa.c4
-rw-r--r--src/aig/saig/saigMiter.c18
-rw-r--r--src/aig/saig/saigPhase.c12
-rw-r--r--src/aig/saig/saigRetFwd.c8
-rw-r--r--src/aig/saig/saigRetMin.c8
-rw-r--r--src/aig/saig/saigSimExt.c2
-rw-r--r--src/aig/saig/saigSimFast.c27
-rw-r--r--src/aig/saig/saigSimMv.c48
-rw-r--r--src/aig/saig/saigSimSeq.c32
-rw-r--r--src/aig/saig/saigStrSim.c16
-rw-r--r--src/aig/saig/saigSwitch.c34
-rw-r--r--src/aig/saig/saigSynch.c12
-rw-r--r--src/aig/saig/saigTrans.c8
-rw-r--r--src/aig/saig/saigWnd.c4
-rw-r--r--src/aig/ssw/ssw.h8
-rw-r--r--src/aig/ssw/sswAig.c4
-rw-r--r--src/aig/ssw/sswBmc.c4
-rw-r--r--src/aig/ssw/sswClass.c38
-rw-r--r--src/aig/ssw/sswCnf.c8
-rw-r--r--src/aig/ssw/sswCore.c6
-rw-r--r--src/aig/ssw/sswInt.h8
-rw-r--r--src/aig/ssw/sswIslands.c2
-rw-r--r--src/aig/ssw/sswMan.c34
-rw-r--r--src/aig/ssw/sswPairs.c16
-rw-r--r--src/aig/ssw/sswPart.c4
-rw-r--r--src/aig/ssw/sswSat.c4
-rw-r--r--src/aig/ssw/sswSemi.c10
-rw-r--r--src/aig/ssw/sswSim.c10
-rw-r--r--src/aig/tim/tim.c18
-rw-r--r--src/aig/tim/tim.h8
244 files changed, 15844 insertions, 2801 deletions
diff --git a/src/aig/aig/aig.h b/src/aig/aig/aig.h
index 3db9b845..d9e57f7e 100644
--- a/src/aig/aig/aig.h
+++ b/src/aig/aig/aig.h
@@ -21,10 +21,6 @@
#ifndef __AIG_H__
#define __AIG_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -41,6 +37,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -196,17 +196,6 @@ struct Aig_ManCut_t_
unsigned * puTemp[4]; // used for the truth table computation
};
-#ifdef WIN32
-#define ABC_DLLEXPORT __declspec(dllexport)
-#define ABC_DLLIMPORT __declspec(dllimport)
-#else /* defined(WIN32) */
-#define ABC_DLLIMPORT
-#endif /* defined(WIN32) */
-
-#ifndef ABC_DLL
-#define ABC_DLL ABC_DLLIMPORT
-#endif
-
static inline Aig_Cut_t * Aig_ObjCuts( Aig_ManCut_t * p, Aig_Obj_t * pObj ) { return p->pCuts[pObj->Id]; }
static inline void Aig_ObjSetCuts( Aig_ManCut_t * p, Aig_Obj_t * pObj, Aig_Cut_t * pCuts ) { p->pCuts[pObj->Id] = pCuts; }
@@ -231,16 +220,12 @@ static inline Aig_Cut_t * Aig_CutNext( Aig_Cut_t * pCut ) { return
#define AIG_ABS(a) (((a) >= 0)? (a) :-(a))
#define AIG_INFINITY (100000000)
-#ifndef PRT
-#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
-#endif
-
static inline int Aig_IntAbs( int n ) { return (n < 0)? -n : n; }
static inline int Aig_Float2Int( float Val ) { return *((int *)&Val); }
static inline float Aig_Int2Float( int Num ) { return *((float *)&Num); }
static inline int Aig_Base2Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
static inline int Aig_Base10Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
-static inline char * Aig_UtilStrsav( char * s ) { return s ? strcpy(ALLOC(char, strlen(s)+1), s) : NULL; }
+static inline char * Aig_UtilStrsav( char * s ) { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL; }
static inline int Aig_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
static inline int Aig_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline int Aig_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
@@ -265,10 +250,10 @@ static inline int Aig_WordFindFirstBit( unsigned uWord )
return -1;
}
-static inline Aig_Obj_t * Aig_Regular( Aig_Obj_t * p ) { return (Aig_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); }
-static inline Aig_Obj_t * Aig_Not( Aig_Obj_t * p ) { return (Aig_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); }
-static inline Aig_Obj_t * Aig_NotCond( Aig_Obj_t * p, int c ) { return (Aig_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); }
-static inline int Aig_IsComplement( Aig_Obj_t * p ) { return (int)((PORT_PTRUINT_T)(p) & 01); }
+static inline Aig_Obj_t * Aig_Regular( Aig_Obj_t * p ) { return (Aig_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
+static inline Aig_Obj_t * Aig_Not( Aig_Obj_t * p ) { return (Aig_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
+static inline Aig_Obj_t * Aig_NotCond( Aig_Obj_t * p, int c ) { return (Aig_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
+static inline int Aig_IsComplement( Aig_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); }
static inline int Aig_ManPiNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_PI]; }
static inline int Aig_ManPoNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_PO]; }
@@ -344,7 +329,7 @@ static inline void Aig_ObjSetEquiv( Aig_Man_t * p, Aig_Obj_t * pObj, Aig
static inline Aig_Obj_t * Aig_ObjRepr( Aig_Man_t * p, Aig_Obj_t * pObj ) { return p->pReprs? p->pReprs[pObj->Id] : NULL; }
static inline void Aig_ObjSetRepr( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pRepr ) { assert(p->pReprs); p->pReprs[pObj->Id] = pRepr; }
static inline Aig_Obj_t * Aig_ObjHaig( Aig_Obj_t * pObj ) { assert( Aig_Regular(pObj)->pHaig ); return Aig_NotCond( Aig_Regular(pObj)->pHaig, Aig_IsComplement(pObj) ); }
-static inline int Aig_ObjPioNum( Aig_Obj_t * pObj ) { assert( !Aig_ObjIsNode(pObj) ); return (int)(PORT_PTRINT_T)pObj->pNext; }
+static inline int Aig_ObjPioNum( Aig_Obj_t * pObj ) { assert( !Aig_ObjIsNode(pObj) ); return (int)(ABC_PTRINT_T)pObj->pNext; }
static inline int Aig_ObjWhatFanin( Aig_Obj_t * pObj, Aig_Obj_t * pFanin )
{
if ( Aig_ObjFanin0(pObj) == pFanin ) return 0;
@@ -635,6 +620,7 @@ extern Aig_Man_t * Aig_ManConstReduce( Aig_Man_t * p, int fVerbose );
/*=== aigUtil.c =========================================================*/
extern unsigned Aig_PrimeCudd( unsigned p );
extern void Aig_ManIncrementTravId( Aig_Man_t * p );
+extern int Aig_ManHasNoGaps( Aig_Man_t * p );
extern int Aig_ManLevels( Aig_Man_t * p );
extern void Aig_ManResetRefs( Aig_Man_t * p );
extern void Aig_ManCleanMarkA( Aig_Man_t * p );
@@ -658,9 +644,10 @@ extern void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName, Vec_Ptr
extern void Aig_ManDumpVerilog( Aig_Man_t * p, char * pFileName );
extern void Aig_ManSetPioNumbers( Aig_Man_t * p );
extern void Aig_ManCleanPioNumbers( Aig_Man_t * p );
-extern int Aig_ManCountChoices( Aig_Man_t * p );
+extern int Aig_ManChoiceNum( Aig_Man_t * p );
extern char * Aig_FileNameGenericAppend( char * pBase, char * pSuffix );
extern unsigned Aig_ManRandom( int fReset );
+extern void Aig_ManRandomInfo( Vec_Ptr_t * vInfo, int iWordStart, int iWordStop );
extern void Aig_NodeUnionLists( Vec_Ptr_t * vArr1, Vec_Ptr_t * vArr2, Vec_Ptr_t * vArr );
extern void Aig_NodeIntersectLists( Vec_Ptr_t * vArr1, Vec_Ptr_t * vArr2, Vec_Ptr_t * vArr );
diff --git a/src/aig/aig/aigCanon.c b/src/aig/aig/aigCanon.c
index febad8ae..4f241842 100644
--- a/src/aig/aig/aigCanon.c
+++ b/src/aig/aig/aigCanon.c
@@ -96,14 +96,14 @@ Aig_RMan_t * Aig_RManStart()
{
static Bdc_Par_t Pars = {0}, * pPars = &Pars;
Aig_RMan_t * p;
- p = ALLOC( Aig_RMan_t, 1 );
+ p = ABC_ALLOC( Aig_RMan_t, 1 );
memset( p, 0, sizeof(Aig_RMan_t) );
p->nVars = RMAN_MAXVARS;
p->pAig = Aig_ManStart( 1000000 );
Aig_IthVar( p->pAig, p->nVars-1 );
// create hash table
p->nBins = Aig_PrimeCudd(5000);
- p->pBins = CALLOC( Aig_Tru_t *, p->nBins );
+ p->pBins = ABC_CALLOC( Aig_Tru_t *, p->nBins );
p->pMemTrus = Aig_MmFlexStart();
// bi-decomposition manager
pPars->nVarsMax = p->nVars;
@@ -179,7 +179,7 @@ clk = clock();
nBinsOld = p->nBins;
// get the new Bins
p->nBins = Aig_PrimeCudd( 3 * nBinsOld );
- p->pBins = CALLOC( Aig_Tru_t *, p->nBins );
+ p->pBins = ABC_CALLOC( Aig_Tru_t *, p->nBins );
// rehash the entries from the old table
Counter = 0;
for ( i = 0; i < nBinsOld; i++ )
@@ -195,8 +195,8 @@ clk = clock();
Counter++;
}
assert( Counter == p->nEntries );
-// PRT( "Time", clock() - clk );
- free( pBinsOld );
+// ABC_PRT( "Time", clock() - clk );
+ ABC_FREE( pBinsOld );
}
/**Function*************************************************************
@@ -259,8 +259,8 @@ void Aig_RManStop( Aig_RMan_t * p )
Aig_MmFlexStop( p->pMemTrus, 0 );
Aig_ManStop( p->pAig );
Bdc_ManFree( p->pBidec );
- free( p->pBins );
- free( p );
+ ABC_FREE( p->pBins );
+ ABC_FREE( p );
}
diff --git a/src/aig/aig/aigCuts.c b/src/aig/aig/aigCuts.c
index 494d0d5b..dc677269 100644
--- a/src/aig/aig/aigCuts.c
+++ b/src/aig/aig/aigCuts.c
@@ -46,7 +46,7 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in
assert( nCutsMax >= 2 );
assert( nLeafMax <= 16 );
// allocate the fraiging manager
- p = ALLOC( Aig_ManCut_t, 1 );
+ p = ABC_ALLOC( Aig_ManCut_t, 1 );
memset( p, 0, sizeof(Aig_ManCut_t) );
p->nCutsMax = nCutsMax;
p->nLeafMax = nLeafMax;
@@ -54,7 +54,7 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in
p->fVerbose = fVerbose;
p->pAig = pMan;
// allocate room for cuts and equivalent nodes
- p->pCuts = ALLOC( Aig_Cut_t *, Aig_ManObjNumMax(pMan) );
+ p->pCuts = ABC_ALLOC( Aig_Cut_t *, Aig_ManObjNumMax(pMan) );
memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pMan) );
// allocate memory manager
p->nTruthWords = Aig_TruthWordNum(nLeafMax);
@@ -63,7 +63,7 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in
// room for temporary truth tables
if ( fTruth )
{
- p->puTemp[0] = ALLOC( unsigned, 4 * p->nTruthWords );
+ p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords );
p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
@@ -85,9 +85,9 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in
void Aig_ManCutStop( Aig_ManCut_t * p )
{
Aig_MmFixedStop( p->pMemCuts, 0 );
- FREE( p->puTemp[0] );
- free( p->pCuts );
- free( p );
+ ABC_FREE( p->puTemp[0] );
+ ABC_FREE( p->pCuts );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -207,7 +207,7 @@ static inline float Aig_CutFindCost2( Aig_ManCut_t * p, Aig_Cut_t * pCut )
/**Function*************************************************************
- Synopsis [Returns the next free cut to use.]
+ Synopsis [Returns the next ABC_FREE cut to use.]
Description []
@@ -650,7 +650,7 @@ Aig_ManCut_t * Aig_ComputeCuts( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, in
Aig_ManObjNum(pAig), nCuts, nLeafMax, nCutsK );
printf( "Cut size = %2d. Truth size = %2d. Total mem = %5.2f Mb ",
p->nCutSize, 4*p->nTruthWords, 1.0*Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) );
- PRT( "Runtime", clock() - clk );
+ ABC_PRT( "Runtime", clock() - clk );
/*
Aig_ManForEachNode( pAig, pObj, i )
if ( i % 300 == 0 )
diff --git a/src/aig/aig/aigDup.c b/src/aig/aig/aigDup.c
index ade1edc0..6c9cb499 100644
--- a/src/aig/aig/aigDup.c
+++ b/src/aig/aig/aigDup.c
@@ -431,12 +431,12 @@ Aig_Man_t * Aig_ManDupDfs( Aig_Man_t * p )
// duplicate representation of choice nodes
if ( p->pEquivs )
{
- pNew->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
+ pNew->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
memset( pNew->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) );
}
if ( p->pReprs )
{
- pNew->pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
+ pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) );
}
// create the PIs
@@ -578,12 +578,12 @@ Aig_Man_t * Aig_ManDupDfsGuided( Aig_Man_t * p, Aig_Man_t * pGuide )
// duplicate representation of choice nodes
if ( p->pEquivs )
{
- pNew->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
+ pNew->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
memset( pNew->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) );
}
if ( p->pReprs )
{
- pNew->pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
+ pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) );
}
// create the PIs
@@ -651,12 +651,12 @@ Aig_Man_t * Aig_ManDupLevelized( Aig_Man_t * p )
// duplicate representation of choice nodes
if ( p->pEquivs )
{
- pNew->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
+ pNew->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
memset( pNew->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) );
}
if ( p->pReprs )
{
- pNew->pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
+ pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) );
}
// create the PIs
diff --git a/src/aig/aig/aigFanout.c b/src/aig/aig/aigFanout.c
index d0beb128..89702087 100644
--- a/src/aig/aig/aigFanout.c
+++ b/src/aig/aig/aigFanout.c
@@ -60,7 +60,7 @@ void Aig_ManFanoutStart( Aig_Man_t * p )
p->nFansAlloc = 2 * Aig_ManObjNumMax(p);
if ( p->nFansAlloc < (1<<12) )
p->nFansAlloc = (1<<12);
- p->pFanData = ALLOC( int, 5 * p->nFansAlloc );
+ p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc );
memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc );
// add fanouts for all objects
Aig_ManForEachObj( p, pObj, i )
@@ -86,7 +86,7 @@ void Aig_ManFanoutStart( Aig_Man_t * p )
void Aig_ManFanoutStop( Aig_Man_t * p )
{
assert( p->pFanData != NULL );
- FREE( p->pFanData );
+ ABC_FREE( p->pFanData );
p->nFansAlloc = 0;
}
@@ -110,7 +110,7 @@ void Aig_ObjAddFanout( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFanout )
if ( pObj->Id >= p->nFansAlloc || pFanout->Id >= p->nFansAlloc )
{
int nFansAlloc = 2 * AIG_MAX( pObj->Id, pFanout->Id );
- p->pFanData = REALLOC( int, p->pFanData, 5 * nFansAlloc );
+ p->pFanData = ABC_REALLOC( int, p->pFanData, 5 * nFansAlloc );
memset( p->pFanData + 5 * p->nFansAlloc, 0, sizeof(int) * 5 * (nFansAlloc - p->nFansAlloc) );
p->nFansAlloc = nFansAlloc;
}
diff --git a/src/aig/aig/aigFrames.c b/src/aig/aig/aigFrames.c
index 4cd23290..f25f7a8f 100644
--- a/src/aig/aig/aigFrames.c
+++ b/src/aig/aig/aigFrames.c
@@ -53,7 +53,7 @@ Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int fOuts, int
int i, f;
// create mapping for the frames nodes
- pObjMap = ALLOC( Aig_Obj_t *, nFs * Aig_ManObjNumMax(pAig) );
+ pObjMap = ABC_ALLOC( Aig_Obj_t *, nFs * Aig_ManObjNumMax(pAig) );
memset( pObjMap, 0, sizeof(Aig_Obj_t *) * nFs * Aig_ManObjNumMax(pAig) );
// start the fraig package
@@ -124,7 +124,7 @@ Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int fOuts, int
if ( ppObjMap )
*ppObjMap = pObjMap;
else
- free( pObjMap );
+ ABC_FREE( pObjMap );
return pFrames;
}
diff --git a/src/aig/aig/aigInter.c b/src/aig/aig/aigInter.c
index 80198753..23c1dbf5 100644
--- a/src/aig/aig/aigInter.c
+++ b/src/aig/aig/aigInter.c
@@ -122,14 +122,14 @@ void Aig_ManInterFast( Aig_Man_t * pManOn, Aig_Man_t * pManOff, int fVerbose )
Lits[0] = toLitCond( pCnfOn->pVarNums[pObj->Id], 0 );
Lits[1] = toLitCond( pCnfOff->pVarNums[pObj2->Id], 0 );
- status = sat_solver_solve( pSat, Lits, Lits+2, (sint64)0, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, Lits, Lits+2, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( status != l_False )
printf( "The incremental SAT problem is not UNSAT.\n" );
}
Cnf_DataFree( pCnfOn );
Cnf_DataFree( pCnfOff );
sat_solver_delete( pSat );
-// PRT( "Fast interpolation time", clock() - clk );
+// ABC_PRT( "Fast interpolation time", clock() - clk );
}
/**Function*************************************************************
@@ -242,7 +242,7 @@ clk = clock();
*/
// solve the problem
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
timeSat += clock() - clk;
if ( status == l_False )
{
diff --git a/src/aig/aig/aigMan.c b/src/aig/aig/aigMan.c
index a13550df..0b6ff6bd 100644
--- a/src/aig/aig/aigMan.c
+++ b/src/aig/aig/aigMan.c
@@ -47,7 +47,7 @@ Aig_Man_t * Aig_ManStart( int nNodesMax )
if ( nNodesMax <= 0 )
nNodesMax = 10007;
// start the manager
- p = ALLOC( Aig_Man_t, 1 );
+ p = ABC_ALLOC( Aig_Man_t, 1 );
memset( p, 0, sizeof(Aig_Man_t) );
// perform initializations
p->nTravIds = 1;
@@ -66,7 +66,7 @@ Aig_Man_t * Aig_ManStart( int nNodesMax )
p->nObjs[AIG_OBJ_CONST1]++;
// start the table
p->nTableSize = Aig_PrimeCudd( nNodesMax );
- p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize );
+ p->pTable = ABC_ALLOC( Aig_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
return p;
}
@@ -186,8 +186,8 @@ void Aig_ManStop( Aig_Man_t * p )
if ( p->vMapped )
Vec_PtrFree( p->vMapped );
// print time
- if ( p->time1 ) { PRT( "time1", p->time1 ); }
- if ( p->time2 ) { PRT( "time2", p->time2 ); }
+ if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); }
+ if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); }
// delete timing
if ( p->pManTime )
Tim_ManStop( p->pManTime );
@@ -211,16 +211,16 @@ void Aig_ManStop( Aig_Man_t * p )
if ( p->vOnehots ) Vec_VecFree( (Vec_Vec_t *)p->vOnehots );
if ( p->vClockDoms) Vec_VecFree( p->vClockDoms );
if ( p->vProbs ) Vec_IntFree( p->vProbs );
- FREE( p->pFastSim );
- FREE( p->pData );
- FREE( p->pSeqModel );
- FREE( p->pName );
- FREE( p->pSpec );
- FREE( p->pObjCopies );
- FREE( p->pReprs );
- FREE( p->pEquivs );
- free( p->pTable );
- free( p );
+ ABC_FREE( p->pFastSim );
+ ABC_FREE( p->pData );
+ ABC_FREE( p->pSeqModel );
+ ABC_FREE( p->pName );
+ ABC_FREE( p->pSpec );
+ ABC_FREE( p->pObjCopies );
+ ABC_FREE( p->pReprs );
+ ABC_FREE( p->pEquivs );
+ ABC_FREE( p->pTable );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -371,7 +371,7 @@ int Aig_ManHaigCounter( Aig_Man_t * pAig )
***********************************************************************/
void Aig_ManPrintStats( Aig_Man_t * p )
{
- int nChoices = Aig_ManCountChoices(p);
+ int nChoices = Aig_ManChoiceNum(p);
printf( "%-15s : ", p->pName );
printf( "pi = %5d ", Aig_ManPiNum(p) );
printf( "po = %5d ", Aig_ManPoNum(p) );
diff --git a/src/aig/aig/aigMem.c b/src/aig/aig/aigMem.c
index 80a5ceb5..c0b76ff8 100644
--- a/src/aig/aig/aigMem.c
+++ b/src/aig/aig/aigMem.c
@@ -31,7 +31,7 @@ struct Aig_MmFixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of free entries
+ char * pEntriesFree; // the linked list of ABC_FREE entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -48,8 +48,8 @@ struct Aig_MmFlex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
- char * pCurrent; // the current pointer to free memory
- char * pEnd; // the first entry outside the free memory
+ char * pCurrent; // the current pointer to ABC_FREE memory
+ char * pEnd; // the first entry outside the ABC_FREE memory
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -74,12 +74,6 @@ struct Aig_MmStep_t_
char ** pChunks; // the allocated memory
};
-#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
-#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
-#define REALLOC(type, obj, num) \
- ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
- ((type *) malloc(sizeof(type) * (num))))
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,7 +94,7 @@ Aig_MmFixed_t * Aig_MmFixedStart( int nEntrySize, int nEntriesMax )
{
Aig_MmFixed_t * p;
- p = ALLOC( Aig_MmFixed_t, 1 );
+ p = ABC_ALLOC( Aig_MmFixed_t, 1 );
memset( p, 0, sizeof(Aig_MmFixed_t) );
p->nEntrySize = nEntrySize;
@@ -114,7 +108,7 @@ Aig_MmFixed_t * Aig_MmFixedStart( int nEntrySize, int nEntriesMax )
p->nChunksAlloc = 64;
p->nChunks = 0;
- p->pChunks = ALLOC( char *, p->nChunksAlloc );
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
p->nMemoryUsed = 0;
p->nMemoryAlloc = 0;
@@ -145,9 +139,9 @@ void Aig_MmFixedStop( Aig_MmFixed_t * p, int fVerbose )
p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc );
}
for ( i = 0; i < p->nChunks; i++ )
- free( p->pChunks[i] );
- free( p->pChunks );
- free( p );
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -166,16 +160,16 @@ char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p )
char * pTemp;
int i;
- // check if there are still free entries
+ // check if there are still ABC_FREE entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
if ( p->nChunks == p->nChunksAlloc )
{
p->nChunksAlloc *= 2;
- p->pChunks = REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
}
- p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize );
+ p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize );
p->nMemoryAlloc += p->nEntrySize * p->nChunkSize;
// transform these entries into a linked list
pTemp = p->pEntriesFree;
@@ -195,7 +189,7 @@ char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the free entry list
+ // return the first entry in the ABC_FREE entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -216,7 +210,7 @@ void Aig_MmFixedEntryRecycle( Aig_MmFixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of free entries
+ // add the entry to the linked list of ABC_FREE entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -240,7 +234,7 @@ void Aig_MmFixedRestart( Aig_MmFixed_t * p )
return;
// deallocate all chunks except the first one
for ( i = 1; i < p->nChunks; i++ )
- free( p->pChunks[i] );
+ ABC_FREE( p->pChunks[i] );
p->nChunks = 1;
// transform these entries into a linked list
pTemp = p->pChunks[0];
@@ -251,7 +245,7 @@ void Aig_MmFixedRestart( Aig_MmFixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the free entry list
+ // set the ABC_FREE entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -309,7 +303,7 @@ Aig_MmFlex_t * Aig_MmFlexStart()
{
Aig_MmFlex_t * p;
- p = ALLOC( Aig_MmFlex_t, 1 );
+ p = ABC_ALLOC( Aig_MmFlex_t, 1 );
memset( p, 0, sizeof(Aig_MmFlex_t) );
p->nEntriesUsed = 0;
@@ -319,7 +313,7 @@ Aig_MmFlex_t * Aig_MmFlexStart()
p->nChunkSize = (1 << 18);
p->nChunksAlloc = 64;
p->nChunks = 0;
- p->pChunks = ALLOC( char *, p->nChunksAlloc );
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
p->nMemoryUsed = 0;
p->nMemoryAlloc = 0;
@@ -350,9 +344,9 @@ void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose )
p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc );
}
for ( i = 0; i < p->nChunks; i++ )
- free( p->pChunks[i] );
- free( p->pChunks );
- free( p );
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -369,13 +363,13 @@ void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose )
char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes )
{
char * pTemp;
- // check if there are still free entries
+ // check if there are still ABC_FREE entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries
if ( p->nChunks == p->nChunksAlloc )
{
p->nChunksAlloc *= 2;
- p->pChunks = REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
}
if ( nBytes > p->nChunkSize )
{
@@ -383,7 +377,7 @@ char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes )
// (ideally, this should never happen)
p->nChunkSize = 2 * nBytes;
}
- p->pCurrent = ALLOC( char, p->nChunkSize );
+ p->pCurrent = ABC_ALLOC( char, p->nChunkSize );
p->pEnd = p->pCurrent + p->nChunkSize;
p->nMemoryAlloc += p->nChunkSize;
// add the chunk to the chunk storage
@@ -418,7 +412,7 @@ void Aig_MmFlexRestart( Aig_MmFlex_t * p )
return;
// deallocate all chunks except the first one
for ( i = 1; i < p->nChunks; i++ )
- free( p->pChunks[i] );
+ ABC_FREE( p->pChunks[i] );
p->nChunks = 1;
p->nMemoryAlloc = p->nChunkSize;
// transform these entries into a linked list
@@ -461,7 +455,7 @@ int Aig_MmFlexReadMemUsage( Aig_MmFlex_t * p )
are employed internally. Calling this procedure with nSteps equal
to 10 results in 10 hierarchically arranged internal memory managers,
which can allocate up to 4096 (1Kb) entries. Requests for larger
- entries are handed over to malloc() and then free()ed.]
+ entries are handed over to malloc() and then ABC_FREE()ed.]
SideEffects []
@@ -472,16 +466,16 @@ Aig_MmStep_t * Aig_MmStepStart( int nSteps )
{
Aig_MmStep_t * p;
int i, k;
- p = ALLOC( Aig_MmStep_t, 1 );
+ p = ABC_ALLOC( Aig_MmStep_t, 1 );
memset( p, 0, sizeof(Aig_MmStep_t) );
p->nMems = nSteps;
// start the fixed memory managers
- p->pMems = ALLOC( Aig_MmFixed_t *, p->nMems );
+ p->pMems = ABC_ALLOC( Aig_MmFixed_t *, p->nMems );
for ( i = 0; i < p->nMems; i++ )
p->pMems[i] = Aig_MmFixedStart( (8<<i), (1<<13) );
// set up the mapping of the required memory size into the corresponding manager
p->nMapSize = (4<<p->nMems);
- p->pMap = ALLOC( Aig_MmFixed_t *, p->nMapSize+1 );
+ p->pMap = ABC_ALLOC( Aig_MmFixed_t *, p->nMapSize+1 );
p->pMap[0] = NULL;
for ( k = 1; k <= 4; k++ )
p->pMap[k] = p->pMems[0];
@@ -492,7 +486,7 @@ Aig_MmStep_t * Aig_MmStepStart( int nSteps )
//printf( "%10d: size = %10d\n", i, p->pMap[i]->nEntrySize );
p->nChunksAlloc = 64;
p->nChunks = 0;
- p->pChunks = ALLOC( char *, p->nChunksAlloc );
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
return p;
}
@@ -515,12 +509,12 @@ void Aig_MmStepStop( Aig_MmStep_t * p, int fVerbose )
if ( p->nChunksAlloc )
{
for ( i = 0; i < p->nChunks; i++ )
- free( p->pChunks[i] );
- free( p->pChunks );
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
}
- free( p->pMems );
- free( p->pMap );
- free( p );
+ ABC_FREE( p->pMems );
+ ABC_FREE( p->pMap );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -543,9 +537,9 @@ char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes )
if ( p->nChunks == p->nChunksAlloc )
{
p->nChunksAlloc *= 2;
- p->pChunks = REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
}
- p->pChunks[ p->nChunks++ ] = ALLOC( char, nBytes );
+ p->pChunks[ p->nChunks++ ] = ABC_ALLOC( char, nBytes );
return p->pChunks[p->nChunks-1];
}
return Aig_MmFixedEntryFetch( p->pMap[nBytes] );
@@ -569,7 +563,7 @@ void Aig_MmStepEntryRecycle( Aig_MmStep_t * p, char * pEntry, int nBytes )
return;
if ( nBytes > p->nMapSize )
{
-// free( pEntry );
+// ABC_FREE( pEntry );
return;
}
Aig_MmFixedEntryRecycle( p->pMap[nBytes], pEntry );
diff --git a/src/aig/aig/aigOrder.c b/src/aig/aig/aigOrder.c
index 62aeca6e..746f0f18 100644
--- a/src/aig/aig/aigOrder.c
+++ b/src/aig/aig/aigOrder.c
@@ -49,7 +49,7 @@ void Aig_ManOrderStart( Aig_Man_t * p )
p->nOrderAlloc = 2 * Aig_ManObjNumMax(p);
if ( p->nOrderAlloc < (1<<12) )
p->nOrderAlloc = (1<<12);
- p->pOrderData = ALLOC( unsigned, 2 * p->nOrderAlloc );
+ p->pOrderData = ABC_ALLOC( unsigned, 2 * p->nOrderAlloc );
memset( p->pOrderData, 0xFF, sizeof(unsigned) * 2 * p->nOrderAlloc );
// add the constant node
p->pOrderData[0] = p->pOrderData[1] = 0;
@@ -73,7 +73,7 @@ void Aig_ManOrderStart( Aig_Man_t * p )
void Aig_ManOrderStop( Aig_Man_t * p )
{
assert( p->pOrderData );
- FREE( p->pOrderData );
+ ABC_FREE( p->pOrderData );
p->nOrderAlloc = 0;
p->iPrev = p->iNext = 0;
}
@@ -97,7 +97,7 @@ void Aig_ObjOrderInsert( Aig_Man_t * p, int ObjId )
if ( ObjId >= p->nOrderAlloc )
{
int nOrderAlloc = 2 * ObjId;
- p->pOrderData = REALLOC( unsigned, p->pOrderData, 2 * nOrderAlloc );
+ p->pOrderData = ABC_REALLOC( unsigned, p->pOrderData, 2 * nOrderAlloc );
memset( p->pOrderData + 2 * p->nOrderAlloc, 0xFF, sizeof(unsigned) * 2 * (nOrderAlloc - p->nOrderAlloc) );
p->nOrderAlloc = nOrderAlloc;
}
diff --git a/src/aig/aig/aigPart.c b/src/aig/aig/aigPart.c
index aca07bd9..1fd85768 100644
--- a/src/aig/aig/aigPart.c
+++ b/src/aig/aig/aigPart.c
@@ -30,10 +30,10 @@ struct Part_Man_t_
{
int nChunkSize; // the size of one chunk of memory (~1 Mb)
int nStepSize; // the step size in saving memory (~64 bytes)
- char * pFreeBuf; // the pointer to free memory
- int nFreeSize; // the size of remaining free memory
+ char * pFreeBuf; // the pointer to ABC_FREE memory
+ int nFreeSize; // the size of remaining ABC_FREE memory
Vec_Ptr_t * vMemory; // the memory allocated
- Vec_Ptr_t * vFree; // the vector of free pieces of memory
+ Vec_Ptr_t * vFree; // the vector of ABC_FREE pieces of memory
};
typedef struct Part_One_t_ Part_One_t;
@@ -67,7 +67,7 @@ static inline void Part_OneSetNext( char * pPart, char * pNext ) { *((char **)
Part_Man_t * Part_ManStart( int nChunkSize, int nStepSize )
{
Part_Man_t * p;
- p = ALLOC( Part_Man_t, 1 );
+ p = ABC_ALLOC( Part_Man_t, 1 );
memset( p, 0, sizeof(Part_Man_t) );
p->nChunkSize = nChunkSize;
p->nStepSize = nStepSize;
@@ -92,10 +92,10 @@ void Part_ManStop( Part_Man_t * p )
void * pMemory;
int i;
Vec_PtrForEachEntry( p->vMemory, pMemory, i )
- free( pMemory );
+ ABC_FREE( pMemory );
Vec_PtrFree( p->vMemory );
Vec_PtrFree( p->vFree );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -124,7 +124,7 @@ char * Part_ManFetch( Part_Man_t * p, int nSize )
nSizeReal = p->nStepSize * Type;
if ( p->nFreeSize < nSizeReal )
{
- p->pFreeBuf = ALLOC( char, p->nChunkSize );
+ p->pFreeBuf = ABC_ALLOC( char, p->nChunkSize );
p->nFreeSize = p->nChunkSize;
Vec_PtrPush( p->vMemory, p->pFreeBuf );
}
@@ -447,7 +447,7 @@ unsigned * Aig_ManSuppCharStart( Vec_Int_t * vOne, int nPis )
unsigned * pBuffer;
int i, Entry;
int nWords = Aig_BitWordNum(nPis);
- pBuffer = ALLOC( unsigned, nWords );
+ pBuffer = ABC_ALLOC( unsigned, nWords );
memset( pBuffer, 0, sizeof(unsigned) * nWords );
Vec_IntForEachEntry( vOne, Entry, i )
{
@@ -670,7 +670,7 @@ clk = clock();
vSupports = Aig_ManSupports( p );
if ( fVerbose )
{
-PRT( "Supps", clock() - clk );
+ABC_PRT( "Supps", clock() - clk );
}
// start char-based support representation
vPartSuppsBit = Vec_PtrAlloc( 1000 );
@@ -716,13 +716,13 @@ clk = clock();
// stop char-based support representation
Vec_PtrForEachEntry( vPartSuppsBit, vTemp, i )
- free( vTemp );
+ ABC_FREE( vTemp );
Vec_PtrFree( vPartSuppsBit );
//printf( "\n" );
if ( fVerbose )
{
-PRT( "Parts", clock() - clk );
+ABC_PRT( "Parts", clock() - clk );
}
clk = clock();
@@ -748,7 +748,7 @@ clk = clock();
if ( fVerbose )
{
-//PRT( "Comps", clock() - clk );
+//ABC_PRT( "Comps", clock() - clk );
}
// cleanup
@@ -797,7 +797,7 @@ clk = clock();
Vec_IntPush( vOne, i );
if ( fVerbose )
{
-PRT( "Supps", clock() - clk );
+ABC_PRT( "Supps", clock() - clk );
}
// start char-based support representation
@@ -844,13 +844,13 @@ clk = clock();
// stop char-based support representation
Vec_PtrForEachEntry( vPartSuppsBit, vTemp, i )
- free( vTemp );
+ ABC_FREE( vTemp );
Vec_PtrFree( vPartSuppsBit );
//printf( "\n" );
if ( fVerbose )
{
-PRT( "Parts", clock() - clk );
+ABC_PRT( "Parts", clock() - clk );
}
clk = clock();
@@ -876,7 +876,7 @@ clk = clock();
if ( fVerbose )
{
-//PRT( "Comps", clock() - clk );
+//ABC_PRT( "Comps", clock() - clk );
}
// cleanup
@@ -1281,7 +1281,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
}
Vec_PtrFree( vOuts );
// store contents of pData pointers
- ppData = ALLOC( void *, Aig_ManObjNumMax(pAigPart) );
+ ppData = ABC_ALLOC( void *, Aig_ManObjNumMax(pAigPart) );
Aig_ManForEachObj( pAigPart, pObj, k )
ppData[k] = pObj->pData;
// report the process
@@ -1295,7 +1295,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
// reset the pData pointers
Aig_ManForEachObj( pAigPart, pObj, k )
pObj->pData = ppData[k];
- free( ppData );
+ ABC_FREE( ppData );
// transfer representatives to the total AIG
if ( pAigPart->pReprs )
Aig_ManTransferRepr( pAigTotal, pAigPart );
@@ -1372,7 +1372,7 @@ Aig_Man_t * Aig_ManFraigPartitioned( Aig_Man_t * pAig, int nPartSize, int nConfM
// derive the partition AIG
pAigPart = Aig_ManDupPartAll( pAig, vPart );
// store contents of pData pointers
- ppData = ALLOC( void *, Aig_ManObjNumMax(pAigPart) );
+ ppData = ABC_ALLOC( void *, Aig_ManObjNumMax(pAigPart) );
Aig_ManForEachObj( pAigPart, pObj, k )
ppData[k] = pObj->pData;
// report the process
@@ -1386,7 +1386,7 @@ Aig_Man_t * Aig_ManFraigPartitioned( Aig_Man_t * pAig, int nPartSize, int nConfM
// reset the pData pointers
Aig_ManForEachObj( pAigPart, pObj, k )
pObj->pData = ppData[k];
- free( ppData );
+ ABC_FREE( ppData );
// transfer representatives to the total AIG
if ( pAigPart->pReprs )
Aig_ManTransferRepr( pAig, pAigPart );
@@ -1549,7 +1549,7 @@ Aig_Man_t * Aig_ManChoiceConstructive( Vec_Ptr_t * vAigs, int fVerbose )
// create room for equivalent nodes and representatives
assert( pNew->pReprs == NULL );
pNew->nReprsAlloc = Vec_PtrSize(vAigs) * Aig_ManObjNumMax(pNew);
- pNew->pReprs = ALLOC( Aig_Obj_t *, pNew->nReprsAlloc );
+ pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, pNew->nReprsAlloc );
memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * pNew->nReprsAlloc );
// add other AIGs one by one
Vec_PtrForEachEntryStart( vAigs, pThis, i, 1 )
diff --git a/src/aig/aig/aigPartReg.c b/src/aig/aig/aigPartReg.c
index 36be0810..1e77c224 100644
--- a/src/aig/aig/aigPartReg.c
+++ b/src/aig/aig/aigPartReg.c
@@ -39,7 +39,7 @@ struct Aig_ManPre_t_
// info about the current partition
Vec_Int_t * vRegs; // registers of this partition
Vec_Int_t * vUniques; // unique registers of this partition
- Vec_Int_t * vFreeVars; // free variables of this partition
+ Vec_Int_t * vFreeVars; // ABC_FREE variables of this partition
Vec_Flt_t * vPartCost; // costs of adding each variable
char * pfPartVars; // input/output registers of the partition
};
@@ -63,7 +63,7 @@ struct Aig_ManPre_t_
Aig_ManPre_t * Aig_ManRegManStart( Aig_Man_t * pAig, int nPartSize )
{
Aig_ManPre_t * p;
- p = ALLOC( Aig_ManPre_t, 1 );
+ p = ABC_ALLOC( Aig_ManPre_t, 1 );
memset( p, 0, sizeof(Aig_ManPre_t) );
p->pAig = pAig;
p->vMatrix = Aig_ManSupportsRegisters( pAig );
@@ -73,9 +73,9 @@ Aig_ManPre_t * Aig_ManRegManStart( Aig_Man_t * pAig, int nPartSize )
p->vUniques = Vec_IntAlloc(256);
p->vFreeVars = Vec_IntAlloc(256);
p->vPartCost = Vec_FltAlloc(256);
- p->pfUsedRegs = ALLOC( char, Aig_ManRegNum(p->pAig) );
+ p->pfUsedRegs = ABC_ALLOC( char, Aig_ManRegNum(p->pAig) );
memset( p->pfUsedRegs, 0, sizeof(char) * Aig_ManRegNum(p->pAig) );
- p->pfPartVars = ALLOC( char, Aig_ManRegNum(p->pAig) );
+ p->pfPartVars = ABC_ALLOC( char, Aig_ManRegNum(p->pAig) );
return p;
}
@@ -99,9 +99,9 @@ void Aig_ManRegManStop( Aig_ManPre_t * p )
Vec_IntFree( p->vUniques );
Vec_IntFree( p->vFreeVars );
Vec_FltFree( p->vPartCost );
- free( p->pfUsedRegs );
- free( p->pfPartVars );
- free( p );
+ ABC_FREE( p->pfUsedRegs );
+ ABC_FREE( p->pfPartVars );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -155,7 +155,7 @@ int Aig_ManRegFindBestVar( Aig_ManPre_t * p )
Vec_Int_t * vSupp;
int nNewVars, nNewVarsBest = AIG_INFINITY;
int iVarFree, iVarSupp, iVarBest = -1, i, k;
- // go through the free variables
+ // go through the ABC_FREE variables
Vec_IntForEachEntry( p->vFreeVars, iVarFree, i )
{
// if ( p->pfUsedRegs[iVarFree] )
@@ -205,7 +205,7 @@ void Aig_ManRegPartitionAdd( Aig_ManPre_t * p, int iReg )
p->pfUsedRegs[iReg] = 1;
Vec_IntPush( p->vUniques, iReg );
}
- // remove it from the free variables
+ // remove it from the ABC_FREE variables
if ( Vec_IntSize(p->vFreeVars) > 0 )
{
assert( p->pfPartVars[iReg] );
@@ -372,7 +372,7 @@ Aig_Man_t * Aig_ManRegCreatePart( Aig_Man_t * pAig, Vec_Int_t * vPart, int * pnC
// create map
if ( ppMapBack )
{
- pMapBack = ALLOC( int, Aig_ManObjNumMax(pNew) );
+ pMapBack = ABC_ALLOC( int, Aig_ManObjNumMax(pNew) );
memset( pMapBack, 0xff, sizeof(int) * Aig_ManObjNumMax(pNew) );
// map constant nodes
pMapBack[0] = 0;
@@ -441,7 +441,7 @@ Vec_Ptr_t * Aig_ManRegPartitionSmart( Aig_Man_t * pAig, int nPartSize )
//printf( "Part %3d Reg %3d : Free = %4d. Total = %4d. Ratio = %6.2f. Unique = %4d.\n", i, k,
// Vec_IntSize(p->vFreeVars), Vec_IntSize(p->vRegs),
// 1.0*Vec_IntSize(p->vFreeVars)/Vec_IntSize(p->vRegs), Vec_IntSize(p->vUniques) );
- // quit if there are not free variables
+ // quit if there are not ABC_FREE variables
if ( Vec_IntSize(p->vFreeVars) == 0 )
break;
}
diff --git a/src/aig/aig/aigPartSat.c b/src/aig/aig/aigPartSat.c
index 15aa1a05..a8c9008f 100644
--- a/src/aig/aig/aigPartSat.c
+++ b/src/aig/aig/aigPartSat.c
@@ -520,7 +520,7 @@ int Aig_ManPartitionedSat( Aig_Man_t * p, int nAlgo, int nPartSize,
if ( fVerbose )
{
printf( "Partitioning derived %d partitions. ", Vec_IntFindMax(vNode2Part) + 1 );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// split the original AIG into partition AIGs (vAigs)
@@ -532,7 +532,7 @@ int Aig_ManPartitionedSat( Aig_Man_t * p, int nAlgo, int nPartSize,
if ( fVerbose )
{
printf( "Partions were transformed into AIGs. " );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// synthesize partitions
@@ -567,13 +567,13 @@ clk = clock();
break;
}
// call the SAT solver
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfRemaining, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfRemaining, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( fVerbose )
{
printf( "%4d : Aig = %6d. Vs = %7d. RootCs = %7d. LearnCs = %6d. ",
i, nNodes += Aig_ManNodeNum(pAig), sat_solver_nvars(pSat),
(int)pSat->stats.clauses, (int)pSat->stats.learnts );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
// analize the result
if ( status == l_False )
diff --git a/src/aig/aig/aigRepr.c b/src/aig/aig/aigRepr.c
index 7a092c0f..0ab02144 100644
--- a/src/aig/aig/aigRepr.c
+++ b/src/aig/aig/aigRepr.c
@@ -44,7 +44,7 @@ void Aig_ManReprStart( Aig_Man_t * p, int nIdMax )
assert( Aig_ManBufNum(p) == 0 );
assert( p->pReprs == NULL );
p->nReprsAlloc = nIdMax;
- p->pReprs = ALLOC( Aig_Obj_t *, p->nReprsAlloc );
+ p->pReprs = ABC_ALLOC( Aig_Obj_t *, p->nReprsAlloc );
memset( p->pReprs, 0, sizeof(Aig_Obj_t *) * p->nReprsAlloc );
}
@@ -62,7 +62,7 @@ void Aig_ManReprStart( Aig_Man_t * p, int nIdMax )
void Aig_ManReprStop( Aig_Man_t * p )
{
assert( p->pReprs != NULL );
- FREE( p->pReprs );
+ ABC_FREE( p->pReprs );
p->nReprsAlloc = 0;
}
@@ -214,7 +214,7 @@ void Aig_ManTransferRepr( Aig_Man_t * pNew, Aig_Man_t * pOld )
if ( pNew->nReprsAlloc < Aig_ManObjNumMax(pNew) )
{
int nReprsAllocNew = 2 * Aig_ManObjNumMax(pNew);
- pNew->pReprs = REALLOC( Aig_Obj_t *, pNew->pReprs, nReprsAllocNew );
+ pNew->pReprs = ABC_REALLOC( Aig_Obj_t *, pNew->pReprs, nReprsAllocNew );
memset( pNew->pReprs + pNew->nReprsAlloc, 0, sizeof(Aig_Obj_t *) * (nReprsAllocNew-pNew->nReprsAlloc) );
pNew->nReprsAlloc = nReprsAllocNew;
}
@@ -476,7 +476,7 @@ void Aig_ManMarkValidChoices( Aig_Man_t * p )
assert( p->pReprs != NULL );
// create equivalent nodes in the manager
assert( p->pEquivs == NULL );
- p->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
+ p->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) );
memset( p->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) );
// make the choice nodes
Aig_ManForEachNode( p, pObj, i )
diff --git a/src/aig/aig/aigRet.c b/src/aig/aig/aigRet.c
index 4641318a..c5cc6392 100644
--- a/src/aig/aig/aigRet.c
+++ b/src/aig/aig/aigRet.c
@@ -174,7 +174,7 @@ void Rtm_ObjTransferToBig( Rtm_Man_t * p, Rtm_Edg_t * pEdge )
if ( p->nExtraCur + 1 > p->nExtraAlloc )
{
int nExtraAllocNew = AIG_MAX( 2 * p->nExtraAlloc, 1024 );
- p->pExtra = REALLOC( unsigned, p->pExtra, nExtraAllocNew );
+ p->pExtra = ABC_REALLOC( unsigned, p->pExtra, nExtraAllocNew );
p->nExtraAlloc = nExtraAllocNew;
}
p->pExtra[p->nExtraCur] = pEdge->LData;
@@ -200,7 +200,7 @@ void Rtm_ObjTransferToBigger( Rtm_Man_t * p, Rtm_Edg_t * pEdge )
if ( p->nExtraCur + nWords + 1 > p->nExtraAlloc )
{
int nExtraAllocNew = AIG_MAX( 2 * p->nExtraAlloc, 1024 );
- p->pExtra = REALLOC( unsigned, p->pExtra, nExtraAllocNew );
+ p->pExtra = ABC_REALLOC( unsigned, p->pExtra, nExtraAllocNew );
p->nExtraAlloc = nExtraAllocNew;
}
memcpy( p->pExtra + p->nExtraCur, p->pExtra + pEdge->LData, sizeof(unsigned) * nWords );
@@ -300,7 +300,7 @@ Rtm_Man_t * Rtm_ManAlloc( Aig_Man_t * p )
{
Rtm_Man_t * pRtm;
// start the manager
- pRtm = ALLOC( Rtm_Man_t, 1 );
+ pRtm = ABC_ALLOC( Rtm_Man_t, 1 );
memset( pRtm, 0, sizeof(Rtm_Man_t) );
// perform initializations
pRtm->vObjs = Vec_PtrAlloc( Aig_ManObjNum(p) );
@@ -327,8 +327,8 @@ void Rtm_ManFree( Rtm_Man_t * p )
Vec_PtrFree( p->vPis );
Vec_PtrFree( p->vPos );
Aig_MmFlexStop( p->pMem, 0 );
- FREE( p->pExtra );
- free( p );
+ ABC_FREE( p->pExtra );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -767,7 +767,7 @@ Aig_Man_t * Rtm_ManToAig( Rtm_Man_t * pRtm )
Rtm_Edg_t * pEdge;
int i, k, m, Val, nLatches, * pLatches;
// count latches and mark the first latch on each edge
- pLatches = ALLOC( int, 2 * Vec_PtrSize(pRtm->vObjs) );
+ pLatches = ABC_ALLOC( int, 2 * Vec_PtrSize(pRtm->vObjs) );
nLatches = 0;
Rtm_ManForEachObj( pRtm, pObjRtm, i )
Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k )
@@ -808,7 +808,7 @@ Aig_Man_t * Rtm_ManToAig( Rtm_Man_t * pRtm )
}
// assert( Aig_Regular(pObjNew)->nRefs > 0 );
}
- free( pLatches );
+ ABC_FREE( pLatches );
Aig_ManSetRegNum( pNew, nLatches );
// remove useless nodes
Aig_ManCleanup( pNew );
@@ -852,7 +852,7 @@ clk = clock();
if ( fVerbose )
{
printf( "Detected %d autonomous objects. ", nAutos );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// set the current retiming number
@@ -943,7 +943,7 @@ clk = clock();
printf( "Performed %d %s latch moves of max depth %d and max latch count %d.\n",
Vec_PtrSize(vQueue), fForward? "fwd":"bwd", DegreeMax, Rtm_ManLatchMax(pRtm) );
printf( "Memory usage = %d. ", pRtm->nExtraCur );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
Vec_PtrFree( vQueue );
@@ -957,7 +957,7 @@ clk = clock();
pNew = Aig_ManReduceLaches( pNew, fVerbose );
if ( fVerbose )
{
- PRT( "Register sharing time", clock() - clk );
+ ABC_PRT( "Register sharing time", clock() - clk );
}
return pNew;
}
diff --git a/src/aig/aig/aigScl.c b/src/aig/aig/aigScl.c
index 57b7b989..b6331b0e 100644
--- a/src/aig/aig/aigScl.c
+++ b/src/aig/aig/aigScl.c
@@ -396,7 +396,7 @@ Vec_Ptr_t * Aig_ManReduceLachesOnce( Aig_Man_t * p )
Aig_ManForEachPiSeq( p, pObj, i )
Vec_PtrPush( vMap, pObj );
// create mapping of fanin nodes into the corresponding latch outputs
- pMapping = ALLOC( int, 2 * Aig_ManObjNumMax(p) );
+ pMapping = ABC_ALLOC( int, 2 * Aig_ManObjNumMax(p) );
Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
{
pFanin = Aig_ObjFanin0(pObjLi);
@@ -427,7 +427,7 @@ Vec_Ptr_t * Aig_ManReduceLachesOnce( Aig_Man_t * p )
}
}
}
- free( pMapping );
+ ABC_FREE( pMapping );
Aig_ManForEachLiSeq( p, pObj, i )
{
pFanin = Aig_ObjFanin0(pObj);
@@ -456,6 +456,7 @@ Aig_Man_t * Aig_ManReduceLaches( Aig_Man_t * p, int fVerbose )
printf( "Performing combinational register sweep:\n" );
for ( nSaved = 0; (nCur = Aig_ManReduceLachesCount(p)); nSaved += nCur )
{
+// printf( "Reducible = %d\n", nCur );
vMap = Aig_ManReduceLachesOnce( p );
p = Aig_ManRemap( pTemp = p, vMap );
Vec_PtrFree( vMap );
@@ -532,7 +533,7 @@ void Aig_ManComputeSccs( Aig_Man_t * p )
// detect strongly connected components
vComp = Vec_IntAlloc( Aig_ManRegNum(p) );
- pVarsTot = ALLOC( char, Aig_ManRegNum(p) );
+ pVarsTot = ABC_ALLOC( char, Aig_ManRegNum(p) );
memset( pVarsTot, 0, Aig_ManRegNum(p) * sizeof(char) );
for ( nComps = 0; ; nComps++ )
{
@@ -571,7 +572,7 @@ void Aig_ManComputeSccs( Aig_Man_t * p )
}
printf( "SCC #%d contains %5d registers.\n", nComps+1, Vec_IntSize(vComp) );
}
- free( pVarsTot );
+ ABC_FREE( pVarsTot );
Vec_IntFree( vComp );
Vec_PtrFree( vMatrix );
Vec_VecFree( (Vec_Vec_t *)vMatrix2 );
@@ -622,7 +623,7 @@ Aig_Man_t * Aig_ManSclPart( Aig_Man_t * pAig, int fLatchConst, int fLatchEqual,
Aig_ManStop( pNew );
}
Aig_ManStop( pTemp );
- free( pMapBack );
+ ABC_FREE( pMapBack );
}
pNew = Aig_ManDupRepr( pAig, 0 );
Aig_ManSeqCleanup( pNew );
diff --git a/src/aig/aig/aigTable.c b/src/aig/aig/aigTable.c
index 68efbba6..7ca4bb32 100644
--- a/src/aig/aig/aigTable.c
+++ b/src/aig/aig/aigTable.c
@@ -75,7 +75,7 @@ clk = clock();
nTableSizeOld = p->nTableSize;
// get the new table
p->nTableSize = Aig_PrimeCudd( 2 * Aig_ManNodeNum(p) );
- p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize );
+ p->pTable = ABC_ALLOC( Aig_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
// rehash the entries from the old table
Counter = 0;
@@ -93,9 +93,9 @@ clk = clock();
}
assert( Counter == Aig_ManNodeNum(p) );
// printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
// replace the table and the parameters
- free( pTableOld );
+ ABC_FREE( pTableOld );
}
/**Function*************************************************************
@@ -259,7 +259,7 @@ void Aig_TableProfile( Aig_Man_t * p )
******************************************************************************/
void Aig_TableClear( Aig_Man_t * p )
{
- FREE( p->pTable );
+ ABC_FREE( p->pTable );
p->nTableSize = 0;
}
diff --git a/src/aig/aig/aigTsim.c b/src/aig/aig/aigTsim.c
index c411100b..e9bad08e 100644
--- a/src/aig/aig/aigTsim.c
+++ b/src/aig/aig/aigTsim.c
@@ -126,14 +126,14 @@ static inline void Aig_TsiSetNext( unsigned * pState, int nWords, unsigned
Aig_Tsi_t * Aig_TsiStart( Aig_Man_t * pAig )
{
Aig_Tsi_t * p;
- p = (Aig_Tsi_t *)malloc( sizeof(Aig_Tsi_t) );
+ p = ABC_ALLOC( Aig_Tsi_t, 1 );
memset( p, 0, sizeof(Aig_Tsi_t) );
p->pAig = pAig;
p->nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) );
p->vStates = Vec_PtrAlloc( 1000 );
p->pMem = Aig_MmFixedStart( sizeof(unsigned) * p->nWords + sizeof(unsigned *), 10000 );
p->nBins = Aig_PrimeCudd(TSI_MAX_ROUNDS/2);
- p->pBins = ALLOC( unsigned *, p->nBins );
+ p->pBins = ABC_ALLOC( unsigned *, p->nBins );
memset( p->pBins, 0, sizeof(unsigned *) * p->nBins );
return p;
}
@@ -153,8 +153,8 @@ void Aig_TsiStop( Aig_Tsi_t * p )
{
Aig_MmFixedStop( p->pMem, 0 );
Vec_PtrFree( p->vStates );
- free( p->pBins );
- free( p );
+ ABC_FREE( p->pBins );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/aig/aigUtil.c b/src/aig/aig/aigUtil.c
index 2668bbb2..b5c7272b 100644
--- a/src/aig/aig/aigUtil.c
+++ b/src/aig/aig/aigUtil.c
@@ -84,6 +84,22 @@ void Aig_ManIncrementTravId( Aig_Man_t * p )
/**Function*************************************************************
+ Synopsis [Make sure AIG has not gaps in the numeric order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Aig_ManHasNoGaps( Aig_Man_t * p )
+{
+ return (int)(Aig_ManObjNum(p) == Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManNodeNum(p) + 1);
+}
+
+/**Function*************************************************************
+
Synopsis [Collect the latches.]
Description []
@@ -997,7 +1013,7 @@ void Aig_ManCleanPioNumbers( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-int Aig_ManCountChoices( Aig_Man_t * p )
+int Aig_ManChoiceNum( Aig_Man_t * p )
{
Aig_Obj_t * pObj;
int i, Counter = 0;
@@ -1162,6 +1178,26 @@ unsigned Aig_ManRandom( int fReset )
/**Function*************************************************************
+ Synopsis [Creates random info for the primary inputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_ManRandomInfo( Vec_Ptr_t * vInfo, int iWordStart, int iWordStop )
+{
+ unsigned * pInfo;
+ int i, w;
+ Vec_PtrForEachEntry( vInfo, pInfo, i )
+ for ( w = iWordStart; w < iWordStop; w++ )
+ pInfo[w] = Aig_ManRandom(0);
+}
+
+/**Function*************************************************************
+
Synopsis [Returns the result of merging the two vectors.]
Description [Assumes that the vectors are sorted in the increasing order.]
diff --git a/src/aig/bar/bar.c b/src/aig/bar/bar.c
index f802d60c..2c5065cb 100644
--- a/src/aig/bar/bar.c
+++ b/src/aig/bar/bar.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "abc_global.h"
#include "bar.h"
////////////////////////////////////////////////////////////////////////
@@ -67,7 +68,7 @@ Bar_Progress_t * Bar_ProgressStart( FILE * pFile, int nItemsTotal )
if ( pFrame == NULL )
return NULL;
if ( !Abc_FrameShowProgress(pFrame) ) return NULL;
- p = (Bar_Progress_t *) malloc(sizeof(Bar_Progress_t));
+ p = ABC_ALLOC( Bar_Progress_t, 1 );
memset( p, 0, sizeof(Bar_Progress_t) );
p->pFile = pFile;
p->nItemsTotal = nItemsTotal;
@@ -123,7 +124,7 @@ void Bar_ProgressStop( Bar_Progress_t * p )
{
if ( p == NULL ) return;
Bar_ProgressClean( p );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/bar/bar.h b/src/aig/bar/bar.h
index 814fbe6f..104c6f47 100644
--- a/src/aig/bar/bar.h
+++ b/src/aig/bar/bar.h
@@ -21,10 +21,6 @@
#ifndef __BAR_H__
#define __BAR_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
@@ -37,6 +33,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define BAR_PROGRESS_USE 1
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/bbr/bbr.h b/src/aig/bbr/bbr.h
index 69d5fae7..ee91fe8b 100644
--- a/src/aig/bbr/bbr.h
+++ b/src/aig/bbr/bbr.h
@@ -21,10 +21,6 @@
#ifndef __BBR_H__
#define __BBR_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -38,6 +34,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/bbr/bbrCex.c b/src/aig/bbr/bbrCex.c
index be5377af..41253dbc 100644
--- a/src/aig/bbr/bbrCex.c
+++ b/src/aig/bbr/bbrCex.c
@@ -73,7 +73,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
}
// allocate room for the cube
- pValues = ALLOC( char, dd->size );
+ pValues = ABC_ALLOC( char, dd->size );
// get the last cube
RetValue = Cudd_bddPickOneCube( dd, bCubeFirst, pValues );
@@ -105,7 +105,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
if ( !fSilent )
printf( "BDDs blew up during image computation. " );
Bbr_bddImageTreeDelete( pTree );
- free( pValues );
+ ABC_FREE( pValues );
return NULL;
}
Cudd_Ref( bImage );
@@ -145,7 +145,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
}
// cleanup
Bbr_bddImageTreeDelete( pTree );
- free( pValues );
+ ABC_FREE( pValues );
// verify the counter example
if ( Vec_PtrSize(vOnionRings) < 1000 )
{
@@ -155,7 +155,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
}
if ( fVerbose && !fSilent )
{
- PRT( "Counter-example generation time", clock() - clk );
+ ABC_PRT( "Counter-example generation time", clock() - clk );
}
return pCex;
}
diff --git a/src/aig/bbr/bbrImage.c b/src/aig/bbr/bbrImage.c
index afc8dc39..edd344bf 100644
--- a/src/aig/bbr/bbrImage.c
+++ b/src/aig/bbr/bbrImage.c
@@ -94,8 +94,8 @@ struct Bbr_ImageVar_t_
#define b0 Cudd_Not((dd)->one)
#define b1 (dd)->one
-#ifndef PRB
-#define PRB(dd,f) printf("%s = ", #f); Bbr_bddPrint(dd,f); printf("\n")
+#ifndef ABC_PRB
+#define ABC_PRB(dd,f) printf("%s = ", #f); Bbr_bddPrint(dd,f); printf("\n")
#endif
/**AutomaticStart*************************************************************/
@@ -191,26 +191,26 @@ Bbr_ImageTree_t * Bbr_bddImageStart(
{
for ( v = 0; v < dd->size; v++ )
if ( pVars[v] )
- free( pVars[v] );
- free( pVars );
+ ABC_FREE( pVars[v] );
+ ABC_FREE( pVars );
for ( v = 0; v <= nParts; v++ )
if ( pNodes[v] )
{
Bbr_DeleteParts_rec( pNodes[v] );
Bbr_bddImageTreeDelete_rec( pNodes[v] );
}
- free( pNodes );
- free( pParts );
+ ABC_FREE( pNodes );
+ ABC_FREE( pParts );
return NULL;
}
// make sure the variables are gone
for ( v = 0; v < dd->size; v++ )
assert( pVars[v] == NULL );
- FREE( pVars );
+ ABC_FREE( pVars );
// create the tree
- pTree = ALLOC( Bbr_ImageTree_t, 1 );
+ pTree = ABC_ALLOC( Bbr_ImageTree_t, 1 );
memset( pTree, 0, sizeof(Bbr_ImageTree_t) );
pTree->pCare = pCare;
pTree->fVerbose = fVerbose;
@@ -221,7 +221,7 @@ Bbr_ImageTree_t * Bbr_bddImageStart(
// make sure the nodes are gone
for ( v = 0; v < nParts + 1; v++ )
assert( pNodes[v] == NULL );
- FREE( pNodes );
+ ABC_FREE( pNodes );
// if ( fVerbose )
// Bbr_bddImagePrintTree( pTree );
@@ -231,7 +231,7 @@ Bbr_ImageTree_t * Bbr_bddImageStart(
// clean the partitions
Bbr_DeleteParts_rec( pTree->pRoot );
- FREE( pParts );
+ ABC_FREE( pParts );
return pTree;
}
@@ -261,9 +261,9 @@ DdNode * Bbr_bddImageCompute( Bbr_ImageTree_t * pTree, DdNode * bCare )
if ( bRem != b1 )
{
printf( "Original care set support: " );
-PRB( dd, pTree->bCareSupp );
+ABC_PRB( dd, pTree->bCareSupp );
printf( "Current care set support: " );
-PRB( dd, bSupp );
+ABC_PRB( dd, bSupp );
Cudd_RecursiveDeref( dd, bSupp );
Cudd_RecursiveDeref( dd, bRem );
printf( "The care set depends on some vars that were not in the care set during scheduling.\n" );
@@ -305,7 +305,7 @@ void Bbr_bddImageTreeDelete( Bbr_ImageTree_t * pTree )
if ( pTree->bCareSupp )
Cudd_RecursiveDeref( pTree->pRoot->dd, pTree->bCareSupp );
Bbr_bddImageTreeDelete_rec( pTree->pRoot );
- FREE( pTree );
+ ABC_FREE( pTree );
}
/**Function*************************************************************
@@ -406,11 +406,11 @@ Bbr_ImagePart_t ** Bbr_CreateParts( DdManager * dd,
int i;
// start the partitions
- pParts = ALLOC( Bbr_ImagePart_t *, nParts + 1 );
+ pParts = ABC_ALLOC( Bbr_ImagePart_t *, nParts + 1 );
// create structures for each variable
for ( i = 0; i < nParts; i++ )
{
- pParts[i] = ALLOC( Bbr_ImagePart_t, 1 );
+ pParts[i] = ABC_ALLOC( Bbr_ImagePart_t, 1 );
pParts[i]->bFunc = pbParts[i]; Cudd_Ref( pParts[i]->bFunc );
pParts[i]->bSupp = Cudd_Support( dd, pParts[i]->bFunc ); Cudd_Ref( pParts[i]->bSupp );
pParts[i]->nSupp = Cudd_SupportSize( dd, pParts[i]->bSupp );
@@ -418,7 +418,7 @@ Bbr_ImagePart_t ** Bbr_CreateParts( DdManager * dd,
pParts[i]->iPart = i;
}
// add the care set as the last partition
- pParts[nParts] = ALLOC( Bbr_ImagePart_t, 1 );
+ pParts[nParts] = ABC_ALLOC( Bbr_ImagePart_t, 1 );
pParts[nParts]->bFunc = bCare; Cudd_Ref( pParts[nParts]->bFunc );
pParts[nParts]->bSupp = Cudd_Support( dd, pParts[nParts]->bFunc ); Cudd_Ref( pParts[nParts]->bSupp );
pParts[nParts]->nSupp = Cudd_SupportSize( dd, pParts[nParts]->bSupp );
@@ -448,11 +448,11 @@ Bbr_ImageVar_t ** Bbr_CreateVars( DdManager * dd,
int nVarsTotal, iVar, p, Counter;
// put all the functions into one array
- pbFuncs = ALLOC( DdNode *, nParts );
+ pbFuncs = ABC_ALLOC( DdNode *, nParts );
for ( p = 0; p < nParts; p++ )
pbFuncs[p] = pParts[p]->bSupp;
bSupp = Cudd_VectorSupport( dd, pbFuncs, nParts ); Cudd_Ref( bSupp );
- FREE( pbFuncs );
+ ABC_FREE( pbFuncs );
// remove the NS vars
bCubeNs = Cudd_bddComputeCube( dd, pbVars, NULL, nVars ); Cudd_Ref( bCubeNs );
@@ -464,13 +464,13 @@ Bbr_ImageVar_t ** Bbr_CreateVars( DdManager * dd,
nVarsTotal = Cudd_SupportSize( dd, bSupp );
// start the variables
- pVars = ALLOC( Bbr_ImageVar_t *, dd->size );
+ pVars = ABC_ALLOC( Bbr_ImageVar_t *, dd->size );
memset( pVars, 0, sizeof(Bbr_ImageVar_t *) * dd->size );
// create structures for each variable
for ( bSuppTemp = bSupp; bSuppTemp != b1; bSuppTemp = cuddT(bSuppTemp) )
{
iVar = bSuppTemp->index;
- pVars[iVar] = ALLOC( Bbr_ImageVar_t, 1 );
+ pVars[iVar] = ABC_ALLOC( Bbr_ImageVar_t, 1 );
pVars[iVar]->iNum = iVar;
// collect all the parts this var belongs to
Counter = 0;
@@ -517,11 +517,11 @@ Bbr_ImageNode_t ** Bbr_CreateNodes( DdManager * dd,
Bbr_ImagePart_t * pPart; // the partition (temporary)
*/
// start the partitions
- pNodes = ALLOC( Bbr_ImageNode_t *, nParts );
+ pNodes = ABC_ALLOC( Bbr_ImageNode_t *, nParts );
// create structures for each leaf nodes
for ( i = 0; i < nParts; i++ )
{
- pNodes[i] = ALLOC( Bbr_ImageNode_t, 1 );
+ pNodes[i] = ABC_ALLOC( Bbr_ImageNode_t, 1 );
memset( pNodes[i], 0, sizeof(Bbr_ImageNode_t) );
pNodes[i]->dd = dd;
pNodes[i]->pPart = pParts[i];
@@ -548,7 +548,7 @@ Bbr_ImageNode_t ** Bbr_CreateNodes( DdManager * dd,
}
// remove these variables
Cudd_RecursiveDeref( dd, pVars[v]->bParts );
- FREE( pVars[v] );
+ ABC_FREE( pVars[v] );
}
// assign the leaf node images
@@ -583,9 +583,9 @@ Bbr_ImageNode_t ** Bbr_CreateNodes( DdManager * dd,
for ( i = 0; i < nParts; i++ )
{
pNode = pNodes[i];
-PRB( dd, pNode->bCube );
-PRB( dd, pNode->pPart->bFunc );
-PRB( dd, pNode->pPart->bSupp );
+ABC_PRB( dd, pNode->bCube );
+ABC_PRB( dd, pNode->pPart->bFunc );
+ABC_PRB( dd, pNode->pPart->bSupp );
printf( "\n" );
}
*/
@@ -614,7 +614,7 @@ void Bbr_DeleteParts_rec( Bbr_ImageNode_t * pNode )
pPart = pNode->pPart;
Cudd_RecursiveDeref( pNode->dd, pPart->bFunc );
Cudd_RecursiveDeref( pNode->dd, pPart->bSupp );
- FREE( pNode->pPart );
+ ABC_FREE( pNode->pPart );
}
/**Function*************************************************************
@@ -639,7 +639,7 @@ void Bbr_bddImageTreeDelete_rec( Bbr_ImageNode_t * pNode )
if ( pNode->bImage )
Cudd_RecursiveDeref( pNode->dd, pNode->bImage );
assert( pNode->pPart == NULL );
- FREE( pNode );
+ ABC_FREE( pNode );
}
/**Function*************************************************************
@@ -757,11 +757,11 @@ int Bbr_BuildTreeNode( DdManager * dd,
Cudd_RecursiveDeref( dd, bTemp );
// clean this var
Cudd_RecursiveDeref( dd, pVars[v]->bParts );
- FREE( pVars[v] );
+ ABC_FREE( pVars[v] );
}
// clean the best var
Cudd_RecursiveDeref( dd, pVars[iVarBest]->bParts );
- FREE( pVars[iVarBest] );
+ ABC_FREE( pVars[iVarBest] );
// combines two nodes
pNode = Bbr_CombineTwoNodes( dd, bCube, pNode1, pNode2 );
@@ -884,7 +884,7 @@ Bbr_ImageNode_t * Bbr_CombineTwoNodes( DdManager * dd, DdNode * bCube,
Bbr_ImagePart_t * pPart;
// create a new partition
- pPart = ALLOC( Bbr_ImagePart_t, 1 );
+ pPart = ABC_ALLOC( Bbr_ImagePart_t, 1 );
memset( pPart, 0, sizeof(Bbr_ImagePart_t) );
// create the function
pPart->bFunc = Cudd_bddAndAbstract( dd, pNode1->pPart->bFunc, pNode2->pPart->bFunc, bCube );
@@ -897,12 +897,12 @@ Bbr_ImageNode_t * Bbr_CombineTwoNodes( DdManager * dd, DdNode * bCube,
pPart->nNodes = Cudd_DagSize( pPart->bFunc );
pPart->iPart = -1;
/*
-PRB( dd, pNode1->pPart->bSupp );
-PRB( dd, pNode2->pPart->bSupp );
-PRB( dd, pPart->bSupp );
+ABC_PRB( dd, pNode1->pPart->bSupp );
+ABC_PRB( dd, pNode2->pPart->bSupp );
+ABC_PRB( dd, pPart->bSupp );
*/
// create a new node
- pNode = ALLOC( Bbr_ImageNode_t, 1 );
+ pNode = ABC_ALLOC( Bbr_ImageNode_t, 1 );
memset( pNode, 0, sizeof(Bbr_ImageNode_t) );
pNode->dd = dd;
pNode->pPart = pPart;
@@ -1114,7 +1114,7 @@ void Bbr_bddImagePrintTree_rec( Bbr_ImageNode_t * pNode, int Offset )
printf( "<%d> ", pNode->pPart->iPart );
if ( Cube != NULL )
{
- PRB( pNode->dd, Cube );
+ ABC_PRB( pNode->dd, Cube );
}
else
printf( "\n" );
@@ -1124,7 +1124,7 @@ void Bbr_bddImagePrintTree_rec( Bbr_ImageNode_t * pNode, int Offset )
printf( "<*> " );
if ( Cube != NULL )
{
- PRB( pNode->dd, Cube );
+ ABC_PRB( pNode->dd, Cube );
}
else
printf( "\n" );
@@ -1198,7 +1198,7 @@ Bbr_ImageTree2_t * Bbr_bddImageStart2(
DdNode * bCubeAll, * bCubeNot, * bTemp;
int i;
- pTree = ALLOC( Bbr_ImageTree2_t, 1 );
+ pTree = ABC_ALLOC( Bbr_ImageTree2_t, 1 );
pTree->dd = dd;
pTree->bImage = NULL;
@@ -1259,7 +1259,7 @@ void Bbr_bddImageTreeDelete2( Bbr_ImageTree2_t * pTree )
Cudd_RecursiveDeref( pTree->dd, pTree->bCube );
if ( pTree->bImage )
Cudd_RecursiveDeref( pTree->dd, pTree->bImage );
- FREE( pTree );
+ ABC_FREE( pTree );
}
/**Function*************************************************************
diff --git a/src/aig/bbr/bbrReach.c b/src/aig/bbr/bbrReach.c
index 05f7ef55..c2982856 100644
--- a/src/aig/bbr/bbrReach.c
+++ b/src/aig/bbr/bbrReach.c
@@ -101,8 +101,8 @@ DdNode * Aig_ManInitStateVarMap( DdManager * dd, Aig_Man_t * p, int fVerbose )
int i;
// set the variable mapping for Cudd_bddVarMap()
- pbVarsX = ALLOC( DdNode *, dd->size );
- pbVarsY = ALLOC( DdNode *, dd->size );
+ pbVarsX = ABC_ALLOC( DdNode *, dd->size );
+ pbVarsY = ABC_ALLOC( DdNode *, dd->size );
bProd = (dd)->one; Cudd_Ref( bProd );
Saig_ManForEachLo( p, pLatch, i )
{
@@ -113,8 +113,8 @@ DdNode * Aig_ManInitStateVarMap( DdManager * dd, Aig_Man_t * p, int fVerbose )
Cudd_RecursiveDeref( dd, bTemp );
}
Cudd_SetVarMap( dd, pbVarsX, pbVarsY, Saig_ManRegNum(p) );
- FREE( pbVarsX );
- FREE( pbVarsY );
+ ABC_FREE( pbVarsX );
+ ABC_FREE( pbVarsY );
Cudd_Deref( bProd );
return bProd;
@@ -137,7 +137,7 @@ DdNode ** Aig_ManCreateOutputs( DdManager * dd, Aig_Man_t * p )
Aig_Obj_t * pNode;
int i;
// compute the transition relation
- pbOutputs = ALLOC( DdNode *, Saig_ManPoNum(p) );
+ pbOutputs = ABC_ALLOC( DdNode *, Saig_ManPoNum(p) );
Saig_ManForEachPo( p, pNode, i )
{
pbOutputs[i] = Aig_ObjGlobalBdd(pNode); Cudd_Ref( pbOutputs[i] );
@@ -174,13 +174,13 @@ DdNode ** Aig_ManCreatePartitions( DdManager * dd, Aig_Man_t * p, int fReorder,
Cudd_AutodynDisable( dd );
// compute the transition relation
- pbParts = ALLOC( DdNode *, Saig_ManRegNum(p) );
+ pbParts = ABC_ALLOC( DdNode *, Saig_ManRegNum(p) );
Saig_ManForEachLi( p, pNode, i )
{
bVar = Cudd_bddIthVar( dd, Saig_ManCiNum(p) + i );
pbParts[i] = Cudd_bddXnor( dd, bVar, Aig_ObjGlobalBdd(pNode) ); Cudd_Ref( pbParts[i] );
}
- // free global BDDs
+ // ABC_FREE global BDDs
Aig_ManFreeGlobalBdds( p, dd );
// reorder and disable reordering
@@ -316,7 +316,7 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
fprintf( stdout, "\r" );
}
Cudd_RecursiveDeref( dd, bNext );
- // free the onion rings
+ // ABC_FREE the onion rings
Vec_PtrForEachEntry( vOnionRings, bTemp, i )
Cudd_RecursiveDeref( dd, bTemp );
Vec_PtrFree( vOnionRings );
@@ -338,7 +338,7 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
fprintf( stdout, "Reachable states = %.0f. (Ratio = %.4f %%)\n", nMints, 100.0*nMints/pow(2.0, Saig_ManRegNum(p)) );
fflush( stdout );
}
-//PRB( dd, bReached );
+//ABC_PRB( dd, bReached );
Cudd_RecursiveDeref( dd, bReached );
if ( nIters > nIterMax || Cudd_DagSize(bReached) > nBddMax )
{
@@ -413,7 +413,7 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fParti
break;
}
}
- // free the onion rings
+ // ABC_FREE the onion rings
Vec_PtrForEachEntry( vOnionRings, bTemp, i )
Cudd_RecursiveDeref( dd, bTemp );
Vec_PtrFree( vOnionRings );
@@ -425,10 +425,10 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fParti
Cudd_RecursiveDeref( dd, bInitial );
for ( i = 0; i < Saig_ManRegNum(p); i++ )
Cudd_RecursiveDeref( dd, pbParts[i] );
- free( pbParts );
+ ABC_FREE( pbParts );
for ( i = 0; i < Saig_ManPoNum(p); i++ )
Cudd_RecursiveDeref( dd, pbOutputs[i] );
- free( pbOutputs );
+ ABC_FREE( pbOutputs );
if ( RetValue == -1 )
Cudd_Quit( dd );
else
@@ -437,7 +437,7 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fParti
// report the runtime
if ( !fSilent )
{
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
fflush( stdout );
}
return RetValue;
diff --git a/src/aig/bdc/bdc.h b/src/aig/bdc/bdc.h
index fc476ec6..0bdccf2b 100644
--- a/src/aig/bdc/bdc.h
+++ b/src/aig/bdc/bdc.h
@@ -20,10 +20,6 @@
#ifndef __BDC_H__
#define __BDC_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
@@ -32,6 +28,10 @@ extern "C" {
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+extern "C" {
+#endif
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -49,10 +49,10 @@ struct Bdc_Par_t_
};
// working with complemented attributes of objects
-static inline int Bdc_IsComplement( Bdc_Fun_t * p ) { return (int)((PORT_PTRUINT_T)p & (PORT_PTRUINT_T)01); }
-static inline Bdc_Fun_t * Bdc_Regular( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((PORT_PTRUINT_T)p & ~(PORT_PTRUINT_T)01); }
-static inline Bdc_Fun_t * Bdc_Not( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((PORT_PTRUINT_T)p ^ (PORT_PTRUINT_T)01); }
-static inline Bdc_Fun_t * Bdc_NotCond( Bdc_Fun_t * p, int c ) { return (Bdc_Fun_t *)((PORT_PTRUINT_T)p ^ (PORT_PTRUINT_T)(c!=0)); }
+static inline int Bdc_IsComplement( Bdc_Fun_t * p ) { return (int)((ABC_PTRUINT_T)p & (ABC_PTRUINT_T)01); }
+static inline Bdc_Fun_t * Bdc_Regular( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p & ~(ABC_PTRUINT_T)01); }
+static inline Bdc_Fun_t * Bdc_Not( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)01); }
+static inline Bdc_Fun_t * Bdc_NotCond( Bdc_Fun_t * p, int c ) { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)(c!=0)); }
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
diff --git a/src/aig/bdc/bdcCore.c b/src/aig/bdc/bdcCore.c
index 9067d315..fea08115 100644
--- a/src/aig/bdc/bdcCore.c
+++ b/src/aig/bdc/bdcCore.c
@@ -62,7 +62,7 @@ void Bdc_FuncSetCopy( Bdc_Fun_t * p, void * pCopy ) { p->pCopy = pCop
Bdc_Man_t * Bdc_ManAlloc( Bdc_Par_t * pPars )
{
Bdc_Man_t * p;
- p = ALLOC( Bdc_Man_t, 1 );
+ p = ABC_ALLOC( Bdc_Man_t, 1 );
memset( p, 0, sizeof(Bdc_Man_t) );
assert( pPars->nVarsMax > 1 && pPars->nVarsMax < 16 );
p->pPars = pPars;
@@ -70,18 +70,18 @@ Bdc_Man_t * Bdc_ManAlloc( Bdc_Par_t * pPars )
p->nDivsLimit = 200;
// internal nodes
p->nNodesAlloc = 512;
- p->pNodes = ALLOC( Bdc_Fun_t, p->nNodesAlloc );
+ p->pNodes = ABC_ALLOC( Bdc_Fun_t, p->nNodesAlloc );
// memory
p->vMemory = Vec_IntStart( 8 * p->nWords * p->nNodesAlloc );
Vec_IntClear(p->vMemory);
// set up hash table
p->nTableSize = (1 << p->pPars->nVarsMax);
- p->pTable = ALLOC( Bdc_Fun_t *, p->nTableSize );
+ p->pTable = ABC_ALLOC( Bdc_Fun_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Bdc_Fun_t *) * p->nTableSize );
p->vSpots = Vec_IntAlloc( 256 );
// truth tables
p->vTruths = Vec_PtrAllocTruthTables( p->pPars->nVarsMax );
- p->puTemp1 = ALLOC( unsigned, 4 * p->nWords );
+ p->puTemp1 = ABC_ALLOC( unsigned, 4 * p->nWords );
p->puTemp2 = p->puTemp1 + p->nWords;
p->puTemp3 = p->puTemp2 + p->nWords;
p->puTemp4 = p->puTemp3 + p->nWords;
@@ -112,19 +112,19 @@ void Bdc_ManFree( Bdc_Man_t * p )
p->numCalls, p->numNodes, p->numReuse );
printf( "ANDs = %d. ORs = %d. Weak = %d. Muxes = %d. Memory = %.2f K\n",
p->numAnds, p->numOrs, p->numWeaks, p->numMuxes, 4.0 * Vec_IntSize(p->vMemory) / (1<<10) );
- PRT( "Cache", p->timeCache );
- PRT( "Check", p->timeCheck );
- PRT( "Muxes", p->timeMuxes );
- PRT( "Supps", p->timeSupps );
- PRT( "TOTAL", p->timeTotal );
+ ABC_PRT( "Cache", p->timeCache );
+ ABC_PRT( "Check", p->timeCheck );
+ ABC_PRT( "Muxes", p->timeMuxes );
+ ABC_PRT( "Supps", p->timeSupps );
+ ABC_PRT( "TOTAL", p->timeTotal );
}
Vec_IntFree( p->vMemory );
Vec_IntFree( p->vSpots );
Vec_PtrFree( p->vTruths );
- free( p->puTemp1 );
- free( p->pNodes );
- free( p->pTable );
- free( p );
+ ABC_FREE( p->puTemp1 );
+ ABC_FREE( p->pNodes );
+ ABC_FREE( p->pTable );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/bdc/bdcInt.h b/src/aig/bdc/bdcInt.h
index a35663ef..71ad8449 100644
--- a/src/aig/bdc/bdcInt.h
+++ b/src/aig/bdc/bdcInt.h
@@ -21,10 +21,6 @@
#ifndef __BDC_INT_H__
#define __BDC_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -36,6 +32,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define BDC_SCALE 1000 // value used to compute the cost
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cec/cec.c b/src/aig/cec/cec.c
new file mode 100644
index 00000000..a017f831
--- /dev/null
+++ b/src/aig/cec/cec.c
@@ -0,0 +1,48 @@
+/**CFile****************************************************************
+
+ FileName [cec.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/cec/cec.h b/src/aig/cec/cec.h
index fb0bb830..fa7c5dbc 100644
--- a/src/aig/cec/cec.h
+++ b/src/aig/cec/cec.h
@@ -21,10 +21,6 @@
#ifndef __CEC_H__
#define __CEC_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -44,8 +44,8 @@ struct Cec_ParSat_t_
int nBTLimit; // conflict limit at a node
int nSatVarMax; // the max number of SAT variables
int nCallsRecycle; // calls to perform before recycling SAT solver
+ int fPolarFlip; // flops polarity of variables
int fFirstStop; // stop on the first sat output
- int fPolarFlip; // uses polarity adjustment
int fVerbose; // verbose stats
};
@@ -55,8 +55,15 @@ struct Cec_ParCsw_t_
{
int nWords; // the number of simulation words
int nRounds; // the number of simulation rounds
- int nBTlimit; // conflict limit at a node
+ int nItersMax; // the maximum number of iterations of SAT sweeping
+ int nBTLimit; // conflict limit at a node
+ int nSatVarMax; // the max number of SAT variables
+ int nCallsRecycle; // calls to perform before recycling SAT solver
+ int nLevelMax; // restriction on the level nodes to be swept
+ int nDepthMax; // the depth in terms of steps of speculative reduction
int fRewriting; // enables AIG rewriting
+ int fFirstStop; // stop on the first sat output
+ int fVeryVerbose; // verbose stats
int fVerbose; // verbose stats
};
@@ -86,7 +93,8 @@ struct Cec_ParCec_t_
extern void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p );
extern void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p );
extern void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p );
-extern int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * p );
+extern Gia_Man_t * Cec_ManSatSweeping( Gia_Man_t * pAig, Cec_ParCsw_t * pPars );
+extern Gia_Man_t * Cec_ManSatSolving( Gia_Man_t * pAig, Cec_ParSat_t * pPars );
#ifdef __cplusplus
}
diff --git a/src/aig/cec/cecClass.c b/src/aig/cec/cecClass.c
index f3f6bf11..65fa2e9b 100644
--- a/src/aig/cec/cecClass.c
+++ b/src/aig/cec/cecClass.c
@@ -24,12 +24,69 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
+static inline int Cec_ObjRepr( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iRepr; }
+static inline void Cec_ObjSetRepr( Cec_ManCsw_t * p, int Id, int Num ) { p->pObjs[Id].iRepr = Num; }
+
+static inline int Cec_ObjProved( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iProved; }
+static inline void Cec_ObjSetProved( Cec_ManCsw_t * p, int Id ) { p->pObjs[Id].iProved = 1; }
+
+static inline int Cec_ObjFailed( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iFailed; }
+static inline void Cec_ObjSetFailed( Cec_ManCsw_t * p, int Id ) { p->pObjs[Id].iFailed = 1; }
+
+static inline int Cec_ObjNext( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iNext; }
+static inline void Cec_ObjSetNext( Cec_ManCsw_t * p, int Id, int Num ) { p->pObjs[Id].iNext = Num; }
+
+static inline unsigned Cec_ObjSim( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].SimNum; }
+static inline unsigned * Cec_ObjSimP1( Cec_ManCsw_t * p, int Id ) { return &p->pObjs[Id].SimNum; }
+static inline unsigned * Cec_ObjSimP( Cec_ManCsw_t * p, int Id ) { return p->pMems + Cec_ObjSim(p, Id) + 1; }
+static inline void Cec_ObjSetSim( Cec_ManCsw_t * p, int Id, unsigned n ) { p->pObjs[Id].SimNum = n; }
+
+static inline int Cec_ObjIsConst( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) == 0; }
+static inline int Cec_ObjIsHead( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) < 0 && Cec_ObjNext(p, Id) > 0; }
+static inline int Cec_ObjIsNone( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) < 0 && Cec_ObjNext(p, Id) == 0; }
+static inline int Cec_ObjIsTail( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) > 0 && Cec_ObjNext(p, Id) == 0; }
+static inline int Cec_ObjIsClass( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) > 0 || Cec_ObjNext(p, Id) > 0; }
+
+#define Cec_ManForEachObj( p, i ) \
+ for ( i = 0; i < Gia_ManObjNum(p->pAig); i++ )
+#define Cec_ManForEachObj1( p, i ) \
+ for ( i = 1; i < Gia_ManObjNum(p->pAig); i++ )
+#define Cec_ManForEachClass( p, i ) \
+ for ( i = 1; i < Gia_ManObjNum(p->pAig); i++ ) if ( !Cec_ObjIsHead(p, i) ) {} else
+#define Cec_ClassForEachObj( p, i, iObj ) \
+ for ( assert(Cec_ObjIsHead(p, i)), iObj = i; iObj; iObj = Cec_ObjNext(p, iObj) )
+#define Cec_ClassForEachObj1( p, i, iObj ) \
+ for ( assert(Cec_ObjIsHead(p, i)), iObj = Cec_ObjNext(p, i); iObj; iObj = Cec_ObjNext(p, iObj) )
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
+ Synopsis [Creates the set of representatives.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Cec_ManCswDeriveReprs( Cec_ManCsw_t * p )
+{
+ int i, * pReprs = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) );
+ for ( i = 1; i < Gia_ManObjNum(p->pAig); i++ )
+ if ( Cec_ObjProved(p, i) )
+ {
+ assert( Cec_ObjRepr(p, i) >= 0 );
+ pReprs[i] = Cec_ObjRepr(p, i);
+ }
+ return pReprs;
+}
+
+/**Function*************************************************************
+
Synopsis []
Description []
@@ -39,42 +96,50 @@
SeeAlso []
***********************************************************************/
-Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p )
+Gia_Man_t * Cec_ManCswDupWithClasses( Cec_ManCsw_t * p )
{
- Aig_Man_t * pAig;
- Aig_Obj_t ** pCopy;
- Aig_Obj_t * pMiter, * pRes0, * pRes1, * pRepr;
- int i;
- pCopy = ALLOC( Aig_Obj_t *, p->nObjs );
- pCopy[0] = NULL;
- pAig = Aig_ManStart( p->nNodes );
- for ( i = 1; i < p->nObjs; i++ )
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj, * pRepr;
+ int iRes0, iRes1, iRepr, iNode;
+ int i, fCompl, * piCopies;
+ Vec_IntClear( p->vXorNodes );
+ Gia_ManLevelNum( p->pAig );
+ pNew = Gia_ManStart( Gia_ManObjNum(p->pAig) );
+ pNew->pName = Aig_UtilStrsav( p->pAig->pName );
+ Gia_ManHashAlloc( pNew );
+ piCopies = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) );
+ piCopies[0] = 0;
+ Gia_ManForEachObj1( p->pAig, pObj, i )
{
- if ( p->pFans0[i] == 0 ) // pi always has zero first fanin
+ if ( Gia_ObjIsCi(pObj) )
{
- pCopy[i] = Aig_ObjCreatePi( pAig );
+ piCopies[i] = Gia_ManAppendCi( pNew );
continue;
}
- if ( p->pFans1[i] == 0 ) // po always has non-zero 1st fanin and zero 2nd fanin
+ iRes0 = Gia_LitNotCond( piCopies[Gia_ObjFaninId0(pObj,i)], Gia_ObjFaninC0(pObj) );
+ if ( Gia_ObjIsCo(pObj) )
+ {
+ Gia_ManAppendCo( pNew, iRes0 );
continue;
- pRes0 = pCopy[ Cec_Lit2Var(p->pFans0[i]) ];
- pRes0 = Aig_NotCond( pRes0, Cec_LitIsCompl(p->pFans0[i]) );
- pRes1 = pCopy[ Cec_Lit2Var(p->pFans1[i]) ];
- pRes1 = Aig_NotCond( pRes1, Cec_LitIsCompl(p->pFans1[i]) );
- pCopy[i] = Aig_And( pAig, pRes0, pRes1 );
- if ( p->pReprs[i] < 0 )
+ }
+ iRes1 = Gia_LitNotCond( piCopies[Gia_ObjFaninId1(pObj,i)], Gia_ObjFaninC1(pObj) );
+ iNode = piCopies[i] = Gia_ManHashAnd( pNew, iRes0, iRes1 );
+ if ( Cec_ObjRepr(p, i) < 0 || !Cec_ObjProved(p, i) )
continue;
- assert( p->pReprs[i] < i );
- pRepr = p->pReprs[i]? pCopy[ p->pReprs[i] ] : Aig_ManConst1(pAig);
- if ( Aig_Regular(pCopy[i]) == Aig_Regular(pRepr) )
+ assert( Cec_ObjRepr(p, i) < i );
+ iRepr = piCopies[Cec_ObjRepr(p, i)];
+ if ( Gia_LitRegular(iNode) == Gia_LitRegular(iRepr) )
continue;
- pMiter = Aig_Exor( pAig, pCopy[i], pRepr );
- Aig_ObjCreatePo( pAig, Aig_NotCond(pMiter, Aig_ObjPhaseReal(pMiter)) );
+ pRepr = Gia_ManObj( p->pAig, Cec_ObjRepr(p, i) );
+ fCompl = Gia_ObjPhaseReal(pObj) ^ Gia_ObjPhaseReal(pRepr);
+ piCopies[i] = Gia_LitNotCond( iRepr, fCompl );
}
- free( pCopy );
- Aig_ManSetRegNum( pAig, 0 );
- Aig_ManCleanup( pAig );
- return pAig;
+ ABC_FREE( piCopies );
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, 0 );
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
}
/**Function*************************************************************
@@ -88,16 +153,70 @@ Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p )
SeeAlso []
***********************************************************************/
-int Caig_ManCountOne( Caig_Man_t * p, int i )
+Gia_Man_t * Cec_ManCswSpecReduction( Cec_ManCsw_t * p )
{
- int Ent, nLits = 0;
- assert( p->pReprs[i] < 0 && p->pNexts[i] > 0 );
- for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] )
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj, * pRepr;
+ int iRes0, iRes1, iRepr, iNode, iMiter;
+ int i, fCompl, * piCopies, * pDepths;
+ Vec_IntClear( p->vXorNodes );
+// Gia_ManLevelNum( p->pAig );
+ pNew = Gia_ManStart( Gia_ManObjNum(p->pAig) );
+ pNew->pName = Aig_UtilStrsav( p->pAig->pName );
+ Gia_ManHashAlloc( pNew );
+ piCopies = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) );
+ pDepths = ABC_CALLOC( int, Gia_ManObjNum(p->pAig) );
+ piCopies[0] = 0;
+ Gia_ManForEachObj1( p->pAig, pObj, i )
{
- assert( p->pReprs[Ent] == i );
- nLits++;
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ piCopies[i] = Gia_ManAppendCi( pNew );
+ continue;
+ }
+ if ( Gia_ObjIsCo(pObj) )
+ continue;
+ if ( piCopies[Gia_ObjFaninId0(pObj,i)] == -1 ||
+ piCopies[Gia_ObjFaninId1(pObj,i)] == -1 )
+ continue;
+ iRes0 = Gia_LitNotCond( piCopies[Gia_ObjFaninId0(pObj,i)], Gia_ObjFaninC0(pObj) );
+ iRes1 = Gia_LitNotCond( piCopies[Gia_ObjFaninId1(pObj,i)], Gia_ObjFaninC1(pObj) );
+ iNode = piCopies[i] = Gia_ManHashAnd( pNew, iRes0, iRes1 );
+ pDepths[i] = AIG_MAX( pDepths[Gia_ObjFaninId0(pObj,i)], pDepths[Gia_ObjFaninId1(pObj,i)] );
+ if ( Cec_ObjRepr(p, i) < 0 || Cec_ObjFailed(p, i) )
+ continue;
+ assert( Cec_ObjRepr(p, i) < i );
+ iRepr = piCopies[Cec_ObjRepr(p, i)];
+ if ( iRepr == -1 )
+ continue;
+ if ( Gia_LitRegular(iNode) == Gia_LitRegular(iRepr) )
+ continue;
+ pRepr = Gia_ManObj( p->pAig, Cec_ObjRepr(p, i) );
+ fCompl = Gia_ObjPhaseReal(pObj) ^ Gia_ObjPhaseReal(pRepr);
+ piCopies[i] = Gia_LitNotCond( iRepr, fCompl );
+ if ( Cec_ObjProved(p, i) )
+ continue;
+// if ( p->pPars->nLevelMax &&
+// (Gia_ObjLevel(p->pAig, pObj) > p->pPars->nLevelMax ||
+// Gia_ObjLevel(p->pAig, pRepr) > p->pPars->nLevelMax) )
+// continue;
+ // produce speculative miter
+ iMiter = Gia_ManHashXor( pNew, iNode, piCopies[i] );
+ Gia_ManAppendCo( pNew, iMiter );
+ Vec_IntPush( p->vXorNodes, Cec_ObjRepr(p, i) );
+ Vec_IntPush( p->vXorNodes, i );
+ // add to the depth of this node
+ pDepths[i] = 1 + AIG_MAX( pDepths[i], pDepths[Cec_ObjRepr(p, i)] );
+ if ( p->pPars->nDepthMax && pDepths[i] >= p->pPars->nDepthMax )
+ piCopies[i] = -1;
}
- return 1 + nLits;
+ ABC_FREE( piCopies );
+ ABC_FREE( pDepths );
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, 0 );
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
}
/**Function*************************************************************
@@ -109,15 +228,52 @@ int Caig_ManCountOne( Caig_Man_t * p, int i )
SideEffects []
SeeAlso []
-
+
***********************************************************************/
-int Caig_ManCountLiterals( Caig_Man_t * p )
+Gia_Man_t * Cec_ManCswSpecReductionProved( Cec_ManCsw_t * p )
{
- int i, nLits = 0;
- for ( i = 1; i < p->nObjs; i++ )
- if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
- nLits += Caig_ManCountOne(p, i) - 1;
- return nLits;
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj, * pRepr;
+ int iRes0, iRes1, iRepr, iNode, iMiter;
+ int i, fCompl, * piCopies;
+ Vec_IntClear( p->vXorNodes );
+ Gia_ManLevelNum( p->pAig );
+ pNew = Gia_ManStart( Gia_ManObjNum(p->pAig) );
+ pNew->pName = Aig_UtilStrsav( p->pAig->pName );
+ Gia_ManHashAlloc( pNew );
+ piCopies = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) );
+ piCopies[0] = 0;
+ Gia_ManForEachObj1( p->pAig, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ piCopies[i] = Gia_ManAppendCi( pNew );
+ continue;
+ }
+ if ( Gia_ObjIsCo(pObj) )
+ continue;
+ iRes0 = Gia_LitNotCond( piCopies[Gia_ObjFaninId0(pObj,i)], Gia_ObjFaninC0(pObj) );
+ iRes1 = Gia_LitNotCond( piCopies[Gia_ObjFaninId1(pObj,i)], Gia_ObjFaninC1(pObj) );
+ iNode = piCopies[i] = Gia_ManHashAnd( pNew, iRes0, iRes1 );
+ if ( Cec_ObjRepr(p, i) < 0 || !Cec_ObjProved(p, i) )
+ continue;
+ assert( Cec_ObjRepr(p, i) < i );
+ iRepr = piCopies[Cec_ObjRepr(p, i)];
+ if ( Gia_LitRegular(iNode) == Gia_LitRegular(iRepr) )
+ continue;
+ pRepr = Gia_ManObj( p->pAig, Cec_ObjRepr(p, i) );
+ fCompl = Gia_ObjPhaseReal(pObj) ^ Gia_ObjPhaseReal(pRepr);
+ piCopies[i] = Gia_LitNotCond( iRepr, fCompl );
+ // add speculative miter
+ iMiter = Gia_ManHashXor( pNew, iNode, piCopies[i] );
+ Gia_ManAppendCo( pNew, iMiter );
+ }
+ ABC_FREE( piCopies );
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, 0 );
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
}
/**Function*************************************************************
@@ -131,13 +287,15 @@ int Caig_ManCountLiterals( Caig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Caig_ManPrintOne( Caig_Man_t * p, int i, int Counter )
+int Cec_ManCswCountOne( Cec_ManCsw_t * p, int i )
{
- int Ent;
- printf( "Class %4d : Num = %2d {", Counter, Caig_ManCountOne(p, i) );
- for ( Ent = i; Ent; Ent = p->pNexts[Ent] )
- printf(" %d", Ent );
- printf( " }\n" );
+ int Ent, nLits = 1;
+ Cec_ClassForEachObj1( p, i, Ent )
+ {
+ assert( Cec_ObjRepr(p, Ent) == i );
+ nLits++;
+ }
+ return nLits;
}
/**Function*************************************************************
@@ -151,25 +309,12 @@ void Caig_ManPrintOne( Caig_Man_t * p, int i, int Counter )
SeeAlso []
***********************************************************************/
-void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose )
+int Cec_ManCswCountLitsAll( Cec_ManCsw_t * p )
{
- int i, Counter = 0, Counter1 = 0, CounterX = 0, nLits;
- for ( i = 1; i < p->nObjs; i++ )
- {
- if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
- Counter++;
- if ( p->pReprs[i] == 0 )
- Counter1++;
- if ( p->pReprs[i] < 0 && p->pNexts[i] == 0 )
- CounterX++;
- }
- nLits = Caig_ManCountLiterals( p );
- printf( "Class = %6d. Const1 = %6d. Other = %6d. Lits = %7d. Total = %7d.\n",
- Counter, Counter1, CounterX, nLits, nLits+Counter1 );
- if ( fVerbose )
- for ( i = 1; i < p->nObjs; i++ )
- if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
- Caig_ManPrintOne( p, i, ++Counter );
+ int i, nLits = 0;
+ Cec_ManForEachObj( p, i )
+ nLits += (Cec_ObjRepr(p, i) >= 0);
+ return nLits;
}
/**Function*************************************************************
@@ -183,12 +328,13 @@ void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose )
SeeAlso []
***********************************************************************/
-void Caig_ManCollectSimsSimple( Caig_Man_t * p, int i )
+void Cec_ManCswPrintOne( Cec_ManCsw_t * p, int i, int Counter )
{
int Ent;
- Vec_PtrClear( p->vSims );
- for ( Ent = i; Ent; Ent = p->pNexts[Ent] )
- Vec_PtrPush( p->vSims, p->pSims + Ent );
+ printf( "Class %4d : Num = %2d {", Counter, Cec_ManCswCountOne(p, i) );
+ Cec_ClassForEachObj( p, i, Ent )
+ printf(" %d", Ent );
+ printf( " }\n" );
}
/**Function*************************************************************
@@ -202,15 +348,26 @@ void Caig_ManCollectSimsSimple( Caig_Man_t * p, int i )
SeeAlso []
***********************************************************************/
-void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i )
+void Cec_ManCswPrintClasses( Cec_ManCsw_t * p, int fVerbose )
{
- unsigned * pSim;
- int Ent;
- Vec_PtrClear( p->vSims );
- for ( Ent = i; Ent; Ent = p->pNexts[Ent] )
+ int i, Counter = 0, Counter1 = 0, CounterX = 0, nLits;
+ Cec_ManForEachObj1( p, i )
+ {
+ if ( Cec_ObjIsHead(p, i) )
+ Counter++;
+ else if ( Cec_ObjIsConst(p, i) )
+ Counter1++;
+ else if ( Cec_ObjIsNone(p, i) )
+ CounterX++;
+ }
+ nLits = Cec_ManCswCountLitsAll( p );
+ printf( "Class =%7d. Const =%7d. Unsed =%7d. Lits =%8d. All =%8d. Mem = %5.2f Mb\n",
+ Counter, Counter1, CounterX, nLits-Counter1, nLits, 1.0*p->nMemsMax*(p->pPars->nWords+1)/(1<<20) );
+ if ( fVerbose )
{
- pSim = Caig_ManSimDeref( p, Ent );
- Vec_PtrPush( p->vSims, pSim + 1 );
+ Counter = 0;
+ Cec_ManForEachClass( p, i )
+ Cec_ManCswPrintOne( p, i, ++Counter );
}
}
@@ -225,7 +382,7 @@ void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i )
SeeAlso []
***********************************************************************/
-int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords )
+int Cec_ManCswCompareEqual( unsigned * p0, unsigned * p1, int nWords )
{
int w;
if ( (p0[0] & 1) == (p1[0] & 1) )
@@ -255,7 +412,7 @@ int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords )
SeeAlso []
***********************************************************************/
-int Caig_ManCompareConst( unsigned * p, int nWords )
+int Cec_ManCswCompareConst( unsigned * p, int nWords )
{
int w;
if ( p[0] & 1 )
@@ -285,26 +442,26 @@ int Caig_ManCompareConst( unsigned * p, int nWords )
SeeAlso []
***********************************************************************/
-void Caig_ManClassCreate( Caig_Man_t * p, Vec_Int_t * vClass )
+void Cec_ManCswClassCreate( Cec_ManCsw_t * p, Vec_Int_t * vClass )
{
- int * pNext, Repr, Ent, i;
+ int Repr = -1, EntPrev = -1, Ent, i;
assert( Vec_IntSize(vClass) > 0 );
Vec_IntForEachEntry( vClass, Ent, i )
{
if ( i == 0 )
{
Repr = Ent;
- p->pReprs[Ent] = -1;
- pNext = p->pNexts + Ent;
+ Cec_ObjSetRepr( p, Ent, -1 );
+ EntPrev = Ent;
}
else
{
- p->pReprs[Ent] = Repr;
- *pNext = Ent;
- pNext = p->pNexts + Ent;
+ Cec_ObjSetRepr( p, Ent, Repr );
+ Cec_ObjSetNext( p, EntPrev, Ent );
+ EntPrev = Ent;
}
}
- *pNext = 0;
+ Cec_ObjSetNext( p, EntPrev, 0 );
}
/**Function*************************************************************
@@ -318,32 +475,28 @@ void Caig_ManClassCreate( Caig_Man_t * p, Vec_Int_t * vClass )
SeeAlso []
***********************************************************************/
-int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims )
+int Cec_ManCswClassRefineOne( Cec_ManCsw_t * p, int i, int fFirst )
{
unsigned * pSim0, * pSim1;
- int Ent, c = 0, d = 0;
+ int Ent;
Vec_IntClear( p->vClassOld );
Vec_IntClear( p->vClassNew );
- pSim0 = Vec_PtrEntry( vSims, c++ );
Vec_IntPush( p->vClassOld, i );
- for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] )
+ pSim0 = fFirst? Cec_ObjSimP1(p, i) : Cec_ObjSimP(p, i);
+ Cec_ClassForEachObj1( p, i, Ent )
{
- pSim1 = Vec_PtrEntry( vSims, c++ );
- if ( Caig_ManCompareEqual( pSim0, pSim1, p->nWords ) )
+ pSim1 = fFirst? Cec_ObjSimP1(p, Ent) : Cec_ObjSimP(p, Ent);
+ if ( Cec_ManCswCompareEqual( pSim0, pSim1, p->nWords ) )
Vec_IntPush( p->vClassOld, Ent );
else
- {
Vec_IntPush( p->vClassNew, Ent );
- Vec_PtrWriteEntry( vSims, d++, pSim1 );
- }
}
- Vec_PtrShrink( vSims, d );
- if ( Vec_IntSize(p->vClassNew) == 0 )
+ if ( Vec_IntSize( p->vClassNew ) == 0 )
return 0;
- Caig_ManClassCreate( p, p->vClassOld );
- Caig_ManClassCreate( p, p->vClassNew );
+ Cec_ManCswClassCreate( p, p->vClassOld );
+ Cec_ManCswClassCreate( p, p->vClassNew );
if ( Vec_IntSize(p->vClassNew) > 1 )
- return 1 + Caig_ManClassRefineOne( p, Vec_IntEntry(p->vClassNew,0), vSims );
+ return 1 + Cec_ManCswClassRefineOne( p, Vec_IntEntry(p->vClassNew,0), fFirst );
return 1;
}
@@ -358,7 +511,7 @@ int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims )
SeeAlso []
***********************************************************************/
-int Caig_ManHashKey( unsigned * pSim, int nWords, int nTableSize )
+int Cec_ManCswHashKey( unsigned * pSim, int nWords, int nTableSize )
{
static int s_Primes[16] = {
1291, 1699, 1999, 2357, 2953, 3313, 3907, 4177,
@@ -386,49 +539,51 @@ int Caig_ManHashKey( unsigned * pSim, int nWords, int nTableSize )
SeeAlso []
***********************************************************************/
-void Caig_ManClassesCreate( Caig_Man_t * p )
+void Cec_ManCswClassesCreate( Cec_ManCsw_t * p )
{
int * pTable, nTableSize, i, Key;
- nTableSize = Aig_PrimeCudd( 100 + p->nObjs / 10 );
- pTable = CALLOC( int, nTableSize );
- p->pReprs = ALLOC( int, p->nObjs );
- p->pNexts = CALLOC( int, p->nObjs );
- for ( i = 1; i < p->nObjs; i++ )
+ p->nWords = 1;
+ nTableSize = Aig_PrimeCudd( 100 + Gia_ManObjNum(p->pAig) / 10 );
+ pTable = ABC_CALLOC( int, nTableSize );
+ Cec_ObjSetRepr( p, 0, -1 );
+ Cec_ManForEachObj1( p, i )
{
- if ( Caig_ManCompareConst( p->pSims + i, 1 ) )
+ if ( Gia_ObjIsCo(Gia_ManObj(p->pAig, i)) )
+ {
+ Cec_ObjSetRepr( p, i, -1 );
+ continue;
+ }
+ if ( Cec_ManCswCompareConst( Cec_ObjSimP1(p, i), p->nWords ) )
{
- p->pReprs[i] = 0;
+ Cec_ObjSetRepr( p, i, 0 );
continue;
}
- Key = Caig_ManHashKey( p->pSims + i, 1, nTableSize );
+ Key = Cec_ManCswHashKey( Cec_ObjSimP1(p, i), p->nWords, nTableSize );
if ( pTable[Key] == 0 )
- p->pReprs[i] = -1;
+ Cec_ObjSetRepr( p, i, -1 );
else
{
- p->pNexts[ pTable[Key] ] = i;
- p->pReprs[i] = p->pReprs[ pTable[Key] ];
- if ( p->pReprs[i] == -1 )
- p->pReprs[i] = pTable[Key];
+ Cec_ObjSetNext( p, pTable[Key], i );
+ Cec_ObjSetRepr( p, i, Cec_ObjRepr(p, pTable[Key]) );
+ if ( Cec_ObjRepr(p, i) == -1 )
+ Cec_ObjSetRepr( p, i, pTable[Key] );
}
pTable[Key] = i;
}
- FREE( pTable );
-Caig_ManPrintClasses( p, 0 );
+ ABC_FREE( pTable );
+ if ( p->pPars->fVeryVerbose )
+ Cec_ManCswPrintClasses( p, 0 );
// refine classes
- p->vSims = Vec_PtrAlloc( 100 );
- p->vClassOld = Vec_IntAlloc( 100 );
- p->vClassNew = Vec_IntAlloc( 100 );
- for ( i = 1; i < p->nObjs; i++ )
- if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
- {
- Caig_ManCollectSimsSimple( p, i );
- Caig_ManClassRefineOne( p, i, p->vSims );
- }
+ Cec_ManForEachClass( p, i )
+ Cec_ManCswClassRefineOne( p, i, 1 );
// clean memory
- memset( p->pSims, 0, sizeof(unsigned) * p->nObjs );
-Caig_ManPrintClasses( p, 0 );
+ Cec_ManForEachObj( p, i )
+ Cec_ObjSetSim( p, i, 0 );
+ if ( p->pPars->fVeryVerbose )
+ Cec_ManCswPrintClasses( p, 0 );
}
+
/**Function*************************************************************
Synopsis []
@@ -440,27 +595,87 @@ Caig_ManPrintClasses( p, 0 );
SeeAlso []
***********************************************************************/
-void Caig_ManSimulateSimple( Caig_Man_t * p )
+void Cec_ManCswSimulateSimple( Cec_ManCsw_t * p )
{
+ Gia_Obj_t * pObj;
unsigned Res0, Res1;
int i;
- for ( i = 1; i < p->nObjs; i++ )
+ Gia_ManForEachCi( p->pAig, pObj, i )
+ Cec_ObjSetSim( p, i, Aig_ManRandom(0) );
+ Gia_ManForEachAnd( p->pAig, pObj, i )
+ {
+ Res0 = Cec_ObjSim( p, Gia_ObjFaninId0(pObj, i) );
+ Res1 = Cec_ObjSim( p, Gia_ObjFaninId1(pObj, i) );
+ Cec_ObjSetSim( p, i, (Gia_ObjFaninC0(pObj)? ~Res0: Res0) &
+ (Gia_ObjFaninC1(pObj)? ~Res1: Res1) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [References simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManCswSimMemRelink( Cec_ManCsw_t * p )
+{
+ unsigned * pPlace, Ent;
+ pPlace = &p->MemFree;
+ for ( Ent = p->nMems * (p->nWords + 1);
+ Ent + p->nWords + 1 < (unsigned)p->nWordsAlloc;
+ Ent += p->nWords + 1 )
+ {
+ *pPlace = Ent;
+ pPlace = p->pMems + Ent;
+ }
+ *pPlace = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [References simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned * Cec_ManCswSimRef( Cec_ManCsw_t * p, int i )
+{
+ unsigned * pSim;
+ assert( p->pObjs[i].SimNum == 0 );
+ if ( p->MemFree == 0 )
{
- if ( p->pFans0[i] == 0 ) // pi
+ if ( p->nWordsAlloc == 0 )
{
- p->pSims[i] = Aig_ManRandom( 0 );
- continue;
+ assert( p->pMems == NULL );
+ p->nWordsAlloc = (1<<17); // -> 1Mb
+ p->nMems = 1;
}
- Res0 = p->pSims[Cec_Lit2Var(p->pFans0[i])];
- Res1 = p->pSims[Cec_Lit2Var(p->pFans1[i])];
- p->pSims[i] = (Cec_LitIsCompl(p->pFans0[i]) ? ~Res0: Res0) &
- (Cec_LitIsCompl(p->pFans1[i]) ? ~Res1: Res1);
+ p->nWordsAlloc *= 2;
+ p->pMems = ABC_REALLOC( unsigned, p->pMems, p->nWordsAlloc );
+ Cec_ManCswSimMemRelink( p );
}
+ p->pObjs[i].SimNum = p->MemFree;
+ pSim = p->pMems + p->MemFree;
+ p->MemFree = pSim[0];
+ pSim[0] = Gia_ObjValue( Gia_ManObj(p->pAig, i) );
+ p->nMems++;
+ if ( p->nMemsMax < p->nMems )
+ p->nMemsMax = p->nMems;
+ return pSim;
}
/**Function*************************************************************
- Synopsis []
+ Synopsis [Dereference simulaton info.]
Description []
@@ -469,10 +684,19 @@ void Caig_ManSimulateSimple( Caig_Man_t * p )
SeeAlso []
***********************************************************************/
-void Caig_ManProcessClass( Caig_Man_t * p, int i )
+unsigned * Cec_ManCswSimDeref( Cec_ManCsw_t * p, int i )
{
- Caig_ManCollectSimsNormal( p, i );
- Caig_ManClassRefineOne( p, i, p->vSims );
+ unsigned * pSim;
+ assert( p->pObjs[i].SimNum > 0 );
+ pSim = p->pMems + p->pObjs[i].SimNum;
+ if ( --pSim[0] == 0 )
+ {
+ pSim[0] = p->MemFree;
+ p->MemFree = p->pObjs[i].SimNum;
+ p->pObjs[i].SimNum = 0;
+ p->nMems--;
+ }
+ return pSim;
}
/**Function*************************************************************
@@ -486,51 +710,179 @@ void Caig_ManProcessClass( Caig_Man_t * p, int i )
SeeAlso []
***********************************************************************/
-void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined )
+void Cec_ManCswProcessRefined( Cec_ManCsw_t * p, Vec_Int_t * vRefined )
{
- Vec_Int_t * vClasses;
- int * pTable, nTableSize, i, Key, iNode;
unsigned * pSim;
+ int * pTable, nTableSize, i, k, Key;
if ( Vec_IntSize(vRefined) == 0 )
return;
nTableSize = Aig_PrimeCudd( 100 + Vec_IntSize(vRefined) / 5 );
- pTable = CALLOC( int, nTableSize );
- vClasses = Vec_IntAlloc( 100 );
- Vec_IntForEachEntry( vRefined, iNode, i )
+ pTable = ABC_CALLOC( int, nTableSize );
+ Vec_IntForEachEntry( vRefined, i, k )
{
- pSim = Caig_ManSimRead( p, iNode );
- assert( !Caig_ManCompareConst( pSim + 1, p->nWords ) );
- Key = Caig_ManHashKey( pSim + 1, p->nWords, nTableSize );
+ if ( i == 7720 )
+ {
+ int s = 0;
+ }
+ pSim = Cec_ObjSimP( p, i );
+ assert( !Cec_ManCswCompareConst( pSim, p->nWords ) );
+ Key = Cec_ManCswHashKey( pSim, p->nWords, nTableSize );
if ( pTable[Key] == 0 )
{
- assert( p->pReprs[iNode] == 0 );
- assert( p->pNexts[iNode] == 0 );
- p->pReprs[iNode] = -1;
- Vec_IntPush( vClasses, iNode );
+ assert( Cec_ObjRepr(p, i) == 0 );
+ assert( Cec_ObjNext(p, i) == 0 );
+ Cec_ObjSetRepr( p, i, -1 );
}
else
{
- p->pNexts[ pTable[Key] ] = iNode;
- p->pReprs[iNode] = p->pReprs[ pTable[Key] ];
- if ( p->pReprs[iNode] == -1 )
- p->pReprs[iNode] = pTable[Key];
- assert( p->pReprs[iNode] > 0 );
+ Cec_ObjSetNext( p, pTable[Key], i );
+ Cec_ObjSetRepr( p, i, Cec_ObjRepr(p, pTable[Key]) );
+ if ( Cec_ObjRepr(p, i) == -1 )
+ Cec_ObjSetRepr( p, i, pTable[Key] );
+ assert( Cec_ObjRepr(p, i) > 0 );
}
- pTable[Key] = iNode;
+ pTable[Key] = i;
}
- FREE( pTable );
- // refine classes
- Vec_IntForEachEntry( vClasses, iNode, i )
+ Vec_IntForEachEntry( vRefined, i, k )
{
- if ( p->pNexts[iNode] == 0 )
+ if ( Cec_ObjIsHead( p, i ) )
+ Cec_ManCswClassRefineOne( p, i, 0 );
+ }
+ Vec_IntForEachEntry( vRefined, i, k )
+ Cec_ManCswSimDeref( p, i );
+ ABC_FREE( pTable );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Simulates one round.]
+
+ Description [Returns the number of PO entry if failed; 0 otherwise.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManCswSimulateRound( Cec_ManCsw_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * vInfoCos, int iSeries, int fRandomize )
+{
+ static int nCountRand = 0;
+ Gia_Obj_t * pObj;
+ unsigned * pRes0, * pRes1, * pRes;
+ int i, k, w, Ent, iCiId = 0, iCoId = 0;
+ p->nMemsMax = 0;
+ Vec_IntClear( p->vRefinedC );
+ if ( Gia_ObjValue(Gia_ManConst0(p->pAig)) )
+ {
+ pRes = Cec_ManCswSimRef( p, 0 );
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w] = 0;
+ }
+ Gia_ManForEachObj1( p->pAig, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ if ( Gia_ObjValue(pObj) == 0 )
+ {
+ iCiId++;
+ continue;
+ }
+ pRes = Cec_ManCswSimRef( p, i );
+ if ( vInfoCis )
+ {
+ pRes0 = Vec_PtrEntry( vInfoCis, iCiId++ );
+ for ( w = 1; w <= p->nWords; w++ )
+ {
+ pRes[w] = pRes0[iSeries*p->nWords+w-1];
+ if ( fRandomize )
+ pRes[w] ^= (1 << (nCountRand++ & 0x1f));
+ }
+ }
+ else
+ {
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w] = Aig_ManRandom( 0 );
+ }
+ // make sure the first pattern is always zero
+ pRes[1] ^= (pRes[1] & 1);
+ goto references;
+ }
+ if ( Gia_ObjIsCo(pObj) ) // co always has non-zero 1st fanin and zero 2nd fanin
{
- Caig_ManSimDeref( p, iNode );
+ pRes0 = Cec_ManCswSimDeref( p, Gia_ObjFaninId0(pObj,i) );
+ if ( vInfoCos )
+ {
+ pRes = Vec_PtrEntry( vInfoCos, iCoId++ );
+ if ( Gia_ObjFaninC0(pObj) )
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w-1] = ~pRes0[w];
+ else
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w-1] = pRes0[w];
+ }
continue;
}
- Caig_ManCollectSimsNormal( p, iNode );
- Caig_ManClassRefineOne( p, iNode, p->vSims );
+ assert( Gia_ObjValue(pObj) );
+ pRes = Cec_ManCswSimRef( p, i );
+ pRes0 = Cec_ManCswSimDeref( p, Gia_ObjFaninId0(pObj,i) );
+ pRes1 = Cec_ManCswSimDeref( p, Gia_ObjFaninId1(pObj,i) );
+ if ( Gia_ObjFaninC0(pObj) )
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w] = ~(pRes0[w] | pRes1[w]);
+ else
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w] = ~pRes0[w] & pRes1[w];
+ }
+ else
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w] = pRes0[w] & ~pRes1[w];
+ else
+ for ( w = 1; w <= p->nWords; w++ )
+ pRes[w] = pRes0[w] & pRes1[w];
+ }
+references:
+ // if this node is candidate constant, collect it
+ if ( Cec_ObjIsConst(p, i) && !Cec_ManCswCompareConst(pRes + 1, p->nWords) )
+ {
+ pRes[0]++;
+ Vec_IntPush( p->vRefinedC, i );
+ }
+ // if the node belongs to a class, save it
+ if ( Cec_ObjIsClass(p, i) )
+ pRes[0]++;
+ // if this is the last node of the class, process it
+ if ( Cec_ObjIsTail(p, i) )
+ {
+ Vec_IntClear( p->vClassTemp );
+ Cec_ClassForEachObj( p, Cec_ObjRepr(p, i), Ent )
+ Vec_IntPush( p->vClassTemp, Ent );
+ Cec_ManCswClassRefineOne( p, Cec_ObjRepr(p, i), 0 );
+ Vec_IntForEachEntry( p->vClassTemp, Ent, k )
+ Cec_ManCswSimDeref( p, Ent );
+ }
}
- Vec_IntFree( vClasses );
+ if ( Vec_IntSize(p->vRefinedC) > 0 )
+ Cec_ManCswProcessRefined( p, p->vRefinedC );
+ assert( vInfoCis == NULL || iCiId == Gia_ManCiNum(p->pAig) );
+ assert( vInfoCos == NULL || iCoId == Gia_ManCoNum(p->pAig) );
+ assert( p->nMems == 1 );
+ if ( p->pPars->fVeryVerbose )
+ Cec_ManCswPrintClasses( p, 0 );
+/*
+ if ( p->nMems > 1 )
+ {
+ for ( i = 1; i < p->nObjs; i++ )
+ if ( p->pSims[i] )
+ {
+ int x = 0;
+ }
+ }
+*/
}
/**Function*************************************************************
@@ -544,24 +896,153 @@ void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined )
SeeAlso []
***********************************************************************/
-Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters )
+int Cec_ManCswClassesPrepare( Cec_ManCsw_t * p )
{
- Caig_Man_t * p;
int i;
- Aig_ManRandom( 1 );
- p = Caig_ManCreate( pAig );
- p->nWords = 1;
- Caig_ManSimulateSimple( p );
- Caig_ManClassesCreate( p );
- p->nWords = nWords;
- for ( i = 0; i < nIters; i++ )
+ Gia_ManSetRefs( p->pAig );
+ Cec_ManCswSimulateSimple( p );
+ Cec_ManCswClassesCreate( p );
+ for ( i = 0; i < p->pPars->nRounds; i++ )
+ {
+ p->nWords = i + 1;
+ Cec_ManCswSimMemRelink( p );
+ Cec_ManCswSimulateRound( p, NULL, NULL, 0, 0 );
+ }
+ p->nWords = p->pPars->nWords;
+ Cec_ManCswSimMemRelink( p );
+ for ( i = 0; i < p->pPars->nRounds; i++ )
+ Cec_ManCswSimulateRound( p, NULL, NULL, 0, 0 );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManCswClassesUpdate_rec( Gia_Obj_t * pObj )
+{
+ int Result;
+ if ( pObj->fMark0 )
+ return 1;
+ if ( Gia_ObjIsCi(pObj) || Gia_ObjIsConst0(pObj) )
+ return 0;
+ Result = (Cec_ManCswClassesUpdate_rec( Gia_ObjFanin0(pObj) ) |
+ Cec_ManCswClassesUpdate_rec( Gia_ObjFanin1(pObj) ));
+ return pObj->fMark0 = Result;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManCswClassesUpdate( Cec_ManCsw_t * p, Cec_ManPat_t * pPat, Gia_Man_t * pNew )
+{
+ Vec_Ptr_t * vInfo;
+ Gia_Obj_t * pObj, * pObjOld, * pReprOld;
+ int i, k, iRepr, iNode;
+ vInfo = Cec_ManPatCollectPatterns( pPat, Gia_ManCiNum(p->pAig), p->pPars->nWords );
+ if ( vInfo != NULL )
{
- Caig_ManSimulateRound( p, 0 );
-Caig_ManPrintClasses( p, 0 );
+ for ( i = 0; i < pPat->nSeries; i++ )
+ Cec_ManCswSimulateRound( p, vInfo, NULL, i, 0 );
+ Vec_PtrFree( vInfo );
}
- return p;
+ assert( Vec_IntSize(p->vXorNodes) == 2*Gia_ManCoNum(pNew) );
+ // mark the transitive fanout of failed nodes
+ if ( p->pPars->nDepthMax != 1 )
+ {
+ Gia_ManCleanMark0( p->pAig );
+ Gia_ManCleanMark1( p->pAig );
+ Gia_ManForEachCo( pNew, pObj, k )
+ {
+ iRepr = Vec_IntEntry( p->vXorNodes, 2*k );
+ iNode = Vec_IntEntry( p->vXorNodes, 2*k+1 );
+ if ( pObj->fMark0 == 0 && pObj->fMark1 == 1 ) // proved
+ continue;
+// Gia_ManObj(p->pAig, iRepr)->fMark0 = 1;
+ Gia_ManObj(p->pAig, iNode)->fMark0 = 1;
+ }
+ // mark the nodes reachable through the failed nodes
+ Gia_ManForEachAnd( p->pAig, pObjOld, k )
+ pObjOld->fMark0 |= (Gia_ObjFanin0(pObjOld)->fMark0 | Gia_ObjFanin1(pObjOld)->fMark0);
+ // unmark the disproved nodes
+ Gia_ManForEachCo( pNew, pObj, k )
+ {
+ iRepr = Vec_IntEntry( p->vXorNodes, 2*k );
+ iNode = Vec_IntEntry( p->vXorNodes, 2*k+1 );
+ if ( pObj->fMark0 == 0 && pObj->fMark1 == 1 ) // proved
+ continue;
+ pObjOld = Gia_ManObj(p->pAig, iNode);
+ assert( pObjOld->fMark0 == 1 );
+ if ( Gia_ObjFanin0(pObjOld)->fMark0 == 0 && Gia_ObjFanin1(pObjOld)->fMark0 == 0 )
+ pObjOld->fMark1 = 1;
+ }
+ // clean marks
+ Gia_ManForEachAnd( p->pAig, pObjOld, k )
+ if ( pObjOld->fMark1 )
+ {
+ pObjOld->fMark0 = 0;
+ pObjOld->fMark1 = 0;
+ }
+ }
+ // set the results
+ Gia_ManForEachCo( pNew, pObj, k )
+ {
+ iRepr = Vec_IntEntry( p->vXorNodes, 2*k );
+ iNode = Vec_IntEntry( p->vXorNodes, 2*k+1 );
+ pReprOld = Gia_ManObj(p->pAig, iRepr);
+ pObjOld = Gia_ManObj(p->pAig, iNode);
+ if ( pObj->fMark1 )
+ { // proved
+ assert( pObj->fMark0 == 0 );
+ assert( !Cec_ObjProved(p, iNode) );
+ if ( pReprOld->fMark0 == 0 && pObjOld->fMark0 == 0 )
+// if ( pObjOld->fMark0 == 0 )
+ {
+ assert( iRepr == Cec_ObjRepr(p, iNode) );
+ Cec_ObjSetProved( p, iNode );
+ p->nAllProved++;
+ }
+ }
+ else if ( pObj->fMark0 )
+ { // disproved
+ assert( pObj->fMark1 == 0 );
+ if ( pReprOld->fMark0 == 0 && pObjOld->fMark0 == 0 )
+// if ( pObjOld->fMark0 == 0 )
+ {
+ if ( iRepr == Cec_ObjRepr(p, iNode) )
+ printf( "Cec_ManCswClassesUpdate(): Error! Node is not refined!\n" );
+ p->nAllDisproved++;
+ }
+ }
+ else
+ { // failed
+ assert( pObj->fMark0 == 0 );
+ assert( pObj->fMark1 == 0 );
+ assert( !Cec_ObjFailed(p, iNode) );
+ assert( !Cec_ObjProved(p, iNode) );
+ Cec_ObjSetFailed( p, iNode );
+ p->nAllFailed++;
+ }
+ }
+ return 0;
}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cec/cecCore.c b/src/aig/cec/cecCore.c
index 86287a96..ab8fd5cf 100644
--- a/src/aig/cec/cecCore.c
+++ b/src/aig/cec/cecCore.c
@@ -37,20 +37,20 @@
SideEffects []
SeeAlso []
-
+
***********************************************************************/
void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p )
{
memset( p, 0, sizeof(Cec_ParSat_t) );
- p->nBTLimit = 100; // conflict limit at a node
- p->nSatVarMax = 2000; // the max number of SAT variables
- p->nCallsRecycle = 10; // calls to perform before recycling SAT solver
- p->fFirstStop = 0; // stop on the first sat output
- p->fPolarFlip = 0; // uses polarity adjustment
- p->fVerbose = 0; // verbose stats
-}
-
-/**Function*************************************************************
+ p->nBTLimit = 10; // conflict limit at a node
+ p->nSatVarMax = 2000; // the max number of SAT variables
+ p->nCallsRecycle = 100; // calls to perform before recycling SAT solver
+ p->fPolarFlip = 1; // flops polarity of variables
+ p->fFirstStop = 0; // stop on the first sat output
+ p->fVerbose = 1; // verbose stats
+}
+
+/**Function************ *************************************************
Synopsis [This procedure sets default parameters.]
@@ -64,12 +64,19 @@ void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p )
void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p )
{
memset( p, 0, sizeof(Cec_ParCsw_t) );
- p->nWords = 15; // the number of simulation words
- p->nRounds = 10; // the number of simulation rounds
- p->nBTlimit = 10; // conflict limit at a node
- p->fRewriting = 0; // enables AIG rewriting
- p->fVerbose = 1; // verbose stats
-}
+ p->nWords = 20; // the number of simulation words
+ p->nRounds = 20; // the number of simulation rounds
+ p->nItersMax = 20; // the maximum number of iterations of SAT sweeping
+ p->nBTLimit = 10000; // conflict limit at a node
+ p->nSatVarMax = 2000; // the max number of SAT variables
+ p->nCallsRecycle = 100; // calls to perform before recycling SAT solver
+ p->nLevelMax = 0; // restriction on the level of nodes to be swept
+ p->nDepthMax = 1; // the depth in terms of steps of speculative reduction
+ p->fRewriting = 0; // enables AIG rewriting
+ p->fFirstStop = 0; // stop on the first sat output
+ p->fVeryVerbose = 0; // verbose stats
+ p->fVerbose = 0; // verbose stats
+}
/**Function*************************************************************
@@ -85,20 +92,19 @@ void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p )
void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p )
{
memset( p, 0, sizeof(Cec_ParCec_t) );
- p->nIters = 5; // iterations of SAT solving/sweeping
- p->nBTLimitBeg = 2; // starting backtrack limit
- p->nBTlimitMulti = 8; // multiple of backtrack limiter
- p->fUseSmartCnf = 0; // use smart CNF computation
- p->fRewriting = 0; // enables AIG rewriting
- p->fSatSweeping = 0; // enables SAT sweeping
- p->fFirstStop = 0; // stop on the first sat output
- p->fVerbose = 1; // verbose stats
-}
-
+ p->nIters = 1; // iterations of SAT solving/sweeping
+ p->nBTLimitBeg = 2; // starting backtrack limit
+ p->nBTlimitMulti = 8; // multiple of backtrack limiter
+ p->fUseSmartCnf = 0; // use smart CNF computation
+ p->fRewriting = 0; // enables AIG rewriting
+ p->fSatSweeping = 0; // enables SAT sweeping
+ p->fFirstStop = 0; // stop on the first sat output
+ p->fVerbose = 1; // verbose stats
+}
/**Function*************************************************************
- Synopsis [Performs equivalence checking.]
+ Synopsis [Core procedure for SAT sweeping.]
Description []
@@ -107,39 +113,21 @@ void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p )
SeeAlso []
***********************************************************************/
-int Cec_Sweep( Aig_Man_t * pAig, int nBTLimit )
+Gia_Man_t * Cec_ManSatSolving( Gia_Man_t * pAig, Cec_ParSat_t * pPars )
{
- Cec_MtrStatus_t Status;
- Cec_ParCsw_t ParsCsw, * pParsCsw = &ParsCsw;
- Cec_ParSat_t ParsSat, * pParsSat = &ParsSat;
- Caig_Man_t * pCaig;
- Aig_Man_t * pSRAig;
- int clk;
-
- Cec_ManCswSetDefaultParams( pParsCsw );
- pParsCsw->nBTlimit = nBTLimit;
- pCaig = Caig_ManClassesPrepare( pAig, pParsCsw->nWords, pParsCsw->nRounds );
-
- pSRAig = Caig_ManSpecReduce( pCaig );
- Aig_ManPrintStats( pSRAig );
-
- Cec_ManSatSetDefaultParams( pParsSat );
- pParsSat->fFirstStop = 0;
- pParsSat->nBTLimit = pParsCsw->nBTlimit;
-clk = clock();
- Status = Cec_SatSolveOutputs( pSRAig, pParsSat );
- Cec_MiterStatusPrint( Status, "SRM ", clock() - clk );
-
- Aig_ManStop( pSRAig );
-
- Caig_ManDelete( pCaig );
-
- return 1;
+ Gia_Man_t * pNew;
+ Cec_ManPat_t * pPat;
+ pPat = Cec_ManPatStart();
+ Cec_ManSatSolve( pPat, pAig, pPars );
+ pNew = Gia_ManDupDfsSkip( pAig );
+ Cec_ManPatStop( pPat );
+ return pNew;
}
+
/**Function*************************************************************
- Synopsis [Performs equivalence checking.]
+ Synopsis [Core procedure for SAT sweeping.]
Description []
@@ -148,82 +136,94 @@ clk = clock();
SeeAlso []
***********************************************************************/
-int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * pPars )
+Gia_Man_t * Cec_ManSatSweeping( Gia_Man_t * pAig, Cec_ParCsw_t * pPars )
{
Cec_ParSat_t ParsSat, * pParsSat = &ParsSat;
- Cec_MtrStatus_t Status;
- Aig_Man_t * pMiter;
- int i, clk = clock();
- if ( pPars->fVerbose )
- {
- Status = Cec_MiterStatusTrivial( pAig0 );
- Status.nNodes += pAig1? Aig_ManNodeNum( pAig1 ) : 0;
- Cec_MiterStatusPrint( Status, "Init ", 0 );
- }
- // create combinational miter
- if ( pAig1 == NULL )
+ Gia_Man_t * pNew;
+ Cec_ManCsw_t * p;
+ Cec_ManPat_t * pPat;
+ int i, RetValue, clk, clk2, clkTotal = clock();
+ Aig_ManRandom( 1 );
+ Gia_ManSetPhase( pAig );
+ Gia_ManCleanMark0( pAig );
+ Gia_ManCleanMark1( pAig );
+ p = Cec_ManCswStart( pAig, pPars );
+clk = clock();
+ RetValue = Cec_ManCswClassesPrepare( p );
+p->timeSim += clock() - clk;
+ Cec_ManSatSetDefaultParams( pParsSat );
+ pParsSat->nBTLimit = pPars->nBTLimit;
+ pParsSat->fVerbose = pPars->fVeryVerbose;
+ pPat = Cec_ManPatStart();
+ pPat->fVerbose = pPars->fVeryVerbose;
+ for ( i = 1; i <= pPars->nItersMax; i++ )
{
- Status = Cec_MiterStatus( pAig0 );
- if ( Status.nSat > 0 && pPars->fFirstStop )
+ clk2 = clock();
+ pNew = Cec_ManCswSpecReduction( p );
+ if ( pPars->fVeryVerbose )
{
- if ( pPars->fVerbose )
- printf( "Output %d is trivially SAT.\n", Status.iOut );
- return 0;
+ Gia_ManPrintStats( p->pAig );
+ Gia_ManPrintStats( pNew );
}
- if ( Status.nUndec == 0 )
+ if ( Gia_ManCoNum(pNew) == 0 )
{
- if ( pPars->fVerbose )
- printf( "The miter has no undecided outputs.\n" );
- return 1;
+ Gia_ManStop( pNew );
+ break;
}
- pMiter = Cec_Duplicate( pAig0 );
- }
- else
- {
- pMiter = Cec_DeriveMiter( pAig0, pAig1 );
- Status = Cec_MiterStatus( pMiter );
- if ( Status.nSat > 0 && pPars->fFirstStop )
+clk = clock();
+ Cec_ManSatSolve( pPat, pNew, pParsSat );
+p->timeSat += clock() - clk;
+clk = clock();
+ Cec_ManCswClassesUpdate( p, pPat, pNew );
+p->timeSim += clock() - clk;
+ Gia_ManStop( pNew );
+ pNew = Cec_ManCswDupWithClasses( p );
+ Gia_WriteAiger( pNew, "gia_temp_new.aig", 0, 1 );
+ if ( p->pPars->fVerbose )
{
- if ( pPars->fVerbose )
- printf( "Output %d is trivially SAT.\n", Status.iOut );
- Aig_ManStop( pMiter );
- return 0;
+ printf( "%3d : P =%7d. D =%7d. F =%6d. Lit =%8d. And =%8d. ",
+ i, p->nAllProved, p->nAllDisproved, p->nAllFailed,
+ Cec_ManCswCountLitsAll(p), Gia_ManAndNum(pNew) );
+ ABC_PRT( "Time", clock() - clk2 );
}
- if ( Status.nUndec == 0 )
+ if ( p->pPars->fVeryVerbose )
{
- if ( pPars->fVerbose )
- printf( "The problem is solved by structrual hashing.\n" );
- Aig_ManStop( pMiter );
- return 1;
+ ABC_PRTP( "Sim ", p->timeSim, clock() - clkTotal );
+ ABC_PRTP( "Sat ", p->timeSat, clock() - clkTotal );
+ ABC_PRT( "Time", clock() - clkTotal );
+ printf( "****** Intermedate result %3d ******\n", i );
+ Gia_ManPrintStats( p->pAig );
+ Gia_ManPrintStats( pNew );
+ printf("The result is written into file \"%s\".\n", "gia_temp.aig" );
+ printf( "************************************\n" );
}
- }
- if ( pPars->fVerbose )
- Cec_MiterStatusPrint( Status, "Strash", clock() - clk );
- // start parameter structures
- Cec_ManSatSetDefaultParams( pParsSat );
- pParsSat->fFirstStop = pPars->fFirstStop;
- pParsSat->nBTLimit = pPars->nBTLimitBeg;
- for ( i = 0; i < pPars->nIters; i++ )
- {
- // try SAT solving
- clk = clock();
- pParsSat->nBTLimit *= pPars->nBTlimitMulti;
- Status = Cec_SatSolveOutputs( pMiter, pParsSat );
- if ( pPars->fVerbose )
- Cec_MiterStatusPrint( Status, "SAT ", clock() - clk );
- if ( Status.nSat && pParsSat->fFirstStop )
- break;
- if ( Status.nUndec == 0 )
+ if ( Gia_ManAndNum(pNew) == 0 )
+ {
+ Gia_ManStop( pNew );
break;
+ }
+ Gia_ManStop( pNew );
+ }
+ Gia_ManCleanMark0( pAig );
+ Gia_ManCleanMark1( pAig );
- // try rewriting
-
- // try SAT sweeping
- Cec_Sweep( pMiter, 10 );
- i = i;
+ // verify the result
+ if ( p->pPars->fVerbose )
+ {
+ printf( "Verifying the result:\n" );
+ pNew = Cec_ManCswSpecReductionProved( p );
+ pParsSat->nBTLimit = 1000000;
+ pParsSat->fVerbose = 1;
+ Cec_ManSatSolve( NULL, pNew, pParsSat );
+ Gia_ManStop( pNew );
}
- Aig_ManStop( pMiter );
- return 1;
+
+ // create the resulting miter
+ pAig->pReprs = Cec_ManCswDeriveReprs( p );
+ pNew = Gia_ManDupDfsClasses( pAig );
+ Cec_ManCswStop( p );
+ Cec_ManPatStop( pPat );
+ return pNew;
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cec/cecInt.h b/src/aig/cec/cecInt.h
index 93221f83..309f4292 100644
--- a/src/aig/cec/cecInt.h
+++ b/src/aig/cec/cecInt.h
@@ -21,34 +21,60 @@
#ifndef __CEC_INT_H__
#define __CEC_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
-#include "aig.h"
#include "satSolver.h"
#include "bar.h"
+#include "gia.h"
#include "cec.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
+// simulation pattern manager
+typedef struct Cec_ManPat_t_ Cec_ManPat_t;
+struct Cec_ManPat_t_
+{
+ Vec_Int_t * vPattern1; // pattern in terms of primary inputs
+ Vec_Int_t * vPattern2; // pattern in terms of primary inputs
+ Vec_Str_t * vStorage; // storage for compressed patterns
+ int iStart; // position in the array where recent patterns begin
+ int nPats; // total number of recent patterns
+ int nPatsAll; // total number of all patterns
+ int nPatLits; // total number of literals in recent patterns
+ int nPatLitsAll; // total number of literals in all patterns
+ int nPatLitsMin; // total number of literals in minimized recent patterns
+ int nPatLitsMinAll; // total number of literals in minimized all patterns
+ int nSeries; // simulation series
+ int fVerbose; // verbose stats
+ // runtime statistics
+ int timeFind; // detecting the pattern
+ int timeShrink; // minimizing the pattern
+ int timeVerify; // verifying the result of minimisation
+ int timeSort; // sorting literals
+ int timePack; // packing into sim info structures
+ int timeTotal; // total runtime
+};
+
+// SAT solving manager
typedef struct Cec_ManSat_t_ Cec_ManSat_t;
struct Cec_ManSat_t_
{
// parameters
Cec_ParSat_t * pPars;
// AIGs used in the package
- Aig_Man_t * pAig; // the AIG whose outputs are considered
+ Gia_Man_t * pAig; // the AIG whose outputs are considered
Vec_Int_t * vStatus; // status for each output
// SAT solving
sat_solver * pSat; // recyclable SAT solver
@@ -62,6 +88,11 @@ struct Cec_ManSat_t_
int nSatUnsat; // the number of proofs
int nSatSat; // the number of failure
int nSatUndec; // the number of timeouts
+ int nSatTotal; // the number of calls
+ // conflicts
+ int nConfUnsat;
+ int nConfSat;
+ int nConfUndec;
// runtime stats
int timeSatUnsat; // unsat
int timeSatSat; // sat
@@ -69,144 +100,82 @@ struct Cec_ManSat_t_
int timeTotal; // total runtime
};
-typedef struct Cec_ManCla_t_ Cec_ManCla_t;
-
-typedef struct Cec_ManCsw_t_ Cec_ManCsw_t;
-struct Cec_ManCsw_t_
+// combinational sweeping object
+typedef struct Cec_ObjCsw_t_ Cec_ObjCsw_t;
+struct Cec_ObjCsw_t_
{
- // parameters
- Cec_ParCsw_t * pPars;
- // AIGs used in the package
- Aig_Man_t * pAig; // the AIG for SAT sweeping
- Aig_Man_t * pFraig; // the AIG after SAT sweeping
- // equivalence classes
- Cec_ManCla_t * ppClasses; // equivalence classes of nodes
- // choice node statistics
- int nLits; // the number of lits in the cand equiv classes
- int nReprs; // the number of proved equivalent pairs
- int nEquivs; // the number of final equivalences
- int nChoices; // the number of final choice nodes
-};
-
-typedef struct Cec_ManCec_t_ Cec_ManCec_t;
-struct Cec_ManCec_t_
-{
- // parameters
- Cec_ParCec_t * pPars;
- // AIGs used in the package
- Aig_Man_t * pAig; // the miter for equivalence checking
- // mapping of PI/PO nodes
-
- // counter-example
- int * pCex; // counter-example
- int iOutput; // the output for this counter-example
-
- // statistics
-
-};
-
-typedef struct Cec_MtrStatus_t_ Cec_MtrStatus_t;
-struct Cec_MtrStatus_t_
-{
- int nInputs; // the total number of inputs
- int nNodes; // the total number of nodes
- int nOutputs; // the total number of outputs
- int nUnsat; // the number of UNSAT outputs
- int nSat; // the number of SAT outputs
- int nUndec; // the number of undecided outputs
- int iOut; // the satisfied output
+ int iRepr; // representative node
+ unsigned iNext : 30; // next node in the class
+ unsigned iProved : 1; // this node is proved
+ unsigned iFailed : 1; // this node is failed
+ unsigned SimNum; // simulation info number
};
// combinational simulation manager
-typedef struct Caig_Man_t_ Caig_Man_t;
-struct Caig_Man_t_
+typedef struct Cec_ManCsw_t_ Cec_ManCsw_t;
+struct Cec_ManCsw_t_
{
// parameters
- Aig_Man_t * pAig; // the AIG to be used for simulation
- int nWords; // the number of words to simulate
- // AIG representation
- int nPis; // the number of primary inputs
- int nPos; // the number of primary outputs
- int nNodes; // the number of internal nodes
- int nObjs; // nPis + nNodes + nPos + 1
- int * pFans0; // fanin0 for all objects
- int * pFans1; // fanin1 for all objects
- // simulation info
- unsigned short* pRefs; // reference counter for each node
- unsigned * pSims; // simlulation information for each node
+ Gia_Man_t * pAig; // the AIG to be used for simulation
+ Cec_ParCsw_t * pPars; // SAT sweeping parameters
+ int nWords; // the number of simulation words
+ // equivalence classes
+ Cec_ObjCsw_t * pObjs; // objects used for SAT sweeping
// recycable memory
- unsigned * pMems; // allocated simulaton memory
- int nWordsAlloc; // the number of allocated entries
- int nMems; // the number of used entries
- int nMemsMax; // the max number of used entries
- int MemFree; // next free entry
- // equivalence class representation
- int * pReprs; // representatives of each node
- int * pNexts; // nexts for each node
+ unsigned * pMems; // allocated simulaton memory
+ int nWordsAlloc; // the number of allocated entries
+ int nMems; // the number of used entries
+ int nMemsMax; // the max number of used entries
+ int MemFree; // next free entry
// temporaries
- Vec_Ptr_t * vSims; // pointers to sim info
- Vec_Int_t * vClassOld; // old class numbers
- Vec_Int_t * vClassNew; // new class numbers
+ Vec_Int_t * vClassOld; // old class numbers
+ Vec_Int_t * vClassNew; // new class numbers
+ Vec_Int_t * vClassTemp; // temporary storage
+ Vec_Int_t * vRefinedC; // refined const reprs
+ // simulation patterns
+ Vec_Int_t * vXorNodes; // nodes used in speculative reduction
+ int nAllProved; // total number of proved nodes
+ int nAllDisproved; // total number of disproved nodes
+ int nAllFailed; // total number of failed nodes
+ // runtime stats
+ int timeSim; // unsat
+ int timeSat; // sat
+ int timeTotal; // total runtime
};
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-static inline int Cec_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
-static inline int Cec_Lit2Var( int Lit ) { return Lit >> 1; }
-static inline int Cec_LitIsCompl( int Lit ) { return Lit & 1; }
-static inline int Cec_LitNot( int Lit ) { return Lit ^ 1; }
-static inline int Cec_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); }
-static inline int Cec_LitRegular( int Lit ) { return Lit & ~01; }
-
-static inline int Cec_ObjSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj ) { return p->pSatVars[pObj->Id]; }
-static inline void Cec_ObjSetSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj, int Num ) { p->pSatVars[pObj->Id] = Num; }
-
-static inline Aig_Obj_t * Cec_ObjFraig( Aig_Obj_t * pObj ) { return pObj->pData; }
-static inline void Cec_ObjSetFraig( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { pObj->pData = pNode; }
-
-static inline int Cec_ObjIsConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj )
-{
- return Aig_ObjRepr(pAig, pObj) == Aig_ManConst1(pAig);
-}
-static inline void Cec_ObjSetConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj )
-{
- assert( !Cec_ObjIsConst1Cand( pAig, pObj ) );
- Aig_ObjSetRepr( pAig, pObj, Aig_ManConst1(pAig) );
-}
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-/*=== cecAig.c ==========================================================*/
-extern Aig_Man_t * Cec_Duplicate( Aig_Man_t * p );
-extern Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 );
-/*=== cecClass.c ==========================================================*/
-extern Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p );
-extern int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords );
-extern int Caig_ManCompareConst( unsigned * p, int nWords );
-extern void Caig_ManProcessClass( Caig_Man_t * p, int i );
-extern void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined );
-extern Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters );
-/*=== cecCnf.c ==========================================================*/
-extern void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Aig_Obj_t * pObj );
-/*=== cecSat.c ==========================================================*/
-extern Cec_MtrStatus_t Cec_SatSolveOutputs( Aig_Man_t * pAig, Cec_ParSat_t * pPars );
-/*=== cecSim.c ==========================================================*/
-extern Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig );
-extern void Caig_ManDelete( Caig_Man_t * p );
-extern unsigned * Caig_ManSimRead( Caig_Man_t * p, int i );
-extern unsigned * Caig_ManSimRef( Caig_Man_t * p, int i );
-extern unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i );
-extern int Caig_ManSimulateRound( Caig_Man_t * p, int fMiter );
-extern int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose );
-/*=== cecStatus.c ==========================================================*/
-extern int Cec_OutputStatus( Aig_Man_t * p, Aig_Obj_t * pObj );
-extern Cec_MtrStatus_t Cec_MiterStatus( Aig_Man_t * p );
-extern Cec_MtrStatus_t Cec_MiterStatusTrivial( Aig_Man_t * p );
-extern void Cec_MiterStatusPrint( Cec_MtrStatus_t S, char * pString, int Time );
+/*=== cecCore.c ============================================================*/
+/*=== cecClass.c ============================================================*/
+extern int Cec_ManCswCountLitsAll( Cec_ManCsw_t * p );
+extern int * Cec_ManCswDeriveReprs( Cec_ManCsw_t * p );
+extern Gia_Man_t * Cec_ManCswSpecReduction( Cec_ManCsw_t * p );
+extern Gia_Man_t * Cec_ManCswSpecReductionProved( Cec_ManCsw_t * p );
+extern Gia_Man_t * Cec_ManCswDupWithClasses( Cec_ManCsw_t * p );
+extern int Cec_ManCswClassesPrepare( Cec_ManCsw_t * p );
+extern int Cec_ManCswClassesUpdate( Cec_ManCsw_t * p, Cec_ManPat_t * pPat, Gia_Man_t * pNew );
+/*=== cecMan.c ============================================================*/
+extern Cec_ManCsw_t * Cec_ManCswStart( Gia_Man_t * pAig, Cec_ParCsw_t * pPars );
+extern void Cec_ManCswStop( Cec_ManCsw_t * p );
+extern Cec_ManPat_t * Cec_ManPatStart();
+extern void Cec_ManPatPrintStats( Cec_ManPat_t * p );
+extern void Cec_ManPatStop( Cec_ManPat_t * p );
+extern Cec_ManSat_t * Cec_ManSatCreate( Gia_Man_t * pAig, Cec_ParSat_t * pPars );
+extern void Cec_ManSatPrintStats( Cec_ManSat_t * p );
+extern void Cec_ManSatStop( Cec_ManSat_t * p );
+/*=== cecPat.c ============================================================*/
+extern void Cec_ManPatSavePattern( Cec_ManPat_t * pPat, Cec_ManSat_t * p, Gia_Obj_t * pObj );
+extern Vec_Ptr_t * Cec_ManPatCollectPatterns( Cec_ManPat_t * pMan, int nInputs, int nWords );
+/*=== cecSolve.c ============================================================*/
+extern int Cec_ObjSatVarValue( Cec_ManSat_t * p, Gia_Obj_t * pObj );
+extern void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPars );
+/*=== cecUtil.c ============================================================*/
#ifdef __cplusplus
}
diff --git a/src/aig/cec/cecMan.c b/src/aig/cec/cecMan.c
index 86415c53..b8ee75b2 100644
--- a/src/aig/cec/cecMan.c
+++ b/src/aig/cec/cecMan.c
@@ -30,7 +30,7 @@
/**Function*************************************************************
- Synopsis []
+ Synopsis [Creates AIG.]
Description []
@@ -39,10 +39,26 @@
SeeAlso []
***********************************************************************/
+Cec_ManCsw_t * Cec_ManCswStart( Gia_Man_t * pAig, Cec_ParCsw_t * pPars )
+{
+ Cec_ManCsw_t * p;
+ p = ABC_ALLOC( Cec_ManCsw_t, 1 );
+ memset( p, 0, sizeof(Cec_ManCsw_t) );
+ p->pAig = pAig;
+ p->pPars = pPars;
+ p->pObjs = ABC_CALLOC( Cec_ObjCsw_t, Gia_ManObjNum(pAig) );
+ // temporaries
+ p->vClassOld = Vec_IntAlloc( 1000 );
+ p->vClassNew = Vec_IntAlloc( 1000 );
+ p->vClassTemp = Vec_IntAlloc( 1000 );
+ p->vRefinedC = Vec_IntAlloc( 10000 );
+ p->vXorNodes = Vec_IntAlloc( 1000 );
+ return p;
+}
/**Function*************************************************************
- Synopsis []
+ Synopsis [Deletes AIG.]
Description []
@@ -51,6 +67,161 @@
SeeAlso []
***********************************************************************/
+void Cec_ManCswStop( Cec_ManCsw_t * p )
+{
+ Vec_IntFree( p->vXorNodes );
+ Vec_IntFree( p->vClassOld );
+ Vec_IntFree( p->vClassNew );
+ Vec_IntFree( p->vClassTemp );
+ Vec_IntFree( p->vRefinedC );
+ ABC_FREE( p->pMems );
+ ABC_FREE( p->pObjs );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Creates AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Cec_ManPat_t * Cec_ManPatStart()
+{
+ Cec_ManPat_t * p;
+ p = ABC_CALLOC( Cec_ManPat_t, 1 );
+ p->vStorage = Vec_StrAlloc( 1<<20 );
+ p->vPattern1 = Vec_IntAlloc( 1000 );
+ p->vPattern2 = Vec_IntAlloc( 1000 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatPrintStats( Cec_ManPat_t * p )
+{
+ printf( "Latest: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f Mb\n",
+ p->nPats, p->nPatLits, p->nPatLitsMin, 1.0 * p->nPatLitsMin/p->nPats,
+ 1.0*(Vec_StrSize(p->vStorage)-p->iStart)/(1<<20) );
+ printf( "Total: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f Mb\n",
+ p->nPatsAll, p->nPatLitsAll, p->nPatLitsMinAll, 1.0 * p->nPatLitsMinAll/p->nPatsAll,
+ 1.0*Vec_StrSize(p->vStorage)/(1<<20) );
+ ABC_PRTP( "Finding ", p->timeFind, p->timeTotal );
+ ABC_PRTP( "Shrinking", p->timeShrink, p->timeTotal );
+ ABC_PRTP( "Verifying", p->timeVerify, p->timeTotal );
+ ABC_PRTP( "Sorting ", p->timeSort, p->timeTotal );
+ ABC_PRTP( "Packing ", p->timePack, p->timeTotal );
+ ABC_PRT( "TOTAL ", p->timeTotal );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatStop( Cec_ManPat_t * p )
+{
+ Vec_StrFree( p->vStorage );
+ Vec_IntFree( p->vPattern1 );
+ Vec_IntFree( p->vPattern2 );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Cec_ManSat_t * Cec_ManSatCreate( Gia_Man_t * pAig, Cec_ParSat_t * pPars )
+{
+ Cec_ManSat_t * p;
+ // create interpolation manager
+ p = ABC_ALLOC( Cec_ManSat_t, 1 );
+ memset( p, 0, sizeof(Cec_ManSat_t) );
+ p->pPars = pPars;
+ p->pAig = pAig;
+ // SAT solving
+ p->nSatVars = 1;
+ p->pSatVars = ABC_CALLOC( int, Gia_ManObjNum(pAig) );
+ p->vUsedNodes = Vec_PtrAlloc( 1000 );
+ p->vFanins = Vec_PtrAlloc( 100 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints statistics of the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatPrintStats( Cec_ManSat_t * p )
+{
+ printf( "CO = %6d ", Gia_ManCoNum(p->pAig) );
+ printf( "Conf = %5d ", p->pPars->nBTLimit );
+ printf( "MinVar = %5d ", p->pPars->nSatVarMax );
+ printf( "MinCalls = %5d\n", p->pPars->nCallsRecycle );
+ printf( "Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ p->nSatUnsat, 100.0*p->nSatUnsat/p->nSatTotal, p->nSatUnsat? 1.0*p->nConfUnsat/p->nSatUnsat :0.0 );
+ ABC_PRTP( "Time", p->timeSatUnsat, p->timeTotal );
+ printf( "Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ p->nSatSat, 100.0*p->nSatSat/p->nSatTotal, p->nSatSat? 1.0*p->nConfSat/p->nSatSat : 0.0 );
+ ABC_PRTP( "Time", p->timeSatSat, p->timeTotal );
+ printf( "Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ p->nSatUndec, 100.0*p->nSatUndec/p->nSatTotal, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 );
+ ABC_PRTP( "Time", p->timeSatUndec, p->timeTotal );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Frees the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatStop( Cec_ManSat_t * p )
+{
+ if ( p->pSat )
+ sat_solver_delete( p->pSat );
+ Vec_PtrFree( p->vUsedNodes );
+ Vec_PtrFree( p->vFanins );
+ ABC_FREE( p->pSatVars );
+ ABC_FREE( p );
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
diff --git a/src/aig/cec/cecPat.c b/src/aig/cec/cecPat.c
new file mode 100644
index 00000000..1af4f333
--- /dev/null
+++ b/src/aig/cec/cecPat.c
@@ -0,0 +1,493 @@
+/**CFile****************************************************************
+
+ FileName [cec.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Cec_ManPatStoreNum( Cec_ManPat_t * p, int Num )
+{
+ unsigned x = (unsigned)Num;
+ assert( Num >= 0 );
+ while ( x & ~0x7f )
+ {
+ Vec_StrPush( p->vStorage, (char)((x & 0x7f) | 0x80) );
+ x >>= 7;
+ }
+ Vec_StrPush( p->vStorage, (char)x );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Cec_ManPatRestoreNum( Cec_ManPat_t * p )
+{
+ int ch, i, x = 0;
+ for ( i = 0; (ch = Vec_StrEntry(p->vStorage, p->iStart++)) & 0x80; i++ )
+ x |= (ch & 0x7f) << (7 * i);
+ return x | (ch << (7 * i));
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Cec_ManPatStore( Cec_ManPat_t * p, Vec_Int_t * vPat )
+{
+ int i, Number, NumberPrev;
+ assert( Vec_IntSize(vPat) > 0 );
+ Cec_ManPatStoreNum( p, Vec_IntSize(vPat) );
+ NumberPrev = Vec_IntEntry( vPat, 0 );
+ Cec_ManPatStoreNum( p, NumberPrev );
+ Vec_IntForEachEntryStart( vPat, Number, i, 1 )
+ {
+ assert( NumberPrev < Number );
+ Cec_ManPatStoreNum( p, Number - NumberPrev );
+ NumberPrev = Number;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Cec_ManPatRestore( Cec_ManPat_t * p, Vec_Int_t * vPat )
+{
+ int i, Size, Number;
+ Vec_IntClear( vPat );
+ Size = Cec_ManPatRestoreNum( p );
+ Number = Cec_ManPatRestoreNum( p );
+ Vec_IntPush( vPat, Number );
+ for ( i = 1; i < Size; i++ )
+ {
+ Number += Cec_ManPatRestoreNum( p );
+ Vec_IntPush( vPat, Number );
+ }
+ assert( Vec_IntSize(vPat) == Size );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Derives satisfying assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManPatComputePattern_rec( Cec_ManSat_t * pSat, Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ int Counter = 0;
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ pObj->fMark1 = Cec_ObjSatVarValue( pSat, pObj );
+ return 1;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Counter += Cec_ManPatComputePattern_rec( pSat, p, Gia_ObjFanin0(pObj) );
+ Counter += Cec_ManPatComputePattern_rec( pSat, p, Gia_ObjFanin1(pObj) );
+ pObj->fMark1 = (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) &
+ (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj));
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives satisfying assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatComputePattern1_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ Vec_IntPush( vPat, Gia_Var2Lit( Gia_ObjCioId(pObj), pObj->fMark1==0 ) );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ if ( pObj->fMark1 == 1 )
+ {
+ Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin0(pObj), vPat );
+ Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin1(pObj), vPat );
+ }
+ else
+ {
+ assert( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 0 ||
+ (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj)) == 0 );
+ if ( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 0 )
+ Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin0(pObj), vPat );
+ else
+ Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin1(pObj), vPat );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives satisfying assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatComputePattern2_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ Vec_IntPush( vPat, Gia_Var2Lit( Gia_ObjCioId(pObj), pObj->fMark1==0 ) );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ if ( pObj->fMark1 == 1 )
+ {
+ Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin0(pObj), vPat );
+ Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin1(pObj), vPat );
+ }
+ else
+ {
+ assert( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 0 ||
+ (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj)) == 0 );
+ if ( (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj)) == 0 )
+ Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin1(pObj), vPat );
+ else
+ Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin0(pObj), vPat );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives satisfying assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManPatComputePattern3_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ int Value0, Value1, Value;
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return (pObj->fMark1 << 1) | pObj->fMark0;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ pObj->fMark0 = 1;
+ pObj->fMark1 = 1;
+ return GIA_UND;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Value0 = Cec_ManPatComputePattern3_rec( p, Gia_ObjFanin0(pObj) );
+ Value1 = Cec_ManPatComputePattern3_rec( p, Gia_ObjFanin1(pObj) );
+ Value = Gia_XsimAndCond( Value0, Gia_ObjFaninC0(pObj), Value1, Gia_ObjFaninC1(pObj) );
+ pObj->fMark0 = (Value & 1);
+ pObj->fMark1 = ((Value >> 1) & 1);
+ return Value;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives satisfying assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat )
+{
+ Gia_Obj_t * pTemp;
+ int i, Value;
+ Gia_ManIncrementTravId( p );
+ Vec_IntForEachEntry( vPat, Value, i )
+ {
+ pTemp = Gia_ManCi( p, Gia_Lit2Var(Value) );
+// assert( Gia_LitIsCompl(Value) != (int)pTemp->fMark1 );
+ if ( pTemp->fMark1 )
+ {
+ pTemp->fMark0 = 0;
+ pTemp->fMark1 = 1;
+ }
+ else
+ {
+ pTemp->fMark0 = 1;
+ pTemp->fMark1 = 0;
+ }
+ Gia_ObjSetTravIdCurrent( p, pTemp );
+ }
+ Value = Cec_ManPatComputePattern3_rec( p, Gia_ObjFanin0(pObj) );
+ Value = Gia_XsimNotCond( Value, Gia_ObjFaninC0(pObj) );
+ if ( Value != GIA_ONE )
+ printf( "Cec_ManPatVerifyPattern(): Verification failed.\n" );
+ assert( Value == GIA_ONE );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatComputePattern4_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ pObj->fMark0 = 0;
+ if ( Gia_ObjIsCi(pObj) )
+ return;
+ assert( Gia_ObjIsAnd(pObj) );
+ Cec_ManPatComputePattern4_rec( p, Gia_ObjFanin0(pObj) );
+ Cec_ManPatComputePattern4_rec( p, Gia_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatCleanMark0( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ assert( Gia_ObjIsCo(pObj) );
+ Gia_ManIncrementTravId( p );
+ Cec_ManPatComputePattern4_rec( p, Gia_ObjFanin0(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManPatSavePattern( Cec_ManPat_t * pMan, Cec_ManSat_t * p, Gia_Obj_t * pObj )
+{
+ Vec_Int_t * vPat;
+ int nPatLits, clk, clkTotal = clock();
+ assert( Gia_ObjIsCo(pObj) );
+ pMan->nPats++;
+ pMan->nPatsAll++;
+ // compute values in the cone of influence
+clk = clock();
+ Gia_ManIncrementTravId( p->pAig );
+ nPatLits = Cec_ManPatComputePattern_rec( p, p->pAig, Gia_ObjFanin0(pObj) );
+ assert( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 1 );
+ pMan->nPatLits += nPatLits;
+ pMan->nPatLitsAll += nPatLits;
+pMan->timeFind += clock() - clk;
+ // compute sensitizing path
+clk = clock();
+ Vec_IntClear( pMan->vPattern1 );
+ Gia_ManIncrementTravId( p->pAig );
+ Cec_ManPatComputePattern1_rec( p->pAig, Gia_ObjFanin0(pObj), pMan->vPattern1 );
+ // compute sensitizing path
+ Vec_IntClear( pMan->vPattern2 );
+ Gia_ManIncrementTravId( p->pAig );
+ Cec_ManPatComputePattern2_rec( p->pAig, Gia_ObjFanin0(pObj), pMan->vPattern2 );
+ // compare patterns
+ vPat = Vec_IntSize(pMan->vPattern1) < Vec_IntSize(pMan->vPattern2) ? pMan->vPattern1 : pMan->vPattern2;
+ pMan->nPatLitsMin += Vec_IntSize(vPat);
+ pMan->nPatLitsMinAll += Vec_IntSize(vPat);
+pMan->timeShrink += clock() - clk;
+ // verify pattern using ternary simulation
+clk = clock();
+ Cec_ManPatVerifyPattern( p->pAig, pObj, vPat );
+pMan->timeVerify += clock() - clk;
+ // sort pattern
+clk = clock();
+ Vec_IntSort( vPat, 0 );
+pMan->timeSort += clock() - clk;
+ // save pattern
+ Cec_ManPatStore( pMan, vPat );
+ pMan->timeTotal += clock() - clkTotal;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Packs patterns into array of simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+*************************************`**********************************/
+int Cec_ManPatCollectTry( Vec_Ptr_t * vInfo, Vec_Ptr_t * vPres, int iBit, int * pLits, int nLits )
+{
+ unsigned * pInfo, * pPres;
+ int i;
+ for ( i = 0; i < nLits; i++ )
+ {
+ pInfo = Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ if ( Aig_InfoHasBit( pPres, iBit ) &&
+ Aig_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
+ return 0;
+ }
+ for ( i = 0; i < nLits; i++ )
+ {
+ pInfo = Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ Aig_InfoSetBit( pPres, iBit );
+ if ( Aig_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
+ Aig_InfoXorBit( pInfo, iBit );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Packs patterns into array of simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Cec_ManPatCollectPatterns( Cec_ManPat_t * pMan, int nInputs, int nWordsInit )
+{
+ Vec_Int_t * vPat = pMan->vPattern1;
+ Vec_Ptr_t * vInfo, * vPres;
+ int k, kMax = -1, nPatterns = 0;
+ int iStartOld = pMan->iStart;
+ int nWords = nWordsInit;
+ int nBits = 32 * nWords;
+ int clk = clock();
+ vInfo = Vec_PtrAllocSimInfo( nInputs, nWords );
+ Aig_ManRandomInfo( vInfo, 0, nWords );
+ vPres = Vec_PtrAllocSimInfo( nInputs, nWords );
+ Vec_PtrCleanSimInfo( vPres, 0, nWords );
+ while ( pMan->iStart < Vec_StrSize(pMan->vStorage) )
+ {
+ nPatterns++;
+ Cec_ManPatRestore( pMan, vPat );
+ for ( k = 1; k < nBits; k++, k += ((k % (32 * nWordsInit)) == 0) )
+ if ( Cec_ManPatCollectTry( vInfo, vPres, k, (int *)Vec_IntArray(vPat), Vec_IntSize(vPat) ) )
+ break;
+ kMax = AIG_MAX( kMax, k );
+ if ( k == nBits-1 )
+ {
+ Vec_PtrReallocSimInfo( vInfo );
+ Aig_ManRandomInfo( vInfo, nWords, 2*nWords );
+ Vec_PtrReallocSimInfo( vPres );
+ Vec_PtrCleanSimInfo( vPres, nWords, 2*nWords );
+ nWords *= 2;
+ nBits *= 2;
+ }
+ }
+ Vec_PtrFree( vPres );
+ pMan->nSeries = Vec_PtrReadWordsSimInfo(vInfo) / nWordsInit;
+ pMan->timePack += clock() - clk;
+ pMan->timeTotal += clock() - clk;
+ pMan->iStart = iStartOld;
+ if ( pMan->fVerbose )
+ {
+ printf( "Total = %5d. Max used = %5d. Full = %5d. Series = %d. ",
+ nPatterns, kMax, nWordsInit*32, pMan->nSeries );
+ ABC_PRT( "Time", clock() - clk );
+ Cec_ManPatPrintStats( pMan );
+ }
+ return vInfo;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/cec/cecSolve.c b/src/aig/cec/cecSolve.c
new file mode 100644
index 00000000..0ec7df45
--- /dev/null
+++ b/src/aig/cec/cecSolve.c
@@ -0,0 +1,537 @@
+/**CFile****************************************************************
+
+ FileName [cecSolve.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis [Performs one round of SAT solving.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cecSolve.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline int Cec_ObjSatNum( Cec_ManSat_t * p, Gia_Obj_t * pObj ) { return p->pSatVars[Gia_ObjId(p->pAig,pObj)]; }
+static inline void Cec_ObjSetSatNum( Cec_ManSat_t * p, Gia_Obj_t * pObj, int Num ) { p->pSatVars[Gia_ObjId(p->pAig,pObj)] = Num; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Returns value of the SAT variable.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ObjSatVarValue( Cec_ManSat_t * p, Gia_Obj_t * pObj )
+{
+ return sat_solver_var_value( p->pSat, Cec_ObjSatNum(p, pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Addes clauses to the solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_AddClausesMux( Cec_ManSat_t * p, Gia_Obj_t * pNode )
+{
+ Gia_Obj_t * pNodeI, * pNodeT, * pNodeE;
+ int pLits[4], RetValue, VarF, VarI, VarT, VarE, fCompT, fCompE;
+
+ assert( !Gia_IsComplement( pNode ) );
+ assert( Gia_ObjIsMuxType( pNode ) );
+ // get nodes (I = if, T = then, E = else)
+ pNodeI = Gia_ObjRecognizeMux( pNode, &pNodeT, &pNodeE );
+ // get the variable numbers
+ VarF = Cec_ObjSatNum(p,pNode);
+ VarI = Cec_ObjSatNum(p,pNodeI);
+ VarT = Cec_ObjSatNum(p,Gia_Regular(pNodeT));
+ VarE = Cec_ObjSatNum(p,Gia_Regular(pNodeE));
+ // get the complementation flags
+ fCompT = Gia_IsComplement(pNodeT);
+ fCompE = Gia_IsComplement(pNodeE);
+
+ // f = ITE(i, t, e)
+
+ // i' + t' + f
+ // i' + t + f'
+ // i + e' + f
+ // i + e + f'
+
+ // create four clauses
+ pLits[0] = toLitCond(VarI, 1);
+ pLits[1] = toLitCond(VarT, 1^fCompT);
+ pLits[2] = toLitCond(VarF, 0);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
+ if ( Gia_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] );
+ if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
+ assert( RetValue );
+ pLits[0] = toLitCond(VarI, 1);
+ pLits[1] = toLitCond(VarT, 0^fCompT);
+ pLits[2] = toLitCond(VarF, 1);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
+ if ( Gia_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] );
+ if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
+ assert( RetValue );
+ pLits[0] = toLitCond(VarI, 0);
+ pLits[1] = toLitCond(VarE, 1^fCompE);
+ pLits[2] = toLitCond(VarF, 0);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
+ if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
+ if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
+ assert( RetValue );
+ pLits[0] = toLitCond(VarI, 0);
+ pLits[1] = toLitCond(VarE, 0^fCompE);
+ pLits[2] = toLitCond(VarF, 1);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
+ if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
+ if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
+ assert( RetValue );
+
+ // two additional clauses
+ // t' & e' -> f'
+ // t & e -> f
+
+ // t + e + f'
+ // t' + e' + f
+
+ if ( VarT == VarE )
+ {
+// assert( fCompT == !fCompE );
+ return;
+ }
+
+ pLits[0] = toLitCond(VarT, 0^fCompT);
+ pLits[1] = toLitCond(VarE, 0^fCompE);
+ pLits[2] = toLitCond(VarF, 1);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( Gia_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] );
+ if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
+ if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
+ assert( RetValue );
+ pLits[0] = toLitCond(VarT, 1^fCompT);
+ pLits[1] = toLitCond(VarE, 1^fCompE);
+ pLits[2] = toLitCond(VarF, 0);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( Gia_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] );
+ if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
+ if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
+ assert( RetValue );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Addes clauses to the solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_AddClausesSuper( Cec_ManSat_t * p, Gia_Obj_t * pNode, Vec_Ptr_t * vSuper )
+{
+ Gia_Obj_t * pFanin;
+ int * pLits, nLits, RetValue, i;
+ assert( !Gia_IsComplement(pNode) );
+ assert( Gia_ObjIsAnd( pNode ) );
+ // create storage for literals
+ nLits = Vec_PtrSize(vSuper) + 1;
+ pLits = ABC_ALLOC( int, nLits );
+ // suppose AND-gate is A & B = C
+ // add !A => !C or A + !C
+ Vec_PtrForEachEntry( vSuper, pFanin, i )
+ {
+ pLits[0] = toLitCond(Cec_ObjSatNum(p,Gia_Regular(pFanin)), Gia_IsComplement(pFanin));
+ pLits[1] = toLitCond(Cec_ObjSatNum(p,pNode), 1);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( Gia_Regular(pFanin)->fPhase ) pLits[0] = lit_neg( pLits[0] );
+ if ( pNode->fPhase ) pLits[1] = lit_neg( pLits[1] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
+ assert( RetValue );
+ }
+ // add A & B => C or !A + !B + C
+ Vec_PtrForEachEntry( vSuper, pFanin, i )
+ {
+ pLits[i] = toLitCond(Cec_ObjSatNum(p,Gia_Regular(pFanin)), !Gia_IsComplement(pFanin));
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( Gia_Regular(pFanin)->fPhase ) pLits[i] = lit_neg( pLits[i] );
+ }
+ }
+ pLits[nLits-1] = toLitCond(Cec_ObjSatNum(p,pNode), 0);
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( pNode->fPhase ) pLits[nLits-1] = lit_neg( pLits[nLits-1] );
+ }
+ RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
+ assert( RetValue );
+ ABC_FREE( pLits );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_CollectSuper_rec( Gia_Obj_t * pObj, Vec_Ptr_t * vSuper, int fFirst, int fUseMuxes )
+{
+ // if the new node is complemented or a PI, another gate begins
+ if ( Gia_IsComplement(pObj) || Gia_ObjIsCi(pObj) ||
+ (!fFirst && Gia_ObjValue(pObj) > 1) ||
+ (fUseMuxes && Gia_ObjIsMuxType(pObj)) )
+ {
+ Vec_PtrPushUnique( vSuper, pObj );
+ return;
+ }
+ // go through the branches
+ Cec_CollectSuper_rec( Gia_ObjChild0(pObj), vSuper, 0, fUseMuxes );
+ Cec_CollectSuper_rec( Gia_ObjChild1(pObj), vSuper, 0, fUseMuxes );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_CollectSuper( Gia_Obj_t * pObj, int fUseMuxes, Vec_Ptr_t * vSuper )
+{
+ assert( !Gia_IsComplement(pObj) );
+ assert( !Gia_ObjIsCi(pObj) );
+ Vec_PtrClear( vSuper );
+ Cec_CollectSuper_rec( pObj, vSuper, 1, fUseMuxes );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Updates the solver clause database.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ObjAddToFrontier( Cec_ManSat_t * p, Gia_Obj_t * pObj, Vec_Ptr_t * vFrontier )
+{
+ assert( !Gia_IsComplement(pObj) );
+ if ( Cec_ObjSatNum(p,pObj) )
+ return;
+ assert( Cec_ObjSatNum(p,pObj) == 0 );
+ if ( Gia_ObjIsConst0(pObj) )
+ return;
+ Vec_PtrPush( p->vUsedNodes, pObj );
+ Cec_ObjSetSatNum( p, pObj, p->nSatVars++ );
+ if ( Gia_ObjIsAnd(pObj) )
+ Vec_PtrPush( vFrontier, pObj );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Updates the solver clause database.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Gia_Obj_t * pObj )
+{
+ Vec_Ptr_t * vFrontier;
+ Gia_Obj_t * pNode, * pFanin;
+ int i, k, fUseMuxes = 1;
+ // quit if CNF is ready
+ if ( Cec_ObjSatNum(p,pObj) )
+ return;
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ Vec_PtrPush( p->vUsedNodes, pObj );
+ Cec_ObjSetSatNum( p, pObj, p->nSatVars++ );
+ sat_solver_setnvars( p->pSat, p->nSatVars );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ // start the frontier
+ vFrontier = Vec_PtrAlloc( 100 );
+ Cec_ObjAddToFrontier( p, pObj, vFrontier );
+ // explore nodes in the frontier
+ Vec_PtrForEachEntry( vFrontier, pNode, i )
+ {
+ // create the supergate
+ assert( Cec_ObjSatNum(p,pNode) );
+ if ( fUseMuxes && Gia_ObjIsMuxType(pNode) )
+ {
+ Vec_PtrClear( p->vFanins );
+ Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin0( Gia_ObjFanin0(pNode) ) );
+ Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin0( Gia_ObjFanin1(pNode) ) );
+ Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin1( Gia_ObjFanin0(pNode) ) );
+ Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin1( Gia_ObjFanin1(pNode) ) );
+ Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Cec_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier );
+ Cec_AddClausesMux( p, pNode );
+ }
+ else
+ {
+ Cec_CollectSuper( pNode, fUseMuxes, p->vFanins );
+ Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Cec_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier );
+ Cec_AddClausesSuper( p, pNode, p->vFanins );
+ }
+ assert( Vec_PtrSize(p->vFanins) > 1 );
+ }
+ Vec_PtrFree( vFrontier );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Recycles the SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatSolverRecycle( Cec_ManSat_t * p )
+{
+ int Lit;
+ if ( p->pSat )
+ {
+ Gia_Obj_t * pObj;
+ int i;
+ Vec_PtrForEachEntry( p->vUsedNodes, pObj, i )
+ Cec_ObjSetSatNum( p, pObj, 0 );
+ Vec_PtrClear( p->vUsedNodes );
+// memset( p->pSatVars, 0, sizeof(int) * Aig_ManObjNumMax(p->pAigTotal) );
+ sat_solver_delete( p->pSat );
+ }
+ p->pSat = sat_solver_new();
+ sat_solver_setnvars( p->pSat, 1000 );
+ // var 0 is not used
+ // var 1 is reserved for const0 node - add the clause
+ p->nSatVars = 1;
+// p->nSatVars = 0;
+ Lit = toLitCond( p->nSatVars, 1 );
+ if ( p->pPars->fPolarFlip )
+ Lit = lit_neg( Lit );
+ sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
+ Cec_ObjSetSatNum( p, Gia_ManConst0(p->pAig), p->nSatVars++ );
+
+ p->nRecycles++;
+ p->nCallsSince = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Runs equivalence test for the two nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManSatCheckNode( Cec_ManSat_t * p, Gia_Obj_t * pObj )
+{
+ int nBTLimit = p->pPars->nBTLimit;
+ int Lit, RetValue, status, clk, nConflicts;
+
+ p->nCallsSince++; // experiment with this!!!
+ p->nSatTotal++;
+
+ // check if SAT solver needs recycling
+ if ( p->pSat == NULL ||
+ (p->pPars->nSatVarMax &&
+ p->nSatVars > p->pPars->nSatVarMax &&
+ p->nCallsSince > p->pPars->nCallsRecycle) )
+ Cec_ManSatSolverRecycle( p );
+
+ // if the nodes do not have SAT variables, allocate them
+ Cec_CnfNodeAddToSolver( p, Gia_ObjFanin0(pObj) );
+
+ // propage unit clauses
+ if ( p->pSat->qtail != p->pSat->qhead )
+ {
+ status = sat_solver_simplify(p->pSat);
+ assert( status != 0 );
+ assert( p->pSat->qtail == p->pSat->qhead );
+ }
+
+ // solve under assumptions
+ // A = 1; B = 0 OR A = 1; B = 1
+ Lit = toLitCond( Cec_ObjSatNum(p,Gia_ObjFanin0(pObj)), Gia_ObjFaninC0(pObj) );
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( Gia_ObjFanin0(pObj)->fPhase ) Lit = lit_neg( Lit );
+ }
+//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
+clk = clock();
+ nConflicts = p->pSat->stats.conflicts;
+ RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1,
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( RetValue == l_False )
+ {
+p->timeSatUnsat += clock() - clk;
+ Lit = lit_neg( Lit );
+ RetValue = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
+ assert( RetValue );
+ p->nSatUnsat++;
+ p->nConfUnsat += p->pSat->stats.conflicts - nConflicts;
+ return 1;
+ }
+ else if ( RetValue == l_True )
+ {
+p->timeSatSat += clock() - clk;
+ p->nSatSat++;
+ p->nConfSat += p->pSat->stats.conflicts - nConflicts;
+ return 0;
+ }
+ else // if ( RetValue == l_Undef )
+ {
+p->timeSatUndec += clock() - clk;
+ p->nSatUndec++;
+ p->nConfUndec += p->pSat->stats.conflicts - nConflicts;
+ return -1;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs one round of solving for the POs of the AIG.]
+
+ Description [Labels the nodes that have been proved (pObj->fMark1)
+ and returns the set of satisfying assignments.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPars )
+{
+ Bar_Progress_t * pProgress = NULL;
+ Cec_ManSat_t * p;
+ Gia_Obj_t * pObj;
+ int i, status, clk = clock();
+ // reset the manager
+ if ( pPat )
+ {
+ pPat->iStart = Vec_StrSize(pPat->vStorage);
+ pPat->nPats = 0;
+ pPat->nPatLits = 0;
+ pPat->nPatLitsMin = 0;
+ }
+ Gia_ManSetPhase( pAig );
+ Gia_ManResetTravId( pAig );
+ p = Cec_ManSatCreate( pAig, pPars );
+ pProgress = Bar_ProgressStart( stdout, Gia_ManPoNum(pAig) );
+ Gia_ManForEachCo( pAig, pObj, i )
+ {
+ if ( Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) )
+ {
+ pObj->fMark0 = 0;
+ pObj->fMark1 = 1;
+ continue;
+ }
+ Bar_ProgressUpdate( pProgress, i, "SAT..." );
+ status = Cec_ManSatCheckNode( p, pObj );
+ pObj->fMark0 = (status == 0);
+ pObj->fMark1 = (status == 1);
+/*
+ if ( status == -1 )
+ {
+ Gia_Man_t * pTemp = Gia_ManDupDfsCone( pAig, pObj );
+ Gia_WriteAiger( pTemp, "gia_hard.aig", 0, 0 );
+ Gia_ManStop( pTemp );
+ printf( "Dumping hard cone into file \"%s\".\n", "gia_hard.aig" );
+ }
+*/
+ if ( status != 0 )
+ continue;
+ // save the pattern
+ if ( pPat )
+ Cec_ManPatSavePattern( pPat, p, pObj );
+ // quit if one of them is solved
+ if ( pPars->fFirstStop )
+ break;
+ }
+ p->timeTotal = clock() - clk;
+ Bar_ProgressStop( pProgress );
+ if ( pPars->fVerbose )
+ Cec_ManSatPrintStats( p );
+ Cec_ManSatStop( p );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/cec/module.make b/src/aig/cec/module.make
index 29f8c859..f8e2602a 100644
--- a/src/aig/cec/module.make
+++ b/src/aig/cec/module.make
@@ -1,8 +1,5 @@
-SRC += src/aig/cec/cecAig.c \
- src/aig/cec/cecClass.c \
- src/aig/cec/cecCnf.c \
+SRC += src/aig/cec/cecClass.c \
src/aig/cec/cecCore.c \
src/aig/cec/cecMan.c \
- src/aig/cec/cecSat.c \
- src/aig/cec/cecSim.c \
- src/aig/cec/cecStatus.c
+ src/aig/cec/cecPat.c \
+ src/aig/cec/cecSolve.c
diff --git a/src/aig/cec2/cec.h b/src/aig/cec2/cec.h
new file mode 100644
index 00000000..3586b535
--- /dev/null
+++ b/src/aig/cec2/cec.h
@@ -0,0 +1,104 @@
+/**CFile****************************************************************
+
+ FileName [cec.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __CEC_H__
+#define __CEC_H__
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+// dynamic SAT parameters
+typedef struct Cec_ParSat_t_ Cec_ParSat_t;
+struct Cec_ParSat_t_
+{
+ int nBTLimit; // conflict limit at a node
+ int nSatVarMax; // the max number of SAT variables
+ int nCallsRecycle; // calls to perform before recycling SAT solver
+ int fFirstStop; // stop on the first sat output
+ int fPolarFlip; // uses polarity adjustment
+ int fVerbose; // verbose stats
+};
+
+// combinational SAT sweeping parameters
+typedef struct Cec_ParCsw_t_ Cec_ParCsw_t;
+struct Cec_ParCsw_t_
+{
+ int nWords; // the number of simulation words
+ int nRounds; // the number of simulation rounds
+ int nBTLimit; // conflict limit at a node
+ int nSatVarMax; // the max number of SAT variables
+ int nCallsRecycle; // calls to perform before recycling SAT solver
+ int nLevelMax; // restriction on the level nodes to be swept
+ int fRewriting; // enables AIG rewriting
+ int fFirstStop; // stop on the first sat output
+ int fVerbose; // verbose stats
+};
+
+// combinational equivalence checking parameters
+typedef struct Cec_ParCec_t_ Cec_ParCec_t;
+struct Cec_ParCec_t_
+{
+ int nIters; // iterations of SAT solving/sweeping
+ int nBTLimitBeg; // starting backtrack limit
+ int nBTlimitMulti; // multiple of backtrack limit
+ int fUseSmartCnf; // use smart CNF computation
+ int fRewriting; // enables AIG rewriting
+ int fSatSweeping; // enables SAT sweeping
+ int fFirstStop; // stop on the first sat output
+ int fVerbose; // verbose stats
+};
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== cecCore.c ==========================================================*/
+extern void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p );
+extern void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p );
+extern void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p );
+extern int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * p );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/cec/cecAig.c b/src/aig/cec2/cecAig.c
index 2a6f5683..c322ead8 100644
--- a/src/aig/cec/cecAig.c
+++ b/src/aig/cec2/cecAig.c
@@ -43,12 +43,20 @@ Aig_Obj_t * Cec_DeriveMiter_rec( Aig_Man_t * pNew, Aig_Obj_t * pObj )
{
if ( pObj->pData )
return pObj->pData;
+ if ( Aig_ObjIsPi(pObj) )
+ {
+ pObj->pData = Aig_ObjCreatePi( pNew );
+ if ( pObj->pHaig )
+ {
+ assert( pObj->pHaig->pData == NULL );
+ pObj->pHaig->pData = pObj->pData;
+ }
+ return pObj->pData;
+ }
+ assert( Aig_ObjIsNode(pObj) );
Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj) );
- if ( Aig_ObjIsBuf(pObj) )
- return pObj->pData = Aig_ObjChild0Copy(pObj);
Cec_DeriveMiter_rec( pNew, Aig_ObjFanin1(pObj) );
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
- Aig_Regular(pObj->pData)->pHaig = pObj->pHaig;
return pObj->pData;
}
@@ -81,9 +89,14 @@ Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 )
Aig_ManConst1(p1)->pData = Aig_ManConst1(pNew);
Aig_ManForEachPi( p0, pObj0, i )
{
+ pObj1 = Aig_ManPi( p1, i );
+ pObj0->pHaig = pObj1;
+ pObj1->pHaig = pObj0;
+ if ( Aig_ObjRefs(pObj0) || Aig_ObjRefs(pObj1) )
+ continue;
pObjNew = Aig_ObjCreatePi( pNew );
pObj0->pData = pObjNew;
- Aig_ManPi(p1, i)->pData = pObjNew;
+ pObj1->pData = pObjNew;
}
// add logic for the POs
pProgress = Bar_ProgressStart( stdout, Aig_ManPoNum(p0) );
@@ -97,11 +110,8 @@ Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 )
Aig_ObjCreatePo( pNew, pObjNew );
}
Bar_ProgressStop( pProgress );
- Aig_ManCleanup( pNew );
Aig_ManSetRegNum( pNew, 0 );
- // check the resulting network
-// if ( !Aig_ManCheck(pNew) )
-// printf( "Cec_DeriveMiter(): The check has failed.\n" );
+ assert( Aig_ManHasNoGaps(pNew) );
return pNew;
}
@@ -118,9 +128,13 @@ Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 )
***********************************************************************/
Aig_Man_t * Cec_Duplicate( Aig_Man_t * p )
{
+ Bar_Progress_t * pProgress = NULL;
Aig_Man_t * pNew;
Aig_Obj_t * pObj;
int i;
+ // make sure the AIG does not have choices and dangling nodes
+ Aig_ManForEachNode( p, pObj, i )
+ assert( Aig_ObjRefs(pObj) > 0 );
// create the new manager
pNew = Aig_ManStart( Aig_ManNodeNum(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
@@ -128,19 +142,22 @@ Aig_Man_t * Cec_Duplicate( Aig_Man_t * p )
Aig_ManCleanData( p );
Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
Aig_ManForEachPi( p, pObj, i )
- pObj->pData = Aig_ObjCreatePi( pNew );
+ {
+ pObj->pHaig = NULL;
+ if ( Aig_ObjRefs(pObj) == 0 )
+ pObj->pData = Aig_ObjCreatePi( pNew );
+ }
// add logic for the POs
+ pProgress = Bar_ProgressStart( stdout, Aig_ManPoNum(p) );
Aig_ManForEachPo( p, pObj, i )
{
+ Bar_ProgressUpdate( pProgress, i, "Miter..." );
Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj) );
Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
}
- Aig_ManCleanup( pNew );
+ Bar_ProgressStop( pProgress );
Aig_ManSetRegNum( pNew, 0 );
- assert( Aig_ManBufNum(p) != 0 || Aig_ManNodeNum(p) == Aig_ManNodeNum(pNew) );
- // check the resulting network
-// if ( !Aig_ManCheck(pNew) )
-// printf( "Cec_DeriveMiter(): The check has failed.\n" );
+ assert( Aig_ManHasNoGaps(pNew) );
return pNew;
}
diff --git a/src/aig/cec2/cecClass.c b/src/aig/cec2/cecClass.c
new file mode 100644
index 00000000..24e40281
--- /dev/null
+++ b/src/aig/cec2/cecClass.c
@@ -0,0 +1,571 @@
+/**CFile****************************************************************
+
+ FileName [cecClass.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis [Equivalence class representation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cecClass.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p, int nLevels )
+{
+ Aig_Man_t * pAig;
+ Aig_Obj_t ** pCopy;
+ Aig_Obj_t * pRes0, * pRes1, * pRepr, * pNode;
+ Aig_Obj_t * pMiter;
+ int i;
+ pAig = Aig_ManStart( p->nNodes );
+ pCopy = ABC_ALLOC( Aig_Obj_t *, p->nObjs );
+ pCopy[0] = Aig_ManConst1(pAig);
+ for ( i = 1; i < p->nObjs; i++ )
+ {
+ if ( p->pFans0[i] == -1 ) // pi always has zero first fanin
+ {
+ pCopy[i] = Aig_ObjCreatePi( pAig );
+ continue;
+ }
+ if ( p->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin
+ continue;
+ pRes0 = Aig_NotCond( pCopy[Cec_Lit2Var(p->pFans0[i])], Cec_LitIsCompl(p->pFans0[i]) );
+ pRes1 = Aig_NotCond( pCopy[Cec_Lit2Var(p->pFans1[i])], Cec_LitIsCompl(p->pFans1[i]) );
+ pNode = pCopy[i] = Aig_And( pAig, pRes0, pRes1 );
+ if ( p->pReprs[i] < 0 )
+ continue;
+ assert( p->pReprs[i] < i );
+ pRepr = pCopy[p->pReprs[i]];
+ if ( Aig_Regular(pNode) == Aig_Regular(pRepr) )
+ continue;
+ pCopy[i] = Aig_NotCond( pRepr, Aig_ObjPhaseReal(pRepr) ^ Aig_ObjPhaseReal(pNode) );
+ if ( nLevels && ((int)Aig_Regular(pRepr)->Level > nLevels || (int)Aig_Regular(pNode)->Level > nLevels) )
+ continue;
+ pMiter = Aig_Exor( pAig, pNode, pRepr );
+ Aig_ObjCreatePo( pAig, Aig_NotCond(pMiter, Aig_ObjPhaseReal(pMiter)) );
+// Aig_ObjCreatePo( pAig, Aig_Regular(pRepr) );
+// Aig_ObjCreatePo( pAig, Aig_Regular(pCopy[i]) );
+ }
+ ABC_FREE( pCopy );
+ Aig_ManSetRegNum( pAig, 0 );
+ Aig_ManCleanup( pAig );
+ return pAig;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Caig_ManCountOne( Caig_Man_t * p, int i )
+{
+ int Ent, nLits = 0;
+ assert( p->pReprs[i] < 0 && p->pNexts[i] > 0 );
+ for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] )
+ {
+ assert( p->pReprs[Ent] == i );
+ nLits++;
+ }
+ return 1 + nLits;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Caig_ManCountLiterals( Caig_Man_t * p )
+{
+ int i, nLits = 0;
+ for ( i = 1; i < p->nObjs; i++ )
+ if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
+ nLits += Caig_ManCountOne(p, i) - 1;
+ return nLits;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManPrintOne( Caig_Man_t * p, int i, int Counter )
+{
+ int Ent;
+ printf( "Class %4d : Num = %2d {", Counter, Caig_ManCountOne(p, i) );
+ for ( Ent = i; Ent; Ent = p->pNexts[Ent] )
+ printf(" %d", Ent );
+ printf( " }\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose )
+{
+ int i, Counter = 0, Counter1 = 0, CounterX = 0, nLits;
+ for ( i = 1; i < p->nObjs; i++ )
+ {
+ if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
+ Counter++;
+ if ( p->pReprs[i] == 0 )
+ Counter1++;
+ if ( p->pReprs[i] < 0 && p->pNexts[i] == 0 )
+ CounterX++;
+ }
+ nLits = Caig_ManCountLiterals( p );
+ printf( "Class = %6d. Const = %6d. Unsed = %6d. Lits = %7d. All = %7d. Mem = %5.2f Mb\n",
+ Counter, Counter1, CounterX, nLits, nLits+Counter1, 1.0*p->nMemsMax/(1<<20) );
+ if ( fVerbose )
+ for ( i = 1; i < p->nObjs; i++ )
+ if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
+ Caig_ManPrintOne( p, i, ++Counter );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManCollectSimsSimple( Caig_Man_t * p, int i )
+{
+ int Ent;
+ Vec_PtrClear( p->vSims );
+ for ( Ent = i; Ent; Ent = p->pNexts[Ent] )
+ Vec_PtrPush( p->vSims, p->pSims + Ent );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i )
+{
+ unsigned * pSim;
+ int Ent;
+ Vec_PtrClear( p->vSims );
+ for ( Ent = i; Ent; Ent = p->pNexts[Ent] )
+ {
+ pSim = Caig_ManSimDeref( p, Ent );
+ Vec_PtrPush( p->vSims, pSim + 1 );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords )
+{
+ int w;
+ if ( (p0[0] & 1) == (p1[0] & 1) )
+ {
+ for ( w = 0; w < nWords; w++ )
+ if ( p0[w] != p1[w] )
+ return 0;
+ return 1;
+ }
+ else
+ {
+ for ( w = 0; w < nWords; w++ )
+ if ( p0[w] != ~p1[w] )
+ return 0;
+ return 1;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Caig_ManCompareConst( unsigned * p, int nWords )
+{
+ int w;
+ if ( p[0] & 1 )
+ {
+ for ( w = 0; w < nWords; w++ )
+ if ( p[w] != ~0 )
+ return 0;
+ return 1;
+ }
+ else
+ {
+ for ( w = 0; w < nWords; w++ )
+ if ( p[w] != 0 )
+ return 0;
+ return 1;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManClassCreate( Caig_Man_t * p, Vec_Int_t * vClass )
+{
+ int * pNext, Repr, Ent, i;
+ assert( Vec_IntSize(vClass) > 0 );
+ Vec_IntForEachEntry( vClass, Ent, i )
+ {
+ if ( i == 0 )
+ {
+ Repr = Ent;
+ p->pReprs[Ent] = -1;
+ pNext = p->pNexts + Ent;
+ }
+ else
+ {
+ p->pReprs[Ent] = Repr;
+ *pNext = Ent;
+ pNext = p->pNexts + Ent;
+ }
+ }
+ *pNext = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims )
+{
+ unsigned * pSim0, * pSim1;
+ int Ent, c = 0, d = 0;
+ Vec_IntClear( p->vClassOld );
+ Vec_IntClear( p->vClassNew );
+ pSim0 = Vec_PtrEntry( vSims, c++ );
+ Vec_IntPush( p->vClassOld, i );
+ for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] )
+ {
+ pSim1 = Vec_PtrEntry( vSims, c++ );
+ if ( Caig_ManCompareEqual( pSim0, pSim1, p->nWords ) )
+ Vec_IntPush( p->vClassOld, Ent );
+ else
+ {
+ Vec_IntPush( p->vClassNew, Ent );
+ Vec_PtrWriteEntry( vSims, d++, pSim1 );
+ }
+ }
+//if ( Vec_PtrSize(vSims) > 100 )
+//printf( "%d -> %d %d \n", Vec_PtrSize(vSims), Vec_IntSize(p->vClassOld), Vec_IntSize(p->vClassNew) );
+ Vec_PtrShrink( vSims, d );
+ if ( Vec_IntSize(p->vClassNew) == 0 )
+ return 0;
+ Caig_ManClassCreate( p, p->vClassOld );
+ Caig_ManClassCreate( p, p->vClassNew );
+ if ( Vec_IntSize(p->vClassNew) > 1 )
+ return 1 + Caig_ManClassRefineOne( p, Vec_IntEntry(p->vClassNew,0), vSims );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Caig_ManHashKey( unsigned * pSim, int nWords, int nTableSize )
+{
+ static int s_Primes[16] = {
+ 1291, 1699, 1999, 2357, 2953, 3313, 3907, 4177,
+ 4831, 5147, 5647, 6343, 6899, 7103, 7873, 8147 };
+ unsigned uHash = 0;
+ int i;
+ if ( pSim[0] & 1 )
+ for ( i = 0; i < nWords; i++ )
+ uHash ^= ~pSim[i] * s_Primes[i & 0xf];
+ else
+ for ( i = 0; i < nWords; i++ )
+ uHash ^= pSim[i] * s_Primes[i & 0xf];
+ return (int)(uHash % nTableSize);
+
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManClassesCreate( Caig_Man_t * p )
+{
+ int * pTable, nTableSize, i, Key;
+ nTableSize = Aig_PrimeCudd( 100 + p->nObjs / 10 );
+ pTable = ABC_CALLOC( int, nTableSize );
+ p->pReprs = ABC_ALLOC( int, p->nObjs );
+ p->pNexts = ABC_CALLOC( int, p->nObjs );
+ for ( i = 1; i < p->nObjs; i++ )
+ {
+ if ( p->pFans0[i] > 0 && p->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin
+ continue;
+ if ( Caig_ManCompareConst( p->pSims + i, 1 ) )
+ {
+ p->pReprs[i] = 0;
+ continue;
+ }
+ Key = Caig_ManHashKey( p->pSims + i, 1, nTableSize );
+ if ( pTable[Key] == 0 )
+ p->pReprs[i] = -1;
+ else
+ {
+ p->pNexts[ pTable[Key] ] = i;
+ p->pReprs[i] = p->pReprs[ pTable[Key] ];
+ if ( p->pReprs[i] == -1 )
+ p->pReprs[i] = pTable[Key];
+ }
+ pTable[Key] = i;
+ }
+ ABC_FREE( pTable );
+Caig_ManPrintClasses( p, 0 );
+ // refine classes
+ for ( i = 1; i < p->nObjs; i++ )
+ if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 )
+ {
+ Caig_ManCollectSimsSimple( p, i );
+ Caig_ManClassRefineOne( p, i, p->vSims );
+ }
+ // clean memory
+ memset( p->pSims, 0, sizeof(unsigned) * p->nObjs );
+Caig_ManPrintClasses( p, 0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManSimulateSimple( Caig_Man_t * p )
+{
+ unsigned Res0, Res1;
+ int i;
+ for ( i = 1; i < p->nObjs; i++ )
+ {
+ if ( p->pFans0[i] == -1 ) // pi
+ {
+ p->pSims[i] = Aig_ManRandom( 0 );
+ continue;
+ }
+ if ( p->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin
+ continue;
+ Res0 = p->pSims[Cec_Lit2Var(p->pFans0[i])];
+ Res1 = p->pSims[Cec_Lit2Var(p->pFans1[i])];
+ p->pSims[i] = (Cec_LitIsCompl(p->pFans0[i]) ? ~Res0: Res0) &
+ (Cec_LitIsCompl(p->pFans1[i]) ? ~Res1: Res1);
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined )
+{
+ Vec_Int_t * vClasses;
+ int * pTable, nTableSize, i, Key, iNode;
+ unsigned * pSim;
+ if ( Vec_IntSize(vRefined) == 0 )
+ return;
+ nTableSize = Aig_PrimeCudd( 100 + Vec_IntSize(vRefined) / 5 );
+ pTable = ABC_CALLOC( int, nTableSize );
+ vClasses = Vec_IntAlloc( 100 );
+ Vec_IntForEachEntry( vRefined, iNode, i )
+ {
+ pSim = Caig_ManSimRead( p, iNode );
+ assert( !Caig_ManCompareConst( pSim + 1, p->nWords ) );
+ Key = Caig_ManHashKey( pSim + 1, p->nWords, nTableSize );
+ if ( pTable[Key] == 0 )
+ {
+ assert( p->pReprs[iNode] == 0 );
+ assert( p->pNexts[iNode] == 0 );
+ p->pReprs[iNode] = -1;
+ Vec_IntPush( vClasses, iNode );
+ }
+ else
+ {
+ p->pNexts[ pTable[Key] ] = iNode;
+ p->pReprs[iNode] = p->pReprs[ pTable[Key] ];
+ if ( p->pReprs[iNode] == -1 )
+ p->pReprs[iNode] = pTable[Key];
+ assert( p->pReprs[iNode] > 0 );
+ }
+ pTable[Key] = iNode;
+ }
+ ABC_FREE( pTable );
+ // refine classes
+ Vec_IntForEachEntry( vClasses, iNode, i )
+ {
+ if ( p->pNexts[iNode] == 0 )
+ {
+ Caig_ManSimDeref( p, iNode );
+ continue;
+ }
+ Caig_ManCollectSimsNormal( p, iNode );
+ Caig_ManClassRefineOne( p, iNode, p->vSims );
+ }
+ Vec_IntFree( vClasses );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters )
+{
+ Vec_Ptr_t * vInfo;
+ Caig_Man_t * p;
+ int i;
+ Aig_ManRandom( 1 );
+ p = Caig_ManCreate( pAig );
+ p->nWords = 1;
+ Caig_ManSimulateSimple( p );
+ Caig_ManClassesCreate( p );
+ p->nWords = nWords;
+ for ( i = 0; i < nIters; i++ )
+ {
+ p->nWords = i + 1;
+ Caig_ManSimMemRelink( p );
+ p->nMemsMax = 0;
+
+ vInfo = Vec_PtrAllocSimInfo( p->nPis, p->nWords );
+ Aig_ManRandomInfo( vInfo, 0, p->nWords );
+ Caig_ManSimulateRound( p, vInfo, NULL );
+ Vec_PtrFree( vInfo );
+Caig_ManPrintClasses( p, 0 );
+ }
+
+ p->nWords = nWords;
+ Caig_ManSimMemRelink( p );
+ p->nMemsMax = 0;
+ return p;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/cec/cecCnf.c b/src/aig/cec2/cecCnf.c
index 8b8c011d..706b15e0 100644
--- a/src/aig/cec/cecCnf.c
+++ b/src/aig/cec2/cecCnf.c
@@ -166,7 +166,7 @@ void Cec_AddClausesSuper( Cec_ManSat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSupe
assert( Aig_ObjIsNode( pNode ) );
// create storage for literals
nLits = Vec_PtrSize(vSuper) + 1;
- pLits = ALLOC( int, nLits );
+ pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
Vec_PtrForEachEntry( vSuper, pFanin, i )
@@ -197,7 +197,7 @@ void Cec_AddClausesSuper( Cec_ManSat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSupe
}
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
assert( RetValue );
- free( pLits );
+ ABC_FREE( pLits );
}
/**Function*************************************************************
diff --git a/src/aig/cec2/cecCore.c b/src/aig/cec2/cecCore.c
new file mode 100644
index 00000000..540a3951
--- /dev/null
+++ b/src/aig/cec2/cecCore.c
@@ -0,0 +1,245 @@
+/**CFile****************************************************************
+
+ FileName [cecCore.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis [Core procedures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cecCore.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p )
+{
+ memset( p, 0, sizeof(Cec_ParSat_t) );
+ p->nBTLimit = 10; // conflict limit at a node
+ p->nSatVarMax = 2000; // the max number of SAT variables
+ p->nCallsRecycle = 100; // calls to perform before recycling SAT solver
+ p->fFirstStop = 0; // stop on the first sat output
+ p->fPolarFlip = 0; // uses polarity adjustment
+ p->fVerbose = 0; // verbose stats
+}
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p )
+{
+ memset( p, 0, sizeof(Cec_ParCsw_t) );
+ p->nWords = 10; // the number of simulation words
+ p->nRounds = 10; // the number of simulation rounds
+ p->nBTLimit = 10; // conflict limit at a node
+ p->nSatVarMax = 2000; // the max number of SAT variables
+ p->nCallsRecycle = 100; // calls to perform before recycling SAT solver
+ p->nLevelMax = 50; // restriction on the level of nodes to be swept
+ p->fRewriting = 0; // enables AIG rewriting
+ p->fFirstStop = 0; // stop on the first sat output
+ p->fVerbose = 1; // verbose stats
+}
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p )
+{
+ memset( p, 0, sizeof(Cec_ParCec_t) );
+ p->nIters = 1; // iterations of SAT solving/sweeping
+ p->nBTLimitBeg = 2; // starting backtrack limit
+ p->nBTlimitMulti = 8; // multiple of backtrack limiter
+ p->fUseSmartCnf = 0; // use smart CNF computation
+ p->fRewriting = 0; // enables AIG rewriting
+ p->fSatSweeping = 0; // enables SAT sweeping
+ p->fFirstStop = 0; // stop on the first sat output
+ p->fVerbose = 1; // verbose stats
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs equivalence checking.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_Sweep( Aig_Man_t * pAig, int nBTLimit )
+{
+ extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
+// Cec_MtrStatus_t Status;
+ Cec_ParCsw_t ParsCsw, * pParsCsw = &ParsCsw;
+ Cec_ParSat_t ParsSat, * pParsSat = &ParsSat;
+ Caig_Man_t * pCaig;
+ Aig_Man_t * pSRAig;
+// int clk;
+
+ Cec_ManCswSetDefaultParams( pParsCsw );
+ pParsCsw->nBTLimit = nBTLimit;
+ pCaig = Caig_ManClassesPrepare( pAig, pParsCsw->nWords, pParsCsw->nRounds );
+
+ pSRAig = Caig_ManSpecReduce( pCaig, 20 );
+ Aig_ManPrintStats( pSRAig );
+ Ioa_WriteAiger( pSRAig, "temp_srm.aig", 0, 1 );
+
+/*
+ Cec_ManSatSetDefaultParams( pParsSat );
+ pParsSat->fFirstStop = 0;
+ pParsSat->nBTLimit = pParsCsw->nBTlimit;
+clk = clock();
+ Status = Cec_SatSolveOutputs( pSRAig, pParsSat );
+ Cec_MiterStatusPrint( Status, "SRM ", clock() - clk );
+*/
+
+ Aig_ManStop( pSRAig );
+
+ Caig_ManDelete( pCaig );
+
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs equivalence checking.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * pPars )
+{
+ Cec_ParSat_t ParsSat, * pParsSat = &ParsSat;
+ Cec_ParCsw_t ParsCsw, * pParsCsw = &ParsCsw;
+ Cec_MtrStatus_t Status;
+ Caig_Man_t * pCaig;
+ Aig_Man_t * pMiter;
+ int i, clk = clock();
+ if ( pPars->fVerbose )
+ {
+ Status = Cec_MiterStatusTrivial( pAig0 );
+ Status.nNodes += pAig1? Aig_ManNodeNum( pAig1 ) : 0;
+ Cec_MiterStatusPrint( Status, "Init ", 0 );
+ }
+ // create combinational miter
+ if ( pAig1 == NULL )
+ {
+ Status = Cec_MiterStatus( pAig0 );
+ if ( Status.nSat > 0 && pPars->fFirstStop )
+ {
+ if ( pPars->fVerbose )
+ printf( "Output %d is trivially SAT.\n", Status.iOut );
+ return 0;
+ }
+ if ( Status.nUndec == 0 )
+ {
+ if ( pPars->fVerbose )
+ printf( "The miter has no undecided outputs.\n" );
+ return 1;
+ }
+ pMiter = Cec_Duplicate( pAig0 );
+ }
+ else
+ {
+ pMiter = Cec_DeriveMiter( pAig0, pAig1 );
+ Status = Cec_MiterStatus( pMiter );
+ if ( Status.nSat > 0 && pPars->fFirstStop )
+ {
+ if ( pPars->fVerbose )
+ printf( "Output %d is trivially SAT.\n", Status.iOut );
+ Aig_ManStop( pMiter );
+ return 0;
+ }
+ if ( Status.nUndec == 0 )
+ {
+ if ( pPars->fVerbose )
+ printf( "The problem is solved by structrual hashing.\n" );
+ Aig_ManStop( pMiter );
+ return 1;
+ }
+ }
+ if ( pPars->fVerbose )
+ Cec_MiterStatusPrint( Status, "Strash", clock() - clk );
+ // start parameter structures
+// Cec_ManSatSetDefaultParams( pParsSat );
+// pParsSat->fFirstStop = pPars->fFirstStop;
+// pParsSat->nBTLimit = pPars->nBTLimitBeg;
+/*
+ // try SAT solving
+ clk = clock();
+ pParsSat->nBTLimit *= pPars->nBTlimitMulti;
+ Status = Cec_SatSolveOutputs( pMiter, pParsSat );
+ if ( pPars->fVerbose )
+ Cec_MiterStatusPrint( Status, "SAT ", clock() - clk );
+ if ( Status.nSat && pParsSat->fFirstStop )
+ break;
+ if ( Status.nUndec == 0 )
+ break;
+*/
+
+ Cec_ManCswSetDefaultParams( pParsCsw );
+ pCaig = Caig_ManClassesPrepare( pMiter, pParsCsw->nWords, pParsCsw->nRounds );
+ for ( i = 0; i < pPars->nIters; i++ )
+ {
+ Cec_ManSatSweepInt( pCaig, pParsCsw );
+ i = i;
+ }
+ Caig_ManDelete( pCaig );
+ Aig_ManStop( pMiter );
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/cec2/cecInt.h b/src/aig/cec2/cecInt.h
new file mode 100644
index 00000000..ef43e44c
--- /dev/null
+++ b/src/aig/cec2/cecInt.h
@@ -0,0 +1,208 @@
+/**CFile****************************************************************
+
+ FileName [cecInt.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cecInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __CEC_INT_H__
+#define __CEC_INT_H__
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+#include "aig.h"
+#include "satSolver.h"
+#include "bar.h"
+#include "cec.h"
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Cec_ManSat_t_ Cec_ManSat_t;
+struct Cec_ManSat_t_
+{
+ // parameters
+ Cec_ParSat_t * pPars;
+ // AIGs used in the package
+ Aig_Man_t * pAig; // the AIG whose outputs are considered
+ Vec_Int_t * vStatus; // status for each output
+ // SAT solving
+ sat_solver * pSat; // recyclable SAT solver
+ int nSatVars; // the counter of SAT variables
+ int * pSatVars; // mapping of each node into its SAT var
+ Vec_Ptr_t * vUsedNodes; // nodes whose SAT vars are assigned
+ int nRecycles; // the number of times SAT solver was recycled
+ int nCallsSince; // the number of calls since the last recycle
+ Vec_Ptr_t * vFanins; // fanins of the CNF node
+ // SAT calls statistics
+ int nSatUnsat; // the number of proofs
+ int nSatSat; // the number of failure
+ int nSatUndec; // the number of timeouts
+ // runtime stats
+ int timeSatUnsat; // unsat
+ int timeSatSat; // sat
+ int timeSatUndec; // undecided
+ int timeTotal; // total runtime
+};
+
+typedef struct Cec_ManCec_t_ Cec_ManCec_t;
+struct Cec_ManCec_t_
+{
+ // parameters
+ Cec_ParCec_t * pPars;
+ // AIGs used in the package
+ Aig_Man_t * pAig; // the miter for equivalence checking
+ // mapping of PI/PO nodes
+
+ // counter-example
+ int * pCex; // counter-example
+ int iOutput; // the output for this counter-example
+
+ // statistics
+
+};
+
+typedef struct Cec_MtrStatus_t_ Cec_MtrStatus_t;
+struct Cec_MtrStatus_t_
+{
+ int nInputs; // the total number of inputs
+ int nNodes; // the total number of nodes
+ int nOutputs; // the total number of outputs
+ int nUnsat; // the number of UNSAT outputs
+ int nSat; // the number of SAT outputs
+ int nUndec; // the number of undecided outputs
+ int iOut; // the satisfied output
+};
+
+// combinational simulation manager
+typedef struct Caig_Man_t_ Caig_Man_t;
+struct Caig_Man_t_
+{
+ // parameters
+ Aig_Man_t * pAig; // the AIG to be used for simulation
+ int nWords; // the number of simulation words
+ // AIG representation
+ int nPis; // the number of primary inputs
+ int nPos; // the number of primary outputs
+ int nNodes; // the number of internal nodes
+ int nObjs; // nPis + nNodes + nPos + 1
+ int * pFans0; // fanin0 for all objects
+ int * pFans1; // fanin1 for all objects
+ // simulation info
+ int * pRefs; // reference counter for each node
+ unsigned * pSims; // simlulation information for each node
+ // recycable memory
+ unsigned * pMems; // allocated simulaton memory
+ int nWordsAlloc; // the number of allocated entries
+ int nMems; // the number of used entries
+ int nMemsMax; // the max number of used entries
+ int MemFree; // next ABC_FREE entry
+ // equivalence class representation
+ int * pReprs; // representatives of each node
+ int * pNexts; // nexts for each node
+ // temporaries
+ Vec_Ptr_t * vSims; // pointers to sim info
+ Vec_Int_t * vClassOld; // old class numbers
+ Vec_Int_t * vClassNew; // new class numbers
+ Vec_Int_t * vRefinedC; // refined const reprs
+};
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline int Cec_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
+static inline int Cec_Lit2Var( int Lit ) { return Lit >> 1; }
+static inline int Cec_LitIsCompl( int Lit ) { return Lit & 1; }
+static inline int Cec_LitNot( int Lit ) { return Lit ^ 1; }
+static inline int Cec_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); }
+static inline int Cec_LitRegular( int Lit ) { return Lit & ~01; }
+
+static inline int Cec_ObjSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj ) { return p->pSatVars[pObj->Id]; }
+static inline void Cec_ObjSetSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj, int Num ) { p->pSatVars[pObj->Id] = Num; }
+
+static inline Aig_Obj_t * Cec_ObjFraig( Aig_Obj_t * pObj ) { return pObj->pData; }
+static inline void Cec_ObjSetFraig( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { pObj->pData = pNode; }
+
+static inline int Cec_ObjIsConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj )
+{
+ return Aig_ObjRepr(pAig, pObj) == Aig_ManConst1(pAig);
+}
+static inline void Cec_ObjSetConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj )
+{
+ assert( !Cec_ObjIsConst1Cand( pAig, pObj ) );
+ Aig_ObjSetRepr( pAig, pObj, Aig_ManConst1(pAig) );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== cecAig.c ==========================================================*/
+extern Aig_Man_t * Cec_Duplicate( Aig_Man_t * p );
+extern Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 );
+/*=== cecClass.c ==========================================================*/
+extern Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p, int nLevels );
+extern int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords );
+extern int Caig_ManCompareConst( unsigned * p, int nWords );
+extern void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i );
+extern int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims );
+extern void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined );
+extern void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose );
+extern Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters );
+/*=== cecCnf.c ==========================================================*/
+extern void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Aig_Obj_t * pObj );
+/*=== cecSat.c ==========================================================*/
+extern Cec_MtrStatus_t Cec_SatSolveOutputs( Aig_Man_t * pAig, Cec_ParSat_t * pPars );
+/*=== cecSim.c ==========================================================*/
+extern Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig );
+extern void Caig_ManDelete( Caig_Man_t * p );
+extern void Caig_ManSimMemRelink( Caig_Man_t * p );
+extern unsigned * Caig_ManSimRead( Caig_Man_t * p, int i );
+extern unsigned * Caig_ManSimRef( Caig_Man_t * p, int i );
+extern unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i );
+extern void Caig_ManSimulateRound( Caig_Man_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * vInfoCos );
+extern int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose );
+/*=== cecStatus.c ==========================================================*/
+extern int Cec_OutputStatus( Aig_Man_t * p, Aig_Obj_t * pObj );
+extern Cec_MtrStatus_t Cec_MiterStatus( Aig_Man_t * p );
+extern Cec_MtrStatus_t Cec_MiterStatusTrivial( Aig_Man_t * p );
+extern void Cec_MiterStatusPrint( Cec_MtrStatus_t S, char * pString, int Time );
+/*=== cecSweep.c ==========================================================*/
+extern void Cec_ManSatSweepInt( Caig_Man_t * pMan, Cec_ParCsw_t * pPars );
+extern Aig_Man_t * Cec_ManSatSweep( Aig_Man_t * pAig, Cec_ParCsw_t * pPars );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/cec2/cecMan.c b/src/aig/cec2/cecMan.c
new file mode 100644
index 00000000..86415c53
--- /dev/null
+++ b/src/aig/cec2/cecMan.c
@@ -0,0 +1,59 @@
+/**CFile****************************************************************
+
+ FileName [cecMan.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis [Manager pcocures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cecMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/cec/cecSat.c b/src/aig/cec2/cecSat.c
index 9cf13ebc..a999dd97 100644
--- a/src/aig/cec/cecSat.c
+++ b/src/aig/cec2/cecSat.c
@@ -43,13 +43,13 @@ Cec_ManSat_t * Cec_ManCreate( Aig_Man_t * pAig, Cec_ParSat_t * pPars )
{
Cec_ManSat_t * p;
// create interpolation manager
- p = ALLOC( Cec_ManSat_t, 1 );
+ p = ABC_ALLOC( Cec_ManSat_t, 1 );
memset( p, 0, sizeof(Cec_ManSat_t) );
p->pPars = pPars;
p->pAig = pAig;
// SAT solving
p->nSatVars = 1;
- p->pSatVars = CALLOC( int, Aig_ManObjNumMax(pAig) );
+ p->pSatVars = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) );
p->vUsedNodes = Vec_PtrAlloc( 1000 );
p->vFanins = Vec_PtrAlloc( 100 );
return p;
@@ -72,8 +72,8 @@ void Cec_ManStop( Cec_ManSat_t * p )
sat_solver_delete( p->pSat );
Vec_PtrFree( p->vUsedNodes );
Vec_PtrFree( p->vFanins );
- FREE( p->pSatVars );
- free( p );
+ ABC_FREE( p->pSatVars );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -165,7 +165,7 @@ int Cec_ManSatCheckNode( Cec_ManSat_t * p, Aig_Obj_t * pNode )
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
clk = clock();
RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1,
- (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue == l_False )
{
p->timeSatUnsat += clock() - clk;
diff --git a/src/aig/cec2/cecSat2.c b/src/aig/cec2/cecSat2.c
new file mode 100644
index 00000000..4f009b25
--- /dev/null
+++ b/src/aig/cec2/cecSat2.c
@@ -0,0 +1,284 @@
+/**CFile****************************************************************
+
+ FileName [cecSat.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinational equivalence checking.]
+
+ Synopsis [Backend calling the SAT solver.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 30, 2007.]
+
+ Revision [$Id: cecSat.c,v 1.00 2007/06/30 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "aig.h"
+#include "cnf.h"
+#include "../../sat/lsat/solver.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Writes CNF into a file.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+solver * Cnf_WriteIntoSolverNew( Cnf_Dat_t * p )
+{
+ solver * pSat;
+ int i, status;
+ pSat = solver_new();
+ for ( i = 0; i < p->nVars; i++ )
+ solver_newVar( pSat );
+ for ( i = 0; i < p->nClauses; i++ )
+ {
+ if ( !solver_addClause( pSat, p->pClauses[i+1]-p->pClauses[i], p->pClauses[i] ) )
+ {
+ solver_delete( pSat );
+ return NULL;
+ }
+ }
+ status = solver_simplify(pSat);
+ if ( status == 0 )
+ {
+ solver_delete( pSat );
+ return NULL;
+ }
+ return pSat;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds the OR-clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cnf_DataWriteAndClausesNew( void * p, Cnf_Dat_t * pCnf )
+{
+/*
+ sat_solver * pSat = p;
+ Aig_Obj_t * pObj;
+ int i, Lit;
+ Aig_ManForEachPo( pCnf->pMan, pObj, i )
+ {
+ Lit = toLitCond( pCnf->pVarNums[pObj->Id], 0 );
+ if ( !sat_solver_addclause( pSat, &Lit, &Lit+1 ) )
+ return 0;
+ }
+*/
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds the OR-clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cnf_DataWriteOrClauseNew( solver * pSat, Cnf_Dat_t * pCnf )
+{
+ Aig_Obj_t * pObj;
+ int i, * pLits;
+ pLits = ALLOC( int, Aig_ManPoNum(pCnf->pMan) );
+ Aig_ManForEachPo( pCnf->pMan, pObj, i )
+ pLits[i] = solver_mkLit_args( pCnf->pVarNums[pObj->Id], 0 );
+ if ( !solver_addClause( pSat, Aig_ManPoNum(pCnf->pMan), pLits ) )
+ {
+ free( pLits );
+ return 0;
+ }
+ free( pLits );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the given clause in a file in DIMACS format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Sat_SolverPrintStatsNew( FILE * pFile, solver * pSat )
+{
+// printf( "starts : %8d\n", solver_num_assigns(pSat) );
+ printf( "vars : %8d\n", solver_num_vars(pSat) );
+ printf( "clauses : %8d\n", solver_num_clauses(pSat) );
+ printf( "conflicts : %8d\n", solver_num_learnts(pSat) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns a counter-example.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Sat_SolverGetModelNew( solver * pSat, int * pVars, int nVars )
+{
+ int * pModel;
+ int i;
+ pModel = ALLOC( int, nVars+1 );
+ for ( i = 0; i < nVars; i++ )
+ {
+ assert( pVars[i] >= 0 && pVars[i] < solver_num_vars(pSat) );
+ pModel[i] = (int)(solver_modelValue_Var( pSat, pVars[i] ) == solver_l_True);
+ }
+ return pModel;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_RunSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFlipBits, int fAndOuts, int fVerbose )
+{
+ solver * pSat;
+ Cnf_Dat_t * pCnf;
+ int status, RetValue, clk = clock();
+ Vec_Int_t * vCiIds;
+
+ assert( Aig_ManRegNum(pMan) == 0 );
+ pMan->pData = NULL;
+
+ // derive CNF
+ pCnf = Cnf_Derive( pMan, Aig_ManPoNum(pMan) );
+// pCnf = Cnf_DeriveSimple( pMan, Aig_ManPoNum(pMan) );
+
+ // convert into SAT solver
+ pSat = Cnf_WriteIntoSolverNew( pCnf );
+ if ( pSat == NULL )
+ {
+ Cnf_DataFree( pCnf );
+ return 1;
+ }
+
+
+ if ( fAndOuts )
+ {
+ assert( 0 );
+ // assert each output independently
+ if ( !Cnf_DataWriteAndClausesNew( pSat, pCnf ) )
+ {
+ solver_delete( pSat );
+ Cnf_DataFree( pCnf );
+ return 1;
+ }
+ }
+ else
+ {
+ // add the OR clause for the outputs
+ if ( !Cnf_DataWriteOrClauseNew( pSat, pCnf ) )
+ {
+ solver_delete( pSat );
+ Cnf_DataFree( pCnf );
+ return 1;
+ }
+ }
+ vCiIds = Cnf_DataCollectPiSatNums( pCnf, pMan );
+ Cnf_DataFree( pCnf );
+
+
+// printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
+// PRT( "Time", clock() - clk );
+
+ // simplify the problem
+ clk = clock();
+ status = solver_simplify(pSat);
+// printf( "Simplified the problem to %d variables and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
+// PRT( "Time", clock() - clk );
+ if ( status == 0 )
+ {
+ Vec_IntFree( vCiIds );
+ solver_delete( pSat );
+// printf( "The problem is UNSATISFIABLE after simplification.\n" );
+ return 1;
+ }
+
+ // solve the miter
+ clk = clock();
+ if ( fVerbose )
+ solver_set_verbosity( pSat, 1 );
+ status = solver_solve( pSat, 0, NULL );
+ if ( status == solver_l_Undef )
+ {
+// printf( "The problem timed out.\n" );
+ RetValue = -1;
+ }
+ else if ( status == solver_l_True )
+ {
+// printf( "The problem is SATISFIABLE.\n" );
+ RetValue = 0;
+ }
+ else if ( status == solver_l_False )
+ {
+// printf( "The problem is UNSATISFIABLE.\n" );
+ RetValue = 1;
+ }
+ else
+ assert( 0 );
+// PRT( "SAT sat_solver time", clock() - clk );
+// printf( "The number of conflicts = %d.\n", (int)pSat->sat_solver_stats.conflicts );
+
+ // if the problem is SAT, get the counterexample
+ if ( status == solver_l_True )
+ {
+ pMan->pData = Sat_SolverGetModelNew( pSat, vCiIds->pArray, vCiIds->nSize );
+ }
+ // free the sat_solver
+ if ( fVerbose )
+ Sat_SolverPrintStatsNew( stdout, pSat );
+//sat_solver_store_write( pSat, "trace.cnf" );
+//sat_solver_store_free( pSat );
+ solver_delete( pSat );
+ Vec_IntFree( vCiIds );
+ return RetValue;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/cec/cecSim.c b/src/aig/cec2/cecSim.c
index 8a5f3cd5..4fedbddc 100644
--- a/src/aig/cec/cecSim.c
+++ b/src/aig/cec2/cecSim.c
@@ -30,53 +30,7 @@
/**Function*************************************************************
- Synopsis [Count PIs with fanout.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Caig_ManCountRelevantPis( Aig_Man_t * pAig )
-{
- Aig_Obj_t * pObj;
- int i, Counter = 0;
- Aig_ManForEachPi( pAig, pObj, i )
- if ( Aig_ObjRefs(pObj) )
- Counter++;
- else
- pObj->iData = -1;
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Count PIs with fanout.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Caig_ManCountRelevantPos( Aig_Man_t * pAig )
-{
- Aig_Obj_t * pObj;
- int i, Counter = 0;
- Aig_ManForEachPo( pAig, pObj, i )
- if ( !Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
- Counter++;
- else
- pObj->iData = -1;
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Find the PO corresponding to the PO driver.]
+ Synopsis [Creates fast simulation manager.]
Description []
@@ -85,54 +39,51 @@ int Caig_ManCountRelevantPos( Aig_Man_t * pAig )
SeeAlso []
***********************************************************************/
-int Caig_ManFindPo( Aig_Man_t * pAig, int iNode )
+Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig )
{
+ Caig_Man_t * p;
Aig_Obj_t * pObj;
int i;
- Aig_ManForEachPo( pAig, pObj, i )
- if ( pObj->iData == iNode )
- return i;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates fast simulation manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Caig_ManCreate_rec( Caig_Man_t * p, Aig_Obj_t * pObj )
-{
- int iFan0, iFan1;
- assert( !Aig_IsComplement(pObj) );
- assert( !Aig_ObjIsConst1(pObj) );
- if ( pObj->iData )
- return pObj->iData;
- if ( Aig_ObjIsNode(pObj) )
- {
- iFan0 = Caig_ManCreate_rec( p, Aig_ObjFanin0(pObj) );
- iFan0 = (iFan0 << 1) | Aig_ObjFaninC0(pObj);
- iFan1 = Caig_ManCreate_rec( p, Aig_ObjFanin1(pObj) );
- iFan1 = (iFan1 << 1) | Aig_ObjFaninC1(pObj);
- }
- else if ( Aig_ObjIsPo(pObj) )
+ assert( Aig_ManHasNoGaps(pAig) );
+ Aig_ManCleanData( pAig );
+ p = (Caig_Man_t *)ABC_ALLOC( Caig_Man_t, 1 );
+ memset( p, 0, sizeof(Caig_Man_t) );
+ p->pAig = pAig;
+ p->nPis = Aig_ManPiNum(pAig);
+ p->nPos = Aig_ManPoNum(pAig);
+ p->nNodes = Aig_ManNodeNum(pAig);
+ p->nObjs = p->nPis + p->nPos + p->nNodes + 1;
+ p->pFans0 = ABC_ALLOC( int, p->nObjs );
+ p->pFans1 = ABC_ALLOC( int, p->nObjs );
+ p->pRefs = ABC_ALLOC( int, p->nObjs );
+ p->pSims = ABC_CALLOC( unsigned, p->nObjs );
+ // add objects
+ Aig_ManForEachObj( pAig, pObj, i )
{
- iFan0 = Caig_ManCreate_rec( p, Aig_ObjFanin0(pObj) );
- iFan0 = (iFan0 << 1) | Aig_ObjFaninC0(pObj);
- iFan1 = 0;
+ p->pRefs[i] = Aig_ObjRefs(pObj);
+ if ( Aig_ObjIsNode(pObj) )
+ {
+ p->pFans0[i] = (Aig_ObjFaninId0(pObj) << 1) | Aig_ObjFaninC0(pObj);
+ p->pFans1[i] = (Aig_ObjFaninId1(pObj) << 1) | Aig_ObjFaninC1(pObj);
+ }
+ else if ( Aig_ObjIsPo(pObj) )
+ {
+ p->pFans0[i] = (Aig_ObjFaninId0(pObj) << 1) | Aig_ObjFaninC0(pObj);
+ p->pFans1[i] = -1;
+ }
+ else
+ {
+ assert( Aig_ObjIsPi(pObj) || Aig_ObjIsConst1(pObj) );
+ p->pFans0[i] = -1;
+ p->pFans1[i] = -1;
+ }
}
- else
- iFan0 = iFan1 = 0;
- assert( Aig_ObjRefs(pObj) < (1<<16) );
- p->pFans0[p->nObjs] = iFan0;
- p->pFans1[p->nObjs] = iFan1;
- p->pRefs[p->nObjs] = (unsigned short)Aig_ObjRefs(pObj);
- return pObj->iData = p->nObjs++;
+ // temporaries
+ p->vClassOld = Vec_IntAlloc( 1000 );
+ p->vClassNew = Vec_IntAlloc( 1000 );
+ p->vRefinedC = Vec_IntAlloc( 10000 );
+ p->vSims = Vec_PtrAlloc( 1000 );
+ return p;
}
/**Function*************************************************************
@@ -146,35 +97,25 @@ int Caig_ManCreate_rec( Caig_Man_t * p, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig )
+void Caig_ManDelete( Caig_Man_t * p )
{
- Caig_Man_t * p;
- Aig_Obj_t * pObj;
- int i, nObjs;
- Aig_ManCleanData( pAig );
- p = (Caig_Man_t *)ALLOC( Caig_Man_t, 1 );
- memset( p, 0, sizeof(Caig_Man_t) );
- p->pAig = pAig;
- p->nPis = Caig_ManCountRelevantPis(pAig);
- p->nPos = Caig_ManCountRelevantPos(pAig);
- p->nNodes = Aig_ManNodeNum(pAig);
- nObjs = p->nPis + p->nPos + p->nNodes + 1;
- p->pFans0 = ALLOC( int, nObjs );
- p->pFans1 = ALLOC( int, nObjs );
- p->pRefs = ALLOC( unsigned short, nObjs );
- p->pSims = CALLOC( unsigned, nObjs );
- // add objects
- p->nObjs = 1;
- Aig_ManForEachPo( pAig, pObj, i )
- if ( !Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
- Caig_ManCreate_rec( p, pObj );
- assert( p->nObjs == nObjs );
- return p;
+ Vec_IntFree( p->vClassOld );
+ Vec_IntFree( p->vClassNew );
+ Vec_IntFree( p->vRefinedC );
+ Vec_PtrFree( p->vSims );
+ ABC_FREE( p->pFans0 );
+ ABC_FREE( p->pFans1 );
+ ABC_FREE( p->pRefs );
+ ABC_FREE( p->pSims );
+ ABC_FREE( p->pMems );
+ ABC_FREE( p->pReprs );
+ ABC_FREE( p->pNexts );
+ ABC_FREE( p );
}
/**Function*************************************************************
- Synopsis [Creates fast simulation manager.]
+ Synopsis [References simulation info.]
Description []
@@ -183,19 +124,18 @@ Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig )
SeeAlso []
***********************************************************************/
-void Caig_ManDelete( Caig_Man_t * p )
+void Caig_ManSimMemRelink( Caig_Man_t * p )
{
- if ( p->vSims ) Vec_PtrFree( p->vSims );
- if ( p->vClassOld ) Vec_IntFree( p->vClassOld );
- if ( p->vClassNew ) Vec_IntFree( p->vClassNew );
- FREE( p->pFans0 );
- FREE( p->pFans1 );
- FREE( p->pRefs );
- FREE( p->pSims );
- FREE( p->pMems );
- FREE( p->pReprs );
- FREE( p->pNexts );
- FREE( p );
+ int * pPlace, Ent;
+ pPlace = &p->MemFree;
+ for ( Ent = p->nMems * (p->nWords + 1);
+ Ent + p->nWords + 1 < p->nWordsAlloc;
+ Ent += p->nWords + 1 )
+ {
+ *pPlace = Ent;
+ pPlace = p->pMems + Ent;
+ }
+ *pPlace = 0;
}
/**Function*************************************************************
@@ -229,11 +169,9 @@ unsigned * Caig_ManSimRead( Caig_Man_t * p, int i )
unsigned * Caig_ManSimRef( Caig_Man_t * p, int i )
{
unsigned * pSim;
- assert( i );
assert( p->pSims[i] == 0 );
if ( p->MemFree == 0 )
{
- int * pPlace, Ent;
if ( p->nWordsAlloc == 0 )
{
assert( p->pMems == NULL );
@@ -241,16 +179,8 @@ unsigned * Caig_ManSimRef( Caig_Man_t * p, int i )
p->nMems = 1;
}
p->nWordsAlloc *= 2;
- p->pMems = REALLOC( unsigned, p->pMems, p->nWordsAlloc );
- pPlace = &p->MemFree;
- for ( Ent = p->nMems * (p->nWords + 1);
- Ent + p->nWords + 1 < p->nWordsAlloc;
- Ent += p->nWords + 1 )
- {
- *pPlace = Ent;
- pPlace = p->pMems + Ent;
- }
- *pPlace = 0;
+ p->pMems = ABC_REALLOC( unsigned, p->pMems, p->nWordsAlloc );
+ Caig_ManSimMemRelink( p );
}
p->pSims[i] = p->MemFree;
pSim = p->pMems + p->MemFree;
@@ -276,7 +206,6 @@ unsigned * Caig_ManSimRef( Caig_Man_t * p, int i )
unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i )
{
unsigned * pSim;
- assert( i );
assert( p->pSims[i] > 0 );
pSim = p->pMems + p->pSims[i];
if ( --pSim[0] == 0 )
@@ -300,71 +229,94 @@ unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i )
SeeAlso []
***********************************************************************/
-int Caig_ManSimulateRound( Caig_Man_t * p, int fMiter )
+void Caig_ManSimulateRound( Caig_Man_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * vInfoCos )
{
- Vec_Int_t * vRefined = NULL;
unsigned * pRes0, * pRes1, * pRes;
- int i, w, iFan0, iFan1;
- if ( p->pReprs )
- vRefined = Vec_IntAlloc( 1000 );
+ int i, w, iCiId = 0, iCoId = 0;
+ int nWords = Vec_PtrReadWordsSimInfo( vInfoCis );
+ assert( vInfoCos == NULL || nWords == Vec_PtrReadWordsSimInfo(vInfoCos) );
+ Vec_IntClear( p->vRefinedC );
+ if ( p->pRefs[0] )
+ {
+ pRes = Caig_ManSimRef( p, 0 );
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w] = ~0;
+ }
for ( i = 1; i < p->nObjs; i++ )
{
- if ( p->pFans0[i] == 0 ) // pi always has zero first fanin
+ if ( p->pFans0[i] == -1 ) // ci always has zero first fanin
{
+ if ( p->pRefs[i] == 0 )
+ {
+ iCiId++;
+ continue;
+ }
pRes = Caig_ManSimRef( p, i );
- for ( w = 1; w <= p->nWords; w++ )
- pRes[w] = Aig_ManRandom( 0 );
+ pRes0 = Vec_PtrEntry( vInfoCis, iCiId++ );
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w] = pRes0[w-1];
goto references;
}
- if ( p->pFans1[i] == 0 ) // po always has non-zero 1st fanin and zero 2nd fanin
+ if ( p->pFans1[i] == -1 ) // co always has non-zero 1st fanin and zero 2nd fanin
{
- if ( fMiter )
+ pRes0 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans0[i]) );
+ if ( vInfoCos )
{
- unsigned Const = Cec_LitIsCompl(p->pFans0[i])? ~0 : 0;
- pRes0 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans0[i]) );
- for ( w = 1; w <= p->nWords; w++ )
- if ( pRes0[w] != Const )
- return i;
+ pRes = Vec_PtrEntry( vInfoCos, iCoId++ );
+ if ( Cec_LitIsCompl(p->pFans0[i]) )
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w-1] = ~pRes0[w];
+ else
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w-1] = pRes0[w];
}
continue;
}
- pRes = Caig_ManSimRef( p, i );
- iFan0 = p->pFans0[i];
- iFan1 = p->pFans1[i];
+ assert( p->pRefs[i] );
+ pRes = Caig_ManSimRef( p, i );
pRes0 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans0[i]) );
pRes1 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans1[i]) );
- if ( Cec_LitIsCompl(iFan0) && Cec_LitIsCompl(iFan1) )
- for ( w = 1; w <= p->nWords; w++ )
- pRes[w] = ~(pRes0[w] | pRes1[w]);
- else if ( Cec_LitIsCompl(iFan0) && !Cec_LitIsCompl(iFan1) )
- for ( w = 1; w <= p->nWords; w++ )
- pRes[w] = ~pRes0[w] & pRes1[w];
- else if ( !Cec_LitIsCompl(iFan0) && Cec_LitIsCompl(iFan1) )
- for ( w = 1; w <= p->nWords; w++ )
- pRes[w] = pRes0[w] & ~pRes1[w];
- else if ( !Cec_LitIsCompl(iFan0) && !Cec_LitIsCompl(iFan1) )
- for ( w = 1; w <= p->nWords; w++ )
- pRes[w] = pRes0[w] & pRes1[w];
+ if ( Cec_LitIsCompl(p->pFans0[i]) )
+ {
+ if ( Cec_LitIsCompl(p->pFans1[i]) )
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w] = ~(pRes0[w] | pRes1[w]);
+ else
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w] = ~pRes0[w] & pRes1[w];
+ }
+ else
+ {
+ if ( Cec_LitIsCompl(p->pFans1[i]) )
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w] = pRes0[w] & ~pRes1[w];
+ else
+ for ( w = 1; w <= nWords; w++ )
+ pRes[w] = pRes0[w] & pRes1[w];
+ }
references:
if ( p->pReprs == NULL )
continue;
// if this node is candidate constant, collect it
- if ( p->pReprs[i] == 0 && !Caig_ManCompareConst(pRes + 1, p->nWords) )
+ if ( p->pReprs[i] == 0 && !Caig_ManCompareConst(pRes + 1, nWords) )
{
pRes[0]++;
- Vec_IntPush( vRefined, i );
+ Vec_IntPush( p->vRefinedC, i );
}
// if the node belongs to a class, save it
if ( p->pReprs[i] > 0 || p->pNexts[i] > 0 )
pRes[0]++;
// if this is the last node of the class, process it
if ( p->pReprs[i] > 0 && p->pNexts[i] == 0 )
- Caig_ManProcessClass( p, p->pReprs[i] );
+ {
+ Caig_ManCollectSimsNormal( p, p->pReprs[i] );
+ Caig_ManClassRefineOne( p, p->pReprs[i], p->vSims );
+ }
}
- if ( p->pReprs )
- Caig_ManProcessRefined( p, vRefined );
- if ( p->pReprs )
- Vec_IntFree( vRefined );
+ if ( Vec_IntSize(p->vRefinedC) > 0 )
+ Caig_ManProcessRefined( p, p->vRefinedC );
+ assert( iCiId == p->nPis );
+ assert( vInfoCos == NULL || iCoId == p->nPos );
assert( p->nMems == 1 );
/*
if ( p->nMems > 1 )
@@ -376,7 +328,28 @@ references:
}
}
*/
- return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of PO that failed.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManFindPo( Vec_Ptr_t * vInfo, int nWords )
+{
+ unsigned * pInfo;
+ int i, w;
+ Vec_PtrForEachEntry( vInfo, pInfo, i )
+ for ( w = 0; w < nWords; w++ )
+ if ( pInfo[w] != 0 )
+ return i;
+ return -1;
}
/**Function*************************************************************
@@ -394,6 +367,7 @@ int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, in
{
Caig_Man_t * p;
Cec_MtrStatus_t Status;
+ Vec_Ptr_t * vInfoCis, * vInfoCos = NULL;
int i, RetValue = 0, clk, clkTotal = clock();
/*
p = Caig_ManClassesPrepare( pAig, nWords, nIters );
@@ -405,35 +379,47 @@ int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, in
Caig_ManDelete( p );
return 0;
*/
- Status = Cec_MiterStatus( pAig );
- if ( Status.nSat > 0 )
- {
- printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut );
- return 1;
- }
- if ( Status.nUndec == 0 )
+ if ( fMiter )
{
- printf( "Miter is trivially unsatisfiable.\n" );
- return 0;
+ Status = Cec_MiterStatus( pAig );
+ if ( Status.nSat > 0 )
+ {
+ printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut );
+ return 1;
+ }
+ if ( Status.nUndec == 0 )
+ {
+ printf( "Miter is trivially unsatisfiable.\n" );
+ return 0;
+ }
}
Aig_ManRandom( 1 );
p = Caig_ManCreate( pAig );
p->nWords = nWords;
+ if ( fMiter )
+ vInfoCos = Vec_PtrAllocSimInfo( Aig_ManPiNum(pAig), nWords );
for ( i = 0; i < nIters; i++ )
{
clk = clock();
- RetValue = Caig_ManSimulateRound( p, fMiter );
+ vInfoCis = Vec_PtrAllocSimInfo( Aig_ManPiNum(pAig), nWords );
+ Aig_ManRandomInfo( vInfoCis, 0, nWords );
+ Caig_ManSimulateRound( p, vInfoCis, vInfoCos );
+ Vec_PtrFree( vInfoCis );
if ( fVerbose )
{
printf( "Iter %3d out of %3d and timeout %3d sec. ", i+1, nIters, TimeLimit );
printf("Time = %7.2f sec\r", (1.0*clock()-clkTotal)/CLOCKS_PER_SEC);
}
- if ( RetValue > 0 )
+ if ( fMiter )
{
- int iOut = Caig_ManFindPo(p->pAig, RetValue);
- if ( fVerbose )
- printf( "Miter is satisfiable after simulation (output %d).\n", iOut );
- break;
+ int iOut = Cec_ManFindPo( vInfoCos, nWords );
+ if ( iOut >= 0 )
+ {
+ if ( fVerbose )
+ printf( "Miter is satisfiable after simulation (output %d).\n", iOut );
+ RetValue = 1;
+ break;
+ }
}
if ( (clock() - clk)/CLOCKS_PER_SEC >= TimeLimit )
{
@@ -447,6 +433,8 @@ int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, in
1.0*(p->nObjs * 14)/(1<<20),
1.0*(p->nMemsMax * 4 * (nWords+1))/(1<<20) );
Caig_ManDelete( p );
+ if ( vInfoCos )
+ Vec_PtrFree( vInfoCos );
return RetValue > 0;
}
diff --git a/src/aig/cec/cecStatus.c b/src/aig/cec2/cecStatus.c
index 79d6ec66..79d6ec66 100644
--- a/src/aig/cec/cecStatus.c
+++ b/src/aig/cec2/cecStatus.c
diff --git a/src/aig/cec2/cecSweep.c b/src/aig/cec2/cecSweep.c
new file mode 100644
index 00000000..d7d85b02
--- /dev/null
+++ b/src/aig/cec2/cecSweep.c
@@ -0,0 +1,582 @@
+/**CFile****************************************************************
+
+ FileName [cecSweep.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinatinoal equivalence checking.]
+
+ Synopsis [Pattern accumulation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cecSweep.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+#include "satSolver.h"
+#include "cnf.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Cec_ManCsw_t_ Cec_ManCsw_t;
+struct Cec_ManCsw_t_
+{
+ // parameters
+ Cec_ParCsw_t * pPars; // parameters
+ Caig_Man_t * p; // AIG and simulation manager
+ // mapping into copy
+ Aig_Obj_t ** pCopy; // the copy of nodes
+ Vec_Int_t * vCopies; // the nodes copied in the last round
+ char * pProved; // tells if the given node is proved
+ char * pProvedNow; // tells if the given node is proved
+ int * pLevel; // level of the nodes
+ // collected patterns
+ Vec_Ptr_t * vInfo; // simulation info accumulated
+ Vec_Ptr_t * vPres; // simulation presence accumulated
+ Vec_Ptr_t * vInfoAll; // vector of vectors of simulation info
+ // temporaries
+ Vec_Int_t * vPiNums; // primary input numbers
+ Vec_Int_t * vPoNums; // primary output numbers
+ Vec_Int_t * vPat; // one counter-example
+ Vec_Ptr_t * vSupp; // support of one node
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Adds pattern to storage.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSavePattern( Cec_ManCsw_t * p, Vec_Int_t * vPat )
+{
+ unsigned * pInfo, * pPres;
+ int nPatsAlloc, iLit, i, c;
+ assert( p->p->nWords == Vec_PtrReadWordsSimInfo(p->vInfo) );
+ // find next empty place
+ nPatsAlloc = 32 * p->p->nWords;
+ for ( c = 0; c < nPatsAlloc; c++ )
+ {
+ Vec_IntForEachEntry( vPat, iLit, i )
+ {
+ pPres = Vec_PtrEntry( p->vPres, Cec_Lit2Var(iLit) );
+ if ( Aig_InfoHasBit( pPres, c ) )
+ break;
+ }
+ if ( i == Vec_IntSize(vPat) )
+ break;
+ }
+ // increase the size if needed
+ if ( c == nPatsAlloc )
+ {
+ p->vInfo = Vec_PtrAllocSimInfo( p->p->nPis, p->p->nWords );
+ Vec_PtrCleanSimInfo( p->vInfo, 0, p->p->nWords );
+ Vec_PtrCleanSimInfo( p->vPres, 0, p->p->nWords );
+ Vec_PtrPush( p->vInfoAll, p->vInfo );
+ c = 0;
+ }
+ // save the pattern
+ Vec_IntForEachEntry( vPat, iLit, i )
+ {
+ pPres = Vec_PtrEntry( p->vPres, Cec_Lit2Var(iLit) );
+ pInfo = Vec_PtrEntry( p->vInfo, Cec_Lit2Var(iLit) );
+ Aig_InfoSetBit( pPres, c );
+ if ( !Cec_LitIsCompl(iLit) )
+ Aig_InfoSetBit( pInfo, c );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Cec_ManCswCreatePartition_rec( Aig_Man_t * pAig, Cec_ManCsw_t * p, int i )
+{
+ Aig_Obj_t * pRes0, * pRes1;
+ if ( p->pCopy[i] )
+ return p->pCopy[i];
+ Vec_IntPush( p->vCopies, i );
+ if ( p->p->pFans0[i] == -1 ) // pi
+ {
+ Vec_IntPush( p->vPiNums, Aig_ObjPioNum( Aig_ManObj(p->p->pAig, i) ) );
+ return p->pCopy[i] = Aig_ObjCreatePi( pAig );
+ }
+ assert( p->p->pFans0[i] && p->p->pFans1[i] );
+ pRes0 = Cec_ManCswCreatePartition_rec( pAig, p, Cec_Lit2Var(p->p->pFans0[i]) );
+ pRes0 = Aig_NotCond( pRes0, Cec_LitIsCompl(p->p->pFans0[i]) );
+ pRes1 = Cec_ManCswCreatePartition_rec( pAig, p, Cec_Lit2Var(p->p->pFans1[i]) );
+ pRes1 = Aig_NotCond( pRes1, Cec_LitIsCompl(p->p->pFans1[i]) );
+ return p->pCopy[i] = Aig_And( pAig, pRes0, pRes1 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates dynamic partition.]
+
+ Description [PIs point to node IDs. POs point to node IDs.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Cec_ManCswCreatePartition( Cec_ManCsw_t * p, int * piStart, int nMitersMin, int nNodesMin, int nLevelMax )
+{
+ Caig_Man_t * pMan = p->p;
+ Aig_Man_t * pAig;
+ Aig_Obj_t * pRepr, * pNode, * pMiter, * pTerm;
+ int i, iNode, Counter = 0;
+ assert( p->pCopy && p->vCopies );
+ // clear previous marks
+ Vec_IntForEachEntry( p->vCopies, iNode, i )
+ p->pCopy[iNode] = NULL;
+ Vec_IntClear( p->vCopies );
+ // iterate through nodes starting from the given one
+ pAig = Aig_ManStart( nNodesMin );
+ p->pCopy[0] = Aig_ManConst1(pAig);
+ Vec_IntPush( p->vCopies, 0 );
+ for ( i = *piStart; i < pMan->nObjs; i++ )
+ {
+ if ( pMan->pFans0[i] == -1 ) // pi always has zero first fanin
+ continue;
+ if ( pMan->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin
+ continue;
+ if ( pMan->pReprs[i] < 0 )
+ continue;
+ if ( p->pPars->nLevelMax && (p->pLevel[i] > p->pPars->nLevelMax || p->pLevel[pMan->pReprs[i]] > p->pPars->nLevelMax) )
+ continue;
+ // create cones
+ pRepr = Cec_ManCswCreatePartition_rec( pAig, p, pMan->pReprs[i] );
+ pNode = Cec_ManCswCreatePartition_rec( pAig, p, i );
+ // skip if they are the same
+ if ( Aig_Regular(pRepr) == Aig_Regular(pNode) )
+ {
+ p->pProvedNow[i] = 1;
+ continue;
+ }
+ // perform speculative reduction
+ assert( p->pCopy[i] == pNode );
+ p->pCopy[i] = Aig_NotCond( pRepr, Aig_ObjPhaseReal(pRepr) ^ Aig_ObjPhaseReal(pNode) );
+ if ( p->pProved[i] )
+ {
+ p->pProvedNow[i] = 1;
+ continue;
+ }
+ pMiter = Aig_Exor( pAig, pRepr, pNode );
+ pTerm = Aig_ObjCreatePo( pAig, Aig_NotCond(pMiter, Aig_ObjPhaseReal(pMiter)) );
+ Vec_IntPush( p->vPoNums, i );
+ if ( ++Counter > nMitersMin && Aig_ManObjNum(pAig) > nNodesMin )
+ break;
+ }
+ *piStart = i + 1;
+ Aig_ManSetRegNum( pAig, 0 );
+ Aig_ManCleanup( pAig );
+ return pAig;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatDerivePattern( Cec_ManCsw_t * p, Aig_Man_t * pAig, Aig_Obj_t * pRoot, Cnf_Dat_t * pCnf, sat_solver * pSat )
+{
+ Aig_Obj_t * pObj;
+ int i, Value, iVar;
+ assert( Aig_ObjIsPo(pRoot) );
+ Aig_SupportNodes( pAig, &pRoot, 1, p->vSupp );
+ Vec_IntClear( p->vPat );
+ Vec_PtrForEachEntry( p->vSupp, pObj, i )
+ {
+ assert( Aig_ObjIsPi(pObj) );
+ Value = sat_solver_var_value( pSat, pCnf->pVarNums[pObj->Id] );
+ iVar = Vec_IntEntry( p->vPiNums, Aig_ObjPioNum(pObj) );
+ assert( iVar >= 0 && iVar < p->p->nPis );
+ Vec_IntPush( p->vPat, Cec_Var2Lit( iVar, !Value ) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates level.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManCreateLevel( Cec_ManCsw_t * p )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ assert( p->pLevel == NULL );
+ p->pLevel = ABC_ALLOC( int, p->p->nObjs );
+ Aig_ManForEachObj( p->p->pAig, pObj, i )
+ p->pLevel[i] = Aig_ObjLevel(pObj);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Cec_ManCsw_t * Cec_ManCswCreate( Caig_Man_t * pMan, Cec_ParCsw_t * pPars )
+{
+ Cec_ManCsw_t * p;
+ // create interpolation manager
+ p = ABC_ALLOC( Cec_ManCsw_t, 1 );
+ memset( p, 0, sizeof(Cec_ManCsw_t) );
+ p->pPars = pPars;
+ p->p = pMan;
+ // internal storage
+ p->vCopies = Vec_IntAlloc( 10000 );
+ p->pCopy = ABC_CALLOC( Aig_Obj_t *, pMan->nObjs );
+ p->pProved = ABC_CALLOC( char, pMan->nObjs );
+ p->pProvedNow = ABC_CALLOC( char, pMan->nObjs );
+ // temporaries
+ p->vPat = Vec_IntAlloc( 1000 );
+ p->vSupp = Vec_PtrAlloc( 1000 );
+ p->vPiNums = Vec_IntAlloc( 1000 );
+ p->vPoNums = Vec_IntAlloc( 1000 );
+ if ( pPars->nLevelMax )
+ Cec_ManCreateLevel( p );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Frees the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManCswStop( Cec_ManCsw_t * p )
+{
+ Vec_IntFree( p->vPiNums );
+ Vec_IntFree( p->vPoNums );
+ Vec_PtrFree( p->vSupp );
+ Vec_IntFree( p->vPat );
+ Vec_IntFree( p->vCopies );
+ Vec_PtrFree( p->vPres );
+ Vec_VecFree( (Vec_Vec_t *)p->vInfoAll );
+ ABC_FREE( p->pLevel );
+ ABC_FREE( p->pCopy );
+ ABC_FREE( p->pProved );
+ ABC_FREE( p->pProvedNow );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Cleans the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManCleanSimInfo( Cec_ManCsw_t * p )
+{
+ if ( p->vInfoAll )
+ Vec_VecFree( (Vec_Vec_t *)p->vInfoAll );
+ if ( p->vPres )
+ Vec_PtrFree( p->vPres );
+ p->vInfoAll = Vec_PtrAlloc( 100 );
+ p->vInfo = Vec_PtrAllocSimInfo( p->p->nPis, p->pPars->nWords );
+ p->vPres = Vec_PtrAllocSimInfo( p->p->nPis, p->pPars->nWords );
+ Vec_PtrCleanSimInfo( p->vInfo, 0, p->p->nWords );
+ Vec_PtrCleanSimInfo( p->vPres, 0, p->p->nWords );
+ Vec_PtrPush( p->vInfoAll, p->vInfo );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Update information about proved nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManCountProved( char * pArray, int nSize )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < nSize; i++ )
+ Counter += (pArray[i] == 1);
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Update information about proved nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManCountDisproved( char * pArray, int nSize )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < nSize; i++ )
+ Counter += (pArray[i] == -1);
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Update information about proved nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_ManCountTimedout( char * pArray, int nSize )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < nSize; i++ )
+ Counter += (pArray[i] == -2);
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Update information about proved nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManUpdateProved( Cec_ManCsw_t * p )
+{
+ Caig_Man_t * pMan = p->p;
+ int i;
+ for ( i = 1; i < pMan->nObjs; i++ )
+ {
+ if ( pMan->pFans0[i] == -1 ) // pi always has zero first fanin
+ continue;
+ if ( pMan->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin
+ continue;
+ if ( p->pProvedNow[Cec_Lit2Var(pMan->pFans0[i])] < 0 ||
+ p->pProvedNow[Cec_Lit2Var(pMan->pFans1[i])] < 0 )
+ p->pProvedNow[i] = -1;
+ if ( pMan->pReprs[i] < 0 )
+ {
+ assert( p->pProvedNow[i] <= 0 );
+ continue;
+ }
+ if ( p->pProved[i] )
+ {
+ assert( p->pProvedNow[i] == 1 );
+ continue;
+ }
+ if ( p->pProvedNow[i] == 1 )
+ p->pProved[i] = 1;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates dynamic partition.]
+
+ Description [PIs point to node IDs. POs point to node IDs.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatSweepRound( Cec_ManCsw_t * p )
+{
+ Bar_Progress_t * pProgress = NULL;
+ Vec_Ptr_t * vInfo;
+ Aig_Man_t * pAig, * pTemp;
+ Aig_Obj_t * pObj;
+ Cnf_Dat_t * pCnf;
+ sat_solver * pSat;
+ int i, Lit, iNode, iStart, status;
+ int nProved, nDisproved, nTimedout, nBefore, nAfter, nRecycles = 0;
+ int clk = clock();
+ Cec_ManCleanSimInfo( p );
+ memset( p->pProvedNow, 0, sizeof(char) * p->p->nObjs );
+ pProgress = Bar_ProgressStart( stdout, p->p->nObjs );
+ for ( iStart = 1; iStart < p->p->nObjs; )
+ {
+ Bar_ProgressUpdate( pProgress, iStart, "Sweep..." );
+ Vec_IntClear( p->vPiNums );
+ Vec_IntClear( p->vPoNums );
+ // generate AIG, synthesize, convert to CNF, and solve
+ pAig = Cec_ManCswCreatePartition( p, &iStart, p->pPars->nCallsRecycle, p->pPars->nSatVarMax, p->pPars->nLevelMax );
+ Aig_ManPrintStats( pAig );
+
+ if ( p->pPars->fRewriting )
+ {
+ pAig = Dar_ManRwsat( pTemp = pAig, 1, 0 );
+ Aig_ManStop( pTemp );
+ }
+ pCnf = Cnf_Derive( pAig, Aig_ManPoNum(pAig) );
+ pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ Aig_ManForEachPo( pAig, pObj, i )
+ {
+ iNode = Vec_IntEntry( p->vPoNums, i );
+ Lit = toLitCond( pCnf->pVarNums[pObj->Id], 0 );
+ status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( status == l_False )
+ p->pProvedNow[iNode] = 1;
+ else if ( status == l_Undef )
+ p->pProvedNow[iNode] = -2;
+ else if ( status == l_True )
+ {
+ p->pProvedNow[iNode] = -1;
+ Cec_ManSatDerivePattern( p, pAig, pObj, pCnf, pSat );
+ Cec_ManSavePattern( p, p->vPat );
+ }
+ }
+ // clean up
+ Aig_ManStop( pAig );
+ Cnf_DataFree( pCnf );
+ sat_solver_delete( pSat );
+ nRecycles++;
+ }
+ Bar_ProgressStop( pProgress );
+ // collect statistics
+ nProved = Cec_ManCountProved( p->pProvedNow, p->p->nObjs );
+ nDisproved = Cec_ManCountDisproved( p->pProvedNow, p->p->nObjs );
+ nTimedout = Cec_ManCountTimedout( p->pProvedNow, p->p->nObjs );
+ nBefore = Cec_ManCountProved( p->pProved, p->p->nObjs );
+ Cec_ManUpdateProved( p );
+ nAfter = Cec_ManCountProved( p->pProved, p->p->nObjs );
+ printf( "Pr =%6d. Cex =%6d. Fail =%6d. Bef =%6d. Aft =%6d. Rcl =%4d.",
+ nProved, nDisproved, nTimedout, nBefore, nAfter, nRecycles );
+ ABC_PRT( "Time", clock() - clk );
+ // resimulate with the collected information
+ Vec_PtrForEachEntry( p->vInfoAll, vInfo, i )
+ Caig_ManSimulateRound( p->p, vInfo, NULL );
+Caig_ManPrintClasses( p->p, 0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs one round of sweeping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_ManSatSweepInt( Caig_Man_t * pMan, Cec_ParCsw_t * pPars )
+{
+ Cec_ManCsw_t * p;
+ p = Cec_ManCswCreate( pMan, pPars );
+ Cec_ManSatSweepRound( p );
+ Cec_ManCswStop( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs equivalence checking.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Cec_ManTrasferReprs( Aig_Man_t * pAig, Caig_Man_t * pCaig )
+{
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs equivalence checking.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Cec_ManSatSweep( Aig_Man_t * pAig, Cec_ParCsw_t * pPars )
+{
+/*
+ Aig_Man_t * pAigNew, * pAigDfs;
+ Caig_Man_t * pCaig;
+ Cec_ManCsw_t * p;
+ pAigDfs = Cec_Duplicate( pAig );
+ pCaig = Caig_ManClassesPrepare( pAigDfs, pPars->nWords, pPars->nRounds );
+ p = Cec_ManCswCreate( pCaig, pPars );
+ Cec_ManSatSweep( p, pPars );
+ Cec_ManCswStop( p );
+// pAigNew =
+ Caig_ManDelete( pCaig );
+ Aig_ManStop( pAigDfs );
+ return pAigNew;
+*/
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/cec2/module.make b/src/aig/cec2/module.make
new file mode 100644
index 00000000..537397e3
--- /dev/null
+++ b/src/aig/cec2/module.make
@@ -0,0 +1,9 @@
+SRC += src/aig/cec/cecAig.c \
+ src/aig/cec/cecClass.c \
+ src/aig/cec/cecCnf.c \
+ src/aig/cec/cecCore.c \
+ src/aig/cec/cecMan.c \
+ src/aig/cec/cecSat.c \
+ src/aig/cec/cecSim.c \
+ src/aig/cec/cecStatus.c \
+ src/aig/cec/cecSweep.c
diff --git a/src/aig/cgt/cgt.h b/src/aig/cgt/cgt.h
index f8c1cc2e..8d18ea80 100644
--- a/src/aig/cgt/cgt.h
+++ b/src/aig/cgt/cgt.h
@@ -21,10 +21,6 @@
#ifndef __CGT_H__
#define __CGT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
The algorithm implemented in this package is based on the paper:
A. Hurst. "Automatic synthesis of clock gating logic with controlled
@@ -39,6 +35,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cgt/cgtCore.c b/src/aig/cgt/cgtCore.c
index f49cd46f..b213297e 100644
--- a/src/aig/cgt/cgtCore.c
+++ b/src/aig/cgt/cgtCore.c
@@ -220,7 +220,7 @@ p->timePrepare += clock() - clk;
p->nCallsSat -nCallsSat,
p->nCallsUndec-nCallsUndec,
p->nCallsFiltered-nCallsFiltered );
- PRT( "Time", clock() - clkTotal );
+ ABC_PRT( "Time", clock() - clkTotal );
}
Cgt_ManClean( p );
p->nRecycles++;
diff --git a/src/aig/cgt/cgtDecide.c b/src/aig/cgt/cgtDecide.c
index 0fb2a681..3e79ff73 100644
--- a/src/aig/cgt/cgtDecide.c
+++ b/src/aig/cgt/cgtDecide.c
@@ -227,7 +227,7 @@ Vec_Vec_t * Cgt_ManDecideSimple( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int nO
// printf( "Gated transitions = %5.2f %%. (%5.2f %%.) ",
// 100.0*nTransSaved/nTransTotal, Cgt_ManComputeCoverage(pAig, vGates) );
printf( "Gated transitions = %5.2f %%. ", Cgt_ManComputeCoverage(pAig, vGates) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
/*
{
@@ -283,7 +283,7 @@ Vec_Vec_t * Cgt_ManDecideArea( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int nOdc
Vec_VecSizeSize(vGatesAll), Counter, Saig_ManRegNum(pAig) );
printf( "Complete gates = %6d. Gated transitions = %5.2f %%. ",
Vec_PtrSize(vCompletes), Cgt_ManComputeCoverage(pAig, vGates) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
Vec_PtrFree( vCompletes );
return vGates;
diff --git a/src/aig/cgt/cgtInt.h b/src/aig/cgt/cgtInt.h
index 23d851f3..3d9823c3 100644
--- a/src/aig/cgt/cgtInt.h
+++ b/src/aig/cgt/cgtInt.h
@@ -21,10 +21,6 @@
#ifndef __CGT_INT_H__
#define __CGT_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -38,6 +34,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cgt/cgtMan.c b/src/aig/cgt/cgtMan.c
index a3385228..ddc1c5e0 100644
--- a/src/aig/cgt/cgtMan.c
+++ b/src/aig/cgt/cgtMan.c
@@ -47,7 +47,7 @@ Cgt_Man_t * Cgt_ManCreate( Aig_Man_t * pAig, Aig_Man_t * pCare, Cgt_Par_t * pPar
Aig_ManFanoutStart( pAig );
Aig_ManSetPioNumbers( pAig );
// create interpolation manager
- p = ALLOC( Cgt_Man_t, 1 );
+ p = ABC_ALLOC( Cgt_Man_t, 1 );
memset( p, 0, sizeof(Cgt_Man_t) );
p->pPars = pPars;
p->pAig = pAig;
@@ -123,17 +123,17 @@ void Cgt_ManPrintStats( Cgt_Man_t * p )
p->pPars->nConfMax, p->pPars->nVarsMin, p->pPars->nFlopsMin );
printf( "SAT : Calls = %d. Unsat = %d. Sat = %d. Fails = %d. Recycles = %d. ",
p->nCalls, p->nCallsUnsat, p->nCallsSat, p->nCallsUndec, p->nRecycles );
- PRT( "Time", p->timeTotal );
+ ABC_PRT( "Time", p->timeTotal );
/*
p->timeOther = p->timeTotal-p->timeAig-p->timePrepare-p->timeSat-p->timeDecision;
- PRTP( "AIG ", p->timeAig, p->timeTotal );
- PRTP( "Prepare ", p->timePrepare, p->timeTotal );
- PRTP( "SAT solving", p->timeSat, p->timeTotal );
- PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
- PRTP( " sat ", p->timeSatSat, p->timeTotal );
- PRTP( " undecided", p->timeSatUndec, p->timeTotal );
- PRTP( "Other ", p->timeOther, p->timeTotal );
- PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+ ABC_PRTP( "AIG ", p->timeAig, p->timeTotal );
+ ABC_PRTP( "Prepare ", p->timePrepare, p->timeTotal );
+ ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal );
+ ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
+ ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal );
+ ABC_PRTP( " undecided", p->timeSatUndec, p->timeTotal );
+ ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
+ ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
*/
}
@@ -163,7 +163,7 @@ void Cgt_ManStop( Cgt_Man_t * p )
Vec_VecFree( p->vGatesAll );
if ( p->vSuppsInv )
Vec_VecFree( p->vSuppsInv );
- free( p );
+ ABC_FREE( p );
}
diff --git a/src/aig/cgt/cgtSat.c b/src/aig/cgt/cgtSat.c
index 094fb47d..94168978 100644
--- a/src/aig/cgt/cgtSat.c
+++ b/src/aig/cgt/cgtSat.c
@@ -57,7 +57,7 @@ int Cgt_CheckImplication( Cgt_Man_t * p, Aig_Obj_t * pGate, Aig_Obj_t * pMiter )
pLits[1] = toLitCond( p->pCnf->pVarNums[pMiter->Id], 0 );
clk = clock();
- RetValue = sat_solver_solve( p->pSat, pLits, pLits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSat, pLits, pLits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
p->timeSat += clock() - clk;
if ( RetValue == l_False )
{
diff --git a/src/aig/cnf/cnf.h b/src/aig/cnf/cnf.h
index c9c5bce3..4343bf9a 100644
--- a/src/aig/cnf/cnf.h
+++ b/src/aig/cnf/cnf.h
@@ -21,10 +21,6 @@
#ifndef __CNF_H__
#define __CNF_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -43,6 +39,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cnf/cnfCore.c b/src/aig/cnf/cnfCore.c
index e1d62de0..11a7af43 100644
--- a/src/aig/cnf/cnfCore.c
+++ b/src/aig/cnf/cnfCore.c
@@ -77,9 +77,9 @@ p->timeSave = clock() - clk;
// reset reference counters
Aig_ManResetRefs( pAig );
-//PRT( "Cuts ", p->timeCuts );
-//PRT( "Map ", p->timeMap );
-//PRT( "Saving ", p->timeSave );
+//ABC_PRT( "Cuts ", p->timeCuts );
+//ABC_PRT( "Map ", p->timeMap );
+//ABC_PRT( "Saving ", p->timeSave );
return pCnf;
}
@@ -141,7 +141,7 @@ Cnf_Dat_t * Cnf_Derive_old( Aig_Man_t * pAig )
clk = clock();
Cnf_ManScanMapping( p, 0 );
Cnf_ManMapForCnf( p );
-PRT( "iter ", clock() - clk );
+ABC_PRT( "iter ", clock() - clk );
}
*/
// write the file
@@ -159,7 +159,7 @@ clk = clock();
Cnf_ManPostprocess( p );
Cnf_ManScanMapping( p, 0 );
*/
-PRT( "Ext ", clock() - clk );
+ABC_PRT( "Ext ", clock() - clk );
/*
vMapped = Cnf_ManScanMapping( p, 1 );
diff --git a/src/aig/cnf/cnfData.c b/src/aig/cnf/cnfData.c
index 01f6ff8a..8df93fdb 100644
--- a/src/aig/cnf/cnfData.c
+++ b/src/aig/cnf/cnfData.c
@@ -4554,7 +4554,7 @@ void Cnf_ReadMsops( char ** ppSopSizes, char *** ppSops )
assert( Size < 100000 );
// allocate memory
- pMemory = ALLOC( char, Size * 75 );
+ pMemory = ABC_ALLOC( char, Size * 75 );
// copy the array into memory
for ( i = 0; i < Size; i++ )
for ( k = 0; k < 75; k++ )
@@ -4564,8 +4564,8 @@ void Cnf_ReadMsops( char ** ppSopSizes, char *** ppSops )
pMemory[i*75+k] = Map[(int)s_Data4[i][k]];
// set pointers and compute SOP sizes
- pSopSizes = ALLOC( char, 65536 );
- pSops = ALLOC( char *, 65536 );
+ pSopSizes = ABC_ALLOC( char, 65536 );
+ pSops = ABC_ALLOC( char *, 65536 );
pSopSizes[0] = 0;
pSops[0] = NULL;
pPrev = pMemory;
diff --git a/src/aig/cnf/cnfMan.c b/src/aig/cnf/cnfMan.c
index 7c24606c..f8e88b8f 100644
--- a/src/aig/cnf/cnfMan.c
+++ b/src/aig/cnf/cnfMan.c
@@ -49,7 +49,7 @@ Cnf_Man_t * Cnf_ManStart()
Cnf_Man_t * p;
int i;
// allocate the manager
- p = ALLOC( Cnf_Man_t, 1 );
+ p = ABC_ALLOC( Cnf_Man_t, 1 );
memset( p, 0, sizeof(Cnf_Man_t) );
// derive internal data structures
Cnf_ReadMsops( &p->pSopSizes, &p->pSops );
@@ -57,7 +57,7 @@ Cnf_Man_t * Cnf_ManStart()
p->pMemCuts = Aig_MmFlexStart();
p->nMergeLimit = 10;
// allocate temporary truth tables
- p->pTruths[0] = ALLOC( unsigned, 4 * Aig_TruthWordNum(p->nMergeLimit) );
+ p->pTruths[0] = ABC_ALLOC( unsigned, 4 * Aig_TruthWordNum(p->nMergeLimit) );
for ( i = 1; i < 4; i++ )
p->pTruths[i] = p->pTruths[i-1] + Aig_TruthWordNum(p->nMergeLimit);
p->vMemory = Vec_IntAlloc( 1 << 18 );
@@ -78,12 +78,12 @@ Cnf_Man_t * Cnf_ManStart()
void Cnf_ManStop( Cnf_Man_t * p )
{
Vec_IntFree( p->vMemory );
- free( p->pTruths[0] );
+ ABC_FREE( p->pTruths[0] );
Aig_MmFlexStop( p->pMemCuts, 0 );
- free( p->pSopSizes );
- free( p->pSops[1] );
- free( p->pSops );
- free( p );
+ ABC_FREE( p->pSopSizes );
+ ABC_FREE( p->pSops[1] );
+ ABC_FREE( p->pSops );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -123,16 +123,16 @@ Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiter
{
Cnf_Dat_t * pCnf;
int i;
- pCnf = ALLOC( Cnf_Dat_t, 1 );
+ pCnf = ABC_ALLOC( Cnf_Dat_t, 1 );
memset( pCnf, 0, sizeof(Cnf_Dat_t) );
pCnf->pMan = pAig;
pCnf->nVars = nVars;
pCnf->nClauses = nClauses;
pCnf->nLiterals = nLiterals;
- pCnf->pClauses = ALLOC( int *, nClauses + 1 );
- pCnf->pClauses[0] = ALLOC( int, nLiterals );
+ pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 );
+ pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals );
pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals;
- pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(pAig) );
+ pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(pAig) );
// memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(pAig) );
for ( i = 0; i < Aig_ManObjNumMax(pAig); i++ )
pCnf->pVarNums[i] = -1;
@@ -177,10 +177,10 @@ void Cnf_DataFree( Cnf_Dat_t * p )
{
if ( p == NULL )
return;
- free( p->pClauses[0] );
- free( p->pClauses );
- free( p->pVarNums );
- free( p );
+ ABC_FREE( p->pClauses[0] );
+ ABC_FREE( p->pClauses );
+ ABC_FREE( p->pVarNums );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -425,15 +425,15 @@ int Cnf_DataWriteOrClause( void * p, Cnf_Dat_t * pCnf )
sat_solver * pSat = p;
Aig_Obj_t * pObj;
int i, * pLits;
- pLits = ALLOC( int, Aig_ManPoNum(pCnf->pMan) );
+ pLits = ABC_ALLOC( int, Aig_ManPoNum(pCnf->pMan) );
Aig_ManForEachPo( pCnf->pMan, pObj, i )
pLits[i] = toLitCond( pCnf->pVarNums[pObj->Id], 0 );
if ( !sat_solver_addclause( pSat, pLits, pLits + Aig_ManPoNum(pCnf->pMan) ) )
{
- free( pLits );
+ ABC_FREE( pLits );
return 0;
}
- free( pLits );
+ ABC_FREE( pLits );
return 1;
}
@@ -479,7 +479,7 @@ void Cnf_DataTranformPolarity( Cnf_Dat_t * pCnf, int fTransformPos )
int * pVarToPol;
int i, iVar;
// create map from the variable number to its polarity
- pVarToPol = CALLOC( int, pCnf->nVars );
+ pVarToPol = ABC_CALLOC( int, pCnf->nVars );
Aig_ManForEachObj( pCnf->pMan, pObj, i )
{
if ( !fTransformPos && Aig_ObjIsPo(pObj) )
@@ -495,7 +495,7 @@ void Cnf_DataTranformPolarity( Cnf_Dat_t * pCnf, int fTransformPos )
if ( pVarToPol[iVar] )
pCnf->pClauses[0][i] = lit_neg( pCnf->pClauses[0][i] );
}
- free( pVarToPol );
+ ABC_FREE( pVarToPol );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/cnf/cnfMap.c b/src/aig/cnf/cnfMap.c
index 8453e3cc..63625e6f 100644
--- a/src/aig/cnf/cnfMap.c
+++ b/src/aig/cnf/cnfMap.c
@@ -101,7 +101,7 @@ void Cnf_DeriveMapping( Cnf_Man_t * p )
Dar_Cut_t * pCut, * pCutBest;
int i, k, AreaFlow, * pAreaFlows;
// allocate area flows
- pAreaFlows = ALLOC( int, Aig_ManObjNumMax(p->pManAig) );
+ pAreaFlows = ABC_ALLOC( int, Aig_ManObjNumMax(p->pManAig) );
memset( pAreaFlows, 0, sizeof(int) * Aig_ManObjNumMax(p->pManAig) );
// visit the nodes in the topological order and update their best cuts
vSuper = Vec_PtrAlloc( 100 );
@@ -136,7 +136,7 @@ void Cnf_DeriveMapping( Cnf_Man_t * p )
}
}
Vec_PtrFree( vSuper );
- free( pAreaFlows );
+ ABC_FREE( pAreaFlows );
/*
// compute the area of mapping
diff --git a/src/aig/cnf/cnfWrite.c b/src/aig/cnf/cnfWrite.c
index 8a6a9160..638e67da 100644
--- a/src/aig/cnf/cnfWrite.c
+++ b/src/aig/cnf/cnfWrite.c
@@ -205,17 +205,17 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
//printf( "\n" );
// allocate CNF
- pCnf = ALLOC( Cnf_Dat_t, 1 );
+ pCnf = ABC_ALLOC( Cnf_Dat_t, 1 );
memset( pCnf, 0, sizeof(Cnf_Dat_t) );
pCnf->pMan = p->pManAig;
pCnf->nLiterals = nLiterals;
pCnf->nClauses = nClauses;
- pCnf->pClauses = ALLOC( int *, nClauses + 1 );
- pCnf->pClauses[0] = ALLOC( int, nLiterals );
+ pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 );
+ pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals );
pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals;
// create room for variable numbers
- pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(p->pManAig) );
+ pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p->pManAig) );
// memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p->pManAig) );
for ( i = 0; i < Aig_ManObjNumMax(p->pManAig); i++ )
pCnf->pVarNums[i] = -1;
@@ -356,17 +356,17 @@ Cnf_Dat_t * Cnf_DeriveSimple( Aig_Man_t * p, int nOutputs )
nClauses = 1 + 3 * Aig_ManNodeNum(p) + Aig_ManPoNum( p ) + nOutputs;
// allocate CNF
- pCnf = ALLOC( Cnf_Dat_t, 1 );
+ pCnf = ABC_ALLOC( Cnf_Dat_t, 1 );
memset( pCnf, 0, sizeof(Cnf_Dat_t) );
pCnf->pMan = p;
pCnf->nLiterals = nLiterals;
pCnf->nClauses = nClauses;
- pCnf->pClauses = ALLOC( int *, nClauses + 1 );
- pCnf->pClauses[0] = ALLOC( int, nLiterals );
+ pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 );
+ pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals );
pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals;
// create room for variable numbers
- pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(p) );
+ pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p) );
// memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p) );
for ( i = 0; i < Aig_ManObjNumMax(p); i++ )
pCnf->pVarNums[i] = -1;
@@ -478,17 +478,17 @@ Cnf_Dat_t * Cnf_DeriveSimpleForRetiming( Aig_Man_t * p )
nClauses = 1 + 3 * Aig_ManNodeNum(p) + 3 * Aig_ManPoNum(p);
// allocate CNF
- pCnf = ALLOC( Cnf_Dat_t, 1 );
+ pCnf = ABC_ALLOC( Cnf_Dat_t, 1 );
memset( pCnf, 0, sizeof(Cnf_Dat_t) );
pCnf->pMan = p;
pCnf->nLiterals = nLiterals;
pCnf->nClauses = nClauses;
- pCnf->pClauses = ALLOC( int *, nClauses + 1 );
- pCnf->pClauses[0] = ALLOC( int, nLiterals );
+ pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 );
+ pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals );
pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals;
// create room for variable numbers
- pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(p) );
+ pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p) );
// memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p) );
for ( i = 0; i < Aig_ManObjNumMax(p); i++ )
pCnf->pVarNums[i] = -1;
diff --git a/src/aig/csw/csw.h b/src/aig/csw/csw.h
index 1443f4d9..3d704d5f 100644
--- a/src/aig/csw/csw.h
+++ b/src/aig/csw/csw.h
@@ -21,10 +21,6 @@
#ifndef __CSW_H__
#define __CSW_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/csw/cswCut.c b/src/aig/csw/cswCut.c
index a3d9b04e..14cc3e4c 100644
--- a/src/aig/csw/cswCut.c
+++ b/src/aig/csw/cswCut.c
@@ -78,7 +78,7 @@ static inline float Csw_CutFindCost2( Csw_Man_t * p, Csw_Cut_t * pCut )
/**Function*************************************************************
- Synopsis [Returns the next free cut to use.]
+ Synopsis [Returns the next ABC_FREE cut to use.]
Description []
diff --git a/src/aig/csw/cswInt.h b/src/aig/csw/cswInt.h
index 37efe9b4..76c673a3 100644
--- a/src/aig/csw/cswInt.h
+++ b/src/aig/csw/cswInt.h
@@ -21,10 +21,6 @@
#ifndef __CSW_INT_H__
#define __CSW_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -44,6 +40,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/csw/cswMan.c b/src/aig/csw/cswMan.c
index c3061dee..4225402c 100644
--- a/src/aig/csw/cswMan.c
+++ b/src/aig/csw/cswMan.c
@@ -47,7 +47,7 @@ Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer
assert( nCutsMax >= 2 );
assert( nLeafMax <= 16 );
// allocate the fraiging manager
- p = ALLOC( Csw_Man_t, 1 );
+ p = ABC_ALLOC( Csw_Man_t, 1 );
memset( p, 0, sizeof(Csw_Man_t) );
p->nCutsMax = nCutsMax;
p->nLeafMax = nLeafMax;
@@ -57,9 +57,9 @@ Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer
p->pManRes = Aig_ManStartFrom( pMan );
assert( Aig_ManPiNum(p->pManAig) == Aig_ManPiNum(p->pManRes) );
// allocate room for cuts and equivalent nodes
- p->pnRefs = ALLOC( int, Aig_ManObjNumMax(pMan) );
- p->pEquiv = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMan) );
- p->pCuts = ALLOC( Csw_Cut_t *, Aig_ManObjNumMax(pMan) );
+ p->pnRefs = ABC_ALLOC( int, Aig_ManObjNumMax(pMan) );
+ p->pEquiv = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMan) );
+ p->pCuts = ABC_ALLOC( Csw_Cut_t *, Aig_ManObjNumMax(pMan) );
memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pMan) );
memset( p->pnRefs, 0, sizeof(int) * Aig_ManObjNumMax(pMan) );
// allocate memory manager
@@ -68,14 +68,14 @@ Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer
p->pMemCuts = Aig_MmFixedStart( p->nCutSize * p->nCutsMax, 512 );
// allocate hash table for cuts
p->nTableSize = Aig_PrimeCudd( Aig_ManNodeNum(pMan) * p->nCutsMax / 2 );
- p->pTable = ALLOC( Csw_Cut_t *, p->nTableSize );
+ p->pTable = ABC_ALLOC( Csw_Cut_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
// set the pointers to the available fraig nodes
Csw_ObjSetEquiv( p, Aig_ManConst1(p->pManAig), Aig_ManConst1(p->pManRes) );
Aig_ManForEachPi( p->pManAig, pObj, i )
Csw_ObjSetEquiv( p, pObj, Aig_ManPi(p->pManRes, i) );
// room for temporary truth tables
- p->puTemp[0] = ALLOC( unsigned, 4 * p->nTruthWords );
+ p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords );
p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
@@ -104,18 +104,18 @@ void Csw_ManStop( Csw_Man_t * p )
p->nNodesTried, Csw_TableCountCuts( p ) );
printf( "Triv0 = %6d. Triv1 = %6d. Triv2 = %6d. Cut-replace = %6d.\n",
p->nNodesTriv0, p->nNodesTriv1, p->nNodesTriv2, p->nNodesCuts );
- PRTP( "Cuts ", p->timeCuts, p->timeTotal );
- PRTP( "Hashing ", p->timeHash, p->timeTotal );
- PRTP( "Other ", p->timeOther, p->timeTotal );
- PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+ ABC_PRTP( "Cuts ", p->timeCuts, p->timeTotal );
+ ABC_PRTP( "Hashing ", p->timeHash, p->timeTotal );
+ ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
+ ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
}
- free( p->puTemp[0] );
+ ABC_FREE( p->puTemp[0] );
Aig_MmFixedStop( p->pMemCuts, 0 );
- free( p->pnRefs );
- free( p->pEquiv );
- free( p->pCuts );
- free( p->pTable );
- free( p );
+ ABC_FREE( p->pnRefs );
+ ABC_FREE( p->pEquiv );
+ ABC_FREE( p->pCuts );
+ ABC_FREE( p->pTable );
+ ABC_FREE( p );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/dar/dar.h b/src/aig/dar/dar.h
index c2d53c89..86f43a9e 100644
--- a/src/aig/dar/dar.h
+++ b/src/aig/dar/dar.h
@@ -21,10 +21,6 @@
#ifndef __DAR_H__
#define __DAR_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -48,6 +48,7 @@ struct Dar_RwrPar_t_
int fUpdateLevel; // update level
int fUseZeros; // performs zero-cost replacement
int fPower; // enables power-aware rewriting
+ int fRecycle; // enables cut recycling
int fVerbose; // enables verbose output
int fVeryVerbose; // enables very verbose output
};
diff --git a/src/aig/dar/darCore.c b/src/aig/dar/darCore.c
index 957b4cc9..3c8423cf 100644
--- a/src/aig/dar/darCore.c
+++ b/src/aig/dar/darCore.c
@@ -48,6 +48,7 @@ void Dar_ManDefaultRwrParams( Dar_RwrPar_t * pPars )
pPars->fUpdateLevel = 0;
pPars->fUseZeros = 0;
pPars->fPower = 0;
+ pPars->fRecycle = 1;
pPars->fVerbose = 0;
pPars->fVeryVerbose = 0;
}
@@ -71,7 +72,7 @@ int Dar_ManRewrite( Aig_Man_t * pAig, Dar_RwrPar_t * pPars )
Dar_Cut_t * pCut;
Aig_Obj_t * pObj, * pObjNew;
int i, k, nNodesOld, nNodeBefore, nNodeAfter, Required;
- int clk = 0, clkStart;
+ int clk = 0, clkStart, Counter = 0;
// prepare the library
Dar_LibPrepare( pPars->nSubgMax );
// create rewriting manager
@@ -86,7 +87,7 @@ int Dar_ManRewrite( Aig_Man_t * pAig, Dar_RwrPar_t * pPars )
if ( p->pPars->fUpdateLevel )
Aig_ManStartReverseLevels( pAig, 0 );
// set elementary cuts for the PIs
- Dar_ManCutsStart( p );
+// Dar_ManCutsStart( p );
// resynthesize each node once
clkStart = clock();
p->nNodesInit = Aig_ManNodeNum(pAig);
@@ -105,6 +106,13 @@ int Dar_ManRewrite( Aig_Man_t * pAig, Dar_RwrPar_t * pPars )
if ( i > nNodesOld )
// if ( p->pPars->fUseZeros && i > nNodesOld )
break;
+ if ( pPars->fRecycle && ++Counter % 50000 == 0 && Aig_DagSize(pObj) < Vec_PtrSize(p->vCutNodes)/100 )
+ {
+// printf( "Counter = %7d. Node = %7d. Dag = %5d. Vec = %5d.\n",
+// Counter, i, Aig_DagSize(pObj), Vec_PtrSize(p->vCutNodes) );
+// fflush( stdout );
+ Dar_ManCutsRestart( p, pObj );
+ }
// consider freeing the cuts
// if ( (i & 0xFFF) == 0 && Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) > 100 )
@@ -173,7 +181,6 @@ p->timeTotal = clock() - clkStart;
p->timeOther = p->timeTotal - p->timeCuts - p->timeEval;
// Bar_ProgressStop( pProgress );
- p->nCutMemUsed = Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20);
Dar_ManCutsFree( p );
// put the nodes into the DFS order and reassign their IDs
// Aig_NtkReassignIds( p );
@@ -260,7 +267,11 @@ Aig_MmFixed_t * Dar_ManComputeCuts( Aig_Man_t * pAig, int nCutsMax, int fVerbose
// create rewriting manager
p = Dar_ManStart( pAig, pPars );
// set elementary cuts for the PIs
- Dar_ManCutsStart( p );
+// Dar_ManCutsStart( p );
+ Aig_MmFixedRestart( p->pMemCuts );
+ Dar_ObjPrepareCuts( p, Aig_ManConst1(p->pAig) );
+ Aig_ManForEachPi( pAig, pObj, i )
+ Dar_ObjPrepareCuts( p, pObj );
// compute cuts for each nodes in the topological order
Aig_ManForEachNode( pAig, pObj, i )
Dar_ObjComputeCuts( p, pObj );
@@ -274,14 +285,14 @@ Aig_MmFixed_t * Dar_ManComputeCuts( Aig_Man_t * pAig, int nCutsMax, int fVerbose
Aig_ManObjNum(pAig), nCuts, nCutsK );
printf( "Cut size = %2d. Truth size = %2d. Total mem = %5.2f Mb ",
(int)sizeof(Dar_Cut_t), (int)4, 1.0*Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) );
- PRT( "Runtime", clock() - clk );
+ ABC_PRT( "Runtime", clock() - clk );
/*
Aig_ManForEachNode( pAig, pObj, i )
if ( i % 300 == 0 )
Dar_ObjCutPrint( pAig, pObj );
*/
}
- // free the cuts
+ // ABC_FREE the cuts
pMemCuts = p->pMemCuts;
p->pMemCuts = NULL;
// Dar_ManCutsFree( p );
diff --git a/src/aig/dar/darCut.c b/src/aig/dar/darCut.c
index 6ebfec9d..1e1e4edb 100644
--- a/src/aig/dar/darCut.c
+++ b/src/aig/dar/darCut.c
@@ -127,7 +127,7 @@ static inline int Dar_CutFindValue( Dar_Man_t * p, Dar_Cut_t * pCut )
/**Function*************************************************************
- Synopsis [Returns the next free cut to use.]
+ Synopsis [Returns the next ABC_FREE cut to use.]
Description [Uses the cut with the smallest value.]
@@ -585,9 +585,11 @@ Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj )
pObj->nCuts = p->pPars->nCutsMax;
// create the cutset of the node
pCutSet = (Dar_Cut_t *)Aig_MmFixedEntryFetch( p->pMemCuts );
+ memset( pCutSet, 0, p->pPars->nCutsMax * sizeof(Dar_Cut_t) );
Dar_ObjSetCuts( pObj, pCutSet );
Dar_ObjForEachCutAll( pObj, pCut, i )
pCut->fUsed = 0;
+ Vec_PtrPush( p->vCutNodes, pObj );
// add unit cut if needed
pCut = pCutSet;
pCut->fUsed = 1;
@@ -605,6 +607,8 @@ Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj )
pCut->uTruth = 0xAAAA;
}
pCut->Value = Dar_CutFindValue( p, pCut );
+ if ( p->nCutMemUsed < Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) )
+ p->nCutMemUsed = Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20);
return pCutSet;
}
@@ -619,15 +623,16 @@ Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-void Dar_ManCutsStart( Dar_Man_t * p )
+void Dar_ManCutsRestart( Dar_Man_t * p, Aig_Obj_t * pRoot )
{
Aig_Obj_t * pObj;
int i;
- Aig_ManCleanData( p->pAig );
+ Vec_PtrForEachEntry( p->vCutNodes, pObj, i )
+ if ( !Aig_ObjIsNone(pObj) )
+ Dar_ObjSetCuts( pObj, NULL );
+ Vec_PtrClear( p->vCutNodes );
Aig_MmFixedRestart( p->pMemCuts );
Dar_ObjPrepareCuts( p, Aig_ManConst1(p->pAig) );
- Aig_ManForEachPi( p->pAig, pObj, i )
- Dar_ObjPrepareCuts( p, pObj );
}
/**Function*************************************************************
@@ -725,6 +730,8 @@ Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Aig_Obj_t * pObj )
{
if ( Dar_ObjCuts(pObj) )
return Dar_ObjCuts(pObj);
+ if ( Aig_ObjIsPi(pObj) )
+ return Dar_ObjPrepareCuts( p, pObj );
if ( Aig_ObjIsBuf(pObj) )
return Dar_ObjComputeCuts_rec( p, Aig_ObjFanin0(pObj) );
Dar_ObjComputeCuts_rec( p, Aig_ObjFanin0(pObj) );
diff --git a/src/aig/dar/darData.c b/src/aig/dar/darData.c
index cb403b8a..e644c92b 100644
--- a/src/aig/dar/darData.c
+++ b/src/aig/dar/darData.c
@@ -11174,7 +11174,7 @@ void Aig_NtkGenerateArrays( Abc_Ntk_t * pNtk )
pObj->pCopy = (void *)Count++;
Pos = 0;
- pBuffer = ALLOC( char, 200000 );
+ pBuffer = ABC_ALLOC( char, 200000 );
Abc_AigForEachAnd( pNtk, pObj, i )
{
pObj->pCopy = (void *)Count++;
@@ -11250,7 +11250,7 @@ void Aig_NtkGenerateArrays( Abc_Ntk_t * pNtk )
Vec_IntSort( vOuts, 0 );
Pos = 0;
- pBuffer = ALLOC( char, 50000 );
+ pBuffer = ABC_ALLOC( char, 50000 );
Prev = 0;
Vec_IntForEachEntry( vOuts, Out, i )
{
diff --git a/src/aig/dar/darInt.h b/src/aig/dar/darInt.h
index afa3bd07..0f2e8894 100644
--- a/src/aig/dar/darInt.h
+++ b/src/aig/dar/darInt.h
@@ -21,10 +21,6 @@
#ifndef __DAR_INT_H__
#define __DAR_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -44,6 +40,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -72,6 +72,7 @@ struct Dar_Man_t_
// various data members
Aig_MmFixed_t * pMemCuts; // memory manager for cuts
void * pManCnf; // CNF managers
+ Vec_Ptr_t * vCutNodes; // the nodes with cuts allocated
// current rewriting step
Vec_Ptr_t * vLeavesBest; // the best set of leaves
int OutBest; // the best output (in the library)
@@ -130,8 +131,9 @@ static inline void Dar_ObjSetCuts( Aig_Obj_t * pObj, Dar_Cut_t * pCuts )
/*=== darBalance.c ========================================================*/
/*=== darCore.c ===========================================================*/
/*=== darCut.c ============================================================*/
-extern void Dar_ManCutsStart( Dar_Man_t * p );
+extern void Dar_ManCutsRestart( Dar_Man_t * p, Aig_Obj_t * pRoot );
extern void Dar_ManCutsFree( Dar_Man_t * p );
+extern Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj );
extern Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Aig_Obj_t * pObj );
extern Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Aig_Obj_t * pObj );
extern void Dar_ObjCutPrint( Aig_Man_t * p, Aig_Obj_t * pObj );
diff --git a/src/aig/dar/darLib.c b/src/aig/dar/darLib.c
index 24693df2..c5fd4696 100644
--- a/src/aig/dar/darLib.c
+++ b/src/aig/dar/darLib.c
@@ -123,11 +123,11 @@ Dar_Lib_t * Dar_LibAlloc( int nObjs )
unsigned uTruths[4] = { 0xAAAA, 0xCCCC, 0xF0F0, 0xFF00 };
Dar_Lib_t * p;
int i;//, clk = clock();
- p = ALLOC( Dar_Lib_t, 1 );
+ p = ABC_ALLOC( Dar_Lib_t, 1 );
memset( p, 0, sizeof(Dar_Lib_t) );
// allocate objects
p->nObjs = nObjs;
- p->pObjs = ALLOC( Dar_LibObj_t, nObjs );
+ p->pObjs = ABC_ALLOC( Dar_LibObj_t, nObjs );
memset( p->pObjs, 0, sizeof(Dar_LibObj_t) * nObjs );
// allocate canonical data
p->pPerms4 = Dar_Permutations( 4 );
@@ -139,7 +139,7 @@ Dar_Lib_t * Dar_LibAlloc( int nObjs )
p->pObjs[i].fTerm = 1;
p->pObjs[i].Num = uTruths[i];
}
-// PRT( "Library start", clock() - clk );
+// ABC_PRT( "Library start", clock() - clk );
return p;
}
@@ -156,21 +156,21 @@ Dar_Lib_t * Dar_LibAlloc( int nObjs )
***********************************************************************/
void Dar_LibFree( Dar_Lib_t * p )
{
- free( p->pObjs );
- free( p->pDatas );
- free( p->pNodesMem );
- free( p->pNodes0Mem );
- free( p->pSubgrMem );
- free( p->pSubgr0Mem );
- free( p->pPriosMem );
- FREE( p->pPlaceMem );
- FREE( p->pScoreMem );
- free( p->pPerms4 );
- free( p->puCanons );
- free( p->pPhases );
- free( p->pPerms );
- free( p->pMap );
- free( p );
+ ABC_FREE( p->pObjs );
+ ABC_FREE( p->pDatas );
+ ABC_FREE( p->pNodesMem );
+ ABC_FREE( p->pNodes0Mem );
+ ABC_FREE( p->pSubgrMem );
+ ABC_FREE( p->pSubgr0Mem );
+ ABC_FREE( p->pPriosMem );
+ ABC_FREE( p->pPlaceMem );
+ ABC_FREE( p->pScoreMem );
+ ABC_FREE( p->pPerms4 );
+ ABC_FREE( p->puCanons );
+ ABC_FREE( p->pPhases );
+ ABC_FREE( p->pPerms );
+ ABC_FREE( p->pMap );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -275,8 +275,8 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios )
p->nSubgr[Class]++;
}
// allocate memory for the roots of each class
- p->pSubgrMem = ALLOC( int, Vec_IntSize(vOuts) );
- p->pSubgr0Mem = ALLOC( int, Vec_IntSize(vOuts) );
+ p->pSubgrMem = ABC_ALLOC( int, Vec_IntSize(vOuts) );
+ p->pSubgr0Mem = ABC_ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
@@ -298,7 +298,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios )
if ( fTraining )
{
// allocate memory for the priority of roots of each class
- p->pPriosMem = ALLOC( int, Vec_IntSize(vOuts) );
+ p->pPriosMem = ABC_ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
@@ -311,7 +311,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios )
assert( p->nSubgrTotal == Vec_IntSize(vOuts) );
// allocate memory for the priority of roots of each class
- p->pPlaceMem = ALLOC( int, Vec_IntSize(vOuts) );
+ p->pPlaceMem = ABC_ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
@@ -324,7 +324,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios )
assert( p->nSubgrTotal == Vec_IntSize(vOuts) );
// allocate memory for the priority of roots of each class
- p->pScoreMem = ALLOC( int, Vec_IntSize(vOuts) );
+ p->pScoreMem = ABC_ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
@@ -340,7 +340,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios )
{
int Counter = 0;
// allocate memory for the priority of roots of each class
- p->pPriosMem = ALLOC( int, Vec_IntSize(vOuts) );
+ p->pPriosMem = ABC_ALLOC( int, Vec_IntSize(vOuts) );
p->nSubgrTotal = 0;
for ( i = 0; i < 222; i++ )
{
@@ -366,8 +366,8 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios )
for ( i = 0; i < 222; i++ )
p->nNodesTotal += p->nNodes[i];
// allocate memory for the nodes of each class
- p->pNodesMem = ALLOC( int, p->nNodesTotal );
- p->pNodes0Mem = ALLOC( int, p->nNodesTotal );
+ p->pNodesMem = ABC_ALLOC( int, p->nNodesTotal );
+ p->pNodes0Mem = ABC_ALLOC( int, p->nNodesTotal );
p->nNodesTotal = 0;
for ( i = 0; i < 222; i++ )
{
@@ -409,10 +409,10 @@ void Dar_LibCreateData( Dar_Lib_t * p, int nDatas )
{
if ( p->nDatas == nDatas )
return;
- FREE( p->pDatas );
+ ABC_FREE( p->pDatas );
// allocate datas
p->nDatas = nDatas;
- p->pDatas = ALLOC( Dar_LibDat_t, nDatas );
+ p->pDatas = ABC_ALLOC( Dar_LibDat_t, nDatas );
memset( p->pDatas, 0, sizeof(Dar_LibDat_t) * nDatas );
}
@@ -572,7 +572,7 @@ void Dar_LibStart()
assert( s_DarLib == NULL );
s_DarLib = Dar_LibRead();
// printf( "The 4-input library started with %d nodes and %d subgraphs. ", s_DarLib->nObjs - 4, s_DarLib->nSubgrTotal );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
}
/**Function*************************************************************
diff --git a/src/aig/dar/darMan.c b/src/aig/dar/darMan.c
index 9ab504c0..b11d3175 100644
--- a/src/aig/dar/darMan.c
+++ b/src/aig/dar/darMan.c
@@ -42,14 +42,13 @@
Dar_Man_t * Dar_ManStart( Aig_Man_t * pAig, Dar_RwrPar_t * pPars )
{
Dar_Man_t * p;
- // start the manager
- p = ALLOC( Dar_Man_t, 1 );
+ Aig_ManCleanData( pAig );
+ p = ABC_ALLOC( Dar_Man_t, 1 );
memset( p, 0, sizeof(Dar_Man_t) );
p->pPars = pPars;
p->pAig = pAig;
- // prepare the internal memory manager
+ p->vCutNodes = Vec_PtrAlloc( 1000 );
p->pMemCuts = Aig_MmFixedStart( p->pPars->nCutsMax * sizeof(Dar_Cut_t), 1024 );
- // other data
p->vLeavesBest = Vec_PtrAlloc( 4 );
return p;
}
@@ -69,11 +68,13 @@ void Dar_ManStop( Dar_Man_t * p )
{
if ( p->pPars->fVerbose )
Dar_ManPrintStats( p );
+ if ( p->vCutNodes )
+ Vec_PtrFree( p->vCutNodes );
if ( p->pMemCuts )
Aig_MmFixedStop( p->pMemCuts, 0 );
if ( p->vLeavesBest )
Vec_PtrFree( p->vLeavesBest );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -102,10 +103,10 @@ void Dar_ManPrintStats( Dar_Man_t * p )
printf( "Bufs = %5d. BufMax = %5d. BufReplace = %6d. BufFix = %6d. Levels = %4d.\n",
Aig_ManBufNum(p->pAig), p->pAig->nBufMax, p->pAig->nBufReplaces, p->pAig->nBufFixes, Aig_ManLevels(p->pAig) );
- PRT( "Cuts ", p->timeCuts );
- PRT( "Eval ", p->timeEval );
- PRT( "Other ", p->timeOther );
- PRT( "TOTAL ", p->timeTotal );
+ ABC_PRT( "Cuts ", p->timeCuts );
+ ABC_PRT( "Eval ", p->timeEval );
+ ABC_PRT( "Other ", p->timeOther );
+ ABC_PRT( "TOTAL ", p->timeTotal );
if ( !p->pPars->fVeryVerbose )
return;
@@ -119,7 +120,7 @@ void Dar_ManPrintStats( Dar_Man_t * p )
printf( "S = %8d (%5.2f %%) ", p->ClassSubgs[i], p->nTotalSubgs? 100.0*p->ClassSubgs[i]/p->nTotalSubgs : 0.0 );
printf( "R = %7d ", p->ClassGains[i]? p->ClassSubgs[i]/p->ClassGains[i] : 9999999 );
// Kit_DsdPrintFromTruth( pCanons + i, 4 );
-// PRTP( "T", p->ClassTimes[i], p->timeEval );
+// ABC_PRTP( "T", p->ClassTimes[i], p->timeEval );
printf( "\n" );
}
fflush( stdout );
diff --git a/src/aig/dar/darPrec.c b/src/aig/dar/darPrec.c
index 8c3a4ce3..85a31dfc 100644
--- a/src/aig/dar/darPrec.c
+++ b/src/aig/dar/darPrec.c
@@ -45,7 +45,7 @@ char ** Dar_ArrayAlloc( int nCols, int nRows, int Size )
char * pBuffer;
int i;
assert( nCols > 0 && nRows > 0 && Size > 0 );
- pBuffer = ALLOC( char, nCols * (sizeof(void *) + nRows * Size) );
+ pBuffer = ABC_ALLOC( char, nCols * (sizeof(void *) + nRows * Size) );
pRes = (char **)pBuffer;
pRes[0] = pBuffer + nCols * sizeof(void *);
for ( i = 1; i < nCols; i++ )
@@ -130,8 +130,8 @@ void Dar_Permutations_rec( char ** pRes, int nFact, int n, char Array[] )
Description [The number of permutations in the array is n!. The number of
entries in each permutation is n. Therefore, the resulting array is a
- two-dimentional array of the size: n! x n. To free the resulting array,
- call free() on the pointer returned by this procedure.]
+ two-dimentional array of the size: n! x n. To ABC_FREE the resulting array,
+ call ABC_FREE() on the pointer returned by this procedure.]
SideEffects []
@@ -210,8 +210,8 @@ unsigned Dar_TruthPermute( unsigned Truth, char * pPerms, int nVars, int fRevers
assert( nVars < 6 );
nMints = (1 << nVars);
- pMints = ALLOC( int, nMints );
- pMintsP = ALLOC( int, nMints );
+ pMints = ABC_ALLOC( int, nMints );
+ pMintsP = ABC_ALLOC( int, nMints );
for ( i = 0; i < nMints; i++ )
pMints[i] = i;
@@ -231,8 +231,8 @@ unsigned Dar_TruthPermute( unsigned Truth, char * pPerms, int nVars, int fRevers
Result |= (1 << pMintsP[m]);
}
- free( pMints );
- free( pMintsP );
+ ABC_FREE( pMints );
+ ABC_FREE( pMintsP );
return Result;
}
@@ -297,10 +297,10 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP
int i, k;
nFuncs = (1 << 16);
- uCanons = ALLOC( unsigned short, nFuncs );
- uPhases = ALLOC( char, nFuncs );
- uPerms = ALLOC( char, nFuncs );
- uMap = ALLOC( unsigned char, nFuncs );
+ uCanons = ABC_ALLOC( unsigned short, nFuncs );
+ uPhases = ABC_ALLOC( char, nFuncs );
+ uPerms = ABC_ALLOC( char, nFuncs );
+ uMap = ABC_ALLOC( unsigned char, nFuncs );
memset( uCanons, 0, sizeof(unsigned short) * nFuncs );
memset( uPhases, 0, sizeof(char) * nFuncs );
memset( uPerms, 0, sizeof(char) * nFuncs );
@@ -361,23 +361,23 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP
}
uPhases[(1<<16)-1] = 16;
assert( nClasses == 222 );
- free( pPerms4 );
+ ABC_FREE( pPerms4 );
if ( puCanons )
*puCanons = uCanons;
else
- free( uCanons );
+ ABC_FREE( uCanons );
if ( puPhases )
*puPhases = uPhases;
else
- free( uPhases );
+ ABC_FREE( uPhases );
if ( puPerms )
*puPerms = uPerms;
else
- free( uPerms );
+ ABC_FREE( uPerms );
if ( puMap )
*puMap = uMap;
else
- free( uMap );
+ ABC_FREE( uMap );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/dar/darRefact.c b/src/aig/dar/darRefact.c
index ecf032be..f0173a3c 100644
--- a/src/aig/dar/darRefact.c
+++ b/src/aig/dar/darRefact.c
@@ -106,7 +106,7 @@ Ref_Man_t * Dar_ManRefStart( Aig_Man_t * pAig, Dar_RefPar_t * pPars )
{
Ref_Man_t * p;
// start the manager
- p = ALLOC( Ref_Man_t, 1 );
+ p = ABC_ALLOC( Ref_Man_t, 1 );
memset( p, 0, sizeof(Ref_Man_t) );
p->pAig = pAig;
p->pPars = pPars;
@@ -143,10 +143,10 @@ void Dar_ManRefPrintStats( Ref_Man_t * p )
p->nNodesInit, Aig_ManNodeNum(p->pAig), Gain, 100.0*Gain/p->nNodesInit );
printf( "Tried = %6d. Below = %5d. Extended = %5d. Used = %5d. Levels = %4d.\n",
p->nNodesTried, p->nNodesBelow, p->nNodesExten, p->nCutsUsed, Aig_ManLevels(p->pAig) );
- PRT( "Cuts ", p->timeCuts );
- PRT( "Eval ", p->timeEval );
- PRT( "Other ", p->timeOther );
- PRT( "TOTAL ", p->timeTotal );
+ ABC_PRT( "Cuts ", p->timeCuts );
+ ABC_PRT( "Eval ", p->timeEval );
+ ABC_PRT( "Other ", p->timeOther );
+ ABC_PRT( "TOTAL ", p->timeTotal );
}
/**Function*************************************************************
@@ -172,7 +172,7 @@ void Dar_ManRefStop( Ref_Man_t * p )
Vec_PtrFree( p->vLeavesBest );
Vec_IntFree( p->vMemory );
Vec_PtrFree( p->vCutNodes );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/dar/darScript.c b/src/aig/dar/darScript.c
index 6df776e6..383b5b6b 100644
--- a/src/aig/dar/darScript.c
+++ b/src/aig/dar/darScript.c
@@ -401,7 +401,7 @@ clk = clock();
if ( fVerbose )
{
-PRT( "Synthesis time", clock() - clk );
+ABC_PRT( "Synthesis time", clock() - clk );
}
clk = clock();
if ( fConstruct )
@@ -413,7 +413,7 @@ clk = clock();
Vec_PtrFree( vAigs );
if ( fVerbose )
{
-PRT( "Choicing time ", clock() - clk );
+ABC_PRT( "Choicing time ", clock() - clk );
}
return pMan;
// return NULL;
@@ -458,7 +458,7 @@ clk = clock();
if ( fVerbose )
{
-PRT( "Synthesis time", clock() - clk );
+ABC_PRT( "Synthesis time", clock() - clk );
}
// pPars->timeSynth = clock() - clk;
@@ -493,7 +493,7 @@ clk = clock();
if ( fVerbose )
{
-//PRT( "Choicing time ", clock() - clk );
+//ABC_PRT( "Choicing time ", clock() - clk );
}
return pMan;
// return NULL;
diff --git a/src/aig/dch/dch.h b/src/aig/dch/dch.h
index d0092a5f..a5a56da6 100644
--- a/src/aig/dch/dch.h
+++ b/src/aig/dch/dch.h
@@ -21,10 +21,6 @@
#ifndef __DCH_H__
#define __DCH_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/dch/dchChoice.c b/src/aig/dch/dchChoice.c
index 19689051..019f4ec4 100644
--- a/src/aig/dch/dchChoice.c
+++ b/src/aig/dch/dchChoice.c
@@ -247,8 +247,8 @@ Aig_Man_t * Dch_DeriveChoiceAig( Aig_Man_t * pAig )
int i;
// start recording equivalences
pChoices = Aig_ManStart( Aig_ManObjNumMax(pAig) );
- pChoices->pEquivs = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
- pChoices->pReprs = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ pChoices->pEquivs = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ pChoices->pReprs = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
// map constants and PIs
Aig_ManCleanData( pAig );
Aig_ManConst1(pAig)->pData = Aig_ManConst1(pChoices);
@@ -262,7 +262,7 @@ Aig_Man_t * Dch_DeriveChoiceAig( Aig_Man_t * pAig )
Aig_ObjCreatePo( pChoices, Aig_ObjChild0CopyRepr(pChoices, pObj) );
Dch_DeriveChoiceCountEquivs( pChoices );
// there is no need for cleanup
- FREE( pChoices->pReprs );
+ ABC_FREE( pChoices->pReprs );
pChoices = Aig_ManDupDfs( pTemp = pChoices );
Aig_ManStop( pTemp );
return pChoices;
diff --git a/src/aig/dch/dchClass.c b/src/aig/dch/dchClass.c
index 5d042847..d8fbe8ed 100644
--- a/src/aig/dch/dchClass.c
+++ b/src/aig/dch/dchClass.c
@@ -134,11 +134,11 @@ static inline Aig_Obj_t ** Dch_ObjRemoveClass( Dch_Cla_t * p, Aig_Obj_t * pRepr
Dch_Cla_t * Dch_ClassesStart( Aig_Man_t * pAig )
{
Dch_Cla_t * p;
- p = ALLOC( Dch_Cla_t, 1 );
+ p = ABC_ALLOC( Dch_Cla_t, 1 );
memset( p, 0, sizeof(Dch_Cla_t) );
p->pAig = pAig;
- p->pId2Class = CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) );
- p->pClassSizes = CALLOC( int, Aig_ManObjNumMax(pAig) );
+ p->pId2Class = ABC_CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) );
+ p->pClassSizes = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) );
p->vClassOld = Vec_PtrAlloc( 100 );
p->vClassNew = Vec_PtrAlloc( 100 );
assert( pAig->pReprs == NULL );
@@ -183,10 +183,10 @@ void Dch_ClassesStop( Dch_Cla_t * p )
{
if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
- FREE( p->pId2Class );
- FREE( p->pClassSizes );
- FREE( p->pMemClasses );
- free( p );
+ ABC_FREE( p->pId2Class );
+ ABC_FREE( p->pClassSizes );
+ ABC_FREE( p->pMemClasses );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -338,8 +338,8 @@ void Dch_ClassesPrepare( Dch_Cla_t * p, int fLatchCorr, int nMaxLevs )
// allocate the hash table hashing simulation info into nodes
nTableSize = Aig_PrimeCudd( Aig_ManObjNumMax(p->pAig)/4 );
- ppTable = CALLOC( Aig_Obj_t *, nTableSize );
- ppNexts = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
+ ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize );
+ ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
// add all the nodes to the hash table
nEntries = 0;
@@ -390,7 +390,7 @@ void Dch_ClassesPrepare( Dch_Cla_t * p, int fLatchCorr, int nMaxLevs )
}
// allocate room for classes
- p->pMemClasses = ALLOC( Aig_Obj_t *, nEntries + p->nCands1 );
+ p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, nEntries + p->nCands1 );
p->pMemClassesFree = p->pMemClasses + nEntries;
// copy the entries into storage in the topological order
@@ -419,8 +419,8 @@ void Dch_ClassesPrepare( Dch_Cla_t * p, int fLatchCorr, int nMaxLevs )
nEntries2 += nNodes;
}
assert( nEntries == nEntries2 );
- free( ppTable );
- free( ppNexts );
+ ABC_FREE( ppTable );
+ ABC_FREE( ppNexts );
// now it is time to refine the classes
Dch_ClassesRefine( p );
Dch_ClassesCheck( p );
diff --git a/src/aig/dch/dchCnf.c b/src/aig/dch/dchCnf.c
index dc822d77..81fc2f2c 100644
--- a/src/aig/dch/dchCnf.c
+++ b/src/aig/dch/dchCnf.c
@@ -166,7 +166,7 @@ void Dch_AddClausesSuper( Dch_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
assert( Aig_ObjIsNode( pNode ) );
// create storage for literals
nLits = Vec_PtrSize(vSuper) + 1;
- pLits = ALLOC( int, nLits );
+ pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
Vec_PtrForEachEntry( vSuper, pFanin, i )
@@ -197,7 +197,7 @@ void Dch_AddClausesSuper( Dch_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
}
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
assert( RetValue );
- free( pLits );
+ ABC_FREE( pLits );
}
/**Function*************************************************************
diff --git a/src/aig/dch/dchCore.c b/src/aig/dch/dchCore.c
index 27c039cf..8e854355 100644
--- a/src/aig/dch/dchCore.c
+++ b/src/aig/dch/dchCore.c
@@ -93,7 +93,7 @@ p->timeChoice = clock() - clk;
// pResult = Aig_ManDupSimpleDfs( p->pAigTotal );
// count the number of equivalences and choices
p->nEquivs = Dch_DeriveChoiceCountEquivs( pResult );
- p->nChoices = Aig_ManCountChoices( pResult );
+ p->nChoices = Aig_ManChoiceNum( pResult );
p->timeTotal = clock() - clkTotal;
Dch_ManStop( p );
return pResult;
diff --git a/src/aig/dch/dchInt.h b/src/aig/dch/dchInt.h
index e9a6f2e4..4e6315a4 100644
--- a/src/aig/dch/dchInt.h
+++ b/src/aig/dch/dchInt.h
@@ -21,10 +21,6 @@
#ifndef __DCH_INT_H__
#define __DCH_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,6 +33,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/dch/dchMan.c b/src/aig/dch/dchMan.c
index a5faa2a6..caed0ed5 100644
--- a/src/aig/dch/dchMan.c
+++ b/src/aig/dch/dchMan.c
@@ -43,7 +43,7 @@ Dch_Man_t * Dch_ManCreate( Vec_Ptr_t * vAigs, Dch_Pars_t * pPars )
{
Dch_Man_t * p;
// create interpolation manager
- p = ALLOC( Dch_Man_t, 1 );
+ p = ABC_ALLOC( Dch_Man_t, 1 );
memset( p, 0, sizeof(Dch_Man_t) );
p->pPars = pPars;
p->vAigs = vAigs;
@@ -51,13 +51,13 @@ Dch_Man_t * Dch_ManCreate( Vec_Ptr_t * vAigs, Dch_Pars_t * pPars )
Aig_ManFanoutStart( p->pAigTotal );
// SAT solving
p->nSatVars = 1;
- p->pSatVars = CALLOC( int, Aig_ManObjNumMax(p->pAigTotal) );
+ p->pSatVars = ABC_CALLOC( int, Aig_ManObjNumMax(p->pAigTotal) );
p->vUsedNodes = Vec_PtrAlloc( 1000 );
p->vFanins = Vec_PtrAlloc( 100 );
p->vSimRoots = Vec_PtrAlloc( 1000 );
p->vSimClasses = Vec_PtrAlloc( 1000 );
// equivalences proved
- p->pReprsProved = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAigTotal) );
+ p->pReprsProved = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAigTotal) );
return p;
}
@@ -95,18 +95,18 @@ void Dch_ManPrintStats( Dch_Man_t * p )
p->nLits, p->nReprs, p->nEquivs, p->nChoices );
printf( "Choicing runtime statistics:\n" );
p->timeOther = p->timeTotal-p->timeSimInit-p->timeSimSat-p->timeSat-p->timeChoice;
- PRTP( "Sim init ", p->timeSimInit, p->timeTotal );
- PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal );
- PRTP( "SAT solving", p->timeSat, p->timeTotal );
- PRTP( " sat ", p->timeSatSat, p->timeTotal );
- PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
- PRTP( " undecided", p->timeSatUndec, p->timeTotal );
- PRTP( "Choice ", p->timeChoice, p->timeTotal );
- PRTP( "Other ", p->timeOther, p->timeTotal );
- PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+ ABC_PRTP( "Sim init ", p->timeSimInit, p->timeTotal );
+ ABC_PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal );
+ ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal );
+ ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal );
+ ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
+ ABC_PRTP( " undecided", p->timeSatUndec, p->timeTotal );
+ ABC_PRTP( "Choice ", p->timeChoice, p->timeTotal );
+ ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
+ ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
if ( p->pPars->timeSynth )
{
- PRT( "Synthesis ", p->pPars->timeSynth );
+ ABC_PRT( "Synthesis ", p->pPars->timeSynth );
}
}
@@ -137,9 +137,9 @@ void Dch_ManStop( Dch_Man_t * p )
Vec_PtrFree( p->vFanins );
Vec_PtrFree( p->vSimRoots );
Vec_PtrFree( p->vSimClasses );
- FREE( p->pReprsProved );
- FREE( p->pSatVars );
- free( p );
+ ABC_FREE( p->pReprsProved );
+ ABC_FREE( p->pSatVars );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/dch/dchSat.c b/src/aig/dch/dchSat.c
index 07196259..6966e635 100644
--- a/src/aig/dch/dchSat.c
+++ b/src/aig/dch/dchSat.c
@@ -83,7 +83,7 @@ int Dch_NodesAreEquiv( Dch_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
clk = clock();
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
{
@@ -125,7 +125,7 @@ p->timeSatUndec += clock() - clk;
}
clk = clock();
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
{
diff --git a/src/aig/dch/dchSweep.c b/src/aig/dch/dchSweep.c
index 36c5fc33..afaf7426 100644
--- a/src/aig/dch/dchSweep.c
+++ b/src/aig/dch/dchSweep.c
@@ -127,7 +127,7 @@ void Dch_ManSweep( Dch_Man_t * p )
}
Bar_ProgressStop( pProgress );
// update the representatives of the nodes (makes classes invalid)
- FREE( p->pAigTotal->pReprs );
+ ABC_FREE( p->pAigTotal->pReprs );
p->pAigTotal->pReprs = p->pReprsProved;
p->pReprsProved = NULL;
// clean the mark
diff --git a/src/aig/deco/deco.h b/src/aig/deco/deco.h
index 67126902..07afd15c 100644
--- a/src/aig/deco/deco.h
+++ b/src/aig/deco/deco.h
@@ -21,10 +21,6 @@
#ifndef __DEC_H__
#define __DEC_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -201,12 +201,12 @@ static inline Dec_Edge_t Dec_IntToEdge_( unsigned Edge )
static inline Dec_Graph_t * Dec_GraphCreate( int nLeaves )
{
Dec_Graph_t * pGraph;
- pGraph = ALLOC( Dec_Graph_t, 1 );
+ pGraph = ABC_ALLOC( Dec_Graph_t, 1 );
memset( pGraph, 0, sizeof(Dec_Graph_t) );
pGraph->nLeaves = nLeaves;
pGraph->nSize = nLeaves;
pGraph->nCap = 2 * nLeaves + 50;
- pGraph->pNodes = ALLOC( Dec_Node_t, pGraph->nCap );
+ pGraph->pNodes = ABC_ALLOC( Dec_Node_t, pGraph->nCap );
memset( pGraph->pNodes, 0, sizeof(Dec_Node_t) * pGraph->nSize );
return pGraph;
}
@@ -225,7 +225,7 @@ static inline Dec_Graph_t * Dec_GraphCreate( int nLeaves )
static inline Dec_Graph_t * Dec_GraphCreateConst0()
{
Dec_Graph_t * pGraph;
- pGraph = ALLOC( Dec_Graph_t, 1 );
+ pGraph = ABC_ALLOC( Dec_Graph_t, 1 );
memset( pGraph, 0, sizeof(Dec_Graph_t) );
pGraph->fConst = 1;
pGraph->eRoot.fCompl = 1;
@@ -246,7 +246,7 @@ static inline Dec_Graph_t * Dec_GraphCreateConst0()
static inline Dec_Graph_t * Dec_GraphCreateConst1()
{
Dec_Graph_t * pGraph;
- pGraph = ALLOC( Dec_Graph_t, 1 );
+ pGraph = ABC_ALLOC( Dec_Graph_t, 1 );
memset( pGraph, 0, sizeof(Dec_Graph_t) );
pGraph->fConst = 1;
return pGraph;
@@ -286,8 +286,8 @@ static inline Dec_Graph_t * Dec_GraphCreateLeaf( int iLeaf, int nLeaves, int fCo
***********************************************************************/
static inline void Dec_GraphFree( Dec_Graph_t * pGraph )
{
- FREE( pGraph->pNodes );
- free( pGraph );
+ ABC_FREE( pGraph->pNodes );
+ ABC_FREE( pGraph );
}
/**Function*************************************************************
@@ -549,7 +549,7 @@ static inline Dec_Node_t * Dec_GraphAppendNode( Dec_Graph_t * pGraph )
Dec_Node_t * pNode;
if ( pGraph->nSize == pGraph->nCap )
{
- pGraph->pNodes = REALLOC( Dec_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
+ pGraph->pNodes = ABC_REALLOC( Dec_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
pGraph->nCap = 2 * pGraph->nCap;
}
pNode = pGraph->pNodes + pGraph->nSize++;
diff --git a/src/aig/fra/fra.h b/src/aig/fra/fra.h
index e7cd0550..a2c10367 100644
--- a/src/aig/fra/fra.h
+++ b/src/aig/fra/fra.h
@@ -21,10 +21,6 @@
#ifndef __FRA_H__
#define __FRA_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -45,6 +41,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -215,8 +215,8 @@ struct Fra_Man_t_
sat_solver * pSat; // SAT solver
int nSatVars; // the number of variables currently used
Vec_Ptr_t * vPiVars; // the PIs of the cone used
- sint64 nBTLimitGlobal; // resource limit
- sint64 nInsLimitGlobal; // resource limit
+ ABC_INT64_T nBTLimitGlobal; // resource limit
+ ABC_INT64_T nInsLimitGlobal; // resource limit
Vec_Ptr_t ** pMemFanins; // the arrays of fanins for some FRAIG nodes
int * pMemSatNums; // the array of SAT numbers for some FRAIG nodes
int nMemAlloc; // allocated size of the arrays for FRAIG varnums and fanins
@@ -290,7 +290,7 @@ static inline int Fra_ImpCreate( int Left, int Right )
////////////////////////////////////////////////////////////////////////
/*=== fraCec.c ========================================================*/
-extern int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFlipBits, int fAndOuts, int fVerbose );
+extern int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fFlipBits, int fAndOuts, int fVerbose );
extern int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose );
extern int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimit, int nPartSize, int fSmart, int fVerbose );
/*=== fraClass.c ========================================================*/
@@ -376,7 +376,7 @@ extern void Fra_SmlSimulate( Fra_Man_t * p, int fInit );
extern void Fra_SmlResimulate( Fra_Man_t * p );
extern Fra_Sml_t * Fra_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFrame );
extern void Fra_SmlStop( Fra_Sml_t * p );
-extern Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords );
+extern Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords, int fCheckMiter );
extern Fra_Sml_t * Fra_SmlSimulateComb( Aig_Man_t * pAig, int nWords );
extern Fra_Cex_t * Fra_SmlGetCounterExample( Fra_Sml_t * p );
extern Fra_Cex_t * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel );
diff --git a/src/aig/fra/fraBmc.c b/src/aig/fra/fraBmc.c
index 411ca2c1..689d7d67 100644
--- a/src/aig/fra/fraBmc.c
+++ b/src/aig/fra/fraBmc.c
@@ -188,13 +188,13 @@ void Fra_BmcFilterImplications( Fra_Man_t * p, Fra_Bmc_t * pBmc )
Fra_Bmc_t * Fra_BmcStart( Aig_Man_t * pAig, int nPref, int nDepth )
{
Fra_Bmc_t * p;
- p = ALLOC( Fra_Bmc_t, 1 );
+ p = ABC_ALLOC( Fra_Bmc_t, 1 );
memset( p, 0, sizeof(Fra_Bmc_t) );
p->pAig = pAig;
p->nPref = nPref;
p->nDepth = nDepth;
p->nFramesAll = nPref + nDepth;
- p->pObjToFrames = ALLOC( Aig_Obj_t *, p->nFramesAll * Aig_ManObjNumMax(pAig) );
+ p->pObjToFrames = ABC_ALLOC( Aig_Obj_t *, p->nFramesAll * Aig_ManObjNumMax(pAig) );
memset( p->pObjToFrames, 0, sizeof(Aig_Obj_t *) * p->nFramesAll * Aig_ManObjNumMax(pAig) );
return p;
}
@@ -215,9 +215,9 @@ void Fra_BmcStop( Fra_Bmc_t * p )
Aig_ManStop( p->pAigFrames );
if ( p->pAigFraig )
Aig_ManStop( p->pAigFraig );
- free( p->pObjToFrames );
- free( p->pObjToFraig );
- free( p );
+ ABC_FREE( p->pObjToFrames );
+ ABC_FREE( p->pObjToFraig );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -253,7 +253,7 @@ Aig_Man_t * Fra_BmcFrames( Fra_Bmc_t * p, int fKeepPos )
Bmc_ObjSetFrames( pObj, 0, Aig_ManConst0(pAigFrames) );
// add timeframes
- pLatches = ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
+ pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
for ( f = 0; f < p->nFramesAll; f++ )
{
// add internal nodes of this frame
@@ -275,7 +275,7 @@ Aig_Man_t * Fra_BmcFrames( Fra_Bmc_t * p, int fKeepPos )
Bmc_ObjSetFrames( pObj, f+1, pLatches[k++] );
assert( k == Aig_ManRegNum(p->pAig) );
}
- free( pLatches );
+ ABC_FREE( pLatches );
if ( fKeepPos )
{
for ( f = 0; f < p->nFramesAll; f++ )
@@ -333,7 +333,7 @@ void Fra_BmcPerform( Fra_Man_t * p, int nPref, int nDepth )
printf( "Original AIG = %d. Init %d frames = %d. Fraig = %d. ",
Aig_ManNodeNum(p->pBmc->pAig), p->pBmc->nFramesAll,
Aig_ManNodeNum(p->pBmc->pAigFrames), Aig_ManNodeNum(p->pBmc->pAigFraig) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
printf( "Before BMC: " );
// Fra_ClassesPrint( p->pCla, 0 );
printf( "Const = %5d. Class = %5d. Lit = %5d. ",
@@ -360,7 +360,7 @@ void Fra_BmcPerform( Fra_Man_t * p, int nPref, int nDepth )
printf( "Imp = %5d. ", Vec_IntSize(p->pCla->vImps) );
printf( "\n" );
}
- // free the BMC manager
+ // ABC_FREE the BMC manager
Fra_BmcStop( p->pBmc );
p->pBmc = NULL;
}
@@ -397,7 +397,7 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew
printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ",
nFrames, Aig_ManPiNum(pBmc->pAigFrames), Aig_ManPoNum(pBmc->pAigFrames),
Aig_ManNodeNum(pBmc->pAigFrames), Aig_ManLevelNum(pBmc->pAigFrames) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
if ( fRewrite )
{
@@ -408,7 +408,7 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew
{
printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ",
Aig_ManNodeNum(pBmc->pAigFrames), Aig_ManLevelNum(pBmc->pAigFrames) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
}
clk = clock();
@@ -422,7 +422,7 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew
if ( pBmc->pAigFraig->pData )
{
pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pBmc->pAigFrames, pBmc->pAigFraig->pData );
- FREE( pBmc->pAigFraig->pData );
+ ABC_FREE( pBmc->pAigFraig->pData );
}
else if ( iOutput >= 0 )
pAig->pSeqModel = Fra_SmlTrivCounterExample( pAig, iOutput );
@@ -432,10 +432,10 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew
printf( "Fraiged init frames: Node = %6d. Lev = %5d. ",
pBmc->pAigFraig? Aig_ManNodeNum(pBmc->pAigFraig) : -1,
pBmc->pAigFraig? Aig_ManLevelNum(pBmc->pAigFraig) : -1 );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
Fra_BmcStop( pBmc );
- free( pTemp );
+ ABC_FREE( pTemp );
}
diff --git a/src/aig/fra/fraCec.c b/src/aig/fra/fraCec.c
index 2cdf203d..0cc6748c 100644
--- a/src/aig/fra/fraCec.c
+++ b/src/aig/fra/fraCec.c
@@ -40,7 +40,7 @@
SeeAlso []
***********************************************************************/
-int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFlipBits, int fAndOuts, int fVerbose )
+int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fFlipBits, int fAndOuts, int fVerbose )
{
sat_solver * pSat;
Cnf_Dat_t * pCnf;
@@ -91,13 +91,13 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl
// printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
// simplify the problem
clk = clock();
status = sat_solver_simplify(pSat);
// printf( "Simplified the problem to %d variables and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
if ( status == 0 )
{
Vec_IntFree( vCiIds );
@@ -110,7 +110,7 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl
clk = clock();
if ( fVerbose )
pSat->verbosity = 1;
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)nInsLimit, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( status == l_Undef )
{
// printf( "The problem timed out.\n" );
@@ -128,7 +128,7 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl
}
else
assert( 0 );
-// PRT( "SAT sat_solver time", clock() - clk );
+// ABC_PRT( "SAT sat_solver time", clock() - clk );
// printf( "The number of conflicts = %d.\n", (int)pSat->sat_solver_stats.conflicts );
// if the problem is SAT, get the counterexample
@@ -136,7 +136,7 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl
{
pMan->pData = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
}
- // free the sat_solver
+ // ABC_FREE the sat_solver
if ( fVerbose )
Sat_SolverPrintStats( stdout, pSat );
//sat_solver_store_write( pSat, "trace.cnf" );
@@ -176,18 +176,18 @@ int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose )
// assert( RetValue == -1 );
if ( RetValue == 0 )
{
- pAig->pData = ALLOC( int, Aig_ManPiNum(pAig) );
+ pAig->pData = ABC_ALLOC( int, Aig_ManPiNum(pAig) );
memset( pAig->pData, 0, sizeof(int) * Aig_ManPiNum(pAig) );
return RetValue;
}
// if SAT only, solve without iteration
clk = clock();
- RetValue = Fra_FraigSat( pAig, (sint64)2*nBTLimitStart, (sint64)0, 1, 0, 0 );
+ RetValue = Fra_FraigSat( pAig, (ABC_INT64_T)2*nBTLimitStart, (ABC_INT64_T)0, 1, 0, 0 );
if ( fVerbose )
{
printf( "Initial SAT: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
if ( RetValue >= 0 )
return RetValue;
@@ -199,7 +199,7 @@ clk = clock();
if ( fVerbose )
{
printf( "Rewriting: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
// perform the loop
@@ -218,7 +218,7 @@ clk = clock();
if ( fVerbose )
{
printf( "Fraiging (i=%d): Nodes = %6d. ", i+1, Aig_ManNodeNum(pAig) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
// check the miter status
@@ -233,7 +233,7 @@ clk = clock();
if ( fVerbose )
{
printf( "Rewriting: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
// check the miter status
@@ -251,11 +251,11 @@ PRT( "Time", clock() - clk );
if ( RetValue == -1 )
{
clk = clock();
- RetValue = Fra_FraigSat( pAig, (sint64)nBTLimitLast, (sint64)0, 1, 0, 0 );
+ RetValue = Fra_FraigSat( pAig, (ABC_INT64_T)nBTLimitLast, (ABC_INT64_T)0, 1, 0, 0 );
if ( fVerbose )
{
printf( "Final SAT: Nodes = %6d. ", Aig_ManNodeNum(pAig) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
}
@@ -318,7 +318,7 @@ int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimi
printf( "Timed out after verifying %d partitions (out of %d).\n", nOutputs, Vec_PtrSize(vParts) );
fflush( stdout );
}
- // free intermediate results
+ // ABC_FREE intermediate results
Vec_PtrForEachEntry( vParts, pAig, i )
Aig_ManStop( pAig );
Vec_PtrFree( vParts );
@@ -373,17 +373,17 @@ int Fra_FraigCecTop( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimit, int n
if ( RetValue == 1 )
{
printf( "Networks are equivalent. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
else if ( RetValue == 0 )
{
printf( "Networks are NOT EQUIVALENT. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
else
{
printf( "Networks are UNDECIDED. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
fflush( stdout );
return RetValue;
diff --git a/src/aig/fra/fraClass.c b/src/aig/fra/fraClass.c
index 064d2b9c..8554b312 100644
--- a/src/aig/fra/fraClass.c
+++ b/src/aig/fra/fraClass.c
@@ -57,10 +57,10 @@ static inline void Fra_ObjSetNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pOb
Fra_Cla_t * Fra_ClassesStart( Aig_Man_t * pAig )
{
Fra_Cla_t * p;
- p = ALLOC( Fra_Cla_t, 1 );
+ p = ABC_ALLOC( Fra_Cla_t, 1 );
memset( p, 0, sizeof(Fra_Cla_t) );
p->pAig = pAig;
- p->pMemRepr = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ p->pMemRepr = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
memset( p->pMemRepr, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) );
p->vClasses = Vec_PtrAlloc( 100 );
p->vClasses1 = Vec_PtrAlloc( 100 );
@@ -86,15 +86,15 @@ Fra_Cla_t * Fra_ClassesStart( Aig_Man_t * pAig )
***********************************************************************/
void Fra_ClassesStop( Fra_Cla_t * p )
{
- FREE( p->pMemClasses );
- FREE( p->pMemRepr );
+ ABC_FREE( p->pMemClasses );
+ ABC_FREE( p->pMemRepr );
if ( p->vClassesTemp ) Vec_PtrFree( p->vClassesTemp );
if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
if ( p->vClasses1 ) Vec_PtrFree( p->vClasses1 );
if ( p->vClasses ) Vec_PtrFree( p->vClasses );
if ( p->vImps ) Vec_IntFree( p->vImps );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -278,8 +278,8 @@ void Fra_ClassesPrepare( Fra_Cla_t * p, int fLatchCorr, int nMaxLevs )
// allocate the hash table hashing simulation info into nodes
nTableSize = Aig_PrimeCudd( Aig_ManObjNumMax(p->pAig) );
- ppTable = ALLOC( Aig_Obj_t *, nTableSize );
- ppNexts = ALLOC( Aig_Obj_t *, nTableSize );
+ ppTable = ABC_ALLOC( Aig_Obj_t *, nTableSize );
+ ppNexts = ABC_ALLOC( Aig_Obj_t *, nTableSize );
memset( ppTable, 0, sizeof(Aig_Obj_t *) * nTableSize );
// add all the nodes to the hash table
@@ -338,7 +338,7 @@ void Fra_ClassesPrepare( Fra_Cla_t * p, int fLatchCorr, int nMaxLevs )
}
// allocate room for classes
- p->pMemClasses = ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) );
+ p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) );
p->pMemClassesFree = p->pMemClasses + 2*nEntries;
// copy the entries into storage in the topological order
@@ -374,8 +374,8 @@ void Fra_ClassesPrepare( Fra_Cla_t * p, int fLatchCorr, int nMaxLevs )
// increment the number of entries
nEntries += k;
}
- free( ppTable );
- free( ppNexts );
+ ABC_FREE( ppTable );
+ ABC_FREE( ppNexts );
// now it is time to refine the classes
Fra_ClassesRefine( p );
// Fra_ClassesPrint( p, 0 );
@@ -587,7 +587,7 @@ int Fra_ClassesRefine1( Fra_Cla_t * p, int fRefineNewClass, int * pSkipped )
void Fra_ClassesTest( Fra_Cla_t * p, int Id1, int Id2 )
{
Aig_Obj_t ** pClass;
- p->pMemClasses = ALLOC( Aig_Obj_t *, 4 );
+ p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 4 );
pClass = p->pMemClasses;
assert( Id1 < Id2 );
pClass[0] = Aig_ManObj( p->pAig, Id1 );
@@ -620,7 +620,7 @@ void Fra_ClassesLatchCorr( Fra_Man_t * p )
Fra_ClassObjSetRepr( pObj, Aig_ManConst1(p->pManAig) );
}
// allocate room for classes
- p->pCla->pMemClasses = ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->pCla->vClasses1)) );
+ p->pCla->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->pCla->vClasses1)) );
p->pCla->pMemClassesFree = p->pCla->pMemClasses + 2*nEntries;
}
@@ -644,7 +644,7 @@ void Fra_ClassesPostprocess( Fra_Cla_t * p )
// perform combinational simulation
pComb = Fra_SmlSimulateComb( p->pAig, 32 );
// compute the weight of each node in the classes
- pWeights = ALLOC( int, Aig_ManObjNumMax(p->pAig) );
+ pWeights = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) );
memset( pWeights, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) );
Aig_ManForEachObj( p->pAig, pObj, i )
{
@@ -686,7 +686,7 @@ void Fra_ClassesPostprocess( Fra_Cla_t * p )
Vec_PtrWriteEntry( p->vClasses, k++, ppClass );
Vec_PtrShrink( p->vClasses, k );
printf( "After: Const = %6d. Class = %6d. \n", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
- free( pWeights );
+ ABC_FREE( pWeights );
}
/**Function*************************************************************
@@ -804,13 +804,13 @@ Aig_Man_t * Fra_ClassesDeriveAig( Fra_Cla_t * p, int nFramesK )
pManFraig->pName = Aig_UtilStrsav( p->pAig->pName );
pManFraig->pSpec = Aig_UtilStrsav( p->pAig->pSpec );
// allocate place for the node mapping
- ppEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
+ ppEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
Fra_ObjSetEqu( ppEquivs, Aig_ManConst1(p->pAig), Aig_ManConst1(pManFraig) );
// create latches for the first frame
Aig_ManForEachLoSeq( p->pAig, pObj, i )
Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreatePi(pManFraig) );
// add timeframes
- pLatches = ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
+ pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
for ( f = 0; f < nFramesAll; f++ )
{
// create PIs for this frame
@@ -839,8 +839,8 @@ Aig_Man_t * Fra_ClassesDeriveAig( Fra_Cla_t * p, int nFramesK )
Aig_ManForEachLoSeq( p->pAig, pObj, i )
Fra_ObjSetEqu( ppEquivs, pObj, pLatches[k++] );
}
- free( pLatches );
- free( ppEquivs );
+ ABC_FREE( pLatches );
+ ABC_FREE( ppEquivs );
// mark the asserts
assert( Aig_ManPoNum(pManFraig) % nFramesAll == 0 );
printf( "Assert miters = %6d. Output miters = %6d.\n",
diff --git a/src/aig/fra/fraClau.c b/src/aig/fra/fraClau.c
index 919d0000..96d06380 100644
--- a/src/aig/fra/fraClau.c
+++ b/src/aig/fra/fraClau.c
@@ -152,7 +152,7 @@ int * Fra_ClauCreateMapping( Vec_Int_t * vSatVarsFrom, Vec_Int_t * vSatVarsTo, i
{
int * pMapping, Var, i;
assert( Vec_IntSize(vSatVarsFrom) == Vec_IntSize(vSatVarsTo) );
- pMapping = ALLOC( int, nVarsMax );
+ pMapping = ABC_ALLOC( int, nVarsMax );
for ( i = 0; i < nVarsMax; i++ )
pMapping[i] = -1;
Vec_IntForEachEntry( vSatVarsFrom, Var, i )
@@ -174,10 +174,10 @@ int * Fra_ClauCreateMapping( Vec_Int_t * vSatVarsFrom, Vec_Int_t * vSatVarsTo, i
***********************************************************************/
void Fra_ClauStop( Cla_Man_t * p )
{
- free( p->pMapCsMainToCsTest );
- free( p->pMapCsTestToCsMain );
- free( p->pMapCsTestToNsTest );
- free( p->pMapCsTestToNsBmc );
+ ABC_FREE( p->pMapCsMainToCsTest );
+ ABC_FREE( p->pMapCsTestToCsMain );
+ ABC_FREE( p->pMapCsTestToNsTest );
+ ABC_FREE( p->pMapCsTestToNsBmc );
Vec_IntFree( p->vSatVarsMainCs );
Vec_IntFree( p->vSatVarsTestCs );
Vec_IntFree( p->vSatVarsTestNs );
@@ -191,7 +191,7 @@ void Fra_ClauStop( Cla_Man_t * p )
if ( p->pSatMain ) sat_solver_delete( p->pSatMain );
if ( p->pSatTest ) sat_solver_delete( p->pSatTest );
if ( p->pSatBmc ) sat_solver_delete( p->pSatBmc );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -217,7 +217,7 @@ Cla_Man_t * Fra_ClauStart( Aig_Man_t * pMan )
assert( Aig_ManPoNum(pMan) - Aig_ManRegNum(pMan) == 1 );
// start the manager
- p = ALLOC( Cla_Man_t, 1 );
+ p = ABC_ALLOC( Cla_Man_t, 1 );
memset( p, 0, sizeof(Cla_Man_t) );
p->vCexMain0 = Vec_IntAlloc( Aig_ManRegNum(pMan) );
p->vCexMain = Vec_IntAlloc( Aig_ManRegNum(pMan) );
@@ -362,7 +362,7 @@ int Fra_ClauCheckProperty( Cla_Man_t * p, Vec_Int_t * vCex )
int nBTLimit = 0;
int RetValue, iVar, i;
sat_solver_act_var_clear( p->pSatMain );
- RetValue = sat_solver_solve( p->pSatMain, NULL, NULL, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSatMain, NULL, NULL, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
Vec_IntClear( vCex );
if ( RetValue == l_False )
return 1;
@@ -396,7 +396,7 @@ int Fra_ClauCheckBmc( Cla_Man_t * p, Vec_Int_t * vClause )
int nBTLimit = 0;
int RetValue;
RetValue = sat_solver_solve( p->pSatBmc, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause),
- (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue == l_False )
return 1;
assert( RetValue == l_True );
@@ -458,7 +458,7 @@ int Fra_ClauCheckClause( Cla_Man_t * p, Vec_Int_t * vClause, Vec_Int_t * vCex )
Vec_IntPush( p->vCexAssm, toLitCond(i,0) ); // positive helper
// try to solve
RetValue = sat_solver_solve( p->pSatTest, Vec_IntArray(p->vCexAssm), Vec_IntArray(p->vCexAssm) + Vec_IntSize(p->vCexAssm),
- (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( vCex )
Vec_IntClear( vCex );
if ( RetValue == l_False )
diff --git a/src/aig/fra/fraClaus.c b/src/aig/fra/fraClaus.c
index 91b70702..e5fe3f40 100644
--- a/src/aig/fra/fraClaus.c
+++ b/src/aig/fra/fraClaus.c
@@ -98,7 +98,7 @@ int Fra_ClausRunBmc( Clu_Man_t * p )
for ( i = 0; i < p->nPref + p->nFrames; i++ )
{
Lits[0] = i * nLitsTot + toLitCond( p->pCnf->pVarNums[pObj->Id], 0 );
- RetValue = sat_solver_solve( p->pSatBmc, Lits, Lits + 1, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSatBmc, Lits, Lits + 1, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue != l_False )
return 0;
}
@@ -121,14 +121,14 @@ int Fra_ClausRunSat( Clu_Man_t * p )
Aig_Obj_t * pObj;
int * pLits;
int i, RetValue;
- pLits = ALLOC( int, p->nFrames + 1 );
+ pLits = ABC_ALLOC( int, p->nFrames + 1 );
// set the output literals
pObj = Aig_ManPo(p->pAig, 0);
for ( i = 0; i <= p->nFrames; i++ )
pLits[i] = i * 2 * p->pCnf->nVars + toLitCond( p->pCnf->pVarNums[pObj->Id], i != p->nFrames );
// try to solve the problem
- RetValue = sat_solver_solve( p->pSatMain, pLits, pLits + p->nFrames + 1, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
- free( pLits );
+ RetValue = sat_solver_solve( p->pSatMain, pLits, pLits + p->nFrames + 1, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ ABC_FREE( pLits );
if ( RetValue == l_False )
return 1;
// get the counter-example
@@ -153,7 +153,7 @@ int Fra_ClausRunSat0( Clu_Man_t * p )
int Lits[2], RetValue;
pObj = Aig_ManPo(p->pAig, 0);
Lits[0] = toLitCond( p->pCnf->pVarNums[pObj->Id], 0 );
- RetValue = sat_solver_solve( p->pSatMain, Lits, Lits + 1, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSatMain, Lits, Lits + 1, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue == l_False )
return 1;
return 0;
@@ -350,7 +350,7 @@ int Fra_ClausSelectClauses( Clu_Man_t * p )
assert( Vec_IntSize(p->vClauses) > p->nClausesMax );
// count how many implications have each cost
CostMax = p->nSimWords * 32 + 1;
- pCostCount = ALLOC( int, CostMax );
+ pCostCount = ABC_ALLOC( int, CostMax );
memset( pCostCount, 0, sizeof(int) * CostMax );
Vec_IntForEachEntry( p->vCosts, Cost, i )
{
@@ -380,7 +380,7 @@ int Fra_ClausSelectClauses( Clu_Man_t * p )
}
Vec_IntWriteEntry( p->vCosts, i, -1 );
}
- free( pCostCount );
+ ABC_FREE( pCostCount );
p->nClauses = nClauCount;
if ( p->fVerbose )
printf( "Selected %d clauses. Cost range: [%d < %d < %d]\n", nClauCount, 1, c, CostMax );
@@ -608,7 +608,7 @@ int Fra_ClausProcessClauses( Clu_Man_t * p, int fRefs )
clk = clock();
// srand( 0xAABBAABB );
Aig_ManRandom(1);
- pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames );
+ pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames, 1 );
if ( p->fTarget && pSeq->fNonConstOut )
{
printf( "Property failed after sequential simulation!\n" );
@@ -617,7 +617,7 @@ clk = clock();
}
if ( p->fVerbose )
{
-PRT( "Sim-seq", clock() - clk );
+ABC_PRT( "Sim-seq", clock() - clk );
}
@@ -627,7 +627,7 @@ clk = clock();
Fra_ClausCollectLatchClauses( p, pSeq );
if ( p->fVerbose )
{
-PRT( "Lat-cla", clock() - clk );
+ABC_PRT( "Lat-cla", clock() - clk );
}
}
@@ -638,7 +638,7 @@ clk = clock();
// pManCut = Aig_ComputeCuts( p->pAig, 10, 4, 0, 1 );
if ( p->fVerbose )
{
-PRT( "Cuts ", clock() - clk );
+ABC_PRT( "Cuts ", clock() - clk );
}
// collect sequential info for each cut
@@ -656,7 +656,7 @@ clk = clock();
}
if ( p->fVerbose )
{
-PRT( "Infoseq", clock() - clk );
+ABC_PRT( "Infoseq", clock() - clk );
}
Fra_SmlStop( pSeq );
@@ -667,7 +667,7 @@ clk = clock();
pComb = Fra_SmlSimulateComb( p->pAig, p->nSimWords + p->nSimWordsPref );
if ( p->fVerbose )
{
-PRT( "Sim-cmb", clock() - clk );
+ABC_PRT( "Sim-cmb", clock() - clk );
}
// collect combinational info for each cut
@@ -692,7 +692,7 @@ clk = clock();
// Aig_ManCutStop( pManCut );
if ( p->fVerbose )
{
-PRT( "Infocmb", clock() - clk );
+ABC_PRT( "Infocmb", clock() - clk );
}
if ( p->fVerbose )
@@ -732,7 +732,7 @@ int Fra_ClausProcessClauses2( Clu_Man_t * p, int fRefs )
clk = clock();
// srand( 0xAABBAABB );
Aig_ManRandom(1);
- pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames );
+ pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames, 1 );
if ( p->fTarget && pSeq->fNonConstOut )
{
printf( "Property failed after sequential simulation!\n" );
@@ -741,7 +741,7 @@ clk = clock();
}
if ( p->fVerbose )
{
-//PRT( "Sim-seq", clock() - clk );
+//ABC_PRT( "Sim-seq", clock() - clk );
}
// perform combinational simulation
@@ -751,7 +751,7 @@ clk = clock();
pComb = Fra_SmlSimulateComb( p->pAig, p->nSimWords + p->nSimWordsPref );
if ( p->fVerbose )
{
-//PRT( "Sim-cmb", clock() - clk );
+//ABC_PRT( "Sim-cmb", clock() - clk );
}
@@ -761,7 +761,7 @@ clk = clock();
Fra_ClausCollectLatchClauses( p, pSeq );
if ( p->fVerbose )
{
-//PRT( "Lat-cla", clock() - clk );
+//ABC_PRT( "Lat-cla", clock() - clk );
}
}
@@ -772,7 +772,7 @@ clk = clock();
pManCut = Aig_ComputeCuts( p->pAig, p->nCutsMax, p->nLutSize, 0, p->fVerbose );
if ( p->fVerbose )
{
-//PRT( "Cuts ", clock() - clk );
+//ABC_PRT( "Cuts ", clock() - clk );
}
// collect combinational info for each cut
@@ -805,7 +805,7 @@ clk = clock();
{
printf( "Node = %5d. Cuts = %7d. Clauses = %6d. Clause/cut = %6.2f.\n",
Aig_ManNodeNum(p->pAig), nCuts, Vec_IntSize(p->vClauses), 1.0*Vec_IntSize(p->vClauses)/nCuts );
- PRT( "Processing sim-info to find candidate clauses (unoptimized)", clock() - clk );
+ ABC_PRT( "Processing sim-info to find candidate clauses (unoptimized)", clock() - clk );
}
// filter out clauses that are contained in the already proven clauses
@@ -852,7 +852,7 @@ clk = clock();
// check the clause
for ( k = Beg; k < End; k++ )
pStart[k] = lit_neg( pStart[k] );
- RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
for ( k = Beg; k < End; k++ )
pStart[k] = lit_neg( pStart[k] );
// the clause holds
@@ -924,7 +924,7 @@ int Fra_ClausBmcClauses( Clu_Man_t * p )
for ( k = Beg; k < End; k++ )
pStart[k] = lit_neg( pStart[k] );
- RetValue = sat_solver_solve( p->pSatBmc, pStart + Beg, pStart + End, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSatBmc, pStart + Beg, pStart + End, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
for ( k = Beg; k < End; k++ )
pStart[k] = lit_neg( pStart[k] );
@@ -1292,7 +1292,7 @@ int Fra_ClausInductiveClauses( Clu_Man_t * p )
for ( k = Beg; k < End; k++ )
pStart[k] = lit_neg( pStart[k] );
- RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
for ( k = Beg; k < End; k++ )
pStart[k] = lit_neg( pStart[k] );
@@ -1359,7 +1359,7 @@ int Fra_ClausInductiveClauses( Clu_Man_t * p )
Clu_Man_t * Fra_ClausAlloc( Aig_Man_t * pAig, int nFrames, int nPref, int nClausesMax, int nLutSize, int nLevels, int nCutsMax, int nBatches, int fStepUp, int fTarget, int fVerbose, int fVeryVerbose )
{
Clu_Man_t * p;
- p = ALLOC( Clu_Man_t, 1 );
+ p = ABC_ALLOC( Clu_Man_t, 1 );
memset( p, 0, sizeof(Clu_Man_t) );
p->pAig = pAig;
p->nFrames = nFrames;
@@ -1412,7 +1412,7 @@ void Fra_ClausFree( Clu_Man_t * p )
if ( p->pCnf ) Cnf_DataFree( p->pCnf );
if ( p->pSatMain ) sat_solver_delete( p->pSatMain );
if ( p->pSatBmc ) sat_solver_delete( p->pSatBmc );
- free( p );
+ ABC_FREE( p );
}
@@ -1540,7 +1540,7 @@ void Fra_ClausWriteIndClauses( Clu_Man_t * p )
int * pStart, * pVar2Id;
int Beg, End, i, k;
// create mapping from SAT vars to node IDs
- pVar2Id = ALLOC( int, p->pCnf->nVars );
+ pVar2Id = ABC_ALLOC( int, p->pCnf->nVars );
memset( pVar2Id, 0xFF, sizeof(int) * p->pCnf->nVars );
for ( i = 0; i < Aig_ManObjNumMax(p->pAig); i++ )
if ( p->pCnf->pVarNums[i] >= 0 )
@@ -1564,7 +1564,7 @@ void Fra_ClausWriteIndClauses( Clu_Man_t * p )
Aig_ObjCreatePo( pNew, pClause );
Beg = End;
}
- free( pVar2Id );
+ ABC_FREE( pVar2Id );
Aig_ManCleanup( pNew );
pName = Ioa_FileNameGenericAppend( p->pAig->pName, "_care.aig" );
printf( "Care one-hotness clauses will be written into file \"%s\".\n", pName );
@@ -1624,7 +1624,7 @@ void Fra_ClausEstimateCoverage( Clu_Man_t * p )
Aig_ManRandom(1);
pComb = Fra_SmlSimulateComb( p->pAig, nCombSimWords );
// create mapping from SAT vars to node IDs
- pVar2Id = ALLOC( int, p->pCnf->nVars );
+ pVar2Id = ABC_ALLOC( int, p->pCnf->nVars );
memset( pVar2Id, 0, sizeof(int) * p->pCnf->nVars );
for ( i = 0; i < Aig_ManObjNumMax(p->pAig); i++ )
if ( p->pCnf->pVarNums[i] >= 0 )
@@ -1654,11 +1654,11 @@ void Fra_ClausEstimateCoverage( Clu_Man_t * p )
for ( w = 0; w < nCombSimWords; w++ )
nCovered += Aig_WordCountOnes( pResultTot[w] );
Fra_SmlStop( pComb );
- free( pVar2Id );
+ ABC_FREE( pVar2Id );
// print the result
printf( "Care states ratio = %f. ", 1.0 * (nCombSimWords * 32 - nCovered) / (nCombSimWords * 32) );
printf( "(%d out of %d patterns) ", nCombSimWords * 32 - nCovered, nCombSimWords * 32 );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
@@ -1686,7 +1686,7 @@ if ( p->fVerbose )
{
printf( "PARAMETERS: Frames = %d. Pref = %d. Clauses max = %d. Cut size = %d.\n", nFrames, nPref, nClausesMax, nLutSize );
printf( "Level max = %d. Cuts max = %d. Batches = %d. Increment cut size = %s.\n", nLevels, nCutsMax, nBatches, fStepUp? "yes":"no" );
-//PRT( "Sim-seq", clock() - clk );
+//ABC_PRT( "Sim-seq", clock() - clk );
}
assert( !p->fTarget || Aig_ManPoNum(pAig) - Aig_ManRegNum(pAig) == 1 );
@@ -1700,7 +1700,7 @@ clk = clock();
// p->pAig->nRegs--;
if ( fVerbose )
{
-//PRT( "CNF ", clock() - clk );
+//ABC_PRT( "CNF ", clock() - clk );
}
// check BMC
@@ -1720,7 +1720,7 @@ clk = clock();
}
if ( fVerbose )
{
-//PRT( "SAT-bmc", clock() - clk );
+//ABC_PRT( "SAT-bmc", clock() - clk );
}
// start the SAT solver
@@ -1751,7 +1751,7 @@ clk = clock();
}
if ( fVerbose )
{
-// PRT( "SAT-ind", clock() - clk );
+// ABC_PRT( "SAT-ind", clock() - clk );
}
// collect the candidate inductive clauses using 4-cuts
@@ -1763,7 +1763,7 @@ clk = clock();
p->nSimWordsPref = p->nPref*p->nSimWords/p->nSimFrames;
nClausesBeg = p->nClauses;
- //PRT( "Clauses", clock() - clk );
+ //ABC_PRT( "Clauses", clock() - clk );
// check clauses using BMC
@@ -1775,7 +1775,7 @@ clk = clock();
if ( fVerbose )
{
printf( "BMC disproved %d clauses. ", Counter );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
}
@@ -1794,7 +1794,7 @@ clk = clock();
{
printf( "End = %5d. Exs = %5d. ", p->nClauses, p->nCexes );
// printf( "\n" );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
clk = clock();
}
@@ -1809,14 +1809,14 @@ clk = clock();
printf( "Property FAILS during refinement. " );
else
printf( "Property HOLDS inductively after strengthening. " );
- PRT( "Time ", clock() - clkTotal );
+ ABC_PRT( "Time ", clock() - clkTotal );
if ( !p->fFail )
break;
}
else
{
printf( "Finished proving inductive clauses. " );
- PRT( "Time ", clock() - clkTotal );
+ ABC_PRT( "Time ", clock() - clkTotal );
}
}
diff --git a/src/aig/fra/fraCnf.c b/src/aig/fra/fraCnf.c
index d96fe8a1..27da3fc5 100644
--- a/src/aig/fra/fraCnf.c
+++ b/src/aig/fra/fraCnf.c
@@ -131,7 +131,7 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
assert( Aig_ObjIsNode( pNode ) );
// create storage for literals
nLits = Vec_PtrSize(vSuper) + 1;
- pLits = ALLOC( int, nLits );
+ pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
Vec_PtrForEachEntry( vSuper, pFanin, i )
@@ -147,7 +147,7 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
pLits[nLits-1] = toLitCond(Fra_ObjSatNum(pNode), 0);
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
assert( RetValue );
- free( pLits );
+ ABC_FREE( pLits );
}
/**Function*************************************************************
diff --git a/src/aig/fra/fraHot.c b/src/aig/fra/fraHot.c
index b2156193..c4472121 100644
--- a/src/aig/fra/fraHot.c
+++ b/src/aig/fra/fraHot.c
@@ -378,7 +378,7 @@ void Fra_OneHotEstimateCoverage( Fra_Man_t * p, Vec_Int_t * vOneHots )
// print the result
printf( "Care states ratio = %f. ", 1.0 * (nSimWords * 32 - nCovered) / (nSimWords * 32) );
printf( "(%d out of %d patterns) ", nSimWords * 32 - nCovered, nSimWords * 32 );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
/**Function*************************************************************
diff --git a/src/aig/fra/fraImp.c b/src/aig/fra/fraImp.c
index e2bee834..d579146e 100644
--- a/src/aig/fra/fraImp.c
+++ b/src/aig/fra/fraImp.c
@@ -64,7 +64,7 @@ static inline int * Fra_SmlCountOnes( Fra_Sml_t * p )
{
Aig_Obj_t * pObj;
int i, * pnBits;
- pnBits = ALLOC( int, Aig_ManObjNumMax(p->pAig) );
+ pnBits = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) );
memset( pnBits, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) );
Aig_ManForEachObj( p->pAig, pObj, i )
pnBits[i] = Fra_SmlCountOnesOne( p, i );
@@ -159,7 +159,7 @@ Vec_Ptr_t * Fra_SmlSortUsingOnes( Fra_Sml_t * p, int fLatchCorr )
// count number of nodes having that many 1s
nNodes = 0;
nBits = p->nWordsTotal * 32;
- pnNodes = ALLOC( int, nBits + 1 );
+ pnNodes = ABC_ALLOC( int, nBits + 1 );
memset( pnNodes, 0, sizeof(int) * (nBits + 1) );
Aig_ManForEachObj( p->pAig, pObj, i )
{
@@ -183,7 +183,7 @@ Vec_Ptr_t * Fra_SmlSortUsingOnes( Fra_Sml_t * p, int fLatchCorr )
nNodes++;
}
// allocate memory for all the nodes
- pMemory = ALLOC( int, nNodes + nBits + 1 );
+ pMemory = ABC_ALLOC( int, nNodes + nBits + 1 );
// markup the memory for each node
vNodes = Vec_PtrAlloc( nBits + 1 );
Vec_PtrPush( vNodes, pMemory );
@@ -222,8 +222,8 @@ Vec_Ptr_t * Fra_SmlSortUsingOnes( Fra_Sml_t * p, int fLatchCorr )
nTotal += pnNodes[i];
}
assert( nTotal == nNodes + nBits + 1 );
- free( pnNodes );
- free( pnBits );
+ ABC_FREE( pnNodes );
+ ABC_FREE( pnBits );
return vNodes;
}
@@ -244,7 +244,7 @@ Vec_Int_t * Fra_SmlSelectMaxCost( Vec_Int_t * vImps, int * pCosts, int nCostMax,
int * pCostCount, nImpCount, Imp, i, c;
assert( Vec_IntSize(vImps) >= nImpLimit );
// count how many implications have each cost
- pCostCount = ALLOC( int, nCostMax + 1 );
+ pCostCount = ABC_ALLOC( int, nCostMax + 1 );
memset( pCostCount, 0, sizeof(int) * (nCostMax + 1) );
for ( i = 0; i < Vec_IntSize(vImps); i++ )
{
@@ -271,7 +271,7 @@ Vec_Int_t * Fra_SmlSelectMaxCost( Vec_Int_t * vImps, int * pCosts, int nCostMax,
if ( Vec_IntSize( vImpsNew ) == nImpLimit )
break;
}
- free( pCostCount );
+ ABC_FREE( pCostCount );
if ( pCostRange )
*pCostRange = c;
return vImpsNew;
@@ -329,7 +329,7 @@ Vec_Int_t * Fra_ImpDerive( Fra_Man_t * p, int nImpMaxLimit, int nImpUseLimit, in
assert( nImpMaxLimit > 0 && nImpUseLimit > 0 && nImpUseLimit <= nImpMaxLimit );
// normalize both managers
pComb = Fra_SmlSimulateComb( p->pManAig, nSimWords );
- pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nSimWords, 1 );
+ pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nSimWords, 1, 1 );
// get the nodes sorted by the number of 1s
vNodes = Fra_SmlSortUsingOnes( pSeq, fLatchCorr );
// count the total number of implications
@@ -340,7 +340,7 @@ Vec_Int_t * Fra_ImpDerive( Fra_Man_t * p, int nImpMaxLimit, int nImpUseLimit, in
nImpsTotal++;
// compute implications and their costs
- pImpCosts = ALLOC( int, nImpMaxLimit );
+ pImpCosts = ABC_ALLOC( int, nImpMaxLimit );
vImps = Vec_IntAlloc( nImpMaxLimit );
for ( k = pSeq->nWordsTotal * 32; k > 0; k-- )
for ( i = k - 1; i > 0; i-- )
@@ -384,8 +384,11 @@ finish:
}
// dealloc
- free( pImpCosts );
- free( Vec_PtrEntry(vNodes, 0) );
+ ABC_FREE( pImpCosts );
+ {
+ void * pTemp = Vec_PtrEntry(vNodes, 0);
+ ABC_FREE( pTemp );
+ }
Vec_PtrFree( vNodes );
// reorder implications topologically
qsort( (void *)Vec_IntArray(vImps), Vec_IntSize(vImps), sizeof(int),
@@ -396,7 +399,7 @@ printf( "Implications: All = %d. Try = %d. NonSeq = %d. Comb = %d. Res = %d.\n",
nImpsTotal, nImpsTried, nImpsNonSeq, nImpsComb, nImpsCollected );
printf( "Implication weight: Min = %d. Pivot = %d. Max = %d. ",
CostMin, CostRange, CostMax );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
return vImps;
}
@@ -665,9 +668,9 @@ int Fra_ImpVerifyUsingSimulation( Fra_Man_t * p )
if ( p->pCla->vImps == NULL || Vec_IntSize(p->pCla->vImps) == 0 )
return 0;
// simulate the AIG manager with combinational patterns
- pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nFrames, nSimWords );
+ pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nFrames, nSimWords, 1 );
// go through the implications and check how many of them do not hold
- pfFails = ALLOC( char, Vec_IntSize(p->pCla->vImps) );
+ pfFails = ABC_ALLOC( char, Vec_IntSize(p->pCla->vImps) );
memset( pfFails, 0, sizeof(char) * Vec_IntSize(p->pCla->vImps) );
Vec_IntForEachEntry( p->pCla->vImps, Imp, i )
{
@@ -679,7 +682,7 @@ int Fra_ImpVerifyUsingSimulation( Fra_Man_t * p )
Counter = 0;
for ( i = 0; i < Vec_IntSize(p->pCla->vImps); i++ )
Counter += pfFails[i];
- free( pfFails );
+ ABC_FREE( pfFails );
Fra_SmlStop( pSeq );
return Counter;
}
diff --git a/src/aig/fra/fraInd.c b/src/aig/fra/fraInd.c
index c8b35b28..4f3812c6 100644
--- a/src/aig/fra/fraInd.c
+++ b/src/aig/fra/fraInd.c
@@ -198,7 +198,7 @@ void Fra_FramesAddMore( Aig_Man_t * p, int nFrames )
pObj->pData = pObj;
// iterate and add objects
nNodesOld = Aig_ManObjNumMax(p);
- pLatches = ALLOC( Aig_Obj_t *, Aig_ManRegNum(p) );
+ pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p) );
for ( f = 0; f < nFrames; f++ )
{
// clean latch inputs and outputs
@@ -230,7 +230,7 @@ void Fra_FramesAddMore( Aig_Man_t * p, int nFrames )
pObj->pData = NULL;
}
}
- free( pLatches );
+ ABC_FREE( pLatches );
}
@@ -308,7 +308,7 @@ Aig_Man_t * Fra_FraigInductionPart( Aig_Man_t * pAig, Fra_Ssw_t * pPars )
i, Vec_IntSize(vPart), Aig_ManPiNum(pTemp)-Vec_IntSize(vPart), nCountPis, nCountRegs, Aig_ManNodeNum(pTemp), pPars->nIters, nClasses );
Aig_ManStop( pNew );
Aig_ManStop( pTemp );
- free( pMapBack );
+ ABC_FREE( pMapBack );
}
// remap the AIG
pNew = Aig_ManDupRepr( pAig, 0 );
@@ -320,7 +320,7 @@ Aig_Man_t * Fra_FraigInductionPart( Aig_Man_t * pAig, Fra_Ssw_t * pPars )
pPars->fVerbose = fVerbose;
if ( fVerbose )
{
- PRT( "Total time", clock() - clk );
+ ABC_PRT( "Total time", clock() - clk );
}
return pNew;
}
@@ -420,10 +420,10 @@ Aig_Man_t * Fra_FraigInduction( Aig_Man_t * pManAig, Fra_Ssw_t * pParams )
// refine the classes with more simulation rounds
if ( pPars->fVerbose )
printf( "Simulating %d AIG nodes for %d cycles ... ", Aig_ManNodeNum(pManAig), pPars->nFramesP + 32 );
- p->pSml = Fra_SmlSimulateSeq( pManAig, pPars->nFramesP, 32, 1 ); //pPars->nFramesK + 1, 1 );
+ p->pSml = Fra_SmlSimulateSeq( pManAig, pPars->nFramesP, 32, 1, 1 ); //pPars->nFramesK + 1, 1 );
if ( pPars->fVerbose )
{
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
Fra_ClassesPrepare( p->pCla, p->pPars->fLatchCorr, p->pPars->nMaxLevs );
// Fra_ClassesPostprocess( p->pCla );
@@ -556,7 +556,7 @@ clk2 = clock();
Fra_FraigSweep( p );
if ( pPars->fVerbose )
{
- PRT( "T", clock() - clk3 );
+ ABC_PRT( "T", clock() - clk3 );
}
// Sat_SolverPrintStats( stdout, p->pSat );
@@ -589,7 +589,7 @@ clk2 = clock();
printf( "Implications failing the simulation test = %d (out of %d). ", Temp, Vec_IntSize(p->pCla->vImps) );
else
printf( "All %d implications have passed the simulation test. ", Vec_IntSize(p->pCla->vImps) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
*/
@@ -629,7 +629,7 @@ p->timeTotal = clock() - clk;
p->nLitsEnd = Fra_ClassesCountLits( p->pCla );
p->nNodesEnd = Aig_ManNodeNum(pManAigNew);
p->nRegsEnd = Aig_ManRegNum(pManAigNew);
- // free the manager
+ // ABC_FREE the manager
finish:
Fra_ManStop( p );
// check the output
diff --git a/src/aig/fra/fraIndVer.c b/src/aig/fra/fraIndVer.c
index efc516c9..71faa346 100644
--- a/src/aig/fra/fraIndVer.c
+++ b/src/aig/fra/fraIndVer.c
@@ -150,7 +150,7 @@ int Fra_InvariantVerify( Aig_Man_t * pAig, int nFrames, Vec_Int_t * vClauses, Ve
if ( CounterBase || CounterInd )
return 0;
printf( "Invariant verification: %d clauses verified correctly. ", Vec_IntSize(vClauses) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
return 1;
}
diff --git a/src/aig/fra/fraLcr.c b/src/aig/fra/fraLcr.c
index d3be9842..16912f46 100644
--- a/src/aig/fra/fraLcr.c
+++ b/src/aig/fra/fraLcr.c
@@ -77,12 +77,12 @@ struct Fra_Lcr_t_
Fra_Lcr_t * Lcr_ManAlloc( Aig_Man_t * pAig )
{
Fra_Lcr_t * p;
- p = ALLOC( Fra_Lcr_t, 1 );
+ p = ABC_ALLOC( Fra_Lcr_t, 1 );
memset( p, 0, sizeof(Fra_Lcr_t) );
p->pAig = pAig;
- p->pInToOutPart = ALLOC( int, Aig_ManPiNum(pAig) );
+ p->pInToOutPart = ABC_ALLOC( int, Aig_ManPiNum(pAig) );
memset( p->pInToOutPart, 0, sizeof(int) * Aig_ManPiNum(pAig) );
- p->pInToOutNum = ALLOC( int, Aig_ManPiNum(pAig) );
+ p->pInToOutNum = ABC_ALLOC( int, Aig_ManPiNum(pAig) );
memset( p->pInToOutNum, 0, sizeof(int) * Aig_ManPiNum(pAig) );
p->vFraigs = Vec_PtrAlloc( 1000 );
return p;
@@ -106,12 +106,12 @@ void Lcr_ManPrint( Fra_Lcr_t * p )
printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
p->nNodesBeg, p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg,
p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/p->nRegsBeg );
- PRT( "AIG simulation ", p->timeSim );
- PRT( "AIG partitioning", p->timePart );
- PRT( "AIG rebuiding ", p->timeTrav );
- PRT( "FRAIGing ", p->timeFraig );
- PRT( "AIG updating ", p->timeUpdate );
- PRT( "TOTAL RUNTIME ", p->timeTotal );
+ ABC_PRT( "AIG simulation ", p->timeSim );
+ ABC_PRT( "AIG partitioning", p->timePart );
+ ABC_PRT( "AIG rebuiding ", p->timeTrav );
+ ABC_PRT( "FRAIGing ", p->timeFraig );
+ ABC_PRT( "AIG updating ", p->timeUpdate );
+ ABC_PRT( "TOTAL RUNTIME ", p->timeTotal );
}
/**Function*************************************************************
@@ -136,9 +136,9 @@ void Lcr_ManFree( Fra_Lcr_t * p )
Vec_PtrFree( p->vFraigs );
if ( p->pCla ) Fra_ClassesStop( p->pCla );
if ( p->vParts ) Vec_VecFree( (Vec_Vec_t *)p->vParts );
- free( p->pInToOutPart );
- free( p->pInToOutNum );
- free( p );
+ ABC_FREE( p->pInToOutPart );
+ ABC_FREE( p->pInToOutNum );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -157,7 +157,7 @@ Fra_Man_t * Fra_LcrAigPrepare( Aig_Man_t * pAig )
Fra_Man_t * p;
Aig_Obj_t * pObj;
int i;
- p = ALLOC( Fra_Man_t, 1 );
+ p = ABC_ALLOC( Fra_Man_t, 1 );
memset( p, 0, sizeof(Fra_Man_t) );
// Aig_ManForEachPi( pAig, pObj, i )
Aig_ManForEachObj( pAig, pObj, i )
@@ -550,10 +550,10 @@ Aig_Man_t * Fra_FraigLatchCorrespondence( Aig_Man_t * pAig, int nFramesP, int nC
clk2 = clock();
if ( fVerbose )
printf( "Simulating AIG with %d nodes for %d cycles ... ", Aig_ManNodeNum(pAig), nFramesP + 32 );
- pSml = Fra_SmlSimulateSeq( pAig, nFramesP, 32, 1 );
+ pSml = Fra_SmlSimulateSeq( pAig, nFramesP, 32, 1, 1 );
if ( fVerbose )
{
-PRT( "Time", clock() - clk2 );
+ABC_PRT( "Time", clock() - clk2 );
}
timeSim = clock() - clk2;
@@ -592,7 +592,7 @@ printf( "Partitioning AIG ... " );
Aig_ManStop( pAigPart );
if ( fVerbose )
{
-PRT( "Time", clock() - clk2 );
+ABC_PRT( "Time", clock() - clk2 );
p->timePart += clock() - clk2;
}
@@ -636,7 +636,7 @@ p->timeFraig += clock() - clk2;
Aig_ManDumpBlif( pAigPart, Name, NULL, NULL );
}
printf( "Finished part %4d (out of %4d). ", i, Vec_PtrSize(p->vParts) );
-PRT( "Time", clock() - clk3 );
+ABC_PRT( "Time", clock() - clk3 );
*/
Aig_ManStop( pAigPart );
@@ -648,7 +648,7 @@ PRT( "Time", clock() - clk3 );
printf( "%3d : Const = %6d. Class = %6d. L = %6d. Part = %3d. ",
nIter, Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses),
Fra_ClassesCountLits(p->pCla), Vec_PtrSize(p->vParts) );
- PRT( "T", clock() - clk3 );
+ ABC_PRT( "T", clock() - clk3 );
}
// refine the classes
Fra_LcrAigPrepareTwo( p->pAig, pTemp );
@@ -690,7 +690,7 @@ p->timeTotal = clock() - clk;
p->nNodesEnd = Aig_ManNodeNum(pAigNew);
p->nRegsEnd = Aig_ManRegNum(pAigNew);
finish:
- free( pTemp );
+ ABC_FREE( pTemp );
Lcr_ManFree( p );
if ( pnIter ) *pnIter = nIter;
return pAigNew;
diff --git a/src/aig/fra/fraMan.c b/src/aig/fra/fraMan.c
index b8cf13c5..8bdd147d 100644
--- a/src/aig/fra/fraMan.c
+++ b/src/aig/fra/fraMan.c
@@ -104,7 +104,7 @@ Fra_Man_t * Fra_ManStart( Aig_Man_t * pManAig, Fra_Par_t * pPars )
Aig_Obj_t * pObj;
int i;
// allocate the fraiging manager
- p = ALLOC( Fra_Man_t, 1 );
+ p = ABC_ALLOC( Fra_Man_t, 1 );
memset( p, 0, sizeof(Fra_Man_t) );
p->pPars = pPars;
p->pManAig = pManAig;
@@ -112,12 +112,12 @@ Fra_Man_t * Fra_ManStart( Aig_Man_t * pManAig, Fra_Par_t * pPars )
p->nFramesAll = pPars->nFramesK + 1;
// allocate storage for sim pattern
p->nPatWords = Aig_BitWordNum( (Aig_ManPiNum(pManAig) - Aig_ManRegNum(pManAig)) * p->nFramesAll + Aig_ManRegNum(pManAig) );
- p->pPatWords = ALLOC( unsigned, p->nPatWords );
+ p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords );
p->vPiVars = Vec_PtrAlloc( 100 );
// equivalence classes
p->pCla = Fra_ClassesStart( pManAig );
// allocate other members
- p->pMemFraig = ALLOC( Aig_Obj_t *, p->nSizeAlloc * p->nFramesAll );
+ p->pMemFraig = ABC_ALLOC( Aig_Obj_t *, p->nSizeAlloc * p->nFramesAll );
memset( p->pMemFraig, 0, sizeof(Aig_Obj_t *) * p->nSizeAlloc * p->nFramesAll );
// set random number generator
// srand( 0xABCABC );
@@ -150,8 +150,8 @@ void Fra_ManClean( Fra_Man_t * p, int nNodesMax )
if ( p->nMemAlloc < nNodesMax )
{
int nMemAllocNew = nNodesMax + 5000;
- p->pMemFanins = REALLOC( Vec_Ptr_t *, p->pMemFanins, nMemAllocNew );
- p->pMemSatNums = REALLOC( int, p->pMemSatNums, nMemAllocNew );
+ p->pMemFanins = ABC_REALLOC( Vec_Ptr_t *, p->pMemFanins, nMemAllocNew );
+ p->pMemSatNums = ABC_REALLOC( int, p->pMemSatNums, nMemAllocNew );
p->nMemAlloc = nMemAllocNew;
}
// prepare for the new run
@@ -191,9 +191,9 @@ Aig_Man_t * Fra_ManPrepareComb( Fra_Man_t * p )
pObj->pData = p;
// allocate memory for mapping FRAIG nodes into SAT numbers and fanins
p->nMemAlloc = p->nSizeAlloc;
- p->pMemFanins = ALLOC( Vec_Ptr_t *, p->nMemAlloc );
+ p->pMemFanins = ABC_ALLOC( Vec_Ptr_t *, p->nMemAlloc );
memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc );
- p->pMemSatNums = ALLOC( int, p->nMemAlloc );
+ p->pMemSatNums = ABC_ALLOC( int, p->nMemAlloc );
memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc );
// make sure the satisfying assignment is node assigned
assert( pManFraig->pData == NULL );
@@ -242,7 +242,7 @@ void Fra_ManStop( Fra_Man_t * p )
if ( p->pManAig )
{
if ( p->pManAig->pObjCopies )
- free( p->pManAig->pObjCopies );
+ ABC_FREE( p->pManAig->pObjCopies );
p->pManAig->pObjCopies = p->pMemFraig;
p->pMemFraig = NULL;
}
@@ -254,11 +254,11 @@ void Fra_ManStop( Fra_Man_t * p )
if ( p->pSml ) Fra_SmlStop( p->pSml );
if ( p->vCex ) Vec_IntFree( p->vCex );
if ( p->vOneHots ) Vec_IntFree( p->vOneHots );
- FREE( p->pMemFraig );
- FREE( p->pMemFanins );
- FREE( p->pMemSatNums );
- FREE( p->pPatWords );
- free( p );
+ ABC_FREE( p->pMemFraig );
+ ABC_FREE( p->pMemFanins );
+ ABC_FREE( p->pMemSatNums );
+ ABC_FREE( p->pPatWords );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -284,19 +284,19 @@ void Fra_ManPrint( Fra_Man_t * p )
p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/(p->nRegsBeg?p->nRegsBeg:1) );
if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat );
if ( p->pPars->fUse1Hot ) Fra_OneHotEstimateCoverage( p, p->vOneHots );
- PRT( "AIG simulation ", p->pSml->timeSim );
- PRT( "AIG traversal ", p->timeTrav );
+ ABC_PRT( "AIG simulation ", p->pSml->timeSim );
+ ABC_PRT( "AIG traversal ", p->timeTrav );
if ( p->timeRwr )
{
- PRT( "AIG rewriting ", p->timeRwr );
+ ABC_PRT( "AIG rewriting ", p->timeRwr );
}
- PRT( "SAT solving ", p->timeSat );
- PRT( " Unsat ", p->timeSatUnsat );
- PRT( " Sat ", p->timeSatSat );
- PRT( " Fail ", p->timeSatFail );
- PRT( "Class refining ", p->timeRef );
- PRT( "TOTAL RUNTIME ", p->timeTotal );
- if ( p->time1 ) { PRT( "time1 ", p->time1 ); }
+ ABC_PRT( "SAT solving ", p->timeSat );
+ ABC_PRT( " Unsat ", p->timeSatUnsat );
+ ABC_PRT( " Sat ", p->timeSatSat );
+ ABC_PRT( " Fail ", p->timeSatFail );
+ ABC_PRT( "Class refining ", p->timeRef );
+ ABC_PRT( "TOTAL RUNTIME ", p->timeTotal );
+ if ( p->time1 ) { ABC_PRT( "time1 ", p->time1 ); }
if ( p->nSpeculs )
printf( "Speculations = %d.\n", p->nSpeculs );
fflush( stdout );
diff --git a/src/aig/fra/fraPart.c b/src/aig/fra/fraPart.c
index 1766b978..6dfbd2e9 100644
--- a/src/aig/fra/fraPart.c
+++ b/src/aig/fra/fraPart.c
@@ -59,7 +59,7 @@ void Fra_ManPartitionTest( Aig_Man_t * p, int nComLim )
// compute supports
clk = clock();
vSupps = (Vec_Vec_t *)Aig_ManSupports( p );
-PRT( "Supports", clock() - clk );
+ABC_PRT( "Supports", clock() - clk );
// remove last entry
Aig_ManForEachPo( p, pObj, i )
{
@@ -76,9 +76,9 @@ clk = clock();
{
vSup = Vec_VecEntry( vSupps, i );
Vec_IntForEachEntry( vSup, Entry, k )
- Vec_VecPush( vSuppsIn, Entry, (void *)(PORT_PTRUINT_T)i );
+ Vec_VecPush( vSuppsIn, Entry, (void *)(ABC_PTRUINT_T)i );
}
-PRT( "Inverse ", clock() - clk );
+ABC_PRT( "Inverse ", clock() - clk );
clk = clock();
// compute extended supports
@@ -153,7 +153,7 @@ clk = clock();
*/
}
// Bar_ProgressStop( pProgress );
-PRT( "Scanning", clock() - clk );
+ABC_PRT( "Scanning", clock() - clk );
// print cumulative statistics
printf( "PIs = %6d. POs = %6d. Lim = %3d. AveS = %3d. SN = %3d. R = %4.2f Max = %5d.\n",
@@ -193,7 +193,7 @@ void Fra_ManPartitionTest2( Aig_Man_t * p )
// compute supports
clk = clock();
vSupps = (Vec_Vec_t *)Aig_ManSupports( p );
-PRT( "Supports", clock() - clk );
+ABC_PRT( "Supports", clock() - clk );
// remove last entry
Aig_ManForEachPo( p, pObj, i )
{
@@ -212,13 +212,13 @@ clk = clock();
break;
vSup = Vec_VecEntry( vSupps, i );
Vec_IntForEachEntry( vSup, Entry, k )
- Vec_VecPush( vSuppsIn, Entry, (void *)(PORT_PTRUINT_T)i );
+ Vec_VecPush( vSuppsIn, Entry, (void *)(ABC_PTRUINT_T)i );
}
-PRT( "Inverse ", clock() - clk );
+ABC_PRT( "Inverse ", clock() - clk );
// create affective supports
clk = clock();
- pSupp = ALLOC( char, Aig_ManPiNum(p) );
+ pSupp = ABC_ALLOC( char, Aig_ManPiNum(p) );
Aig_ManForEachPo( p, pObj, i )
{
if ( i % 50 != 0 )
@@ -248,9 +248,9 @@ clk = clock();
printf( "%d(%d) ", Vec_IntSize(vSup), Counter );
}
printf( "\n" );
-PRT( "Extension ", clock() - clk );
+ABC_PRT( "Extension ", clock() - clk );
- free( pSupp );
+ ABC_FREE( pSupp );
Vec_VecFree( vSupps );
Vec_VecFree( vSuppsIn );
}
diff --git a/src/aig/fra/fraSat.c b/src/aig/fra/fraSat.c
index 8332fa77..c2eaf453 100644
--- a/src/aig/fra/fraSat.c
+++ b/src/aig/fra/fraSat.c
@@ -101,7 +101,7 @@ clk = clock();
pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase );
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0,
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
@@ -145,7 +145,7 @@ clk = clock();
pLits[0] = toLitCond( Fra_ObjSatNum(pOld), 1 );
pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase ^ pNew->fPhase );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0,
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
@@ -177,12 +177,12 @@ p->timeSatFail += clock() - clk;
// check BDD proof
{
int RetVal;
- PRT( "Sat", clock() - clk2 );
+ ABC_PRT( "Sat", clock() - clk2 );
clk2 = clock();
RetVal = Fra_NodesAreEquivBdd( pOld, pNew );
// printf( "%d ", RetVal );
assert( RetVal );
- PRT( "Bdd", clock() - clk2 );
+ ABC_PRT( "Bdd", clock() - clk2 );
printf( "\n" );
}
*/
@@ -263,7 +263,7 @@ clk = clock();
pLits[1] = toLitCond( Fra_ObjSatNum(pNew), !fComplR );
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0,
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
@@ -370,7 +370,7 @@ clk = clock();
pLits[1] = toLitCond( Fra_ObjSatNum(pNew), !fComplR );
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0,
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
@@ -447,7 +447,7 @@ int Fra_NodeIsConst( Fra_Man_t * p, Aig_Obj_t * pNew )
clk = clock();
pLits[0] = toLitCond( Fra_ObjSatNum(pNew), pNew->fPhase );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 1,
- (sint64)p->pPars->nBTLimitMiter, (sint64)0,
+ (ABC_INT64_T)p->pPars->nBTLimitMiter, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
diff --git a/src/aig/fra/fraSec.c b/src/aig/fra/fraSec.c
index 7545059f..a97af278 100644
--- a/src/aig/fra/fraSec.c
+++ b/src/aig/fra/fraSec.c
@@ -121,7 +121,7 @@ clk = clock();
{
printf( "Sequential cleanup: Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
RetValue = Fra_FraigMiterStatus( pNew );
if ( RetValue >= 0 )
@@ -140,7 +140,7 @@ clk = clock();
{
printf( "Phase abstraction: Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
}
@@ -155,7 +155,7 @@ clk = clock();
{
printf( "Forward retiming: Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
}
@@ -199,9 +199,9 @@ clk = clock();
printf( "The counter-example is invalid because of phase abstraction.\n" );
else
{
- FREE( p->pSeqModel );
+ ABC_FREE( p->pSeqModel );
p->pSeqModel = Ssw_SmlDupCounterExample( pTemp->pSeqModel, Aig_ManRegNum(p) );
- FREE( pTemp->pSeqModel );
+ ABC_FREE( pTemp->pSeqModel );
}
}
if ( pNew == NULL )
@@ -212,12 +212,12 @@ clk = clock();
if ( !pParSec->fSilent )
{
printf( "Networks are NOT EQUIVALENT after simulation. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
if ( pParSec->fReportSolution && !pParSec->fRecursive )
{
printf( "SOLUTION: FAIL " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
Aig_ManStop( pTemp );
return RetValue;
@@ -233,7 +233,7 @@ PRT( "Time", clock() - clkTotal );
{
printf( "Latch-corr (I=%3d): Latches = %5d. Nodes = %6d. ",
nIter, Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
}
/*
@@ -261,7 +261,7 @@ clk = clock();
{
printf( "Fraiging: Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
}
@@ -302,7 +302,7 @@ clk = clock();
{
printf( "Min-reg retiming: Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
}
@@ -370,7 +370,7 @@ clk = clock();
{
printf( "K-step (K=%2d,I=%3d): Latches = %5d. Nodes = %6d. ",
nFrames, pPars2->nIters, Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
if ( RetValue != -1 )
break;
@@ -392,9 +392,9 @@ clk = clock();
{
printf( "Min-reg retiming: Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
- }
+ABC_PRT( "Time", clock() - clk );
}
+ }
if ( pNew->nRegs )
pNew = Aig_ManConstReduce( pNew, 0 );
@@ -410,19 +410,19 @@ clk = clock();
{
printf( "Rewriting: Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
// perform sequential simulation
if ( pNew->nRegs )
{
clk = clock();
- pSml = Fra_SmlSimulateSeq( pNew, 0, 128 * nFrames, 1 + 16/(1+Aig_ManNodeNum(pNew)/1000) );
+ pSml = Fra_SmlSimulateSeq( pNew, 0, 128 * nFrames, 1 + 16/(1+Aig_ManNodeNum(pNew)/1000), 1 );
if ( pParSec->fVerbose )
{
printf( "Seq simulation : Latches = %5d. Nodes = %6d. ",
Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
if ( pSml->fNonConstOut )
{
@@ -432,9 +432,9 @@ PRT( "Time", clock() - clk );
printf( "The counter-example is invalid because of phase abstraction.\n" );
else
{
- FREE( p->pSeqModel );
+ ABC_FREE( p->pSeqModel );
p->pSeqModel = Ssw_SmlDupCounterExample( pNew->pSeqModel, Aig_ManRegNum(p) );
- FREE( pNew->pSeqModel );
+ ABC_FREE( pNew->pSeqModel );
}
Fra_SmlStop( pSml );
@@ -443,12 +443,12 @@ PRT( "Time", clock() - clk );
if ( !pParSec->fSilent )
{
printf( "Networks are NOT EQUIVALENT after simulation. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
if ( pParSec->fReportSolution && !pParSec->fRecursive )
{
printf( "SOLUTION: FAIL " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
return RetValue;
}
@@ -481,7 +481,7 @@ clk = clock();
if ( pNewOrpos->pSeqModel )
{
Ssw_Cex_t * pCex;
- FREE( pNew->pSeqModel );
+ ABC_FREE( pNew->pSeqModel );
pCex = pNew->pSeqModel = pNewOrpos->pSeqModel; pNewOrpos->pSeqModel = NULL;
pCex->iPo = Ssw_SmlFindOutputCounterExample( pNew, pNew->pSeqModel );
}
@@ -498,7 +498,7 @@ clk = clock();
printf( "Property UNDECIDED after interpolation. " );
else
assert( 0 );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
}
@@ -518,12 +518,12 @@ finish:
if ( !pParSec->fSilent )
{
printf( "Networks are equivalent. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
if ( pParSec->fReportSolution && !pParSec->fRecursive )
{
printf( "SOLUTION: PASS " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
}
else if ( RetValue == 0 )
@@ -531,12 +531,12 @@ PRT( "Time", clock() - clkTotal );
if ( !pParSec->fSilent )
{
printf( "Networks are NOT EQUIVALENT. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
if ( pParSec->fReportSolution && !pParSec->fRecursive )
{
printf( "SOLUTION: FAIL " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
}
else
@@ -544,12 +544,12 @@ PRT( "Time", clock() - clkTotal );
if ( !pParSec->fSilent )
{
printf( "Networks are UNDECIDED. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
if ( pParSec->fReportSolution && !pParSec->fRecursive )
{
printf( "SOLUTION: UNDECIDED " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
if ( !TimeOut && !pParSec->fSilent )
{
@@ -566,9 +566,9 @@ PRT( "Time", clock() - clkTotal );
printf( "The counter-example is invalid because of phase abstraction.\n" );
else
{
- FREE( p->pSeqModel );
+ ABC_FREE( p->pSeqModel );
p->pSeqModel = Ssw_SmlDupCounterExample( pNew->pSeqModel, Aig_ManRegNum(p) );
- FREE( pNew->pSeqModel );
+ ABC_FREE( pNew->pSeqModel );
}
}
if ( ppResult != NULL )
diff --git a/src/aig/fra/fraSim.c b/src/aig/fra/fraSim.c
index d1d73a03..aff21219 100644
--- a/src/aig/fra/fraSim.c
+++ b/src/aig/fra/fraSim.c
@@ -293,7 +293,7 @@ void Fra_SmlCheckOutputSavePattern( Fra_Man_t * p, Aig_Obj_t * pObjPo )
// determine the best pattern
BestPat = i * 32 + k;
// fill in the counter-example data
- pModel = ALLOC( int, Aig_ManPiNum(p->pManFraig)+1 );
+ pModel = ABC_ALLOC( int, Aig_ManPiNum(p->pManFraig)+1 );
Aig_ManForEachPi( p->pManAig, pObjPi, i )
{
pModel[i] = Aig_InfoHasBit(Fra_ObjSim(p->pSml, pObjPi->Id), BestPat);
@@ -804,7 +804,7 @@ printf( "Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize(
Fra_Sml_t * Fra_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFrame )
{
Fra_Sml_t * p;
- p = (Fra_Sml_t *)malloc( sizeof(Fra_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame );
+ p = (Fra_Sml_t *)ABC_ALLOC( char, sizeof(Fra_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame );
memset( p, 0, sizeof(Fra_Sml_t) + sizeof(unsigned) * (nPref + nFrames) * nWordsFrame );
p->pAig = pAig;
p->nPref = nPref;
@@ -828,7 +828,7 @@ Fra_Sml_t * Fra_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFr
***********************************************************************/
void Fra_SmlStop( Fra_Sml_t * p )
{
- free( p );
+ ABC_FREE( p );
}
@@ -863,12 +863,13 @@ Fra_Sml_t * Fra_SmlSimulateComb( Aig_Man_t * pAig, int nWords )
SeeAlso []
***********************************************************************/
-Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords )
+Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords, int fCheckMiter )
{
Fra_Sml_t * p;
p = Fra_SmlStart( pAig, nPref, nFrames, nWords );
Fra_SmlInitialize( p, 1 );
Fra_SmlSimulateOne( p );
+ if ( fCheckMiter )
p->fNonConstOut = Fra_SmlCheckNonConstOutputs( p );
return p;
}
@@ -888,7 +889,7 @@ Fra_Cex_t * Fra_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
{
Fra_Cex_t * pCex;
int nWords = Aig_BitWordNum( nRegs + nRealPis * nFrames );
- pCex = (Fra_Cex_t *)malloc( sizeof(Fra_Cex_t) + sizeof(unsigned) * nWords );
+ pCex = (Fra_Cex_t *)ABC_ALLOC( char, sizeof(Fra_Cex_t) + sizeof(unsigned) * nWords );
memset( pCex, 0, sizeof(Fra_Cex_t) + sizeof(unsigned) * nWords );
pCex->nRegs = nRegs;
pCex->nPis = nRealPis;
@@ -909,7 +910,7 @@ Fra_Cex_t * Fra_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
***********************************************************************/
void Fra_SmlFreeCounterExample( Fra_Cex_t * pCex )
{
- free( pCex );
+ ABC_FREE( pCex );
}
/**Function*************************************************************
diff --git a/src/aig/fsim/fsim.h b/src/aig/fsim/fsim.h
index c890ff29..4e1588a7 100644
--- a/src/aig/fsim/fsim.h
+++ b/src/aig/fsim/fsim.h
@@ -21,10 +21,6 @@
#ifndef __FSIM_H__
#define __FSIM_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimFront.c b/src/aig/fsim/fsimFront.c
index d40b1c6f..14906c0b 100644
--- a/src/aig/fsim/fsimFront.c
+++ b/src/aig/fsim/fsimFront.c
@@ -202,11 +202,11 @@ void Fsim_ManVerifyFront( Fsim_Man_t * p )
int * pFans0, * pFans1; // representation of fanins
int * pFrontToId; // mapping of nodes into frontier variables
int i, iVar0, iVar1;
- pFans0 = ALLOC( int, p->nObjs );
- pFans1 = ALLOC( int, p->nObjs );
+ pFans0 = ABC_ALLOC( int, p->nObjs );
+ pFans1 = ABC_ALLOC( int, p->nObjs );
pFans0[0] = pFans1[0] = 0;
pFans0[1] = pFans1[1] = 0;
- pFrontToId = CALLOC( int, p->nFront );
+ pFrontToId = ABC_CALLOC( int, p->nFront );
if ( Aig_ObjRefs(Aig_ManConst1(p->pAig)) )
pFrontToId[1] = 1;
Fsim_ManForEachObj( p, pObj, i )
@@ -223,9 +223,9 @@ void Fsim_ManVerifyFront( Fsim_Man_t * p )
assert( pFans0[i] == p->pFans0[i] );
assert( pFans1[i] == p->pFans1[i] );
}
- free( pFrontToId );
- free( pFans0 );
- free( pFans1 );
+ ABC_FREE( pFrontToId );
+ ABC_FREE( pFans0 );
+ ABC_FREE( pFans1 );
}
/**Function*************************************************************
@@ -246,8 +246,8 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig )
int * pIdToFront; // mapping of nodes into frontier places
int i, iVar0, iVar1, nCrossCut = 0, nCrossCutMax = 0;
// start the frontier
- pFront = CALLOC( char, p->nFront );
- pIdToFront = ALLOC( int, p->nObjs );
+ pFront = ABC_CALLOC( char, p->nFront );
+ pIdToFront = ABC_ALLOC( int, p->nObjs );
pIdToFront[0] = -1;
pIdToFront[1] = -1;
// add constant node
@@ -261,13 +261,13 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig )
if ( fCompressAig )
{
p->nDataAig = p->nObjs * 6;
- p->pDataAig = ALLOC( unsigned char, p->nDataAig );
+ p->pDataAig = ABC_ALLOC( unsigned char, p->nDataAig );
p->pDataCur = p->pDataAig;
p->iNodePrev = 0;
}
else
{
- p->pDataAig2 = ALLOC( int, 3 * p->nObjs );
+ p->pDataAig2 = ABC_ALLOC( int, 3 * p->nObjs );
p->pDataCur2 = p->pDataAig2 + 6;
}
// iterate through the objects
@@ -349,12 +349,12 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig )
assert( nCrossCutMax == p->nCrossCutMax );
for ( i = 0; i < p->nFront; i++ )
assert( pFront[i] == 0 );
- free( pFront );
- free( pIdToFront );
+ ABC_FREE( pFront );
+ ABC_FREE( pIdToFront );
// Fsim_ManVerifyFront( p );
- FREE( p->pFans0 );
- FREE( p->pFans1 );
- FREE( p->pRefs );
+ ABC_FREE( p->pFans0 );
+ ABC_FREE( p->pFans1 );
+ ABC_FREE( p->pRefs );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimInt.h b/src/aig/fsim/fsimInt.h
index 0944bf0c..f46a9024 100644
--- a/src/aig/fsim/fsimInt.h
+++ b/src/aig/fsim/fsimInt.h
@@ -21,10 +21,6 @@
#ifndef __FSIM_INT_H__
#define __FSIM_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -36,6 +32,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimMan.c b/src/aig/fsim/fsimMan.c
index f7a40f40..872e1604 100644
--- a/src/aig/fsim/fsimMan.c
+++ b/src/aig/fsim/fsimMan.c
@@ -102,7 +102,7 @@ Fsim_Man_t * Fsim_ManCreate( Aig_Man_t * pAig )
Aig_Obj_t * pObj;
int i, nObjs;
Aig_ManCleanData( pAig );
- p = (Fsim_Man_t *)ALLOC( Fsim_Man_t, 1 );
+ p = (Fsim_Man_t *)ABC_ALLOC( Fsim_Man_t, 1 );
memset( p, 0, sizeof(Fsim_Man_t) );
p->pAig = pAig;
p->nPis = Saig_ManPiNum(pAig);
@@ -111,9 +111,9 @@ Fsim_Man_t * Fsim_ManCreate( Aig_Man_t * pAig )
p->nCos = Aig_ManPoNum(pAig);
p->nNodes = Aig_ManNodeNum(pAig);
nObjs = p->nCis + p->nCos + p->nNodes + 2;
- p->pFans0 = ALLOC( int, nObjs );
- p->pFans1 = ALLOC( int, nObjs );
- p->pRefs = ALLOC( int, nObjs );
+ p->pFans0 = ABC_ALLOC( int, nObjs );
+ p->pFans1 = ABC_ALLOC( int, nObjs );
+ p->pRefs = ABC_ALLOC( int, nObjs );
p->vCis2Ids = Vec_IntAlloc( Aig_ManPiNum(pAig) );
// add objects (0=unused; 1=const1)
p->pFans0[0] = p->pFans1[0] = 0;
@@ -168,17 +168,17 @@ void Fsim_ManDelete( Fsim_Man_t * p )
Vec_IntFree( p->vCis2Ids );
Vec_IntFree( p->vLos );
Vec_IntFree( p->vLis );
- FREE( p->pDataAig2 );
- FREE( p->pDataAig );
- FREE( p->pFans0 );
- FREE( p->pFans1 );
- FREE( p->pRefs );
- FREE( p->pDataSim );
- FREE( p->pDataSimCis );
- FREE( p->pDataSimCos );
- FREE( p->pData1 );
- FREE( p->pData2 );
- FREE( p );
+ ABC_FREE( p->pDataAig2 );
+ ABC_FREE( p->pDataAig );
+ ABC_FREE( p->pFans0 );
+ ABC_FREE( p->pFans1 );
+ ABC_FREE( p->pRefs );
+ ABC_FREE( p->pDataSim );
+ ABC_FREE( p->pDataSimCis );
+ ABC_FREE( p->pDataSimCos );
+ ABC_FREE( p->pData1 );
+ ABC_FREE( p->pData2 );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/fsim/fsimSim.c b/src/aig/fsim/fsimSim.c
index 320c06a9..52dedc6d 100644
--- a/src/aig/fsim/fsimSim.c
+++ b/src/aig/fsim/fsimSim.c
@@ -385,7 +385,7 @@ void Fsim_ManSimulateRoundTest( Fsim_Man_t * p )
Fsim_ManForEachObj( p, pObj, i )
{
}
-// PRT( "Unpacking time", p->pPars->nIters * (clock() - clk) );
+// ABC_PRT( "Unpacking time", p->pPars->nIters * (clock() - clk) );
}
/**Function*************************************************************
@@ -437,7 +437,7 @@ Ssw_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int
// fill in the binary data
Aig_ManRandom( 1 );
Counter = p->nRegs;
- pData = ALLOC( unsigned, nWords );
+ pData = ABC_ALLOC( unsigned, nWords );
for ( f = 0; f <= iFrame; f++, Counter += p->nPis )
for ( i = 0; i < Aig_ManPiNum(pAig); i++ )
{
@@ -449,7 +449,7 @@ Ssw_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int
if ( Aig_InfoHasBit( pData, iPat ) )
Aig_InfoSetBit( p->pData, Counter + iPioId );
}
- free( pData );
+ ABC_FREE( pData );
return p;
}
@@ -470,16 +470,19 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
Sec_MtrStatus_t Status;
int i, iOut, iPat, clk, clkTotal = clock(), clk2, clk2Total = 0;
assert( Aig_ManRegNum(pAig) > 0 );
- Status = Sec_MiterStatus( pAig );
- if ( Status.nSat > 0 )
+ if ( pPars->fCheckMiter )
{
- printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut );
- return 1;
- }
- if ( Status.nUndec == 0 )
- {
- printf( "Miter is trivially unsatisfiable.\n" );
- return 0;
+ Status = Sec_MiterStatus( pAig );
+ if ( Status.nSat > 0 )
+ {
+ printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut );
+ return 1;
+ }
+ if ( Status.nUndec == 0 )
+ {
+ printf( "Miter is trivially unsatisfiable.\n" );
+ return 0;
+ }
}
// create manager
clk = clock();
@@ -490,7 +493,7 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ",
p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront,
4.0*p->nWords*(p->nFront)/(1<<20) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// create simulation frontier
clk = clock();
@@ -501,14 +504,14 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
p->iNumber, Aig_Base2Log(p->iNumber),
1.0*(p->pDataCur-p->pDataAig)/(1<<20),
1.0*(p->pDataCur-p->pDataAig)/p->nObjs );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// perform simulation
Aig_ManRandom( 1 );
assert( p->pDataSim == NULL );
- p->pDataSim = ALLOC( unsigned, p->nWords * p->nFront * sizeof(unsigned) );
- p->pDataSimCis = ALLOC( unsigned, p->nWords * p->nCis * sizeof(unsigned) );
- p->pDataSimCos = ALLOC( unsigned, p->nWords * p->nCos * sizeof(unsigned) );
+ p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->nFront );
+ p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * p->nCis );
+ p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * p->nCos );
Fsim_ManSimInfoInit( p );
for ( i = 0; i < pPars->nIters; i++ )
{
@@ -542,9 +545,9 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
p->nCrossCutMax,
p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
4.0*p->nWords*(p->nFront+p->nCis+p->nCos)/(1<<20) );
- PRT( "Sim time", clock() - clkTotal );
+ ABC_PRT( "Sim time", clock() - clkTotal );
-// PRT( "Additional time", clk2Total );
+// ABC_PRT( "Additional time", clk2Total );
// Fsim_ManSimulateRoundTest( p );
// Fsim_ManSimulateRoundTest2( p );
}
diff --git a/src/aig/fsim/fsimSwitch.c b/src/aig/fsim/fsimSwitch.c
index 00046af6..97cb612f 100644
--- a/src/aig/fsim/fsimSwitch.c
+++ b/src/aig/fsim/fsimSwitch.c
@@ -28,559 +28,6 @@
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoRandom( Fsim_Man_t * p, unsigned * pInfo, int nProbNum )
-{
- unsigned Mask;
- int w, i;
- if ( nProbNum )
- {
- Mask = Aig_ManRandom( 0 );
- for ( i = 0; i < nProbNum; i++ )
- Mask &= Aig_ManRandom( 0 );
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] ^= Mask;
- }
- else
- {
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = Aig_ManRandom( 0 );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoRandomShift( Fsim_Man_t * p, unsigned * pInfo, int nProbNum )
-{
- unsigned Mask;
- int w, i;
- Mask = Aig_ManRandom( 0 );
- for ( i = 0; i < nProbNum; i++ )
- Mask &= Aig_ManRandom( 0 );
- if ( p->nWords == 1 )
- pInfo[0] = (pInfo[0] << 16) | ((pInfo[0] ^ Mask) & 0xffff);
- else
- {
- assert( (p->nWords & 1) == 0 ); // should be even number
- for ( w = p->nWords-1; w >= 0; w-- )
- if ( w >= p->nWords/2 )
- pInfo[w] = pInfo[w - p->nWords/2];
- else
- pInfo[w] ^= Mask;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoZero( Fsim_Man_t * p, unsigned * pInfo )
-{
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoOne( Fsim_Man_t * p, unsigned * pInfo )
-{
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoCopy( Fsim_Man_t * p, unsigned * pInfo, unsigned * pInfo0 )
-{
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoCopyShift( Fsim_Man_t * p, unsigned * pInfo, unsigned * pInfo0 )
-{
- int w;
- if ( p->nWords == 1 )
- pInfo[0] = (pInfo[0] << 16) | (pInfo0[0] & 0xffff);
- else
- {
- assert( (p->nWords & 1) == 0 ); // should be even number
- for ( w = p->nWords-1; w >= 0; w-- )
- {
- if ( w >= p->nWords/2 )
- pInfo[w] = pInfo[w - p->nWords/2];
- else
- pInfo[w] = pInfo0[w];
- }
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateCi( Fsim_Man_t * p, int iNode, int iCi )
-{
- unsigned * pInfo = Fsim_SimData( p, iNode % p->nFront );
- unsigned * pInfo0 = Fsim_SimDataCi( p, iCi );
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateCo( Fsim_Man_t * p, int iCo, int iFan0 )
-{
- unsigned * pInfo = Fsim_SimDataCo( p, iCo );
- unsigned * pInfo0 = Fsim_SimData( p, Fsim_Lit2Var(iFan0) % p->nFront );
- int w;
- if ( Fsim_LitIsCompl(iFan0) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~pInfo0[w];
- else //if ( !Fsim_LitIsCompl(iFan0) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateNode( Fsim_Man_t * p, int iNode, int iFan0, int iFan1 )
-{
- unsigned * pInfo = Fsim_SimData( p, iNode % p->nFront );
- unsigned * pInfo0 = Fsim_SimData( p, Fsim_Lit2Var(iFan0) % p->nFront );
- unsigned * pInfo1 = Fsim_SimData( p, Fsim_Lit2Var(iFan1) % p->nFront );
- int w;
- if ( Fsim_LitIsCompl(iFan0) && Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
- else if ( Fsim_LitIsCompl(iFan0) && !Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~pInfo0[w] & pInfo1[w];
- else if ( !Fsim_LitIsCompl(iFan0) && Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w] & ~pInfo1[w];
- else //if ( !Fsim_LitIsCompl(iFan0) && !Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w] & pInfo1[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoInit( Fsim_Man_t * p )
-{
- int iPioNum, i;
- Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
- {
- if ( iPioNum < p->nPis )
- Fsim_ManSwitchSimInfoRandom( p, Fsim_SimDataCi(p, i), 0 );
- else
- Fsim_ManSwitchSimInfoZero( p, Fsim_SimDataCi(p, i) );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoTransfer( Fsim_Man_t * p, int nProbNum )
-{
- int iPioNum, i;
- Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
- {
- if ( iPioNum < p->nPis )
- Fsim_ManSwitchSimInfoRandom( p, Fsim_SimDataCi(p, i), nProbNum );
- else
- Fsim_ManSwitchSimInfoCopy( p, Fsim_SimDataCi(p, i), Fsim_SimDataCo(p, p->nPos+iPioNum-p->nPis) );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoTransferShift( Fsim_Man_t * p, int nProbNum )
-{
- int iPioNum, i;
- Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
- {
- if ( iPioNum < p->nPis )
- Fsim_ManSwitchSimInfoRandomShift( p, Fsim_SimDataCi(p, i), nProbNum );
- else
- Fsim_ManSwitchSimInfoCopyShift( p, Fsim_SimDataCi(p, i), Fsim_SimDataCo(p, p->nPos+iPioNum-p->nPis) );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Fsim_ManSwitchSimInfoCountOnes( Fsim_Man_t * p, int iNode )
-{
- unsigned * pInfo;
- int w, Counter = 0;
- pInfo = Fsim_SimData( p, iNode % p->nFront );
- for ( w = p->nWords-1; w >= 0; w-- )
- Counter += Aig_WordCountOnes( pInfo[w] );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Fsim_ManSwitchSimInfoCountTrans( Fsim_Man_t * p, int iNode )
-{
- unsigned * pInfo;
- int w, Counter = 0;
- assert( iNode % p->nFront );
- pInfo = Fsim_SimData( p, iNode % p->nFront );
- if ( p->nWords == 1 )
- return Aig_WordCountOnes( (pInfo[0] ^ (pInfo[0] >> 16)) & 0xffff );
- for ( w = p->nWords/2-1; w >= 0; w-- )
- Counter += Aig_WordCountOnes( pInfo[w] ^ pInfo[w + p->nWords/2] );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateRound( Fsim_Man_t * p, int fCount )
-{
- int * pCur, * pEnd;
- int i, iCis = 0, iCos = 0;
- if ( Aig_ObjRefs(Aig_ManConst1(p->pAig)) )
- Fsim_ManSwitchSimInfoOne( p, Fsim_SimData(p, 1) );
- pCur = p->pDataAig2 + 6;
- pEnd = p->pDataAig2 + 3 * p->nObjs;
- for ( i = 2; pCur < pEnd; i++ )
- {
- if ( pCur[1] == 0 )
- Fsim_ManSwitchSimulateCi( p, pCur[0], iCis++ );
- else if ( pCur[2] == 0 )
- Fsim_ManSwitchSimulateCo( p, iCos++, pCur[1] );
- else
- Fsim_ManSwitchSimulateNode( p, pCur[0], pCur[1], pCur[2] );
- if ( fCount && pCur[0] )
- {
- if ( p->pData1 )
- p->pData1[i] += Fsim_ManSwitchSimInfoCountOnes( p, pCur[0] );
- if ( p->pData2 )
- p->pData2[i] += Fsim_ManSwitchSimInfoCountTrans( p, pCur[0] );
- }
- pCur += 3;
- }
- assert( iCis == p->nCis );
- assert( iCos == p->nCos );
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes switching activity of one node.]
-
- Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float Fsim_ManSwitchComputeSwitching( int nOnes, int nSimWords )
-{
- int nTotal = 32 * nSimWords;
- return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes switching activity of one node.]
-
- Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float Fsim_ManSwitchComputeProbOne( int nOnes, int nSimWords )
-{
- int nTotal = 32 * nSimWords;
- return (float)nOnes / nTotal;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Fsim_ManSwitchSimulate( Aig_Man_t * pAig, Fsim_ParSwitch_t * pPars )
-{
- Vec_Int_t * vSwitching;
- float * pSwitching;
- Aig_Obj_t * pObj;
- Fsim_Man_t * p;
- int i, clk, clkTotal = clock();
- // create manager
- clk = clock();
- p = Fsim_ManCreate( pAig );
- p->nWords = pPars->nWords;
- // if the number of words is larger then 1, it should be even
- if ( p->nWords > 1 && (p->nWords & 1) )
- p->nWords++;
- // print stats
- if ( pPars->fVerbose )
- {
- printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ",
- p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront,
- 4.0*pPars->nWords*(p->nFront)/(1<<20) );
- PRT( "Time", clock() - clk );
- }
- // create simulation frontier
- clk = clock();
- Fsim_ManFront( p, 0 );
- if ( pPars->fVerbose )
- {
- printf( "Max ID = %8d. Log max ID = %2d. AigMem = %7.2f Mb (%5.2f byte/obj). ",
- p->iNumber, Aig_Base2Log(p->iNumber),
- 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
- 1.0*(p->pDataCur-p->pDataAig)/p->nObjs );
- PRT( "Time", clock() - clk );
- }
- // perform simulation
- Aig_ManRandom( 1 );
- assert( p->pDataSim == NULL );
- p->pDataSim = ALLOC( unsigned, pPars->nWords * p->nFront * sizeof(unsigned) );
- p->pDataSimCis = ALLOC( unsigned, pPars->nWords * p->nCis * sizeof(unsigned) );
- p->pDataSimCos = ALLOC( unsigned, pPars->nWords * p->nCos * sizeof(unsigned) );
- if ( pPars->fProbOne )
- p->pData1 = CALLOC( int, p->nObjs * sizeof(int) );
- if ( pPars->fProbTrans )
- p->pData2 = CALLOC( int, p->nObjs * sizeof(int) );
- Fsim_ManSwitchSimInfoInit( p );
- for ( i = 0; i < pPars->nIters; i++ )
- {
- Fsim_ManSwitchSimulateRound( p, i >= pPars->nPref );
- if ( i < pPars->nIters - 1 )
- {
-// if ( pPars->fProbTrans )
- Fsim_ManSwitchSimInfoTransferShift( p, pPars->nRandPiNum );
-// else
-// Fsim_ManSwitchSimInfoTransfer( p, pPars->nRandPiNum );
- }
- }
- if ( pPars->fVerbose )
- {
- printf( "Maxcut = %8d. AigMem = %7.2f Mb. SimMem = %7.2f Mb. ",
- p->nCrossCutMax,
- p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
- 4.0*pPars->nWords*(p->nFront+p->nCis+p->nCos)/(1<<20) );
- PRT( "Sim time", clock() - clkTotal );
- }
- // derive the result
- vSwitching = Vec_IntStart( Aig_ManObjNumMax(pAig) );
- pSwitching = (float *)vSwitching->pArray;
-/*
- if ( pPars->fProbOne && pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
-// pSwitching[pObj->Id] = Fsim_ManSwitchComputeSwitching( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) );
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 );
- }
- else if ( !pPars->fProbOne && pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 );
- }
- else if ( pPars->fProbOne && !pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) );
- }
- else
- assert( 0 );
-*/
- if ( pPars->fProbOne && !pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) );
- }
- else if ( !pPars->fProbOne && pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 );
- }
- else
- assert( 0 );
- Fsim_ManDelete( p );
- return vSwitching;
-
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes probability of switching (or of being 1).]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Saig_ManComputeSwitchProbs4( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
-{
- Fsim_ParSwitch_t Pars, * pPars = &Pars;
- Fsim_ManSetDefaultParamsSwitch( pPars );
- pPars->nWords = 1;
- pPars->nIters = nFrames;
- pPars->nPref = nPref;
- if ( fProbOne )
- {
- pPars->fProbOne = 1;
- pPars->fProbTrans = 0;
- }
- else
- {
- pPars->fProbOne = 0;
- pPars->fProbTrans = 1;
- }
- pPars->fVerbose = 0;
- return Fsim_ManSwitchSimulate( p, pPars );
-}
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimTsim.c b/src/aig/fsim/fsimTsim.c
index 963d7581..0de283e4 100644
--- a/src/aig/fsim/fsimTsim.c
+++ b/src/aig/fsim/fsimTsim.c
@@ -36,7 +36,7 @@ static inline int Aig_XsimNotCond( int Value, int fCompl )
return FSIM_ZER;
return FSIM_ONE;
}
-static inline int Aig_XsimAndCond( int Value0, int Value1, int fCompl0, int fCompl1 )
+static inline int Aig_XsimAndCond( int Value0, int fCompl0, int Value1, int fCompl1 )
{
if ( Value0 == FSIM_UND || Value1 == FSIM_UND )
return FSIM_UND;
@@ -111,7 +111,7 @@ static inline void Fsim_ManTerSimulateNode( Fsim_Man_t * p, int iNode, int iFan0
{
int Value0 = Fsim_ManTerSimInfoGet( p->pDataSim, Fsim_Lit2Var(iFan0) );
int Value1 = Fsim_ManTerSimInfoGet( p->pDataSim, Fsim_Lit2Var(iFan1) );
- Fsim_ManTerSimInfoSet( p->pDataSim, iNode, Aig_XsimAndCond( Value0, Value1, Fsim_LitIsCompl(iFan0), Fsim_LitIsCompl(iFan1) ) );
+ Fsim_ManTerSimInfoSet( p->pDataSim, iNode, Aig_XsimAndCond( Value0, Fsim_LitIsCompl(iFan0), Value1, Fsim_LitIsCompl(iFan1) ) );
}
/**Function*************************************************************
@@ -253,7 +253,7 @@ unsigned * Fsim_ManTerStateCreate( unsigned * pInfo, int nPis, int nCis, int nWo
{
unsigned * pRes;
int i;
- pRes = (unsigned *)CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) );
+ pRes = (unsigned *)ABC_CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) );
for ( i = nPis; i < nCis; i++ )
Fsim_ManTerSimInfoSet( pRes, i-nPis, Fsim_ManTerSimInfoGet(pInfo, i) );
return pRes;
@@ -348,7 +348,7 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose )
printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ",
p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront,
4.0*Aig_BitWordNum(2 * p->nFront)/(1<<20) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// create simulation frontier
clk = clock();
@@ -359,19 +359,19 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose )
p->iNumber, Aig_Base2Log(p->iNumber),
1.0*(p->pDataCur-p->pDataAig)/(1<<20),
1.0*(p->pDataCur-p->pDataAig)/p->nObjs );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// allocate storage for terminary states
nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) );
vStates = Vec_PtrAlloc( 1000 );
nBins = Aig_PrimeCudd( 500 );
- pBins = ALLOC( unsigned *, nBins );
+ pBins = ABC_ALLOC( unsigned *, nBins );
memset( pBins, 0, sizeof(unsigned *) * nBins );
// perform simulation
assert( p->pDataSim == NULL );
- p->pDataSim = ALLOC( unsigned, Aig_BitWordNum(2 * p->nFront) * sizeof(unsigned) );
- p->pDataSimCis = ALLOC( unsigned, Aig_BitWordNum(2 * p->nCis) * sizeof(unsigned) );
- p->pDataSimCos = ALLOC( unsigned, Aig_BitWordNum(2 * p->nCos) * sizeof(unsigned) );
+ p->pDataSim = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nFront) * sizeof(unsigned) );
+ p->pDataSimCis = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nCis) * sizeof(unsigned) );
+ p->pDataSimCos = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nCos) * sizeof(unsigned) );
Fsim_ManTerSimInfoInit( p );
// hash the first state
pState = Fsim_ManTerStateCreate( p->pDataSimCis, p->nPis, p->nCis, nWords );
@@ -395,9 +395,9 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose )
p->nCrossCutMax,
p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
4.0*(Aig_BitWordNum(2 * p->nFront)+Aig_BitWordNum(2 * p->nCis)+Aig_BitWordNum(2 * p->nCos))/(1<<20) );
- PRT( "Sim time", clock() - clkTotal );
+ ABC_PRT( "Sim time", clock() - clkTotal );
}
- free( pBins );
+ ABC_FREE( pBins );
Fsim_ManDelete( p );
return vStates;
diff --git a/src/aig/gia/gia.c b/src/aig/gia/gia.c
new file mode 100644
index 00000000..4cbb1731
--- /dev/null
+++ b/src/aig/gia/gia.c
@@ -0,0 +1,47 @@
+/**CFile****************************************************************
+
+ FileName [gia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h
new file mode 100644
index 00000000..721056de
--- /dev/null
+++ b/src/aig/gia/gia.h
@@ -0,0 +1,423 @@
+/**CFile****************************************************************
+
+ FileName [gia.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: gia.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __GIA_H__
+#define __GIA_H__
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+#include "aig.h"
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GIA_NONE 0x1FFFFFFF
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Gia_Obj_t_ Gia_Obj_t;
+struct Gia_Obj_t_
+{
+ unsigned iDiff0 : 29; // the diff of the first fanin
+ unsigned fCompl0: 1; // the complemented attribute
+ unsigned fMark0 : 1; // first user-controlled mark
+ unsigned fTerm : 1; // terminal node (CI/CO)
+
+ unsigned iDiff1 : 29; // the diff of the second fanin
+ unsigned fCompl1: 1; // the complemented attribute
+ unsigned fMark1 : 1; // second user-controlled mark
+ unsigned fPhase : 1; // value under 000 pattern
+
+ unsigned Value; // application-specific value
+};
+
+typedef struct Gia_Man_t_ Gia_Man_t;
+struct Gia_Man_t_
+{
+ char * pName; // name of the AIG
+ int nRegs; // number of registers
+ int nRegsAlloc; // number of allocated registers
+ int nObjs; // number of objects
+ int nObjsAlloc; // number of allocated objects
+ Gia_Obj_t * pObjs; // the array of objects
+ Vec_Int_t * vCis; // the vector of CIs (PIs + LOs)
+ Vec_Int_t * vCos; // the vector of COs (POs + LIs)
+ int * pHTable; // hash table
+ int nHTable; // hash table size
+ int fAddStrash; // performs additional structural hashing
+ int * pRefs; // the reference count
+ int * pLevels; // levels of the nodes
+ int nLevels; // the mamixum level
+ int nTravIds; // the current traversal ID
+ int nFront; // frontier size
+ int * pReprs; // representatives (for CIs and ANDs)
+ int nTerLoop; // the state where loop begins
+ int nTerStates; // the total number of ternary states
+ int * pFanData; // the database to store fanout information
+ int nFansAlloc; // the size of fanout representation
+};
+
+
+
+
+// frames parameters
+typedef struct Gia_ParFra_t_ Gia_ParFra_t;
+struct Gia_ParFra_t_
+{
+ int nFrames; // the number of frames to unroll
+ int fInit; // initialize the timeframes
+ int fVerbose; // enables verbose output
+};
+
+
+
+// simulation parameters
+typedef struct Gia_ParSim_t_ Gia_ParSim_t;
+struct Gia_ParSim_t_
+{
+ // user-controlled parameters
+ int nWords; // the number of machine words
+ int nIters; // the number of timeframes
+ int TimeLimit; // time limit in seconds
+ int fCheckMiter; // check if miter outputs are non-zero
+ int fVerbose; // enables verbose output
+};
+
+extern void Gia_ManSimSetDefaultParams( Gia_ParSim_t * p );
+extern int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars );
+
+
+
+static inline int Gia_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
+static inline int Gia_Lit2Var( int Lit ) { return Lit >> 1; }
+static inline int Gia_LitIsCompl( int Lit ) { return Lit & 1; }
+static inline int Gia_LitNot( int Lit ) { return Lit ^ 1; }
+static inline int Gia_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); }
+static inline int Gia_LitRegular( int Lit ) { return Lit & ~01; }
+
+static inline Gia_Obj_t * Gia_Regular( Gia_Obj_t * p ) { return (Gia_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
+static inline Gia_Obj_t * Gia_Not( Gia_Obj_t * p ) { return (Gia_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
+static inline Gia_Obj_t * Gia_NotCond( Gia_Obj_t * p, int c ) { return (Gia_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
+static inline int Gia_IsComplement( Gia_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); }
+
+static inline int Gia_ManCiNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCis); }
+static inline int Gia_ManCoNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCos); }
+static inline int Gia_ManPiNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCis) - p->nRegs; }
+static inline int Gia_ManPoNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCos) - p->nRegs; }
+static inline int Gia_ManRegNum( Gia_Man_t * p ) { return p->nRegs; }
+static inline int Gia_ManObjNum( Gia_Man_t * p ) { return p->nObjs; }
+static inline int Gia_ManAndNum( Gia_Man_t * p ) { return p->nObjs - Vec_IntSize(p->vCis) - Vec_IntSize(p->vCos) - 1; }
+
+static inline Gia_Obj_t * Gia_ManConst0( Gia_Man_t * p ) { return p->pObjs; }
+static inline Gia_Obj_t * Gia_ManConst1( Gia_Man_t * p ) { return Gia_Not(Gia_ManConst0(p)); }
+static inline Gia_Obj_t * Gia_ManObj( Gia_Man_t * p, int v ) { assert( v < p->nObjs ); return p->pObjs + v; }
+static inline Gia_Obj_t * Gia_ManCi( Gia_Man_t * p, int v ) { return Gia_ManObj( p, Vec_IntEntry(p->vCis,v) ); }
+static inline Gia_Obj_t * Gia_ManCo( Gia_Man_t * p, int v ) { return Gia_ManObj( p, Vec_IntEntry(p->vCos,v) ); }
+static inline Gia_Obj_t * Gia_ManPi( Gia_Man_t * p, int v ) { assert( v < Gia_ManPiNum(p) ); return Gia_ManCi( p, v ); }
+static inline Gia_Obj_t * Gia_ManPo( Gia_Man_t * p, int v ) { assert( v < Gia_ManPoNum(p) ); return Gia_ManCo( p, v ); }
+static inline Gia_Obj_t * Gia_ManRo( Gia_Man_t * p, int v ) { assert( v < Gia_ManRegNum(p) ); return Gia_ManCi( p, Gia_ManRegNum(p)+v ); }
+static inline Gia_Obj_t * Gia_ManRi( Gia_Man_t * p, int v ) { assert( v < Gia_ManRegNum(p) ); return Gia_ManCo( p, Gia_ManRegNum(p)+v ); }
+
+static inline int Gia_ObjIsTerm( Gia_Obj_t * pObj ) { return pObj->fTerm; }
+static inline int Gia_ObjIsAndOrConst0( Gia_Obj_t * pObj ) { return!pObj->fTerm; }
+static inline int Gia_ObjIsCi( Gia_Obj_t * pObj ) { return pObj->fTerm && pObj->iDiff0 == GIA_NONE; }
+static inline int Gia_ObjIsCo( Gia_Obj_t * pObj ) { return pObj->fTerm && pObj->iDiff0 != GIA_NONE; }
+static inline int Gia_ObjIsAnd( Gia_Obj_t * pObj ) { return!pObj->fTerm && pObj->iDiff0 != GIA_NONE; }
+static inline int Gia_ObjIsConst0( Gia_Obj_t * pObj ) { return pObj->iDiff0 == GIA_NONE && pObj->iDiff1 == GIA_NONE; }
+static inline int Gia_ManObjIsConst0( Gia_Man_t * p, Gia_Obj_t * pObj){ return pObj == p->pObjs; }
+
+static inline int Gia_ObjId( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pObjs <= pObj && pObj < p->pObjs + p->nObjs ); return pObj - p->pObjs; }
+static inline int Gia_ObjCioId( Gia_Obj_t * pObj ) { assert( Gia_ObjIsTerm(pObj) ); return pObj->iDiff1; }
+static inline void Gia_ObjSetCioId( Gia_Obj_t * pObj, int v ) { assert( Gia_ObjIsTerm(pObj) ); pObj->iDiff1 = v; }
+static inline int Gia_ObjPhase( Gia_Obj_t * pObj ) { return pObj->fPhase; }
+static inline int Gia_ObjPhaseReal( Gia_Obj_t * pObj ) { return Gia_Regular(pObj)->fPhase ^ Gia_IsComplement(pObj); }
+
+static inline int Gia_ObjIsPi( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCi(pObj) && Gia_ObjCioId(pObj) < Gia_ManPiNum(p); }
+static inline int Gia_ObjIsPo( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCo(pObj) && Gia_ObjCioId(pObj) < Gia_ManPoNum(p); }
+static inline int Gia_ObjIsRo( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCi(pObj) && Gia_ObjCioId(pObj) >= Gia_ManPiNum(p); }
+static inline int Gia_ObjIsRi( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCo(pObj) && Gia_ObjCioId(pObj) >= Gia_ManPoNum(p); }
+
+static inline Gia_Obj_t * Gia_ObjRoToRi( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsRo(p, pObj) ); return Gia_ManCo(p, Gia_ManCoNum(p) - Gia_ManCiNum(p) + Gia_ObjCioId(pObj)); }
+static inline Gia_Obj_t * Gia_ObjRiToRo( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsRi(p, pObj) ); return Gia_ManCi(p, Gia_ManCiNum(p) - Gia_ManCoNum(p) + Gia_ObjCioId(pObj)); }
+
+static inline int Gia_ObjDiff0( Gia_Obj_t * pObj ) { return pObj->iDiff0; }
+static inline int Gia_ObjDiff1( Gia_Obj_t * pObj ) { return pObj->iDiff1; }
+static inline int Gia_ObjFaninC0( Gia_Obj_t * pObj ) { return pObj->fCompl0; }
+static inline int Gia_ObjFaninC1( Gia_Obj_t * pObj ) { return pObj->fCompl1; }
+static inline Gia_Obj_t * Gia_ObjFanin0( Gia_Obj_t * pObj ) { return pObj - pObj->iDiff0; }
+static inline Gia_Obj_t * Gia_ObjFanin1( Gia_Obj_t * pObj ) { return pObj - pObj->iDiff1; }
+static inline Gia_Obj_t * Gia_ObjChild0( Gia_Obj_t * pObj ) { return Gia_NotCond( Gia_ObjFanin0(pObj), Gia_ObjFaninC0(pObj) ); }
+static inline Gia_Obj_t * Gia_ObjChild1( Gia_Obj_t * pObj ) { return Gia_NotCond( Gia_ObjFanin1(pObj), Gia_ObjFaninC1(pObj) ); }
+static inline int Gia_ObjFaninId0( Gia_Obj_t * pObj, int ObjId ) { return ObjId - pObj->iDiff0; }
+static inline int Gia_ObjFaninId1( Gia_Obj_t * pObj, int ObjId ) { return ObjId - pObj->iDiff1; }
+static inline int Gia_ObjFaninId0p( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjFaninId0( pObj, Gia_ObjId(p, pObj) ); }
+static inline int Gia_ObjFaninId1p( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjFaninId1( pObj, Gia_ObjId(p, pObj) ); }
+static inline int Gia_ObjFaninLit0( Gia_Obj_t * pObj, int ObjId ) { return Gia_Var2Lit( Gia_ObjFaninId0(pObj, ObjId), Gia_ObjFaninC0(pObj) ); }
+static inline int Gia_ObjFaninLit1( Gia_Obj_t * pObj, int ObjId ) { return Gia_Var2Lit( Gia_ObjFaninId1(pObj, ObjId), Gia_ObjFaninC1(pObj) ); }
+static inline int Gia_ObjFaninLit0p( Gia_Man_t * p, Gia_Obj_t * pObj) { return Gia_Var2Lit( Gia_ObjFaninId0p(p, pObj), Gia_ObjFaninC0(pObj) ); }
+static inline int Gia_ObjFaninLit1p( Gia_Man_t * p, Gia_Obj_t * pObj) { return Gia_Var2Lit( Gia_ObjFaninId1p(p, pObj), Gia_ObjFaninC1(pObj) ); }
+static inline void Gia_ObjFlipFaninC0( Gia_Obj_t * pObj ) { assert( Gia_ObjIsCo(pObj) ); pObj->fCompl0 ^= 1; }
+static inline int Gia_ObjWhatFanin( Gia_Obj_t * pObj, Gia_Obj_t * pFanin ) { return Gia_ObjFanin0(pObj) == pFanin ? 0 : (Gia_ObjFanin1(pObj) == pFanin ? 1 : -1); }
+
+static inline int Gia_ObjFanin0Copy( Gia_Obj_t * pObj ) { return Gia_LitNotCond( Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj) ); }
+static inline int Gia_ObjFanin1Copy( Gia_Obj_t * pObj ) { return Gia_LitNotCond( Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC1(pObj) ); }
+
+static inline Gia_Obj_t * Gia_ObjFromLit( Gia_Man_t * p, int iLit ) { return Gia_NotCond( Gia_ManObj(p, Gia_Lit2Var(iLit)), Gia_LitIsCompl(iLit) ); }
+static inline int Gia_ObjToLit( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_LitNotCond( Gia_ObjId(p, pObj), Gia_IsComplement(pObj) ); }
+static inline int Gia_ObjPhaseRealLit( Gia_Man_t * p, int iLit ) { return Gia_ObjPhaseReal( Gia_ObjFromLit(p, iLit) ); }
+
+static inline int Gia_ObjValue( Gia_Obj_t * pObj ) { return pObj->Value; }
+static inline int Gia_ObjLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert(p->pLevels);return p->pLevels[Gia_ObjId(p, pObj)]; }
+
+static inline int Gia_ObjRefs( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); return p->pRefs[Gia_ObjId(p, pObj)]; }
+static inline void Gia_ObjRefInc( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); p->pRefs[Gia_ObjId(p, pObj)]++; }
+static inline void Gia_ObjRefDec( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); p->pRefs[Gia_ObjId(p, pObj)]--; }
+static inline void Gia_ObjRefFanin0Inc(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefInc(p, Gia_ObjFanin0(pObj)); }
+static inline void Gia_ObjRefFanin1Inc(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefInc(p, Gia_ObjFanin1(pObj)); }
+static inline void Gia_ObjRefFanin0Dec(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefDec(p, Gia_ObjFanin0(pObj)); }
+static inline void Gia_ObjRefFanin1Dec(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefDec(p, Gia_ObjFanin1(pObj)); }
+
+static inline void Gia_ManResetTravId( Gia_Man_t * p ) { extern void Gia_ManCleanValue( Gia_Man_t * p ); Gia_ManCleanValue( p ); p->nTravIds = 1; }
+static inline void Gia_ManIncrementTravId( Gia_Man_t * p ) { p->nTravIds++; }
+static inline void Gia_ObjSetTravId( Gia_Obj_t * pObj, int TravId ) { pObj->Value = TravId; }
+static inline void Gia_ObjSetTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { pObj->Value = p->nTravIds; }
+static inline void Gia_ObjSetTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { pObj->Value = p->nTravIds - 1; }
+static inline int Gia_ObjIsTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds); }
+static inline int Gia_ObjIsTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds - 1); }
+
+// AIG construction
+extern void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
+static inline Gia_Obj_t * Gia_ManAppendObj( Gia_Man_t * p )
+{
+ if ( p->nObjs == p->nObjsAlloc )
+ {
+// printf("Reallocing %d.\n", 2 * p->nObjsAlloc );
+ assert( p->nObjsAlloc > 0 );
+ p->pObjs = ABC_REALLOC( Gia_Obj_t, p->pObjs, 2 * p->nObjsAlloc );
+ memset( p->pObjs + p->nObjsAlloc, 0, sizeof(Gia_Obj_t) * p->nObjsAlloc );
+ p->nObjsAlloc *= 2;
+ }
+ return Gia_ManObj( p, p->nObjs++ );
+}
+static inline int Gia_ManAppendCi( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj = Gia_ManAppendObj( p );
+ pObj->fTerm = 1;
+ pObj->iDiff0 = GIA_NONE;
+ pObj->iDiff1 = Vec_IntSize( p->vCis );
+ Vec_IntPush( p->vCis, Gia_ObjId(p, pObj) );
+ return Gia_ObjId( p, pObj ) << 1;
+}
+static inline int Gia_ManAppendAnd( Gia_Man_t * p, int iLit0, int iLit1 )
+{
+ Gia_Obj_t * pObj = Gia_ManAppendObj( p );
+ assert( iLit0 != iLit1 );
+ if ( iLit0 < iLit1 )
+ {
+ pObj->iDiff0 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit0);
+ pObj->fCompl0 = Gia_LitIsCompl(iLit0);
+ pObj->iDiff1 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit1);
+ pObj->fCompl1 = Gia_LitIsCompl(iLit1);
+ }
+ else
+ {
+ pObj->iDiff1 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit0);
+ pObj->fCompl1 = Gia_LitIsCompl(iLit0);
+ pObj->iDiff0 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit1);
+ pObj->fCompl0 = Gia_LitIsCompl(iLit1);
+ }
+ if ( p->pFanData )
+ {
+ Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj );
+ Gia_ObjAddFanout( p, Gia_ObjFanin1(pObj), pObj );
+ }
+ return Gia_ObjId( p, pObj ) << 1;
+}
+static inline int Gia_ManAppendCo( Gia_Man_t * p, int iLit0 )
+{
+ Gia_Obj_t * pObj = Gia_ManAppendObj( p );
+ pObj->fTerm = 1;
+ pObj->iDiff0 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit0);
+ pObj->fCompl0 = Gia_LitIsCompl(iLit0);
+ pObj->iDiff1 = Vec_IntSize( p->vCos );
+ Vec_IntPush( p->vCos, Gia_ObjId(p, pObj) );
+ if ( p->pFanData )
+ Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj );
+ return Gia_ObjId( p, pObj ) << 1;
+}
+
+#define GIA_ZER 1
+#define GIA_ONE 2
+#define GIA_UND 3
+
+static inline int Gia_XsimNotCond( int Value, int fCompl )
+{
+ if ( Value == GIA_UND )
+ return GIA_UND;
+ if ( Value == GIA_ZER + fCompl )
+ return GIA_ZER;
+ return GIA_ONE;
+}
+static inline int Gia_XsimAndCond( int Value0, int fCompl0, int Value1, int fCompl1 )
+{
+ if ( Value0 == GIA_ZER + fCompl0 || Value1 == GIA_ZER + fCompl1 )
+ return GIA_ZER;
+ if ( Value0 == GIA_UND || Value1 == GIA_UND )
+ return GIA_UND;
+ return GIA_ONE;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define Gia_ManForEachObj( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ )
+#define Gia_ManForEachObj1( p, pObj, i ) \
+ for ( i = 1; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ )
+#define Gia_ManForEachObjVec( vVec, p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
+#define Gia_ManForEachAnd( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) if ( !Gia_ObjIsAnd(pObj) ) {} else
+#define Gia_ManForEachCi( p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(p->vCis)) && ((pObj) = Gia_ManCi(p, i)); i++ )
+#define Gia_ManForEachCo( p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(p->vCos)) && ((pObj) = Gia_ManCo(p, i)); i++ )
+#define Gia_ManForEachCoDriver( p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(p->vCos)) && ((pObj) = Gia_ObjFanin0(Gia_ManCo(p, i))); i++ )
+#define Gia_ManForEachPi( p, pObj, i ) \
+ for ( i = 0; (i < Gia_ManPiNum(p)) && ((pObj) = Gia_ManCi(p, i)); i++ )
+#define Gia_ManForEachPo( p, pObj, i ) \
+ for ( i = 0; (i < Gia_ManPoNum(p)) && ((pObj) = Gia_ManCo(p, i)); i++ )
+#define Gia_ManForEachRo( p, pObj, i ) \
+ for ( i = 0; (i < Gia_ManRegNum(p)) && ((pObj) = Gia_ManCi(p, Gia_ManPiNum(p)+i)); i++ )
+#define Gia_ManForEachRi( p, pObj, i ) \
+ for ( i = 0; (i < Gia_ManRegNum(p)) && ((pObj) = Gia_ManCo(p, Gia_ManPoNum(p)+i)); i++ )
+#define Gia_ManForEachRiRo( p, pObjRi, pObjRo, i ) \
+ for ( i = 0; (i < Gia_ManRegNum(p)) && ((pObjRi) = Gia_ManCo(p, Gia_ManPoNum(p)+i)) && ((pObjRo) = Gia_ManCi(p, Gia_ManPiNum(p)+i)); i++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== giaAig.c ============================================================*/
+extern Gia_Man_t * Gia_ManFromAig( Aig_Man_t * p );
+extern Gia_Man_t * Gia_ManFromAigSwitch( Aig_Man_t * p );
+extern Aig_Man_t * Gia_ManToAig( Gia_Man_t * p );
+/*=== giaAiger.c ==========================================================*/
+extern Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck );
+extern void Gia_WriteAiger( Gia_Man_t * p, char * pFileName, int fWriteSymbols, int fCompact );
+/*=== giaCof.c ============================================================*/
+extern void Gia_ManPrintFanio( Gia_Man_t * pGia, int nNodes );
+/*=== giaDfs.c ============================================================*/
+extern void Gia_ManCollectCis( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vSupp );
+extern void Gia_ManCollectAnds( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vNodes );
+extern int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNodes );
+extern int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes );
+/*=== giaDup.c ============================================================*/
+extern Gia_Man_t * Gia_ManDup( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupMarked( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupTimes( Gia_Man_t * p, int nTimes );
+extern Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupDfsSkip( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupDfsCone( Gia_Man_t * p, Gia_Obj_t * pObj );
+extern Gia_Man_t * Gia_ManDupDfsLitArray( Gia_Man_t * p, Vec_Int_t * vLits );
+extern Gia_Man_t * Gia_ManDupNormalized( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupCofactored( Gia_Man_t * p, int iVar );
+extern Gia_Man_t * Gia_ManDupDfsCiMap( Gia_Man_t * p, int * pCi2Lit, Vec_Int_t * vLits );
+extern Gia_Man_t * Gia_ManDupDfsClasses( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupTopAnd( Gia_Man_t * p, int fVerbose );
+/*=== giaFanout.c =========================================================*/
+extern void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
+extern void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
+extern void Gia_ManFanoutStart( Gia_Man_t * p );
+extern void Gia_ManFanoutStop( Gia_Man_t * p );
+/*=== giaFrames.c =========================================================*/
+extern void Gia_ManFraSetDefaultParams( Gia_ParFra_t * p );
+extern Gia_Man_t * Gia_ManFrames( Gia_Man_t * pAig, Gia_ParFra_t * pPars );
+/*=== giaFront.c ==========================================================*/
+extern Gia_Man_t * Gia_ManFront( Gia_Man_t * p );
+extern void Gia_ManFrontTest( Gia_Man_t * p );
+/*=== giaHash.c ===========================================================*/
+extern void Gia_ManHashAlloc( Gia_Man_t * p );
+extern void Gia_ManHashStart( Gia_Man_t * p );
+extern void Gia_ManHashStop( Gia_Man_t * p );
+extern int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 );
+extern int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 );
+extern int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 );
+extern Gia_Man_t * Gia_ManRehash( Gia_Man_t * p );
+/*=== giaLogic.c ===========================================================*/
+extern void Gia_ManTestDistance( Gia_Man_t * p );
+ /*=== giaMan.c ===========================================================*/
+extern Gia_Man_t * Gia_ManStart( int nObjsMax );
+extern void Gia_ManStop( Gia_Man_t * p );
+extern void Gia_ManPrintStats( Gia_Man_t * p );
+extern void Gia_ManPrintStatsShort( Gia_Man_t * p );
+extern void Gia_ManPrintMiterStatus( Gia_Man_t * p );
+extern void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs );
+/*=== giaSat.c ============================================================*/
+extern int Sat_ManTest( Gia_Man_t * pGia, Gia_Obj_t * pObj, int nConfsMax );
+/*=== giaScl.c ============================================================*/
+extern int Gia_ManCombMarkUsed( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManCleanup( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManSeqCleanup( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManSeqStructSweep( Gia_Man_t * p, int fConst, int fEquiv, int fVerbose );
+/*=== giaSim.c ============================================================*/
+extern int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars );
+/*=== giaTsim.c ============================================================*/
+extern Gia_Man_t * Gia_ManReduceConst( Gia_Man_t * pAig, int fVerbose );
+/*=== giaUtil.c ===========================================================*/
+extern void Gia_ManSetMark0( Gia_Man_t * p );
+extern void Gia_ManCleanMark0( Gia_Man_t * p );
+extern void Gia_ManSetMark1( Gia_Man_t * p );
+extern void Gia_ManCleanMark1( Gia_Man_t * p );
+extern void Gia_ManCleanValue( Gia_Man_t * p );
+extern void Gia_ManFillValue( Gia_Man_t * p );
+extern void Gia_ManSetPhase( Gia_Man_t * p );
+extern int Gia_ManLevelNum( Gia_Man_t * p );
+extern void Gia_ManSetRefs( Gia_Man_t * p );
+extern void Gia_ManCreateRefs( Gia_Man_t * p );
+extern int Gia_ManCrossCut( Gia_Man_t * p );
+extern int Gia_ManIsNormalized( Gia_Man_t * p );
+extern Vec_Int_t * Gia_ManCollectPoIds( Gia_Man_t * p );
+extern int Gia_ObjIsMuxType( Gia_Obj_t * pNode );
+extern int Gia_ObjRecognizeExor( Gia_Obj_t * pObj, Gia_Obj_t ** ppFan0, Gia_Obj_t ** ppFan1 );
+extern Gia_Obj_t * Gia_ObjRecognizeMux( Gia_Obj_t * pNode, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/gia/giaAig.c b/src/aig/gia/giaAig.c
new file mode 100644
index 00000000..8b59341a
--- /dev/null
+++ b/src/aig/gia/giaAig.c
@@ -0,0 +1,214 @@
+/**CFile****************************************************************
+
+ FileName [giaAig.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Transformation between AIG manager.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaAig.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline int Gia_ObjChild0Copy( Aig_Obj_t * pObj ) { return Gia_LitNotCond( Aig_ObjFanin0(pObj)->iData, Aig_ObjFaninC0(pObj) ); }
+static inline int Gia_ObjChild1Copy( Aig_Obj_t * pObj ) { return Gia_LitNotCond( Aig_ObjFanin1(pObj)->iData, Aig_ObjFaninC1(pObj) ); }
+
+static inline Aig_Obj_t * Gia_ObjChild0Copy2( Aig_Obj_t ** ppNodes, Gia_Obj_t * pObj, int Id ) { return Aig_NotCond( ppNodes[Gia_ObjFaninId0(pObj, Id)], Gia_ObjFaninC0(pObj) ); }
+static inline Aig_Obj_t * Gia_ObjChild1Copy2( Aig_Obj_t ** ppNodes, Gia_Obj_t * pObj, int Id ) { return Aig_NotCond( ppNodes[Gia_ObjFaninId1(pObj, Id)], Gia_ObjFaninC1(pObj) ); }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Derives combinational miter of the two AIGs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFromAig_rec( Gia_Man_t * pNew, Aig_Obj_t * pObj )
+{
+ if ( pObj->pData )
+ return;
+ if ( Aig_ObjIsPi(pObj) )
+ {
+ pObj->iData = Gia_ManAppendCi( pNew );
+ return;
+ }
+ assert( Aig_ObjIsNode(pObj) );
+ Gia_ManFromAig_rec( pNew, Aig_ObjFanin0(pObj) );
+ Gia_ManFromAig_rec( pNew, Aig_ObjFanin1(pObj) );
+ pObj->iData = Gia_ManAppendAnd( pNew, Gia_ObjChild0Copy(pObj), Gia_ObjChild1Copy(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManFromAig( Aig_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Aig_Obj_t * pObj;
+ int i;
+ // add fake POs to all the dangling nodes (choices)
+ Aig_ManForEachNode( p, pObj, i )
+ assert( Aig_ObjRefs(pObj) > 0 );
+ // create the new manager
+ pNew = Gia_ManStart( Aig_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ // create the PIs
+ Aig_ManCleanData( p );
+ Aig_ManConst1(p)->iData = 1;
+ Aig_ManForEachPi( p, pObj, i )
+ {
+// if ( Aig_ObjRefs(pObj) == 0 )
+ pObj->iData = Gia_ManAppendCi( pNew );
+ }
+ // add logic for the POs
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ Gia_ManFromAig_rec( pNew, Aig_ObjFanin0(pObj) );
+ Gia_ManAppendCo( pNew, Gia_ObjChild0Copy(pObj) );
+ }
+ Gia_ManSetRegNum( pNew, Aig_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Handles choices as additional combinational outputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManFromAigSwitch( Aig_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Aig_Obj_t * pObj;
+ int i;
+ // create the new manager
+ pNew = Gia_ManStart( Aig_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ // create the PIs
+ Aig_ManCleanData( p );
+ Aig_ManConst1(p)->iData = 1;
+ Aig_ManForEachPi( p, pObj, i )
+ pObj->iData = Gia_ManAppendCi( pNew );
+ // add POs corresponding to the nodes with choices
+ Aig_ManForEachNode( p, pObj, i )
+ if ( Aig_ObjRefs(pObj) == 0 )
+ {
+ Gia_ManFromAig_rec( pNew, pObj );
+ Gia_ManAppendCo( pNew, pObj->iData );
+ }
+ // add logic for the POs
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ Gia_ManFromAig_rec( pNew, Aig_ObjFanin0(pObj) );
+ Gia_ManAppendCo( pNew, Gia_ObjChild0Copy(pObj) );
+ }
+ Gia_ManSetRegNum( pNew, Aig_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives combinational miter of the two AIGs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManToAig_rec( Aig_Man_t * pNew, Aig_Obj_t ** ppNodes, Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( ppNodes[Gia_ObjId(p, pObj)] )
+ return;
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ ppNodes[Gia_ObjId(p, pObj)] = Aig_ObjCreatePi( pNew );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManToAig_rec( pNew, ppNodes, p, Gia_ObjFanin0(pObj) );
+ Gia_ManToAig_rec( pNew, ppNodes, p, Gia_ObjFanin1(pObj) );
+ ppNodes[Gia_ObjId(p, pObj)] = Aig_And( pNew, Gia_ObjChild0Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)), Gia_ObjChild1Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Gia_ManToAig( Gia_Man_t * p )
+{
+ Aig_Man_t * pNew;
+ Aig_Obj_t ** ppNodes;
+ Gia_Obj_t * pObj;
+ int i;
+
+ // create the new manager
+ pNew = Aig_ManStart( Gia_ManAndNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ ppNodes = ABC_CALLOC( Aig_Obj_t *, Gia_ManObjNum(p) );
+ // create the PIs
+ ppNodes[0] = Aig_ManConst0(pNew);
+ Gia_ManForEachCi( p, pObj, i )
+ {
+// if ( Aig_ObjRefs(pObj) == 0 )
+ ppNodes[Gia_ObjId(p, pObj)] = Aig_ObjCreatePi( pNew );
+ }
+ // add logic for the POs
+ Gia_ManForEachCo( p, pObj, i )
+ {
+ Gia_ManToAig_rec( pNew, ppNodes, p, Gia_ObjFanin0(pObj) );
+ ppNodes[Gia_ObjId(p, pObj)] = Aig_ObjCreatePo( pNew, Gia_ObjChild0Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)) );
+ }
+ Aig_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ ABC_FREE( ppNodes );
+ return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaAiger.c b/src/aig/gia/giaAiger.c
new file mode 100644
index 00000000..40c5329d
--- /dev/null
+++ b/src/aig/gia/giaAiger.c
@@ -0,0 +1,553 @@
+/**CFile****************************************************************
+
+ FileName [giaAiger.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Procedures to read/write binary AIGER format developed by
+ Armin Biere, Johannes Kepler University (http://fmv.jku.at/)]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaAiger.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Extracts one unsigned AIG edge from the input buffer.]
+
+ Description [This procedure is a slightly modified version of Armin Biere's
+ procedure "unsigned decode (FILE * file)". ]
+
+ SideEffects [Updates the current reading position.]
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gia_ReadAigerDecode( char ** ppPos )
+{
+ unsigned x = 0, i = 0;
+ unsigned char ch;
+ while ((ch = *(*ppPos)++) & 0x80)
+ x |= (ch & 0x7f) << (7 * i++);
+ return x | (ch << (7 * i));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Decodes the encoded array of literals.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_WriteDecodeLiterals( char ** ppPos, int nEntries )
+{
+ Vec_Int_t * vLits;
+ int Lit, LitPrev, Diff, i;
+ vLits = Vec_IntAlloc( nEntries );
+ LitPrev = Gia_ReadAigerDecode( ppPos );
+ Vec_IntPush( vLits, LitPrev );
+ for ( i = 1; i < nEntries; i++ )
+ {
+// Diff = Lit - LitPrev;
+// Diff = (Lit < LitPrev)? -Diff : Diff;
+// Diff = ((2 * Diff) << 1) | (int)(Lit < LitPrev);
+ Diff = Gia_ReadAigerDecode( ppPos );
+ Diff = (Diff & 1)? -(Diff >> 1) : Diff >> 1;
+ Lit = Diff + LitPrev;
+ Vec_IntPush( vLits, Lit );
+ LitPrev = Lit;
+ }
+ return vLits;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the file size.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_FixFileName( char * pFileName )
+{
+ char * pName;
+ for ( pName = pFileName; *pName; pName++ )
+ if ( *pName == '>' )
+ *pName = '\\';
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the file size.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_FileSize( char * pFileName )
+{
+ FILE * pFile;
+ int nFileSize;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Gia_FileSize(): The file is unavailable (absent or open).\n" );
+ return 0;
+ }
+ fseek( pFile, 0, SEEK_END );
+ nFileSize = ftell( pFile );
+ fclose( pFile );
+ return nFileSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_FileNameGeneric( char * FileName )
+{
+ char * pDot, * pRes;
+ pRes = Aig_UtilStrsav( FileName );
+ if ( (pDot = strrchr( pRes, '.' )) )
+ *pDot = 0;
+ return pRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the time stamp.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_TimeStamp()
+{
+ static char Buffer[100];
+ char * TimeStamp;
+ time_t ltime;
+ // get the current time
+ time( &ltime );
+ TimeStamp = asctime( localtime( &ltime ) );
+ TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
+ strcpy( Buffer, TimeStamp );
+ return Buffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
+{
+ FILE * pFile;
+ Gia_Man_t * pNew;
+ Vec_Int_t * vLits = NULL;
+ Vec_Int_t * vNodes, * vDrivers;//, * vTerms;
+ int iObj, iNode0, iNode1;
+ int nTotal, nInputs, nOutputs, nLatches, nAnds, nFileSize, i;//, iTerm, nDigits;
+ char * pContents, * pDrivers, * pSymbols, * pCur, * pName;//, * pType;
+ unsigned uLit0, uLit1, uLit;
+
+ // read the file into the buffer
+ Gia_FixFileName( pFileName );
+ nFileSize = Gia_FileSize( pFileName );
+ pFile = fopen( pFileName, "rb" );
+ pContents = ABC_ALLOC( char, nFileSize );
+ fread( pContents, nFileSize, 1, pFile );
+ fclose( pFile );
+
+ // check if the input file format is correct
+ if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') )
+ {
+ fprintf( stdout, "Wrong input file format.\n" );
+ free( pContents );
+ return NULL;
+ }
+
+ // read the file type
+ pCur = pContents; while ( *pCur++ != ' ' );
+ // read the number of objects
+ nTotal = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of inputs
+ nInputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of latches
+ nLatches = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of outputs
+ nOutputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of nodes
+ nAnds = atoi( pCur ); while ( *pCur++ != '\n' );
+ // check the parameters
+ if ( nTotal != nInputs + nLatches + nAnds )
+ {
+ fprintf( stdout, "The paramters are wrong.\n" );
+ return NULL;
+ }
+
+ // allocate the empty AIG
+ pNew = Gia_ManStart( nTotal + nLatches + nOutputs + 1 );
+ pName = Gia_FileNameGeneric( pFileName );
+ pNew->pName = Aig_UtilStrsav( pName );
+// pNew->pSpec = Aig_UtilStrsav( pFileName );
+ ABC_FREE( pName );
+
+ // prepare the array of nodes
+ vNodes = Vec_IntAlloc( 1 + nTotal );
+ Vec_IntPush( vNodes, 0 );
+
+ // create the PIs
+ for ( i = 0; i < nInputs + nLatches; i++ )
+ {
+ iObj = Gia_ManAppendCi(pNew);
+ Vec_IntPush( vNodes, iObj );
+ }
+
+ // remember the beginning of latch/PO literals
+ pDrivers = pCur;
+ if ( pContents[3] == ' ' ) // standard AIGER
+ {
+ // scroll to the beginning of the binary data
+ for ( i = 0; i < nLatches + nOutputs; )
+ if ( *pCur++ == '\n' )
+ i++;
+ }
+ else // modified AIGER
+ {
+ vLits = Gia_WriteDecodeLiterals( &pCur, nLatches + nOutputs );
+ }
+
+ // create the AND gates
+ for ( i = 0; i < nAnds; i++ )
+ {
+ uLit = ((i + 1 + nInputs + nLatches) << 1);
+ uLit1 = uLit - Gia_ReadAigerDecode( &pCur );
+ uLit0 = uLit1 - Gia_ReadAigerDecode( &pCur );
+// assert( uLit1 > uLit0 );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
+ iNode1 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
+ assert( Vec_IntSize(vNodes) == i + 1 + nInputs + nLatches );
+// Vec_IntPush( vNodes, Gia_And(pNew, iNode0, iNode1) );
+ Vec_IntPush( vNodes, Gia_ManAppendAnd(pNew, iNode0, iNode1) );
+ }
+
+ // remember the place where symbols begin
+ pSymbols = pCur;
+
+ // read the latch driver literals
+ vDrivers = Vec_IntAlloc( nLatches + nOutputs );
+ if ( pContents[3] == ' ' ) // standard AIGER
+ {
+ pCur = pDrivers;
+ for ( i = 0; i < nLatches; i++ )
+ {
+ uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ // read the PO driver literals
+ for ( i = 0; i < nOutputs; i++ )
+ {
+ uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+
+ }
+ else
+ {
+ // read the latch driver literals
+ for ( i = 0; i < nLatches; i++ )
+ {
+ uLit0 = Vec_IntEntry( vLits, i );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ // read the PO driver literals
+ for ( i = 0; i < nOutputs; i++ )
+ {
+ uLit0 = Vec_IntEntry( vLits, i+nLatches );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ Vec_IntFree( vLits );
+ }
+
+ // create the POs
+ for ( i = 0; i < nOutputs; i++ )
+ Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, nLatches + i) );
+ for ( i = 0; i < nLatches; i++ )
+ Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, i) );
+ Vec_IntFree( vDrivers );
+
+ // create the latches
+ Gia_ManSetRegNum( pNew, nLatches );
+
+ // skipping the comments
+ ABC_FREE( pContents );
+ Vec_IntFree( vNodes );
+/*
+ // check the result
+ if ( fCheck && !Gia_ManCheck( pNew ) )
+ {
+ printf( "Gia_ReadAiger: The network check has failed.\n" );
+ Gia_ManStop( pNew );
+ return NULL;
+ }
+*/
+ return pNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Adds one unsigned AIG edge to the output buffer.]
+
+ Description [This procedure is a slightly modified version of Armin Biere's
+ procedure "void encode (FILE * file, unsigned x)" ]
+
+ SideEffects [Returns the current writing position.]
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_WriteAigerEncode( unsigned char * pBuffer, int Pos, unsigned x )
+{
+ unsigned char ch;
+ while (x & ~0x7f)
+ {
+ ch = (x & 0x7f) | 0x80;
+ pBuffer[Pos++] = ch;
+ x >>= 7;
+ }
+ ch = x;
+ pBuffer[Pos++] = ch;
+ return Pos;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Create the array of literals to be written.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_WriteAigerLiterals( Gia_Man_t * p )
+{
+ Vec_Int_t * vLits;
+ Gia_Obj_t * pObj;
+ int i;
+ vLits = Vec_IntAlloc( Gia_ManPoNum(p) );
+ Gia_ManForEachRi( p, pObj, i )
+ Vec_IntPush( vLits, Gia_ObjFaninLit0p(p, pObj) );
+ Gia_ManForEachPo( p, pObj, i )
+ Vec_IntPush( vLits, Gia_ObjFaninLit0p(p, pObj) );
+ return vLits;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the binary encoded array of literals.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Str_t * Gia_WriteEncodeLiterals( Vec_Int_t * vLits )
+{
+ Vec_Str_t * vBinary;
+ int Pos = 0, Lit, LitPrev, Diff, i;
+ vBinary = Vec_StrAlloc( 2 * Vec_IntSize(vLits) );
+ LitPrev = Vec_IntEntry( vLits, 0 );
+ Pos = Gia_WriteAigerEncode( (unsigned char *)Vec_StrArray(vBinary), Pos, LitPrev );
+ Vec_IntForEachEntryStart( vLits, Lit, i, 1 )
+ {
+ Diff = Lit - LitPrev;
+ Diff = (Lit < LitPrev)? -Diff : Diff;
+ Diff = (Diff << 1) | (int)(Lit < LitPrev);
+ Pos = Gia_WriteAigerEncode( (unsigned char *)Vec_StrArray(vBinary), Pos, Diff );
+ LitPrev = Lit;
+ if ( Pos + 10 > vBinary->nCap )
+ Vec_StrGrow( vBinary, vBinary->nCap+1 );
+ }
+ vBinary->nSize = Pos;
+/*
+ // verify
+ {
+ extern Vec_Int_t * Gia_WriteDecodeLiterals( char ** ppPos, int nEntries );
+ char * pPos = Vec_StrArray( vBinary );
+ Vec_Int_t * vTemp = Gia_WriteDecodeLiterals( &pPos, Vec_IntSize(vLits) );
+ for ( i = 0; i < Vec_IntSize(vLits); i++ )
+ {
+ int Entry1 = Vec_IntEntry(vLits,i);
+ int Entry2 = Vec_IntEntry(vTemp,i);
+ assert( Entry1 == Entry2 );
+ }
+ Vec_IntFree( vTemp );
+ }
+*/
+ return vBinary;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteAiger( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int fCompact )
+{
+ FILE * pFile;
+ Gia_Man_t * p;
+ Gia_Obj_t * pObj;
+ int i, nBufferSize, Pos;
+ unsigned char * pBuffer;
+ unsigned uLit0, uLit1, uLit;
+
+ if ( Gia_ManCoNum(pInit) == 0 )
+ {
+ printf( "AIG cannot be written because it has no POs.\n" );
+ return;
+ }
+
+ // start the output stream
+ pFile = fopen( pFileName, "wb" );
+ if ( pFile == NULL )
+ {
+ fprintf( stdout, "Gia_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName );
+ return;
+ }
+
+ // create normalized AIG
+ if ( !Gia_ManIsNormalized(pInit) )
+ p = Gia_ManDupNormalized( pInit );
+ else
+ p = pInit;
+
+ // write the header "M I L O A" where M = I + L + A
+ fprintf( pFile, "aig%s %u %u %u %u %u\n",
+ fCompact? "2" : "",
+ Gia_ManCiNum(p) + Gia_ManAndNum(p),
+ Gia_ManPiNum(p),
+ Gia_ManRegNum(p),
+ Gia_ManPoNum(p),
+ Gia_ManAndNum(p) );
+
+ if ( !fCompact )
+ {
+ // write latch drivers
+ Gia_ManForEachRi( p, pObj, i )
+ fprintf( pFile, "%u\n", Gia_ObjFaninLit0p(p, pObj) );
+ // write PO drivers
+ Gia_ManForEachPo( p, pObj, i )
+ fprintf( pFile, "%u\n", Gia_ObjFaninLit0p(p, pObj) );
+ }
+ else
+ {
+ Vec_Int_t * vLits = Gia_WriteAigerLiterals( p );
+ Vec_Str_t * vBinary = Gia_WriteEncodeLiterals( vLits );
+ fwrite( Vec_StrArray(vBinary), 1, Vec_StrSize(vBinary), pFile );
+ Vec_StrFree( vBinary );
+ Vec_IntFree( vLits );
+ }
+
+ // write the nodes into the buffer
+ Pos = 0;
+ nBufferSize = 6 * Gia_ManAndNum(p) + 100; // skeptically assuming 3 chars per one AIG edge
+ pBuffer = ABC_ALLOC( unsigned char, nBufferSize );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ uLit = Gia_Var2Lit( i, 0 );
+ uLit0 = Gia_ObjFaninLit0( pObj, i );
+ uLit1 = Gia_ObjFaninLit1( pObj, i );
+ assert( uLit0 < uLit1 );
+ Pos = Gia_WriteAigerEncode( pBuffer, Pos, uLit - uLit1 );
+ Pos = Gia_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 );
+ if ( Pos > nBufferSize - 10 )
+ {
+ printf( "Gia_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
+ fclose( pFile );
+ if ( p != pInit )
+ Gia_ManStop( p );
+ return;
+ }
+ }
+ assert( Pos < nBufferSize );
+
+ // write the buffer
+ fwrite( pBuffer, 1, Pos, pFile );
+ ABC_FREE( pBuffer );
+
+ // write the comment
+ fprintf( pFile, "c\n" );
+ if ( p->pName )
+ fprintf( pFile, ".model %s\n", p->pName );
+ fprintf( pFile, "This file was produced by the AIG package on %s\n", Gia_TimeStamp() );
+ fprintf( pFile, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" );
+ fclose( pFile );
+ if ( p != pInit )
+ Gia_ManStop( p );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaCof.c b/src/aig/gia/giaCof.c
new file mode 100644
index 00000000..d58429cd
--- /dev/null
+++ b/src/aig/gia/giaCof.c
@@ -0,0 +1,688 @@
+/**CFile****************************************************************
+
+ FileName [giaCof.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Cofactor estimation procedures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaCof.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <math.h>
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Cof_Fan_t_ Cof_Fan_t;
+struct Cof_Fan_t_
+{
+ unsigned iFan : 31; // ID of the fanin/fanout
+ unsigned fCompl : 1; // complemented attribute
+};
+
+typedef struct Cof_Obj_t_ Cof_Obj_t;
+struct Cof_Obj_t_
+{
+ unsigned fTerm : 1; // terminal node (CI/CO)
+ unsigned fPhase : 1; // value under 000 pattern
+ unsigned fMark0 : 1; // first user-controlled mark
+ unsigned fMark1 : 1; // second user-controlled mark
+ unsigned nFanins : 4; // the number of fanins
+ unsigned nFanouts : 24; // total number of fanouts
+ unsigned Value; // application specific data
+ int Id; // ID of the node
+ int iNext; // next one in the linked list
+ int iLit; // literal of the node after rehashing
+ Cof_Fan_t Fanios[0]; // the array of fanins/fanouts
+};
+
+typedef struct Cof_Man_t_ Cof_Man_t;
+struct Cof_Man_t_
+{
+ Gia_Man_t * pGia; // the original AIG manager
+ Vec_Int_t * vCis; // the vector of CIs (PIs + LOs)
+ Vec_Int_t * vCos; // the vector of COs (POs + LIs)
+ int nObjs; // the number of objects
+ int nNodes; // the number of nodes
+ int nTravIds; // traversal ID of the network
+ int * pObjData; // the logic network defined for the AIG
+ int nObjData; // the size of array to store the logic network
+ int * pLevels; // the linked lists of levels
+ int nLevels; // the max number of logic levels
+};
+
+static inline unsigned Gia_ObjHandle( Gia_Obj_t * pObj ) { return pObj->Value; }
+
+static inline int Cof_ObjLevel( Cof_Man_t * p, Cof_Obj_t * pObj ) { return Gia_ObjLevel(p->pGia, Gia_ManObj(p->pGia,pObj->Id)); }
+
+static inline unsigned Cof_ObjHandle( Cof_Man_t * p, Cof_Obj_t * pObj ) { return (unsigned)(((int *)pObj) - p->pObjData); }
+static inline unsigned Cof_ObjHandleDiff( Cof_Obj_t * pObj, Cof_Obj_t * pFanin ) { return (unsigned)(((int *)pObj) - ((int *)pFanin)); }
+
+static inline int Cof_ObjIsTerm( Cof_Obj_t * pObj ) { return pObj->fTerm; }
+static inline int Cof_ObjIsCi( Cof_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 0; }
+static inline int Cof_ObjIsCo( Cof_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 1; }
+static inline int Cof_ObjIsNode( Cof_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins > 0; }
+static inline int Cof_ObjIsConst0( Cof_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins == 0; }
+
+static inline int Cof_ObjFaninNum( Cof_Obj_t * pObj ) { return pObj->nFanins; }
+static inline int Cof_ObjFanoutNum( Cof_Obj_t * pObj ) { return pObj->nFanouts; }
+static inline int Cof_ObjSize( Cof_Obj_t * pObj ) { return sizeof(Cof_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; }
+
+static inline Cof_Obj_t * Cof_ManObj( Cof_Man_t * p, unsigned iHandle ) { return (Cof_Obj_t *)(p->pObjData + iHandle); }
+static inline Cof_Obj_t * Cof_ObjFanin( Cof_Obj_t * pObj, int i ) { return (Cof_Obj_t *)(((int *)pObj) - pObj->Fanios[i].iFan); }
+static inline Cof_Obj_t * Cof_ObjFanout( Cof_Obj_t * pObj, int i ) { return (Cof_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i].iFan); }
+
+static inline int Cof_ManObjNum( Cof_Man_t * p ) { return p->nObjs; }
+static inline int Cof_ManNodeNum( Cof_Man_t * p ) { return p->nNodes; }
+
+static inline void Cof_ManResetTravId( Cof_Man_t * p ) { extern void Cof_ManCleanValue( Cof_Man_t * p ); Cof_ManCleanValue( p ); p->nTravIds = 1; }
+static inline void Cof_ManIncrementTravId( Cof_Man_t * p ) { p->nTravIds++; }
+static inline void Cof_ObjSetTravId( Cof_Obj_t * pObj, int TravId ) { pObj->Value = TravId; }
+static inline void Cof_ObjSetTravIdCurrent( Cof_Man_t * p, Cof_Obj_t * pObj ) { pObj->Value = p->nTravIds; }
+static inline void Cof_ObjSetTravIdPrevious( Cof_Man_t * p, Cof_Obj_t * pObj ) { pObj->Value = p->nTravIds - 1; }
+static inline int Cof_ObjIsTravIdCurrent( Cof_Man_t * p, Cof_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds); }
+static inline int Cof_ObjIsTravIdPrevious( Cof_Man_t * p, Cof_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds - 1); }
+
+#define Cof_ManForEachObj( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) )
+#define Cof_ManForEachNode( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) ) if ( Cof_ObjIsTerm(pObj) ) {} else
+#define Cof_ObjForEachFanin( pObj, pNext, i ) \
+ for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Cof_ObjFanin(pObj,i)); i++ )
+#define Cof_ObjForEachFanout( pObj, pNext, i ) \
+ for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Cof_ObjFanout(pObj,i)); i++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates logic network isomorphic to the given AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Cof_Man_t * Cof_ManCreateLogicSimple( Gia_Man_t * pGia )
+{
+ Cof_Man_t * p;
+ Cof_Obj_t * pObjLog, * pFanLog;
+ Gia_Obj_t * pObj;
+ int i, iHandle = 0;
+ p = ABC_CALLOC( Cof_Man_t, 1 );
+ p->pGia = pGia;
+ p->vCis = Vec_IntAlloc( Gia_ManCiNum(pGia) );
+ p->vCos = Vec_IntAlloc( Gia_ManCoNum(pGia) );
+ p->nObjData = (sizeof(Cof_Obj_t) / 4) * Gia_ManObjNum(pGia) + 4 * Gia_ManAndNum(pGia) + 2 * Gia_ManCoNum(pGia);
+ p->pObjData = ABC_CALLOC( int, p->nObjData );
+ ABC_FREE( pGia->pRefs );
+ Gia_ManCreateRefs( pGia );
+ Gia_ManForEachObj( pGia, pObj, i )
+ {
+ pObj->Value = iHandle;
+ pObjLog = Cof_ManObj( p, iHandle );
+ pObjLog->nFanins = 0;
+ pObjLog->nFanouts = Gia_ObjRefs( pGia, pObj );
+ pObjLog->Id = i;
+ pObjLog->Value = 0;
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin0(pObj)) );
+ pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan =
+ pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog );
+ pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC0(pObj);
+
+ pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin1(pObj)) );
+ pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan =
+ pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog );
+ pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC1(pObj);
+ p->nNodes++;
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin0(pObj)) );
+ pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan =
+ pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog );
+ pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC0(pObj);
+
+ pObjLog->fTerm = 1;
+ Vec_IntPush( p->vCos, iHandle );
+ }
+ else if ( Gia_ObjIsCi(pObj) )
+ {
+ pObjLog->fTerm = 1;
+ Vec_IntPush( p->vCis, iHandle );
+ }
+ iHandle += Cof_ObjSize( pObjLog );
+ p->nObjs++;
+ }
+ assert( iHandle == p->nObjData );
+ Gia_ManForEachObj( pGia, pObj, i )
+ {
+ pObjLog = Cof_ManObj( p, Gia_ObjHandle(pObj) );
+ assert( pObjLog->nFanouts == pObjLog->Value );
+ }
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates logic network isomorphic to the given AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cof_ManStop( Cof_Man_t * p )
+{
+ Vec_IntFree( p->vCis );
+ Vec_IntFree( p->vCos );
+ ABC_FREE( p->pObjData );
+ ABC_FREE( p->pLevels );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cof_ManTfoSize_rec( Cof_Man_t * p, Cof_Obj_t * pObj )
+{
+ Cof_Obj_t * pNext;
+ unsigned i, Counter = 0;
+ if ( Cof_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Cof_ObjSetTravIdCurrent(p, pObj);
+ if ( Cof_ObjIsCo(pObj) )
+ return 0;
+ assert( Cof_ObjIsCi(pObj) || Cof_ObjIsNode(pObj) );
+ Cof_ObjForEachFanout( pObj, pNext, i )
+ Counter += Cof_ManTfoSize_rec( p, pNext );
+ return 1 + Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cof_ManTfoSize( Cof_Man_t * p, Cof_Obj_t ** ppObjs, int nObjs )
+{
+ int i, Counter = 0;
+ Cof_ManIncrementTravId( p );
+ for ( i = 0; i < nObjs; i++ )
+ Counter += Cof_ManTfoSize_rec( p, ppObjs[i] ) - 1;
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cof_ManTfiSize_rec( Cof_Man_t * p, Cof_Obj_t * pObj )
+{
+ Cof_Obj_t * pNext;
+ unsigned i, Counter = 0;
+ if ( Cof_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Cof_ObjSetTravIdCurrent(p, pObj);
+ if ( Cof_ObjIsCi(pObj) )
+ return 0;
+ assert( Cof_ObjIsNode(pObj) );
+ Cof_ObjForEachFanin( pObj, pNext, i )
+ Counter += Cof_ManTfiSize_rec( p, pNext );
+ return 1 + Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cof_ManTfiSize( Cof_Man_t * p, Cof_Obj_t ** ppObjs, int nObjs )
+{
+ int i, Counter = 0;
+ Cof_ManIncrementTravId( p );
+ for ( i = 0; i < nObjs; i++ )
+ if ( Cof_ObjIsCo(ppObjs[i]) )
+ Counter += Cof_ManTfiSize_rec( p, Cof_ObjFanin(ppObjs[i],0) );
+ else
+ Counter += Cof_ManTfiSize_rec( p, ppObjs[i] );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cof_ManSuppSize_rec( Cof_Man_t * p, Cof_Obj_t * pObj )
+{
+ Cof_Obj_t * pNext;
+ unsigned i, Counter = 0;
+ if ( Cof_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Cof_ObjSetTravIdCurrent(p, pObj);
+ if ( Cof_ObjIsCi(pObj) )
+ return 1;
+ assert( Cof_ObjIsNode(pObj) );
+ Cof_ObjForEachFanin( pObj, pNext, i )
+ Counter += Cof_ManSuppSize_rec( p, pNext );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cof_ManSuppSize( Cof_Man_t * p, Cof_Obj_t ** ppObjs, int nObjs )
+{
+ int i, Counter = 0;
+ Cof_ManIncrementTravId( p );
+ for ( i = 0; i < nObjs; i++ )
+ if ( Cof_ObjIsCo(ppObjs[i]) )
+ Counter += Cof_ManSuppSize_rec( p, Cof_ObjFanin(ppObjs[i],0) );
+ else
+ Counter += Cof_ManSuppSize_rec( p, ppObjs[i] );
+ return Counter;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Cleans the value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cof_ManCleanValue( Cof_Man_t * p )
+{
+ Cof_Obj_t * pObj;
+ int i;
+ Cof_ManForEachObj( p, pObj, i )
+ pObj->Value = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns sorted array of node handles with largest fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cof_ManInsertEntry_rec( Vec_Ptr_t * vNodes, Cof_Obj_t * pNode, int nNodeMax )
+{
+ Cof_Obj_t * pLast;
+ if ( Vec_PtrSize(vNodes) == 0 )
+ {
+ Vec_PtrPush(vNodes, pNode);
+ return;
+ }
+ pLast = Vec_PtrPop(vNodes);
+ if ( Cof_ObjFanoutNum(pLast) < Cof_ObjFanoutNum(pNode) )
+ {
+ Cof_ManInsertEntry_rec( vNodes, pNode, nNodeMax );
+ if ( Vec_PtrSize(vNodes) < nNodeMax )
+ Vec_PtrPush( vNodes, pLast );
+ }
+ else
+ {
+ Vec_PtrPush( vNodes, pLast );
+ if ( Vec_PtrSize(vNodes) < nNodeMax )
+ Vec_PtrPush( vNodes, pNode );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns sorted array of node handles with largest fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Cof_ManCollectHighFanout( Cof_Man_t * p, int nNodes )
+{
+ Vec_Ptr_t * vNodes;
+ Cof_Obj_t * pObj;
+ int i;
+ vNodes = Vec_PtrAlloc( nNodes );
+ Cof_ManForEachObj( p, pObj, i )
+ if ( Cof_ObjIsCi(pObj) || Cof_ObjIsNode(pObj) )
+ Cof_ManInsertEntry_rec( vNodes, pObj, nNodes );
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns sorted array of node handles with largest fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cof_ManCountRemoved( Cof_Man_t * p, Cof_Obj_t * pRoot, int fConst1 )
+{
+ Gia_Obj_t * pNextGia;
+ Cof_Obj_t * pTemp, * pNext, * pFanin0, * pFanin1;
+ int Counter = 0, LevelStart, LevelNext;
+ int i, k, iHandle, iLit0, iLit1, iNextNew;
+ // restart the trav ids
+ Cof_ManIncrementTravId( p );
+ Cof_ObjSetTravIdCurrent( p, pRoot );
+ // add the node to the queue
+ LevelStart = Cof_ObjLevel(p, pRoot);
+ assert( p->pLevels[LevelStart] == 0 );
+ pRoot->iNext = 0;
+ p->pLevels[LevelStart] = Cof_ObjHandle( p, pRoot );
+ // set the new literal
+ pRoot->iLit = Gia_Var2Lit( 0, fConst1 );
+ // process nodes in the levelized order
+ for ( i = LevelStart; i < p->nLevels; i++ )
+ {
+ for ( iHandle = p->pLevels[i];
+ iHandle && (pTemp = Cof_ManObj(p, iHandle));
+ iHandle = pTemp->iNext )
+ {
+ assert( pTemp->Id != Gia_Lit2Var(pTemp->iLit) );
+ Cof_ObjForEachFanout( pTemp, pNext, k )
+ {
+ if ( Cof_ObjIsCo(pNext) )
+ continue;
+ if ( Cof_ObjIsTravIdCurrent(p, pNext) )
+ continue;
+ pFanin0 = Cof_ObjFanin( pNext, 0 );
+ pFanin1 = Cof_ObjFanin( pNext, 1 );
+ assert( pFanin0 == pTemp || pFanin1 == pTemp );
+ pNextGia = Gia_ManObj( p->pGia, pNext->Id );
+ if ( Cof_ObjIsTravIdCurrent(p, pFanin0) )
+ iLit0 = Gia_LitNotCond( pFanin0->iLit, Gia_ObjFaninC0(pNextGia) );
+ else
+ iLit0 = Gia_ObjFaninLit0( pNextGia, pNext->Id );
+ if ( Cof_ObjIsTravIdCurrent(p, pFanin1) )
+ iLit1 = Gia_LitNotCond( pFanin1->iLit, Gia_ObjFaninC1(pNextGia) );
+ else
+ iLit1 = Gia_ObjFaninLit1( pNextGia, pNext->Id );
+ iNextNew = Gia_ManHashAndTry( p->pGia, iLit0, iLit1 );
+ if ( iNextNew == -1 )
+ continue;
+ Cof_ObjSetTravIdCurrent(p, pNext);
+ // set the new literal
+ pNext->iLit = iNextNew;
+ // add it to be processed
+ LevelNext = Cof_ObjLevel( p, pNext );
+ assert( LevelNext > i && LevelNext < p->nLevels );
+ pNext->iNext = p->pLevels[LevelNext];
+ p->pLevels[LevelNext] = Cof_ObjHandle( p, pNext );
+ Counter++;
+ }
+ }
+ p->pLevels[i] = 0;
+ }
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns sorted array of node handles with largest fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cof_ManPrintHighFanoutOne( Cof_Man_t * p, Cof_Obj_t * pObj )
+{
+ printf( "%7d : ", pObj->Id );
+ printf( "fi =%2d ", Cof_ObjFaninNum(pObj) );
+ printf( "fo =%5d ", Cof_ObjFanoutNum(pObj) );
+ printf( "l =%4d ", Cof_ObjLevel(p, pObj) );
+ printf( "s =%5d ", Cof_ManSuppSize(p, &pObj, 1) );
+ printf( "TFI =%7d ", Cof_ManTfiSize(p, &pObj, 1) );
+ printf( "TFO =%7d ", Cof_ManTfoSize(p, &pObj, 1) );
+ printf( "C0 =%6d ", Cof_ManCountRemoved(p, pObj, 0) );
+ printf( "C1 =%6d", Cof_ManCountRemoved(p, pObj, 1) );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns sorted array of node handles with largest fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cof_ManPrintHighFanout( Cof_Man_t * p, int nNodes )
+{
+ Vec_Ptr_t * vNodes;
+ Cof_Obj_t * pObj;
+ int i;
+ vNodes = Cof_ManCollectHighFanout( p, nNodes );
+ Vec_PtrForEachEntry( vNodes, pObj, i )
+ Cof_ManPrintHighFanoutOne( p, pObj );
+ Vec_PtrFree( vNodes );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the distribution of fanins/fanouts in the network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cof_ManPrintFanio( Cof_Man_t * p )
+{
+ char Buffer[100];
+ Cof_Obj_t * pNode;
+ Vec_Int_t * vFanins, * vFanouts;
+ int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll;
+ int i, k, nSizeMax;
+
+ // determine the largest fanin and fanout
+ nFaninsMax = nFanoutsMax = 0;
+ nFaninsAll = nFanoutsAll = 0;
+ Cof_ManForEachNode( p, pNode, i )
+ {
+ if ( i == 0 ) continue;
+ nFanins = Cof_ObjFaninNum(pNode);
+ nFanouts = Cof_ObjFanoutNum(pNode);
+ nFaninsAll += nFanins;
+ nFanoutsAll += nFanouts;
+ nFaninsMax = ABC_MAX( nFaninsMax, nFanins );
+ nFanoutsMax = ABC_MAX( nFanoutsMax, nFanouts );
+ }
+
+ // allocate storage for fanin/fanout numbers
+ nSizeMax = AIG_MAX( 10 * (Aig_Base10Log(nFaninsMax) + 1), 10 * (Aig_Base10Log(nFanoutsMax) + 1) );
+ vFanins = Vec_IntStart( nSizeMax );
+ vFanouts = Vec_IntStart( nSizeMax );
+
+ // count the number of fanins and fanouts
+ Cof_ManForEachNode( p, pNode, i )
+ {
+ if ( i == 0 ) continue;
+ nFanins = Cof_ObjFaninNum(pNode);
+ nFanouts = Cof_ObjFanoutNum(pNode);
+// nFanouts = Cof_NodeMffcSize(pNode);
+
+ if ( nFanins < 10 )
+ Vec_IntAddToEntry( vFanins, nFanins, 1 );
+ else if ( nFanins < 100 )
+ Vec_IntAddToEntry( vFanins, 10 + nFanins/10, 1 );
+ else if ( nFanins < 1000 )
+ Vec_IntAddToEntry( vFanins, 20 + nFanins/100, 1 );
+ else if ( nFanins < 10000 )
+ Vec_IntAddToEntry( vFanins, 30 + nFanins/1000, 1 );
+ else if ( nFanins < 100000 )
+ Vec_IntAddToEntry( vFanins, 40 + nFanins/10000, 1 );
+ else if ( nFanins < 1000000 )
+ Vec_IntAddToEntry( vFanins, 50 + nFanins/100000, 1 );
+ else if ( nFanins < 10000000 )
+ Vec_IntAddToEntry( vFanins, 60 + nFanins/1000000, 1 );
+
+ if ( nFanouts < 10 )
+ Vec_IntAddToEntry( vFanouts, nFanouts, 1 );
+ else if ( nFanouts < 100 )
+ Vec_IntAddToEntry( vFanouts, 10 + nFanouts/10, 1 );
+ else if ( nFanouts < 1000 )
+ Vec_IntAddToEntry( vFanouts, 20 + nFanouts/100, 1 );
+ else if ( nFanouts < 10000 )
+ Vec_IntAddToEntry( vFanouts, 30 + nFanouts/1000, 1 );
+ else if ( nFanouts < 100000 )
+ Vec_IntAddToEntry( vFanouts, 40 + nFanouts/10000, 1 );
+ else if ( nFanouts < 1000000 )
+ Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 );
+ else if ( nFanouts < 10000000 )
+ Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 );
+ }
+
+ printf( "The distribution of fanins and fanouts in the network:\n" );
+ printf( " Number Nodes with fanin Nodes with fanout\n" );
+ for ( k = 0; k < nSizeMax; k++ )
+ {
+ if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
+ continue;
+ if ( k < 10 )
+ printf( "%15d : ", k );
+ else
+ {
+ sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
+ printf( "%15s : ", Buffer );
+ }
+ if ( vFanins->pArray[k] == 0 )
+ printf( " " );
+ else
+ printf( "%12d ", vFanins->pArray[k] );
+ printf( " " );
+ if ( vFanouts->pArray[k] == 0 )
+ printf( " " );
+ else
+ printf( "%12d ", vFanouts->pArray[k] );
+ printf( "\n" );
+ }
+ Vec_IntFree( vFanins );
+ Vec_IntFree( vFanouts );
+
+ printf( "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n",
+ nFaninsMax, 1.0*nFaninsAll/Cof_ManNodeNum(p),
+ nFanoutsMax, 1.0*nFanoutsAll/Cof_ManNodeNum(p) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns sorted array of node handles with largest fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPrintFanio( Gia_Man_t * pGia, int nNodes )
+{
+ Cof_Man_t * p;
+ int clk = clock();
+ p = Cof_ManCreateLogicSimple( pGia );
+ p->nLevels = 1 + Gia_ManLevelNum( pGia );
+ p->pLevels = ABC_CALLOC( int, p->nLevels );
+ Cof_ManPrintFanio( p );
+
+ Cof_ManResetTravId( p );
+ Gia_ManHashStart( pGia );
+ Cof_ManPrintHighFanout( p, nNodes );
+ Gia_ManHashStop( pGia );
+ABC_PRM( "Memory for logic network", 4*p->nObjData );
+ABC_PRT( "Time", clock() - clk );
+ Cof_ManStop( p );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaConstr.c b/src/aig/gia/giaConstr.c
new file mode 100644
index 00000000..14768cc2
--- /dev/null
+++ b/src/aig/gia/giaConstr.c
@@ -0,0 +1,47 @@
+/**CFile****************************************************************
+
+ FileName [giaConstr.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Constraint propagation in CNF-based solver.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaConstr.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaDfs.c b/src/aig/gia/giaDfs.c
new file mode 100644
index 00000000..a978dcc3
--- /dev/null
+++ b/src/aig/gia/giaDfs.c
@@ -0,0 +1,243 @@
+/**CFile****************************************************************
+
+ FileName [giaDfs.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [DFS procedures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaDfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Counts the support size of the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCollectCis_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSupp )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ Vec_IntPush( vSupp, Gia_ObjId(p, pObj) );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManCollectCis_rec( p, Gia_ObjFanin0(pObj), vSupp );
+ Gia_ManCollectCis_rec( p, Gia_ObjFanin1(pObj), vSupp );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCollectCis( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vSupp )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Vec_IntClear( vSupp );
+ Gia_ManIncrementTravId( p );
+ Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+ for ( i = 0; i < nNodes; i++ )
+ {
+ pObj = Gia_ManObj( p, pNodes[i] );
+ if ( Gia_ObjIsCo(pObj) )
+ Gia_ManCollectCis_rec( p, Gia_ObjFanin0(pObj), vSupp );
+ else
+ Gia_ManCollectCis_rec( p, pObj, vSupp );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the support size of the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCollectAnds_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ return;
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManCollectAnds_rec( p, Gia_ObjFanin0(pObj), vNodes );
+ Gia_ManCollectAnds_rec( p, Gia_ObjFanin1(pObj), vNodes );
+ Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCollectAnds( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vNodes )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Vec_IntClear( vNodes );
+ Gia_ManIncrementTravId( p );
+ Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+ for ( i = 0; i < nNodes; i++ )
+ {
+ pObj = Gia_ManObj( p, pNodes[i] );
+ if ( Gia_ObjIsCo(pObj) )
+ Gia_ManCollectAnds_rec( p, Gia_ObjFanin0(pObj), vNodes );
+ else
+ Gia_ManCollectAnds_rec( p, pObj, vNodes );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSuppSize_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ return 1;
+ assert( Gia_ObjIsAnd(pObj) );
+ return Gia_ManSuppSize_rec( p, Gia_ObjFanin0(pObj) ) +
+ Gia_ManSuppSize_rec( p, Gia_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNodes )
+{
+ Gia_Obj_t * pObj;
+ int i, Counter = 0;
+ Gia_ManIncrementTravId( p );
+ Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+ for ( i = 0; i < nNodes; i++ )
+ {
+ pObj = Gia_ManObj( p, pNodes[i] );
+ if ( Gia_ObjIsCo(pObj) )
+ Counter += Gia_ManSuppSize_rec( p, Gia_ObjFanin0(pObj) );
+ else
+ Counter += Gia_ManSuppSize_rec( p, pObj );
+ }
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManConeSize_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ return 0;
+ assert( Gia_ObjIsAnd(pObj) );
+ return 1 + Gia_ManConeSize_rec( p, Gia_ObjFanin0(pObj) ) +
+ Gia_ManConeSize_rec( p, Gia_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes )
+{
+ Gia_Obj_t * pObj;
+ int i, Counter = 0;
+ Gia_ManIncrementTravId( p );
+ Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+ for ( i = 0; i < nNodes; i++ )
+ {
+ pObj = Gia_ManObj( p, pNodes[i] );
+ if ( Gia_ObjIsCo(pObj) )
+ Counter += Gia_ManConeSize_rec( p, Gia_ObjFanin0(pObj) );
+ else
+ Counter += Gia_ManConeSize_rec( p, pObj );
+ }
+ return Counter;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c
new file mode 100644
index 00000000..f8d759be
--- /dev/null
+++ b/src/aig/gia/giaDup.c
@@ -0,0 +1,698 @@
+/**CFile****************************************************************
+
+ FileName [giaDup.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Duplication procedures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaDup.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG without any changes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDup( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ else if ( Gia_ObjIsCi(pObj) )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ }
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG without any changes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupMarked( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i, nRos = 0, nRis = 0;
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( pObj->fMark0 )
+ continue;
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ else if ( Gia_ObjIsCi(pObj) )
+ {
+ pObj->Value = Gia_ManAppendCi( pNew );
+ nRos += Gia_ObjIsRo(p, pObj);
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ nRis += Gia_ObjIsRi(p, pObj);
+ }
+ }
+ assert( nRos == nRis );
+ Gia_ManSetRegNum( pNew, nRos );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG while creating "parallel" copies.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupTimes( Gia_Man_t * p, int nTimes )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ Vec_Int_t * vPis, * vPos, * vRis, * vRos;
+ int i, t, Entry;
+ assert( nTimes > 0 );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ vPis = Vec_IntAlloc( Gia_ManPiNum(p) * nTimes );
+ vPos = Vec_IntAlloc( Gia_ManPoNum(p) * nTimes );
+ vRis = Vec_IntAlloc( Gia_ManRegNum(p) * nTimes );
+ vRos = Vec_IntAlloc( Gia_ManRegNum(p) * nTimes );
+ for ( t = 0; t < nTimes; t++ )
+ {
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ else if ( Gia_ObjIsCi(pObj) )
+ {
+ pObj->Value = Gia_ManAppendCi( pNew );
+ if ( Gia_ObjIsPi(p, pObj) )
+ Vec_IntPush( vPis, Gia_Lit2Var(pObj->Value) );
+ else
+ Vec_IntPush( vRos, Gia_Lit2Var(pObj->Value) );
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ if ( Gia_ObjIsPo(p, pObj) )
+ Vec_IntPush( vPos, Gia_Lit2Var(pObj->Value) );
+ else
+ Vec_IntPush( vRis, Gia_Lit2Var(pObj->Value) );
+ }
+ }
+ }
+ Vec_IntClear( pNew->vCis );
+ Vec_IntForEachEntry( vPis, Entry, i )
+ {
+ Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCis) );
+ Vec_IntPush( pNew->vCis, Entry );
+ }
+ Vec_IntForEachEntry( vRos, Entry, i )
+ {
+ Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCis) );
+ Vec_IntPush( pNew->vCis, Entry );
+ }
+ Vec_IntClear( pNew->vCos );
+ Vec_IntForEachEntry( vPos, Entry, i )
+ {
+ Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCos) );
+ Vec_IntPush( pNew->vCos, Entry );
+ }
+ Vec_IntForEachEntry( vRis, Entry, i )
+ {
+ Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCos) );
+ Vec_IntPush( pNew->vCos, Entry );
+ }
+ Vec_IntFree( vPis );
+ Vec_IntFree( vPos );
+ Vec_IntFree( vRis );
+ Vec_IntFree( vRos );
+ Gia_ManSetRegNum( pNew, nTimes * Gia_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManDupDfs_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( ~pObj->Value )
+ return pObj->Value;
+ if ( p->pReprs && ~p->pReprs[Gia_ObjId(p, pObj)] )
+ {
+ Gia_Obj_t * pRepr = Gia_ManObj( p, p->pReprs[Gia_ObjId(p, pObj)] );
+ pObj->Value = Gia_ManDupDfs_rec( pNew, p, pRepr );
+ return pObj->Value = Gia_LitNotCond( pObj->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) );
+ }
+ if ( Gia_ObjIsCi(pObj) )
+ return pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ if ( Gia_ObjIsCo(pObj) )
+ return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin1(pObj) );
+ if ( pNew->pHTable )
+ return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj, * pObjNew;
+ int i;
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCo( p, pObj, i )
+ Gia_ManDupDfs_rec( pNew, p, pObj );
+ Gia_ManForEachCi( p, pObj, i )
+ if ( ~pObj->Value == 0 )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(p) );
+ // remap combinational inputs
+ Gia_ManForEachCi( p, pObj, i )
+ {
+ pObjNew = Gia_ObjFromLit( pNew, pObj->Value );
+ assert( !Gia_IsComplement(pObjNew) );
+ Vec_IntWriteEntry( pNew->vCis, Gia_ObjCioId(pObj), Gia_ObjId(pNew, pObjNew) );
+ Gia_ObjSetCioId( pObjNew, Gia_ObjCioId(pObj) );
+ }
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupDfsSkip( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManForEachCo( p, pObj, i )
+ if ( pObj->fMark1 == 0 )
+ Gia_ManDupDfs_rec( pNew, p, pObj );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupDfsCone( Gia_Man_t * p, Gia_Obj_t * pRoot )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ assert( Gia_ObjIsCo(pRoot) );
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManDupDfs_rec( pNew, p, pRoot );
+ Gia_ManSetRegNum( pNew, 0 );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupDfsLitArray( Gia_Man_t * p, Vec_Int_t * vLits )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i, iLit, iLitRes;
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Vec_IntForEachEntry( vLits, iLit, i )
+ {
+ iLitRes = Gia_ManDupDfs_rec( pNew, p, Gia_ManObj(p, Gia_Lit2Var(iLit)) );
+ Gia_ManAppendCo( pNew, Gia_LitNotCond( iLitRes, Gia_LitIsCompl(iLit)) );
+ }
+ Gia_ManSetRegNum( pNew, 0 );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupNormalized( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ Gia_ManForEachCo( p, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ assert( Gia_ManIsNormalized(pNew) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManSetRefs( p );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ if ( pObj->Value > 0 || Gia_ObjIsRo(p, pObj) )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ Gia_ManForEachCo( p, pObj, i )
+ if ( !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) || Gia_ObjIsRi(p, pObj) )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupCofactored( Gia_Man_t * p, int iVar )
+{
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj, * pPivot;
+ int i;
+ assert( Gia_ManRegNum(p) == 0 );
+ assert( iVar < Gia_ManObjNum(p) );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManHashAlloc( pNew );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ // find the cofactoring variable
+ pPivot = Gia_ManObj(p, iVar);
+ // compute the negative cofactor
+ if ( Gia_ObjIsCi(pPivot) )
+ pPivot->Value = Gia_Var2Lit( 0, 0 );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ if ( pObj == pPivot )
+ pPivot->Value = Gia_Var2Lit( 0, 0 );
+ }
+ Gia_ManForEachCo( p, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ // compute the positive cofactor
+ if ( Gia_ObjIsCi(pPivot) )
+ pPivot->Value = Gia_Var2Lit( 0, 1 );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ if ( pObj == pPivot )
+ pPivot->Value = Gia_Var2Lit( 0, 1 );
+ }
+ Gia_ManForEachCo( p, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ // rehash the result
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Print representatives.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPrintRepr( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ if ( ~p->pReprs[i] )
+ printf( "%d->%d ", i, p->pReprs[i] );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupDfsCiMap( Gia_Man_t * p, int * pCi2Lit, Vec_Int_t * vLits )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ {
+ pObj->Value = Gia_ManAppendCi(pNew);
+ if ( ~pCi2Lit[i] )
+ pObj->Value = Gia_LitNotCond( Gia_ManObj(p, Gia_Lit2Var(pCi2Lit[i]))->Value, Gia_LitIsCompl(pCi2Lit[i]) );
+ }
+ Gia_ManHashAlloc( pNew );
+ if ( vLits )
+ {
+ int iLit, iLitRes;
+ Vec_IntForEachEntry( vLits, iLit, i )
+ {
+ iLitRes = Gia_ManDupDfs_rec( pNew, p, Gia_ManObj(p, Gia_Lit2Var(iLit)) );
+ Gia_ManAppendCo( pNew, Gia_LitNotCond( iLitRes, Gia_LitIsCompl(iLit)) );
+ }
+ }
+ else
+ {
+ Gia_ManForEachCo( p, pObj, i )
+ Gia_ManDupDfs_rec( pNew, p, pObj );
+ }
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupDfsClasses( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj;
+ int i;
+ assert( p->pReprs != NULL );
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManHashAlloc( pNew );
+ Gia_ManForEachCo( p, pObj, i )
+ Gia_ManDupDfs_rec( pNew, p, pObj );
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Detect topmost gate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupTopAnd_iter( Gia_Man_t * p, int fVerbose )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ Vec_Int_t * vFront, * vLeaves;
+ int i, iLit, iObjId, nCiLits, * pCi2Lit;
+ char * pVar2Val;
+ // collect the frontier
+ vFront = Vec_IntAlloc( 1000 );
+ vLeaves = Vec_IntAlloc( 1000 );
+ Gia_ManForEachCo( p, pObj, i )
+ {
+ if ( Gia_ObjIsConst0( Gia_ObjFanin0(pObj) ) )
+ continue;
+ if ( Gia_ObjFaninC0(pObj) )
+ Vec_IntPush( vLeaves, Gia_ObjFaninLit0p(p, pObj) );
+ else
+ Vec_IntPush( vFront, Gia_ObjFaninId0p(p, pObj) );
+ }
+ if ( Vec_IntSize(vFront) == 0 )
+ {
+ if ( fVerbose )
+ printf( "The AIG cannot be decomposed using AND-decomposition.\n" );
+ Vec_IntFree( vFront );
+ Vec_IntFree( vLeaves );
+ return Gia_ManDupNormalized( p );
+ }
+ // expand the frontier
+ Gia_ManForEachObjVec( vFront, p, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ Vec_IntPush( vLeaves, Gia_Var2Lit( Gia_ObjId(p, pObj), 0 ) );
+ continue;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ if ( Gia_ObjFaninC0(pObj) )
+ Vec_IntPush( vLeaves, Gia_ObjFaninLit0p(p, pObj) );
+ else
+ Vec_IntPush( vFront, Gia_ObjFaninId0p(p, pObj) );
+ if ( Gia_ObjFaninC1(pObj) )
+ Vec_IntPush( vLeaves, Gia_ObjFaninLit1p(p, pObj) );
+ else
+ Vec_IntPush( vFront, Gia_ObjFaninId1p(p, pObj) );
+ }
+ Vec_IntFree( vFront );
+ // sort the literals
+ nCiLits = 0;
+ pCi2Lit = ABC_FALLOC( int, Gia_ManObjNum(p) );
+ pVar2Val = ABC_FALLOC( char, Gia_ManObjNum(p) );
+ Vec_IntForEachEntry( vLeaves, iLit, i )
+ {
+ iObjId = Gia_Lit2Var(iLit);
+ pObj = Gia_ManObj(p, iObjId);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ pCi2Lit[Gia_ObjCioId(pObj)] = !Gia_LitIsCompl(iLit);
+ nCiLits++;
+ }
+ if ( pVar2Val[iObjId] != 0 && pVar2Val[iObjId] != 1 )
+ pVar2Val[iObjId] = Gia_LitIsCompl(iLit);
+ else if ( pVar2Val[iObjId] != Gia_LitIsCompl(iLit) )
+ break;
+ }
+ if ( i < Vec_IntSize(vLeaves) )
+ {
+ printf( "Problem is trivially UNSAT.\n" );
+ ABC_FREE( pCi2Lit );
+ ABC_FREE( pVar2Val );
+ Vec_IntFree( vLeaves );
+ return Gia_ManDupNormalized( p );
+ }
+ // create array of input literals
+ Vec_IntClear( vLeaves );
+ Gia_ManForEachObj( p, pObj, i )
+ if ( !Gia_ObjIsCi(pObj) && (pVar2Val[i] == 0 || pVar2Val[i] == 1) )
+ Vec_IntPush( vLeaves, Gia_Var2Lit(i, pVar2Val[i]) );
+ if ( fVerbose )
+ printf( "Detected %6d AND leaves and %6d CI leaves.\n", Vec_IntSize(vLeaves), nCiLits );
+ // create the input map
+ if ( nCiLits == 0 )
+ pNew = Gia_ManDupDfsLitArray( p, vLeaves );
+ else
+ pNew = Gia_ManDupDfsCiMap( p, pCi2Lit, vLeaves );
+ ABC_FREE( pCi2Lit );
+ ABC_FREE( pVar2Val );
+ Vec_IntFree( vLeaves );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Detect topmost gate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupTopAnd( Gia_Man_t * p, int fVerbose )
+{
+ Gia_Man_t * pNew, * pTemp;
+ int fContinue, iIter = 0;
+ pNew = Gia_ManDupNormalized( p );
+ for ( fContinue = 1; fContinue; )
+ {
+ pNew = Gia_ManDupTopAnd_iter( pTemp = pNew, fVerbose );
+ if ( Gia_ManCoNum(pNew) == Gia_ManCoNum(pTemp) && Gia_ManAndNum(pNew) == Gia_ManAndNum(pTemp) )
+ fContinue = 0;
+ Gia_ManStop( pTemp );
+ if ( fVerbose )
+ {
+ printf( "Iter %2d : ", ++iIter );
+ Gia_ManPrintStatsShort( pNew );
+ }
+ }
+ return pNew;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaFanout.c b/src/aig/gia/giaFanout.c
new file mode 100644
index 00000000..42ccd7e7
--- /dev/null
+++ b/src/aig/gia/giaFanout.c
@@ -0,0 +1,197 @@
+/**CFile****************************************************************
+
+ FileName [giaFanout.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaFanout.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// 0: first iFan
+// 1: prev iFan0
+// 2: prev iFan1
+// 3: next iFan0
+// 4: next iFan1
+
+static inline int Gia_FanoutCreate( int FanId, int Num ) { assert( Num < 2 ); return (FanId << 1) | Num; }
+static inline int * Gia_FanoutObj( int * pData, int ObjId ) { return pData + 5*ObjId; }
+static inline int * Gia_FanoutPrev( int * pData, int iFan ) { return pData + 5*(iFan >> 1) + 1 + (iFan & 1); }
+static inline int * Gia_FanoutNext( int * pData, int iFan ) { return pData + 5*(iFan >> 1) + 3 + (iFan & 1); }
+
+// these two procedures are only here for the use inside the iterator
+static inline int Gia_ObjFanout0Int( Gia_Man_t * p, int ObjId ) { assert(ObjId < p->nFansAlloc); return p->pFanData[5*ObjId]; }
+static inline int Gia_ObjFanoutNext( Gia_Man_t * p, int iFan ) { assert(iFan/2 < p->nFansAlloc); return p->pFanData[5*(iFan >> 1) + 3 + (iFan & 1)]; }
+// iterator over the fanouts
+#define Gia_ObjForEachFanout( p, pObj, pFanout, iFan, i ) \
+ for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \
+ (((iFan) = i? Gia_ObjFanoutNext(p, iFan) : Gia_ObjFanout0Int(p, Gia_ObjId(p, pObj))), 1) && \
+ (((pFanout) = Gia_ManObj(p, iFan>>1)), 1); i++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Create fanout for all objects in the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFanoutStart( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ // allocate fanout datastructure
+ assert( p->pFanData == NULL );
+ p->nFansAlloc = 2 * Gia_ManObjNum(p);
+ if ( p->nFansAlloc < (1<<12) )
+ p->nFansAlloc = (1<<12);
+ p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc );
+ memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc );
+ // add fanouts for all objects
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( Gia_ObjChild0(pObj) )
+ Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj );
+ if ( Gia_ObjChild1(pObj) )
+ Gia_ObjAddFanout( p, Gia_ObjFanin1(pObj), pObj );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes fanout for all objects in the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFanoutStop( Gia_Man_t * p )
+{
+ assert( p->pFanData != NULL );
+ ABC_FREE( p->pFanData );
+ p->nFansAlloc = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds fanout (pFanout) of node (pObj).]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout )
+{
+ int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext;
+ assert( p->pFanData );
+ assert( !Gia_IsComplement(pObj) && !Gia_IsComplement(pFanout) );
+ assert( Gia_ObjId(p, pFanout) > 0 );
+ if ( Gia_ObjId(p, pObj) >= p->nFansAlloc || Gia_ObjId(p, pFanout) >= p->nFansAlloc )
+ {
+ int nFansAlloc = 2 * AIG_MAX( Gia_ObjId(p, pObj), Gia_ObjId(p, pFanout) );
+ p->pFanData = ABC_REALLOC( int, p->pFanData, 5 * nFansAlloc );
+ memset( p->pFanData + 5 * p->nFansAlloc, 0, sizeof(int) * 5 * (nFansAlloc - p->nFansAlloc) );
+ p->nFansAlloc = nFansAlloc;
+ }
+ assert( Gia_ObjId(p, pObj) < p->nFansAlloc && Gia_ObjId(p, pFanout) < p->nFansAlloc );
+ iFan = Gia_FanoutCreate( Gia_ObjId(p, pFanout), Gia_ObjWhatFanin(pFanout, pObj) );
+ pPrevC = Gia_FanoutPrev( p->pFanData, iFan );
+ pNextC = Gia_FanoutNext( p->pFanData, iFan );
+ pFirst = Gia_FanoutObj( p->pFanData, Gia_ObjId(p, pObj) );
+ if ( *pFirst == 0 )
+ {
+ *pFirst = iFan;
+ *pPrevC = iFan;
+ *pNextC = iFan;
+ }
+ else
+ {
+ pPrev = Gia_FanoutPrev( p->pFanData, *pFirst );
+ pNext = Gia_FanoutNext( p->pFanData, *pPrev );
+ assert( *pNext == *pFirst );
+ *pPrevC = *pPrev;
+ *pNextC = *pFirst;
+ *pPrev = iFan;
+ *pNext = iFan;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Removes fanout (pFanout) of node (pObj).]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout )
+{
+ int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext;
+ assert( p->pFanData && Gia_ObjId(p, pObj) < p->nFansAlloc && Gia_ObjId(p, pFanout) < p->nFansAlloc );
+ assert( !Gia_IsComplement(pObj) && !Gia_IsComplement(pFanout) );
+ assert( Gia_ObjId(p, pFanout) > 0 );
+ iFan = Gia_FanoutCreate( Gia_ObjId(p, pFanout), Gia_ObjWhatFanin(pFanout, pObj) );
+ pPrevC = Gia_FanoutPrev( p->pFanData, iFan );
+ pNextC = Gia_FanoutNext( p->pFanData, iFan );
+ pPrev = Gia_FanoutPrev( p->pFanData, *pNextC );
+ pNext = Gia_FanoutNext( p->pFanData, *pPrevC );
+ assert( *pPrev == iFan );
+ assert( *pNext == iFan );
+ pFirst = Gia_FanoutObj( p->pFanData, Gia_ObjId(p, pObj) );
+ assert( *pFirst > 0 );
+ if ( *pFirst == iFan )
+ {
+ if ( *pNextC == iFan )
+ {
+ *pFirst = 0;
+ *pPrev = 0;
+ *pNext = 0;
+ *pPrevC = 0;
+ *pNextC = 0;
+ return;
+ }
+ *pFirst = *pNextC;
+ }
+ *pPrev = *pPrevC;
+ *pNext = *pNextC;
+ *pPrevC = 0;
+ *pNextC = 0;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaForce.c b/src/aig/gia/giaForce.c
new file mode 100644
index 00000000..eae0a1cc
--- /dev/null
+++ b/src/aig/gia/giaForce.c
@@ -0,0 +1,164 @@
+/**CFile****************************************************************
+
+ FileName [gia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [This is implementation of qsort in MiniSat.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static int num_cmp ( int * x, int * y) { return ((*x) < (*y)) ? -1 : 1; }
+// Returns a random float 0 <= x < 1. Seed must never be 0.
+static inline double drand(double* seed) {
+ int q;
+ *seed *= 1389796;
+ q = (int)(*seed / 2147483647);
+ *seed -= (double)q * 2147483647;
+ return *seed / 2147483647; }
+// Returns a random integer 0 <= x < size. Seed must never be 0.
+static inline int irand(double* seed, int size) {
+ return (int)(drand(seed) * size); }
+static inline void selectionsort(int* array, int size, int(*comp)(const void *, const void *))
+{
+ int i, j, best_i;
+ int tmp;
+ for (i = 0; i < size-1; i++){
+ best_i = i;
+ for (j = i+1; j < size; j++){
+ if (comp(array + j, array + best_i) < 0)
+ best_i = j;
+ }
+ tmp = array[i]; array[i] = array[best_i]; array[best_i] = tmp;
+ }
+}
+static void sortrnd(int* array, int size, int(*comp)(const void *, const void *), double* seed)
+{
+ if (size <= 15)
+ selectionsort(array, size, comp);
+ else{
+ int * pivot = array + irand(seed, size);
+ int tmp;
+ int i = -1;
+ int j = size;
+ for(;;){
+ do i++; while(comp(array + i, pivot)<0);
+ do j--; while(comp(pivot, array + j)<0);
+ if (i >= j) break;
+ tmp = array[i]; array[i] = array[j]; array[j] = tmp;
+ }
+ sortrnd(array , i , comp, seed);
+ sortrnd(&array[i], size-i, comp, seed);
+ }
+}
+void minisat_sort(int* array, int size, int(*comp)(const void *, const void *))
+{
+ double seed = 91648253;
+ sortrnd(array,size,comp,&seed);
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Gia_SortGetTest( int nSize )
+{
+ int i, * pArray;
+ Aig_ManRandom( 1 );
+ pArray = ABC_ALLOC( int, nSize );
+ for ( i = 0; i < nSize; i++ )
+ pArray[i] = (Aig_ManRandom( 0 ) >> 2);
+ return pArray;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_SortVerifySorted( int * pArray, int nSize )
+{
+ int i;
+ for ( i = 1; i < nSize; i++ )
+ assert( pArray[i-1] <= pArray[i] );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_SortTest()
+{
+ int nSize = 1000000;
+ int * pArray;
+ int clk = clock();
+ pArray = Gia_SortGetTest( nSize );
+clk = clock();
+ qsort( pArray, nSize, 4, (int (*)(const void *, const void *)) num_cmp );
+ABC_PRT( "qsort ", clock() - clk );
+ Gia_SortVerifySorted( pArray, nSize );
+ ABC_FREE( pArray );
+ pArray = Gia_SortGetTest( nSize );
+clk = clock();
+ minisat_sort( pArray, nSize, (int (*)(const void *, const void *)) num_cmp );
+ABC_PRT( "minisat", clock() - clk );
+ Gia_SortVerifySorted( pArray, nSize );
+ ABC_FREE( pArray );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaFrames.c b/src/aig/gia/giaFrames.c
new file mode 100644
index 00000000..e99ef514
--- /dev/null
+++ b/src/aig/gia/giaFrames.c
@@ -0,0 +1,346 @@
+/**CFile****************************************************************
+
+ FileName [giaFrames.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Timeframe unrolling.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaFrames.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Gia_ManFra_t_ Gia_ManFra_t;
+struct Gia_ManFra_t_
+{
+ Gia_ParFra_t * pPars; // parameters
+ Gia_Man_t * pAig; // AIG to unroll
+ Vec_Ptr_t * vIns; // inputs of each timeframe
+ Vec_Ptr_t * vAnds; // nodes of each timeframe
+ Vec_Ptr_t * vOuts; // outputs of each timeframe
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFraSetDefaultParams( Gia_ParFra_t * p )
+{
+ memset( p, 0, sizeof(Gia_ParFra_t) );
+ p->nFrames = 32; // the number of frames to unroll
+ p->fInit = 0; // initialize the timeframes
+ p->fVerbose = 0; // enables verbose output
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManFra_t * Gia_ManFraStart( Gia_Man_t * pAig, Gia_ParFra_t * pPars )
+{
+ Gia_ManFra_t * p;
+ p = ABC_ALLOC( Gia_ManFra_t, 1 );
+ memset( p, 0, sizeof(Gia_ManFra_t) );
+ p->pAig = pAig;
+ p->pPars = pPars;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFraStop( Gia_ManFra_t * p )
+{
+ Vec_VecFree( (Vec_Vec_t *)p->vIns );
+ Vec_VecFree( (Vec_Vec_t *)p->vAnds );
+ Vec_VecFree( (Vec_Vec_t *)p->vOuts );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes supports of all timeframes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFraSupports( Gia_ManFra_t * p )
+{
+ Vec_Int_t * vIns = NULL, * vAnds, * vOuts;
+ Gia_Obj_t * pObj;
+ int f, i;
+ p->vIns = Vec_PtrStart( p->pPars->nFrames );
+ p->vAnds = Vec_PtrStart( p->pPars->nFrames );
+ p->vOuts = Vec_PtrStart( p->pPars->nFrames );
+ Gia_ManResetTravId( p->pAig );
+ for ( f = p->pPars->nFrames - 1; f >= 0; f-- )
+ {
+ vOuts = Gia_ManCollectPoIds( p->pAig );
+ if ( vIns )
+ Gia_ManForEachObjVec( vIns, p->pAig, pObj, i )
+ if ( Gia_ObjIsRo(p->pAig, pObj) )
+ Vec_IntPush( vOuts, Gia_ObjId( p->pAig, Gia_ObjRoToRi(p->pAig, pObj) ) );
+ vIns = Vec_IntAlloc( 100 );
+ Gia_ManCollectCis( p->pAig, Vec_IntArray(vOuts), Vec_IntSize(vOuts), vIns );
+ vAnds = Vec_IntAlloc( 100 );
+ Gia_ManCollectAnds( p->pAig, Vec_IntArray(vOuts), Vec_IntSize(vOuts), vAnds );
+ Vec_PtrWriteEntry( p->vIns, f, vIns );
+ Vec_PtrWriteEntry( p->vAnds, f, vAnds );
+ Vec_PtrWriteEntry( p->vOuts, f, vOuts );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Moves the first nRegs entries to the end.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFraTransformCis( Gia_Man_t * pAig, Vec_Int_t * vCis )
+{
+ int i, k = 0, Entry;
+ Vec_IntForEachEntryStop( vCis, Entry, i, Gia_ManRegNum(pAig) )
+ assert( Entry == i+1 );
+ Vec_IntForEachEntryStart( vCis, Entry, i, Gia_ManRegNum(pAig) )
+ Vec_IntWriteEntry( vCis, k++, Entry );
+ for ( i = 0; i < Gia_ManRegNum(pAig); i++ )
+ Vec_IntWriteEntry( vCis, k++, i+1 );
+ assert( k == Vec_IntSize(vCis) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManFramesInit( Gia_Man_t * pAig, Gia_ParFra_t * pPars )
+{
+ int fUseAllPis = 1;
+ Gia_Man_t * pFrames, * pTemp;
+ Gia_ManFra_t * p;
+ Gia_Obj_t * pObj;
+ Vec_Int_t * vIns, * vAnds, * vOuts;
+ int i, f;
+ p = Gia_ManFraStart( pAig, pPars );
+ Gia_ManFraSupports( p );
+ pFrames = Gia_ManStart( Vec_VecSizeSize((Vec_Vec_t*)p->vIns)+
+ Vec_VecSizeSize((Vec_Vec_t*)p->vAnds)+Vec_VecSizeSize((Vec_Vec_t*)p->vOuts) );
+ pFrames->pName = Aig_UtilStrsav( pAig->pName );
+ Gia_ManHashAlloc( pFrames );
+ Gia_ManConst0(pAig)->Value = 0;
+ for ( f = 0; f < pPars->nFrames; f++ )
+ {
+ vIns = Vec_PtrEntry( p->vIns, f );
+ vAnds = Vec_PtrEntry( p->vAnds, f );
+ vOuts = Vec_PtrEntry( p->vOuts, f );
+ if ( pPars->fVerbose )
+ printf( "Frame %3d : CI = %6d. AND = %6d. CO = %6d.\n",
+ f, Vec_IntSize(vIns), Vec_IntSize(vAnds), Vec_IntSize(vOuts) );
+ if ( fUseAllPis )
+ {
+ Gia_ManForEachPi( pAig, pObj, i )
+ pObj->Value = Gia_ManAppendCi( pFrames );
+ if ( f == 0 )
+ {
+ Gia_ManForEachObjVec( vIns, pAig, pObj, i )
+ {
+ assert( Gia_ObjIsCi(pObj) );
+ if ( !Gia_ObjIsPi(pAig, pObj) )
+ pObj->Value = 0;
+ }
+ }
+ else
+ {
+ Gia_ManForEachObjVec( vIns, pAig, pObj, i )
+ {
+ assert( Gia_ObjIsCi(pObj) );
+ if ( !Gia_ObjIsPi(pAig, pObj) )
+ pObj->Value = Gia_ObjRoToRi(pAig, pObj)->Value;
+ }
+ }
+ }
+ else
+ {
+ if ( f == 0 )
+ {
+ Gia_ManForEachObjVec( vIns, pAig, pObj, i )
+ {
+ assert( Gia_ObjIsCi(pObj) );
+ if ( Gia_ObjIsPi(pAig, pObj) )
+ pObj->Value = Gia_ManAppendCi( pFrames );
+ else
+ pObj->Value = 0;
+ }
+ }
+ else
+ {
+ Gia_ManForEachObjVec( vIns, pAig, pObj, i )
+ {
+ assert( Gia_ObjIsCi(pObj) );
+ if ( Gia_ObjIsPi(pAig, pObj) )
+ pObj->Value = Gia_ManAppendCi( pFrames );
+ else
+ pObj->Value = Gia_ObjRoToRi(pAig, pObj)->Value;
+ }
+ }
+ }
+ Gia_ManForEachObjVec( vAnds, pAig, pObj, i )
+ {
+ assert( Gia_ObjIsAnd(pObj) );
+ pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ }
+ Gia_ManForEachObjVec( vOuts, pAig, pObj, i )
+ {
+ assert( Gia_ObjIsCo(pObj) );
+ if ( Gia_ObjIsPo(pAig, pObj) )
+ pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) );
+ else
+ pObj->Value = Gia_ObjFanin0Copy(pObj);
+ }
+ }
+ Gia_ManFraStop( p );
+ Gia_ManHashStop( pFrames );
+ if ( Gia_ManCombMarkUsed(pFrames) < Gia_ManAndNum(pFrames) )
+ {
+ pFrames = Gia_ManDupMarked( pTemp = pFrames );
+ if ( pPars->fVerbose )
+ printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
+ Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) );
+ Gia_ManStop( pTemp );
+ }
+ else if ( pPars->fVerbose )
+ printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
+ Gia_ManAndNum(pFrames), Gia_ManAndNum(pFrames) );
+ return pFrames;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManFrames( Gia_Man_t * pAig, Gia_ParFra_t * pPars )
+{
+ Gia_Man_t * pFrames, * pTemp;
+ Gia_Obj_t * pObj;
+ int i, f;
+ assert( Gia_ManRegNum(pAig) > 0 );
+ assert( pPars->nFrames > 0 );
+ if ( pPars->fInit )
+ return Gia_ManFramesInit( pAig, pPars );
+ pFrames = Gia_ManStart( pPars->nFrames * Gia_ManObjNum(pAig) );
+ pFrames->pName = Aig_UtilStrsav( pAig->pName );
+ Gia_ManHashAlloc( pFrames );
+ Gia_ManConst0(pAig)->Value = 0;
+ for ( f = 0; f < pPars->nFrames; f++ )
+ {
+ if ( f == 0 )
+ {
+ Gia_ManForEachRo( pAig, pObj, i )
+ pObj->Value = Gia_ManAppendCi( pFrames );
+ }
+ else
+ {
+ Gia_ManForEachRo( pAig, pObj, i )
+ pObj->Value = Gia_ObjRoToRi( pAig, pObj )->Value;
+ }
+ Gia_ManForEachPi( pAig, pObj, i )
+ pObj->Value = Gia_ManAppendCi( pFrames );
+ Gia_ManForEachAnd( pAig, pObj, i )
+ pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ Gia_ManForEachPo( pAig, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) );
+ if ( f == pPars->nFrames - 1 )
+ {
+ Gia_ManForEachRi( pAig, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) );
+ }
+ else
+ {
+ Gia_ManForEachRi( pAig, pObj, i )
+ pObj->Value = Gia_ObjFanin0Copy(pObj);
+ }
+ }
+ Gia_ManHashStop( pFrames );
+ Gia_ManFraTransformCis( pAig, pFrames->vCis );
+ Gia_ManSetRegNum( pFrames, Gia_ManRegNum(pAig) );
+ if ( Gia_ManCombMarkUsed(pFrames) < Gia_ManAndNum(pFrames) )
+ {
+ pFrames = Gia_ManDupMarked( pTemp = pFrames );
+ if ( pPars->fVerbose )
+ printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
+ Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) );
+ Gia_ManStop( pTemp );
+ }
+ else if ( pPars->fVerbose )
+ printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
+ Gia_ManAndNum(pFrames), Gia_ManAndNum(pFrames) );
+ return pFrames;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaFront.c b/src/aig/gia/giaFront.c
new file mode 100644
index 00000000..ee9e5b5f
--- /dev/null
+++ b/src/aig/gia/giaFront.c
@@ -0,0 +1,248 @@
+/**CFile****************************************************************
+
+ FileName [giaFront.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Frontier representation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaFront.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Find the next place on the frontier.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManFrontFindNext( char * pFront, int nFront, int iFront )
+{
+ assert( iFront < nFront );
+ for ( ; pFront[iFront]; iFront = (iFront + 1) % nFront );
+ assert( pFront[iFront] == 0 );
+ pFront[iFront] = 1;
+ return iFront;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transforms the frontier manager to its initial state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFrontTransform( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, * pFrontToId; // mapping of nodes into frontier variables
+ assert( p->nFront > 0 );
+ pFrontToId = ABC_ALLOC( int, p->nFront );
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( Gia_ObjIsCo(pObj) )
+ {
+ assert( pObj->Value == GIA_NONE );
+ pObj->iDiff0 = i - pFrontToId[Gia_ObjDiff0(pObj)];
+ }
+ else if ( Gia_ObjIsAnd(pObj) )
+ {
+ assert( (int)pObj->Value < p->nFront );
+ pObj->iDiff0 = i - pFrontToId[Gia_ObjDiff0(pObj)];
+ pObj->iDiff1 = i - pFrontToId[Gia_ObjDiff1(pObj)];
+ pFrontToId[pObj->Value] = i;
+ }
+ else
+ {
+ assert( (int)pObj->Value < p->nFront );
+ pFrontToId[pObj->Value] = i;
+ }
+ pObj->Value = 0;
+ }
+ ABC_FREE( pFrontToId );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Determine the frontier.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManFront( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj, * pFanin0New, * pFanin1New, * pObjNew;
+ char * pFront; // places used for the frontier
+ int i, iLit, nCrossCut = 0, nCrossCutMax = 0;
+ int nCrossCutMaxInit = Gia_ManCrossCut( p );
+ int iFront = 0, clk = clock();
+ // set references for all objects
+ Gia_ManSetRefs( p );
+ // start the new manager
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ pNew->nFront = 1 + (int)((float)1.1 * nCrossCutMaxInit);
+ // start the frontier
+ pFront = ABC_CALLOC( char, pNew->nFront );
+ // add constant node
+ Gia_ManConst0(pNew)->Value = iFront = Gia_ManFrontFindNext( pFront, pNew->nFront, iFront );
+ if ( Gia_ObjValue(Gia_ManConst0(p)) == 0 )
+ pFront[iFront] = 0;
+ else
+ nCrossCut = 1;
+ // iterate through the objects
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ if ( Gia_ObjValue(pObj) && nCrossCutMax < ++nCrossCut )
+ nCrossCutMax = nCrossCut;
+ // create new node
+ iLit = Gia_ManAppendCi( pNew );
+ pObjNew = Gia_ManObj( pNew, Gia_Lit2Var(iLit) );
+ assert( Gia_ObjId(pNew, pObjNew) == Gia_ObjId(p, pObj) );
+ pObjNew->Value = iFront = Gia_ManFrontFindNext( pFront, pNew->nFront, iFront );
+ // handle CIs without fanout
+ if ( Gia_ObjValue(pObj) == 0 )
+ pFront[iFront] = 0;
+ continue;
+ }
+ if ( Gia_ObjIsCo(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) == 0 );
+ // create new node
+ iLit = Gia_ManAppendCo( pNew, 0 );
+ pObjNew = Gia_ManObj( pNew, Gia_Lit2Var(iLit) );
+ assert( Gia_ObjId(pNew, pObjNew) == Gia_ObjId(p, pObj) );
+ // get the fanin
+ pFanin0New = Gia_ManObj( pNew, Gia_ObjFaninId0(pObj, i) );
+ assert( pFanin0New->Value != GIA_NONE );
+ pObjNew->Value = GIA_NONE;
+ pObjNew->iDiff0 = pFanin0New->Value;
+ pObjNew->fCompl0 = Gia_ObjFaninC0(pObj);
+ // deref the fanin
+ if ( --Gia_ObjFanin0(pObj)->Value == 0 )
+ {
+ pFront[pFanin0New->Value] = 0;
+ nCrossCut--;
+ }
+ continue;
+ }
+ if ( Gia_ObjValue(pObj) && nCrossCutMax < ++nCrossCut )
+ nCrossCutMax = nCrossCut;
+ // create new node
+ pObjNew = Gia_ManAppendObj( pNew );
+ assert( Gia_ObjId(pNew, pObjNew) == Gia_ObjId(p, pObj) );
+ // assign the first fanin
+ pFanin0New = Gia_ManObj( pNew, Gia_ObjFaninId0(pObj, i) );
+ assert( pFanin0New->Value != GIA_NONE );
+ pObjNew->iDiff0 = pFanin0New->Value;
+ pObjNew->fCompl0 = Gia_ObjFaninC0(pObj);
+ // assign the second fanin
+ pFanin1New = Gia_ManObj( pNew, Gia_ObjFaninId1(pObj, i) );
+ assert( pFanin1New->Value != GIA_NONE );
+ pObjNew->iDiff1 = pFanin1New->Value;
+ pObjNew->fCompl1 = Gia_ObjFaninC1(pObj);
+ // assign the frontier number
+ pObjNew->Value = iFront = Gia_ManFrontFindNext( pFront, pNew->nFront, iFront );
+ // deref the fanins
+ if ( --Gia_ObjFanin0(pObj)->Value == 0 )
+ {
+ pFront[pFanin0New->Value] = 0;
+ nCrossCut--;
+ }
+ if ( --Gia_ObjFanin1(pObj)->Value == 0 )
+ {
+ pFront[pFanin1New->Value] = 0;
+ nCrossCut--;
+ }
+ // handle nodes without fanout (choice nodes)
+ if ( Gia_ObjValue(pObj) == 0 )
+ pFront[iFront] = 0;
+ }
+ assert( pNew->nObjs == p->nObjs );
+ assert( nCrossCut == 0 && nCrossCutMax == nCrossCutMaxInit );
+ for ( i = 0; i < pNew->nFront; i++ )
+ assert( pFront[i] == 0 );
+ ABC_FREE( pFront );
+//printf( "Crosscut = %6d. Frontier = %6d. ", nCrossCutMaxInit, pNew->nFront );
+//ABC_PRT( "Time", clock() - clk );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFrontTest( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ pNew = Gia_ManFront( p );
+ Gia_ManFrontTransform( pNew );
+// Gia_ManCleanValue( p );
+// Gia_ManCleanValue( pNew );
+ if ( memcmp( pNew->pObjs, p->pObjs, sizeof(Gia_Obj_t) * p->nObjs ) )
+ {
+/*
+ Gia_Obj_t * pObj, * pObjNew;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ pObjNew = Gia_ManObj( pNew, i );
+ printf( "%5d %5d %5d %5d\n",
+ pObj->iDiff0, pObjNew->iDiff0,
+ pObj->iDiff1, pObjNew->iDiff1 );
+ }
+*/
+ printf( "Verification failed.\n" );
+ }
+ else
+ printf( "Verification successful.\n" );
+ Gia_ManStop( pNew );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaGlitch.c b/src/aig/gia/giaGlitch.c
new file mode 100644
index 00000000..bbc509c4
--- /dev/null
+++ b/src/aig/gia/giaGlitch.c
@@ -0,0 +1,743 @@
+/**CFile****************************************************************
+
+ FileName [giaGlitch.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Glitch simulation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaGlitch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Gli_Obj_t_ Gli_Obj_t;
+struct Gli_Obj_t_
+{
+ unsigned fTerm : 1; // terminal node
+ unsigned fPhase : 1; // value under 000 pattern
+ unsigned fPhase2 : 1; // value under 000 pattern
+ unsigned fMark : 1; // user-controlled mark
+ unsigned nFanins : 3; // the number of fanins
+ unsigned nFanouts : 25; // total number of fanouts
+ unsigned Handle; // ID of the node
+ unsigned uTruth[2]; // truth table of the node
+ unsigned uSimInfo; // simulation info of the node
+ union
+ {
+ int iFanin; // the number of fanins added
+ int nSwitches; // the number of switches
+ };
+ union
+ {
+ int iFanout; // the number of fanouts added
+ int nGlitches; // the number of glitches ( nGlitches >= nSwitches )
+ };
+ int Fanios[0]; // the array of fanins/fanouts
+};
+
+typedef struct Gli_Man_t_ Gli_Man_t;
+struct Gli_Man_t_
+{
+ Vec_Int_t * vCis; // the vector of CIs (PIs + LOs)
+ Vec_Int_t * vCos; // the vector of COs (POs + LIs)
+ Vec_Int_t * vCisChanged; // the changed CIs
+ Vec_Int_t * vAffected; // the affected nodes
+ Vec_Int_t * vFrontier; // the fanouts of these nodes
+ int nObjs; // the number of objects
+ int nRegs; // the number of registers
+ int nTravIds; // traversal ID of the network
+ int iObjData; // pointer to the current data
+ int nObjData; // the size of array to store the logic network
+ int * pObjData; // the internal nodes
+ unsigned * pSimInfoPrev; // previous values of the CIs
+};
+
+
+static inline int Gli_ManCiNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCis); }
+static inline int Gli_ManCoNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCos); }
+static inline int Gli_ManPiNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCis) - p->nRegs; }
+static inline int Gli_ManPoNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCos) - p->nRegs; }
+static inline int Gli_ManRegNum( Gli_Man_t * p ) { return p->nRegs; }
+static inline int Gli_ManObjNum( Gli_Man_t * p ) { return p->nObjs; }
+static inline int Gli_ManNodeNum( Gli_Man_t * p ) { return p->nObjs - Vec_IntSize(p->vCis) - Vec_IntSize(p->vCos); }
+
+static inline Gli_Obj_t * Gli_ManObj( Gli_Man_t * p, int v ) { return (Gli_Obj_t *)(p->pObjData + v); }
+static inline Gli_Obj_t * Gli_ManCi( Gli_Man_t * p, int v ) { return Gli_ManObj( p, Vec_IntEntry(p->vCis,v) ); }
+static inline Gli_Obj_t * Gli_ManCo( Gli_Man_t * p, int v ) { return Gli_ManObj( p, Vec_IntEntry(p->vCos,v) ); }
+static inline Gli_Obj_t * Gli_ManPi( Gli_Man_t * p, int v ) { assert( v < Gli_ManPiNum(p) ); return Gli_ManCi( p, v ); }
+static inline Gli_Obj_t * Gli_ManPo( Gli_Man_t * p, int v ) { assert( v < Gli_ManPoNum(p) ); return Gli_ManCo( p, v ); }
+static inline Gli_Obj_t * Gli_ManRo( Gli_Man_t * p, int v ) { assert( v < Gli_ManRegNum(p) ); return Gli_ManCi( p, Gli_ManRegNum(p)+v ); }
+static inline Gli_Obj_t * Gli_ManRi( Gli_Man_t * p, int v ) { assert( v < Gli_ManRegNum(p) ); return Gli_ManCo( p, Gli_ManRegNum(p)+v ); }
+
+static inline int Gli_ObjIsTerm( Gli_Obj_t * pObj ) { return pObj->fTerm; }
+static inline int Gli_ObjIsCi( Gli_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 0; }
+static inline int Gli_ObjIsCo( Gli_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 1; }
+static inline int Gli_ObjIsNode( Gli_Obj_t * pObj ) { return!pObj->fTerm; }
+
+static inline int Gli_ObjFaninNum( Gli_Obj_t * pObj ) { return pObj->nFanins; }
+static inline int Gli_ObjFanoutNum( Gli_Obj_t * pObj ) { return pObj->nFanouts; }
+static inline int Gli_ObjSize( Gli_Obj_t * pObj ) { return sizeof(Gli_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; }
+
+static inline Gli_Obj_t * Gli_ObjFanin( Gli_Obj_t * pObj, int i ) { return (Gli_Obj_t *)(((int *)pObj) - pObj->Fanios[i]); }
+static inline Gli_Obj_t * Gli_ObjFanout( Gli_Obj_t * pObj, int i ) { return (Gli_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i]); }
+
+#define Gli_ManForEachObj( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjData) && (pObj = Gli_ManObj(p,i)); i += Gli_ObjSize(pObj) )
+#define Gli_ManForEachNode( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjData) && (pObj = Gli_ManObj(p,i)); i += Gli_ObjSize(pObj) ) if ( Gli_ObjIsTerm(pObj) ) {} else
+
+#define Gli_ManForEachEntry( vVec, p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(vVec)) && (pObj = Gli_ManObj(p,Vec_IntEntry(vVec,i))); i++ )
+#define Gli_ManForEachCi( p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(p->vCis)) && (pObj = Gli_ManObj(p,Vec_IntEntry(p->vCis,i))); i++ )
+#define Gli_ManForEachCo( p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(p->vCos)) && (pObj = Gli_ManObj(p,Vec_IntEntry(p->vCos,i))); i++ )
+
+#define Gli_ManForEachPi( p, pObj, i ) \
+ for ( i = 0; (i < Gli_ManPiNum(p)) && ((pObj) = Gli_ManCi(p, i)); i++ )
+#define Gli_ManForEachPo( p, pObj, i ) \
+ for ( i = 0; (i < Gli_ManPoNum(p)) && ((pObj) = Gli_ManCo(p, i)); i++ )
+#define Gli_ManForEachRo( p, pObj, i ) \
+ for ( i = 0; (i < Gli_ManRegNum(p)) && ((pObj) = Gli_ManCi(p, Gli_ManPiNum(p)+i)); i++ )
+#define Gli_ManForEachRi( p, pObj, i ) \
+ for ( i = 0; (i < Gli_ManRegNum(p)) && ((pObj) = Gli_ManCo(p, Gli_ManPoNum(p)+i)); i++ )
+#define Gli_ManForEachRiRo( p, pObjRi, pObjRo, i ) \
+ for ( i = 0; (i < Gli_ManRegNum(p)) && ((pObjRi) = Gli_ManCo(p, Gli_ManPoNum(p)+i)) && ((pObjRo) = Gli_ManCi(p, Gli_ManPiNum(p)+i)); i++ )
+
+#define Gli_ObjForEachFanin( pObj, pNext, i ) \
+ for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Gli_ObjFanin(pObj,i)); i++ )
+#define Gli_ObjForEachFanout( pObj, pNext, i ) \
+ for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Gli_ObjFanout(pObj,i)); i++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates logic network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gli_Man_t * Gli_ManAlloc( int nObjs, int nRegs, int nFanioPairs )
+{
+ Gli_Man_t * p;
+ p = (Gli_Man_t *)ABC_CALLOC( int, (sizeof(Gli_Man_t) / 4) + (sizeof(Gli_Obj_t) / 4) * nObjs + 2 * nFanioPairs );
+ p->nRegs = nRegs;
+ p->vCis = Vec_IntAlloc( 1000 );
+ p->vCos = Vec_IntAlloc( 1000 );
+ p->vCisChanged = Vec_IntAlloc( 1000 );
+ p->vAffected = Vec_IntAlloc( 1000 );
+ p->vFrontier = Vec_IntAlloc( 1000 );
+ p->nObjData = (sizeof(Gli_Obj_t) / 4) * nObjs + 2 * nFanioPairs;
+ p->pObjData = (int *)(p + 1);
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes logic network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManStop( Gli_Man_t * p )
+{
+ Vec_IntFree( p->vCis );
+ Vec_IntFree( p->vCos );
+ Vec_IntFree( p->vCisChanged );
+ Vec_IntFree( p->vAffected );
+ Vec_IntFree( p->vFrontier );
+ ABC_FREE( p->pSimInfoPrev );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Checks logic network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManPrintObjects( Gli_Man_t * p )
+{
+ Gli_Obj_t * pObj, * pNext;
+ int i, k;
+ Gli_ManForEachObj( p, pObj, i )
+ {
+ printf( "Node %d \n", pObj->Handle );
+ printf( "Fanins: " );
+ Gli_ObjForEachFanin( pObj, pNext, k )
+ printf( "%d ", pNext->Handle );
+ printf( "\n" );
+ printf( "Fanouts: " );
+ Gli_ObjForEachFanout( pObj, pNext, k )
+ printf( "%d ", pNext->Handle );
+ printf( "\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Checks logic network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManFinalize( Gli_Man_t * p )
+{
+ Gli_Obj_t * pObj;
+ int i;
+ assert( p->iObjData == p->nObjData );
+ Gli_ManForEachObj( p, pObj, i )
+ {
+ assert( pObj->iFanin == (int)pObj->nFanins );
+ assert( pObj->iFanout == (int)pObj->nFanouts );
+ pObj->iFanin = 0;
+ pObj->iFanout = 0;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates fanin/fanout pair.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ObjAddFanin( Gli_Obj_t * pObj, Gli_Obj_t * pFanin )
+{
+ assert( pObj->iFanin < (int)pObj->nFanins );
+ assert( pFanin->iFanout < (int)pFanin->nFanouts );
+ pFanin->Fanios[pFanin->nFanins + pFanin->iFanout++] =
+ pObj->Fanios[pObj->iFanin++] = pObj->Handle - pFanin->Handle;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocates object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gli_Obj_t * Gli_ObjAlloc( Gli_Man_t * p, int nFanins, int nFanouts )
+{
+ Gli_Obj_t * pObj;
+ pObj = Gli_ManObj( p, p->iObjData );
+ pObj->Handle = p->iObjData;
+ pObj->nFanins = nFanins;
+ pObj->nFanouts = nFanouts;
+ p->iObjData += Gli_ObjSize( pObj );
+ p->nObjs++;
+ return pObj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates CI.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gli_ManCreateCi( Gli_Man_t * p, int nFanouts )
+{
+ Gli_Obj_t * pObj;
+ pObj = Gli_ObjAlloc( p, 0, nFanouts );
+ pObj->fTerm = 1;
+ Vec_IntPush( p->vCis, pObj->Handle );
+ return pObj->Handle;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates CO.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gli_ManCreateCo( Gli_Man_t * p, int iFanin )
+{
+ Gli_Obj_t * pObj, * pFanin;
+ pObj = Gli_ObjAlloc( p, 1, 0 );
+ pObj->fTerm = 1;
+ pFanin = Gli_ManObj( p, iFanin );
+ Gli_ObjAddFanin( pObj, pFanin );
+ pObj->fPhase = pObj->fPhase2 = pFanin->fPhase;
+ Vec_IntPush( p->vCos, pObj->Handle );
+ return pObj->Handle;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gli_NodeComputeValue( Gli_Obj_t * pNode )
+{
+ int i, Phase = 0;
+ for ( i = 0; i < (int)pNode->nFanins; i++ )
+ Phase |= (Gli_ObjFanin(pNode, i)->fPhase << i);
+ return Aig_InfoHasBit( pNode->uTruth, Phase );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gli_NodeComputeValue2( Gli_Obj_t * pNode )
+{
+ int i, Phase = 0;
+ for ( i = 0; i < (int)pNode->nFanins; i++ )
+ Phase |= (Gli_ObjFanin(pNode, i)->fPhase2 << i);
+ return Aig_InfoHasBit( pNode->uTruth, Phase );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gli_ManCreateNode( Gli_Man_t * p, Vec_Int_t * vFanins, int nFanouts, unsigned * puTruth )
+{
+ Gli_Obj_t * pObj, * pFanin;
+ int i;
+ assert( Vec_IntSize(vFanins) <= 6 );
+ pObj = Gli_ObjAlloc( p, Vec_IntSize(vFanins), nFanouts );
+ Gli_ManForEachEntry( vFanins, p, pFanin, i )
+ Gli_ObjAddFanin( pObj, pFanin );
+ pObj->uTruth[0] = puTruth[0];
+ pObj->uTruth[1] = puTruth[Vec_IntSize(vFanins) == 6];
+ pObj->fPhase = pObj->fPhase2 = Gli_NodeComputeValue( pObj );
+ return pObj->Handle;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of switches of the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gli_ObjNumSwitches( Gli_Man_t * p, int iNode )
+{
+ return Gli_ManObj( p, iNode )->nSwitches;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of glitches of the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gli_ObjNumGlitches( Gli_Man_t * p, int iNode )
+{
+ return Gli_ManObj( p, iNode )->nGlitches;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Sets random info at the PIs and collects changed PIs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManSetPiRandom( Gli_Man_t * p, float PiTransProb )
+{
+ Gli_Obj_t * pObj;
+ float Multi = 1.0 / (1 << 16);
+ int i;
+ assert( 0.0 < PiTransProb && PiTransProb < 1.0 );
+ Vec_IntClear( p->vCisChanged );
+ Gli_ManForEachCi( p, pObj, i )
+ if ( Multi * (Aig_ManRandom(0) & 0xffff) < PiTransProb )
+ {
+ Vec_IntPush( p->vCisChanged, pObj->Handle );
+ pObj->fPhase ^= 1;
+ pObj->fPhase2 ^= 1;
+ pObj->nSwitches++;
+ pObj->nGlitches++;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets random info at the PIs and collects changed PIs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManSetPiFromSaved( Gli_Man_t * p, int iBit )
+{
+ Gli_Obj_t * pObj;
+ int i;
+ Vec_IntClear( p->vCisChanged );
+ Gli_ManForEachCi( p, pObj, i )
+ if ( (p->pSimInfoPrev[i] ^ pObj->uSimInfo) & (1 << iBit) )
+ {
+ Vec_IntPush( p->vCisChanged, pObj->Handle );
+ pObj->fPhase ^= 1;
+ pObj->fPhase2 ^= 1;
+ pObj->nSwitches++;
+ pObj->nGlitches++;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes switching activity of each node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManSwitching( Gli_Man_t * p )
+{
+ Gli_Obj_t * pThis;
+ int i;
+ Gli_ManForEachNode( p, pThis, i )
+ {
+ if ( ((int)pThis->fPhase) == Gli_NodeComputeValue(pThis) )
+ continue;
+ pThis->fPhase ^= 1;
+ pThis->nSwitches++;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes glitching activity of each node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManGlitching( Gli_Man_t * p )
+{
+ Gli_Obj_t * pThis, * pFanout, * pOther = Gli_ManObj(p, 41);
+ int i, k, Handle;
+// Gli_ManForEachObj( p, pThis, i )
+// assert( pThis->fMark == 0 );
+ // start the array of affected nodes
+ Vec_IntClear( p->vAffected );
+ Vec_IntForEachEntry( p->vCisChanged, Handle, i )
+ Vec_IntPush( p->vAffected, Handle );
+ // iteration propagation
+ while ( Vec_IntSize(p->vAffected) > 0 )
+ {
+ // compute the frontier
+ Vec_IntClear( p->vFrontier );
+ Gli_ManForEachEntry( p->vAffected, p, pThis, i )
+ {
+ Gli_ObjForEachFanout( pThis, pFanout, k )
+ {
+ if ( Gli_ObjIsCo(pFanout) )
+ continue;
+ if ( pFanout->fMark )
+ continue;
+ pFanout->fMark = 1;
+ Vec_IntPush( p->vFrontier, pFanout->Handle );
+ }
+ }
+ // compute the next set of affected nodes
+ Vec_IntClear( p->vAffected );
+ Gli_ManForEachEntry( p->vFrontier, p, pThis, i )
+ {
+ pThis->fMark = 0;
+ if ( ((int)pThis->fPhase2) == Gli_NodeComputeValue2(pThis) )
+ continue;
+ pThis->fPhase2 ^= 1;
+ pThis->nGlitches++;
+ Vec_IntPush( p->vAffected, pThis->Handle );
+ }
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Checks that the resulting values are the same.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManVerify( Gli_Man_t * p )
+{
+ Gli_Obj_t * pObj;
+ int i;
+ Gli_ManForEachObj( p, pObj, i )
+ {
+ assert( pObj->fPhase == pObj->fPhase2 );
+ assert( pObj->nGlitches >= pObj->nSwitches );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Simulates one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gli_ManSimulateSeqNode( Gli_Man_t * p, Gli_Obj_t * pNode )
+{
+ unsigned pSimInfos[6], Result = 0;
+ int nFanins = Gli_ObjFaninNum(pNode);
+ int i, k, Phase;
+ Gli_Obj_t * pFanin;
+ assert( nFanins <= 6 );
+ Gli_ObjForEachFanin( pNode, pFanin, i )
+ pSimInfos[i] = pFanin->uSimInfo;
+ for ( i = 0; i < 32; i++ )
+ {
+ Phase = 0;
+ for ( k = 0; k < nFanins; k++ )
+ if ( (pSimInfos[k] >> i) & 1 )
+ Phase |= (1 << k);
+ if ( Aig_InfoHasBit( pNode->uTruth, Phase ) )
+ Result |= (1 << i);
+ }
+ return Result;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Simulates one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline unsigned Gli_ManUpdateRandomInput( unsigned uInfo, float PiTransProb )
+{
+ float Multi = 1.0 / (1 << 16);
+ int i;
+ if ( PiTransProb == 0.5 )
+ return Aig_ManRandom(0);
+ for ( i = 0; i < 32; i++ )
+ if ( Multi * (Aig_ManRandom(0) & 0xffff) < PiTransProb )
+ uInfo ^= 1;
+ return uInfo;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Simulates sequential network randomly for the given number of frames.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gli_ManSimulateSeqOne( Gli_Man_t * p, float PiTransProb )
+{
+ Gli_Obj_t * pObj, * pObjRi, * pObjRo;
+ int i;
+ Gli_ManForEachPi( p, pObj, i )
+ pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, PiTransProb );
+ Gli_ManForEachNode( p, pObj, i )
+ pObj->uSimInfo = Gli_ManSimulateSeqNode( p, pObj );
+ Gli_ManForEachRi( p, pObj, i )
+ pObj->uSimInfo = Gli_ObjFanin(pObj, 0)->uSimInfo;
+ Gli_ManForEachRiRo( p, pObjRi, pObjRo, i )
+ pObjRo->uSimInfo = pObjRi->uSimInfo;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Simulates sequential network randomly for the given number of frames.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gli_ManSaveCiInfo( Gli_Man_t * p )
+{
+ Gli_Obj_t * pObj;
+ int i;
+ if ( p->pSimInfoPrev == NULL )
+ p->pSimInfoPrev = ABC_ALLOC( unsigned, Gli_ManCiNum(p) );
+ Gli_ManForEachCi( p, pObj, i )
+ p->pSimInfoPrev[i] = pObj->uSimInfo;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Simulates sequential network randomly for the given number of frames.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManSimulateSeqPref( Gli_Man_t * p, int nPref )
+{
+ Gli_Obj_t * pObj;
+ int i, f;
+ Gli_ManForEachRo( p, pObj, i )
+ pObj->uSimInfo = 0;
+ for ( f = 0; f < nPref; f++ )
+ Gli_ManSimulateSeqOne( p, 0.5 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes glitching activity of each node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb, int fVerbose )
+{
+ int i, k, clk = clock();
+ Aig_ManRandom( 1 );
+ Gli_ManFinalize( p );
+ if ( p->nRegs == 0 )
+ {
+ for ( i = 0; i < nPatterns; i++ )
+ {
+ Gli_ManSetPiRandom( p, PiTransProb );
+ Gli_ManSwitching( p );
+ Gli_ManGlitching( p );
+// Gli_ManVerify( p );
+ }
+ }
+ else
+ {
+ Gli_ManSimulateSeqPref( p, 16 );
+ for ( k = Aig_BitWordNum(nPatterns) - 1; k >= 0; k-- )
+ {
+ Gli_ManSaveCiInfo( p );
+ Gli_ManSimulateSeqOne( p, PiTransProb );
+ for ( i = 0; i < 32; i++ )
+ {
+ Gli_ManSetPiFromSaved( p, i );
+ Gli_ManSwitching( p );
+ Gli_ManGlitching( p );
+// Gli_ManVerify( p );
+ }
+ }
+ }
+ if ( fVerbose )
+ {
+ printf( "\nSimulated %d patterns. ", nPatterns );
+ ABC_PRM( "Memory", 4*p->nObjData );
+ ABC_PRT( "Time", clock() - clk );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaHash.c b/src/aig/gia/giaHash.c
new file mode 100644
index 00000000..c2bde6ba
--- /dev/null
+++ b/src/aig/gia/giaHash.c
@@ -0,0 +1,541 @@
+/**CFile****************************************************************
+
+ FileName [giaHash.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Structural hashing.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaHash.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Hashing the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManHashOne( int iLit0, int iLit1, int TableSize )
+{
+ unsigned Key = 0;
+ assert( iLit0 < iLit1 );
+ Key ^= Gia_Lit2Var(iLit0) * 7937;
+ Key ^= Gia_Lit2Var(iLit1) * 2971;
+ Key ^= Gia_LitIsCompl(iLit0) * 911;
+ Key ^= Gia_LitIsCompl(iLit1) * 353;
+ return (int)(Key % TableSize);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the place where this node is stored (or should be stored).]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int * Gia_ManHashFind( Gia_Man_t * p, int iLit0, int iLit1 )
+{
+ Gia_Obj_t * pThis;
+ int * pPlace = p->pHTable + Gia_ManHashOne( iLit0, iLit1, p->nHTable );
+ for ( pThis = (*pPlace)? Gia_ManObj(p, Gia_Lit2Var(*pPlace)) : NULL; pThis;
+ pPlace = &pThis->Value, pThis = (*pPlace)? Gia_ManObj(p, Gia_Lit2Var(*pPlace)) : NULL )
+ if ( Gia_ObjFaninLit0p(p, pThis) == iLit0 && Gia_ObjFaninLit1p(p, pThis) == iLit1 )
+ break;
+ return pPlace;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Starts the hash table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManHashAlloc( Gia_Man_t * p )
+{
+ assert( p->pHTable == NULL );
+ p->nHTable = Aig_PrimeCudd( p->nObjsAlloc / 3 );
+ p->pHTable = ABC_CALLOC( int, p->nHTable );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Starts the hash table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManHashStart( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int * pPlace, i;
+ Gia_ManHashAlloc( p );
+ Gia_ManCleanValue( p );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ pPlace = Gia_ManHashFind( p, Gia_ObjFaninLit0(pObj, i), Gia_ObjFaninLit1(pObj, i) );
+ assert( *pPlace == 0 );
+ *pPlace = Gia_Var2Lit( i, 0 );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Stops the hash table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManHashStop( Gia_Man_t * p )
+{
+ ABC_FREE( p->pHTable );
+ p->nHTable = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the hash table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManHashResize( Gia_Man_t * p )
+{
+ Gia_Obj_t * pThis;
+ int * pHTableOld, * pPlace;
+ int nHTableOld, iNext, Counter, Counter2, i;
+ assert( p->pHTable != NULL );
+ // replace the table
+ pHTableOld = p->pHTable;
+ nHTableOld = p->nHTable;
+ p->nHTable = Aig_PrimeCudd( 2 * Gia_ManAndNum(p) );
+ p->pHTable = ABC_CALLOC( int, p->nHTable );
+ // rehash the entries from the old table
+ Counter = 0;
+ for ( i = 0; i < nHTableOld; i++ )
+ for ( pThis = (pHTableOld[i]? Gia_ManObj(p, Gia_Lit2Var(pHTableOld[i])) : NULL),
+ iNext = (pThis? pThis->Value : 0);
+ pThis; pThis = (iNext? Gia_ManObj(p, Gia_Lit2Var(iNext)) : NULL),
+ iNext = (pThis? pThis->Value : 0) )
+ {
+ pThis->Value = 0;
+ pPlace = Gia_ManHashFind( p, Gia_ObjFaninLit0p(p, pThis), Gia_ObjFaninLit1p(p, pThis) );
+ assert( *pPlace == 0 ); // should not be there
+ *pPlace = Gia_Var2Lit( Gia_ObjId(p, pThis), 0 );
+ assert( *pPlace != 0 );
+ Counter++;
+ }
+ Counter2 = Gia_ManAndNum(p);
+ assert( Counter == Counter2 );
+ ABC_FREE( pHTableOld );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Recognizes what nodes are control and data inputs of a MUX.]
+
+ Description [If the node is a MUX, returns the control variable C.
+ Assigns nodes T and E to be the then and else variables of the MUX.
+ Node C is never complemented. Nodes T and E can be complemented.
+ This function also recognizes EXOR/NEXOR gates as MUXes.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Gia_ObjRecognizeMuxTwo( Gia_Obj_t * pNode0, Gia_Obj_t * pNode1, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE )
+{
+ assert( !Gia_IsComplement(pNode0) );
+ assert( !Gia_IsComplement(pNode1) );
+ // find the control variable
+ if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p2) )
+ if ( Gia_ObjFaninC1(pNode0) )
+ { // pNode2->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ return Gia_ObjChild1(pNode1);//pNode2->p2;
+ }
+ else
+ { // pNode1->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ return Gia_ObjChild1(pNode0);//pNode1->p2;
+ }
+ }
+ else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p1) )
+ if ( Gia_ObjFaninC0(pNode0) )
+ { // pNode2->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ return Gia_ObjChild0(pNode1);//pNode2->p1;
+ }
+ else
+ { // pNode1->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ return Gia_ObjChild0(pNode0);//pNode1->p1;
+ }
+ }
+ else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p1) )
+ if ( Gia_ObjFaninC0(pNode0) )
+ { // pNode2->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ return Gia_ObjChild1(pNode1);//pNode2->p2;
+ }
+ else
+ { // pNode1->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ return Gia_ObjChild0(pNode0);//pNode1->p1;
+ }
+ }
+ else if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p2) )
+ if ( Gia_ObjFaninC1(pNode0) )
+ { // pNode2->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ return Gia_ObjChild0(pNode1);//pNode2->p1;
+ }
+ else
+ { // pNode1->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ return Gia_ObjChild1(pNode0);//pNode1->p2;
+ }
+ }
+ assert( 0 ); // this is not MUX
+ return NULL;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Rehashes AIG with mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Gia_ManHashAndP( Gia_Man_t * p, Gia_Obj_t * p0, Gia_Obj_t * p1 )
+{
+ return Gia_ObjFromLit( p, Gia_ManHashAnd( p, Gia_ObjToLit(p, p0), Gia_ObjToLit(p, p1) ) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Rehashes AIG with mapping.]
+
+ Description [http://fmv.jku.at/papers/BrummayerBiere-MEMICS06.pdf]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Gia_ManAddStrash( Gia_Man_t * p, Gia_Obj_t * p0, Gia_Obj_t * p1 )
+{
+ Gia_Obj_t * pNode0, * pNode1, * pFanA, * pFanB, * pFanC, * pFanD;
+ assert( p->fAddStrash );
+ if ( !Gia_ObjIsAnd(Gia_Regular(p0)) && !Gia_ObjIsAnd(Gia_Regular(p1)) )
+ return NULL;
+ pNode0 = Gia_Regular(p0);
+ pNode1 = Gia_Regular(p1);
+ pFanA = Gia_ObjChild0(pNode0);
+ pFanB = Gia_ObjChild1(pNode0);
+ pFanC = Gia_ObjChild0(pNode1);
+ pFanD = Gia_ObjChild1(pNode1);
+ if ( Gia_IsComplement(p0) )
+ {
+ if ( pFanA == Gia_Not(p1) || pFanB == Gia_Not(p1) )
+ return p1;
+ if ( pFanB == p1 )
+ return Gia_ManHashAndP( p, Gia_Not(pFanA), pFanB );
+ if ( pFanA == p1 )
+ return Gia_ManHashAndP( p, Gia_Not(pFanB), pFanA );
+ }
+ else
+ {
+ if ( pFanA == Gia_Not(p1) || pFanB == Gia_Not(p1) )
+ return Gia_ManConst0(p);
+ if ( pFanA == p1 || pFanB == p1 )
+ return p0;
+ }
+ if ( Gia_IsComplement(p1) )
+ {
+ if ( pFanC == Gia_Not(p0) || pFanD == Gia_Not(p0) )
+ return p0;
+ if ( pFanD == p0 )
+ return Gia_ManHashAndP( p, Gia_Not(pFanC), pFanD );
+ if ( pFanC == p0 )
+ return Gia_ManHashAndP( p, Gia_Not(pFanD), pFanC );
+ }
+ else
+ {
+ if ( pFanC == Gia_Not(p0) || pFanD == Gia_Not(p0) )
+ return Gia_ManConst0(p);
+ if ( pFanC == p0 || pFanD == p0 )
+ return p1;
+ }
+ if ( !Gia_IsComplement(p0) && !Gia_IsComplement(p1) )
+ {
+ if ( pFanA == Gia_Not(pFanC) || pFanA == Gia_Not(pFanD) || pFanB == Gia_Not(pFanC) || pFanB == Gia_Not(pFanD) )
+ return Gia_ManConst0(p);
+ if ( pFanA == pFanC || pFanB == pFanC )
+ return Gia_ManHashAndP( p, p0, pFanD );
+ if ( pFanB == pFanC || pFanB == pFanD )
+ return Gia_ManHashAndP( p, pFanA, p1 );
+ if ( pFanA == pFanD || pFanB == pFanD )
+ return Gia_ManHashAndP( p, p0, pFanC );
+ if ( pFanA == pFanC || pFanA == pFanD )
+ return Gia_ManHashAndP( p, pFanB, p1 );
+ }
+ else if ( Gia_IsComplement(p0) && !Gia_IsComplement(p1) )
+ {
+ if ( pFanA == Gia_Not(pFanC) || pFanA == Gia_Not(pFanD) || pFanB == Gia_Not(pFanC) || pFanB == Gia_Not(pFanD) )
+ return p1;
+ if ( pFanB == pFanC || pFanB == pFanD )
+ return Gia_ManHashAndP( p, Gia_Not(pFanA), p1 );
+ if ( pFanA == pFanC || pFanA == pFanD )
+ return Gia_ManHashAndP( p, Gia_Not(pFanB), p1 );
+ }
+ else if ( !Gia_IsComplement(p0) && Gia_IsComplement(p1) )
+ {
+ if ( pFanC == Gia_Not(pFanA) || pFanC == Gia_Not(pFanB) || pFanD == Gia_Not(pFanA) || pFanD == Gia_Not(pFanB) )
+ return p0;
+ if ( pFanD == pFanA || pFanD == pFanB )
+ return Gia_ManHashAndP( p, Gia_Not(pFanC), p0 );
+ if ( pFanC == pFanA || pFanC == pFanB )
+ return Gia_ManHashAndP( p, Gia_Not(pFanD), p0 );
+ }
+ else // if ( Gia_IsComplement(p0) && Gia_IsComplement(p1) )
+ {
+ if ( pFanA == pFanD && pFanB == Gia_Not(pFanC) )
+ return Gia_Not(pFanA);
+ if ( pFanB == pFanC && pFanA == Gia_Not(pFanD) )
+ return Gia_Not(pFanB);
+ if ( pFanA == pFanC && pFanB == Gia_Not(pFanD) )
+ return Gia_Not(pFanA);
+ if ( pFanB == pFanD && pFanA == Gia_Not(pFanC) )
+ return Gia_Not(pFanB);
+ }
+ if ( !Gia_IsComplement(p0) || !Gia_IsComplement(p1) )
+ return NULL;
+ if ( !Gia_ObjIsAnd(pNode0) || !Gia_ObjIsAnd(pNode1) )
+ return NULL;
+ if ( (Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1))) ||
+ (Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1))) ||
+ (Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1))) ||
+ (Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1))) )
+ {
+ Gia_Obj_t * pNodeC, * pNodeT, * pNodeE;
+ int fCompl;
+ pNodeC = Gia_ObjRecognizeMuxTwo( pNode0, pNode1, &pNodeT, &pNodeE );
+ // using non-standard canonical rule for MUX (d0 is not compl; d1 may be compl)
+ if ( (fCompl = Gia_IsComplement(pNodeE)) )
+ {
+ pNodeE = Gia_Not(pNodeE);
+ pNodeT = Gia_Not(pNodeT);
+ }
+ pNode0 = Gia_ManHashAndP( p, Gia_Not(pNodeC), pNodeE );
+ pNode1 = Gia_ManHashAndP( p, pNodeC, pNodeT );
+ return Gia_NotCond( Gia_ManHashAndP( p, pNode0, pNode1 ), !fCompl );
+ }
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Rehashes AIG with mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 )
+{
+ if ( iLit0 < 2 )
+ return iLit0 ? iLit1 : 0;
+ if ( iLit1 < 2 )
+ return iLit1 ? iLit0 : 0;
+ if ( iLit0 == iLit1 )
+ return iLit1;
+ if ( iLit0 == Gia_LitNot(iLit1) )
+ return 0;
+ if ( (p->nObjs & 0xFF) == 0 && 2 * p->nHTable < Gia_ManAndNum(p) )
+ Gia_ManHashResize( p );
+ if ( p->fAddStrash )
+ {
+ Gia_Obj_t * pObj = Gia_ManAddStrash( p, Gia_ObjFromLit(p, iLit0), Gia_ObjFromLit(p, iLit1) );
+ if ( pObj != NULL )
+ return Gia_ObjToLit( p, pObj );
+ }
+ if ( iLit0 > iLit1 )
+ iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
+ {
+ int * pPlace = Gia_ManHashFind( p, iLit0, iLit1 );
+ if ( *pPlace )
+ return *pPlace;
+ if ( p->nObjs < p->nObjsAlloc )
+ return *pPlace = Gia_ManAppendAnd( p, iLit0, iLit1 );
+ else
+ {
+ int iNode = Gia_ManAppendAnd( p, iLit0, iLit1 );
+ pPlace = Gia_ManHashFind( p, iLit0, iLit1 );
+ assert( *pPlace == 0 );
+ return *pPlace = iNode;
+ }
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Rehashes AIG with mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 )
+{
+ if ( iLit0 < 2 )
+ return iLit0 ? iLit1 : 0;
+ if ( iLit1 < 2 )
+ return iLit1 ? iLit0 : 0;
+ if ( iLit0 == iLit1 )
+ return iLit1;
+ if ( iLit0 == Gia_LitNot(iLit1) )
+ return 0;
+ if ( iLit0 > iLit1 )
+ iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
+ {
+ int * pPlace = Gia_ManHashFind( p, iLit0, iLit1 );
+ if ( *pPlace )
+ return *pPlace;
+ return -1;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Rehashes AIG with mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 )
+{
+ int fCompl = Gia_LitIsCompl(iLit0) ^ Gia_LitIsCompl(iLit1);
+ int iTemp0 = Gia_ManHashAnd( p, Gia_LitRegular(iLit0), Gia_LitNot(Gia_LitRegular(iLit1)) );
+ int iTemp1 = Gia_ManHashAnd( p, Gia_LitRegular(iLit1), Gia_LitNot(Gia_LitRegular(iLit0)) );
+ return Gia_LitNotCond( Gia_ManHashAnd( p, Gia_LitNot(iTemp0), Gia_LitNot(iTemp1) ), !fCompl );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Rehashes AIG with mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManRehash( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Gia_ManHashAlloc( pNew );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ else if ( Gia_ObjIsCi(pObj) )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ }
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+// printf( "Top gate is %s\n", Gia_ObjFaninC0(Gia_ManCo(pNew, 0))? "OR" : "AND" );
+ return pNew;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaLogic.c b/src/aig/gia/giaLogic.c
new file mode 100644
index 00000000..825cec02
--- /dev/null
+++ b/src/aig/gia/giaLogic.c
@@ -0,0 +1,725 @@
+/**CFile****************************************************************
+
+ FileName [giaLogic.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Logic network derived from AIG.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaLogic.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <math.h>
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Log_Obj_t_ Log_Obj_t;
+struct Log_Obj_t_
+{
+ unsigned fTerm : 1; // terminal node (CI/CO)
+ unsigned fMark0 : 1; // first user-controlled mark
+ unsigned fMark1 : 1; // second user-controlled mark
+ unsigned nFanins : 28; // the number of fanins
+ unsigned nFanouts; // the number of fanouts
+ unsigned hHandle; // the handle of the node
+ union {
+ unsigned TravId; // user-specified value
+ unsigned iFanin;
+ };
+ union {
+ unsigned Value; // user-specified value
+ unsigned iFanout;
+ };
+ int Fanios[0]; // the array of fanins/fanouts
+};
+
+typedef struct Log_Man_t_ Log_Man_t;
+struct Log_Man_t_
+{
+ Gia_Man_t * pGia; // the original AIG manager
+ Vec_Int_t * vCis; // the vector of CIs (PIs + LOs)
+ Vec_Int_t * vCos; // the vector of COs (POs + LIs)
+ int nObjs; // the number of objects
+ int nNodes; // the number of nodes
+ int nTravIds; // traversal ID of the network
+ int * pObjData; // the array containing data for objects
+ int nObjData; // the size of array to store the logic network
+};
+
+static inline int Log_ManCiNum( Log_Man_t * p ) { return Vec_IntSize(p->vCis); }
+static inline int Log_ManCoNum( Log_Man_t * p ) { return Vec_IntSize(p->vCos); }
+static inline int Log_ManObjNum( Log_Man_t * p ) { return p->nObjs; }
+static inline int Log_ManNodeNum( Log_Man_t * p ) { return p->nNodes; }
+
+static inline Log_Obj_t * Log_ManObj( Log_Man_t * p, unsigned hHandle ) { return (Log_Obj_t *)(p->pObjData + hHandle); }
+static inline Log_Obj_t * Log_ManCi( Log_Man_t * p, int i ) { return Log_ManObj( p, Vec_IntEntry(p->vCis,i) ); }
+static inline Log_Obj_t * Log_ManCo( Log_Man_t * p, int i ) { return Log_ManObj( p, Vec_IntEntry(p->vCos,i) ); }
+
+static inline int Log_ObjIsTerm( Log_Obj_t * pObj ) { return pObj->fTerm; }
+static inline int Log_ObjIsCi( Log_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 0; }
+static inline int Log_ObjIsCo( Log_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 1; }
+static inline int Log_ObjIsNode( Log_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins > 0; }
+static inline int Log_ObjIsConst0( Log_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins == 0; }
+
+static inline int Log_ObjFaninNum( Log_Obj_t * pObj ) { return pObj->nFanins; }
+static inline int Log_ObjFanoutNum( Log_Obj_t * pObj ) { return pObj->nFanouts; }
+static inline int Log_ObjSize( Log_Obj_t * pObj ) { return sizeof(Log_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; }
+static inline Log_Obj_t * Log_ObjFanin( Log_Obj_t * pObj, int i ) { return (Log_Obj_t *)(((int *)pObj) - pObj->Fanios[i]); }
+static inline Log_Obj_t * Log_ObjFanout( Log_Obj_t * pObj, int i ) { return (Log_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i]); }
+
+static inline void Log_ManResetTravId( Log_Man_t * p ) { extern void Log_ManCleanTravId( Log_Man_t * p ); Log_ManCleanTravId( p ); p->nTravIds = 1; }
+static inline void Log_ManIncrementTravId( Log_Man_t * p ) { p->nTravIds++; }
+static inline void Log_ObjSetTravId( Log_Obj_t * pObj, int TravId ) { pObj->TravId = TravId; }
+static inline void Log_ObjSetTravIdCurrent( Log_Man_t * p, Log_Obj_t * pObj ) { pObj->TravId = p->nTravIds; }
+static inline void Log_ObjSetTravIdPrevious( Log_Man_t * p, Log_Obj_t * pObj ) { pObj->TravId = p->nTravIds - 1; }
+static inline int Log_ObjIsTravIdCurrent( Log_Man_t * p, Log_Obj_t * pObj ) { return ((int)pObj->TravId == p->nTravIds); }
+static inline int Log_ObjIsTravIdPrevious( Log_Man_t * p, Log_Obj_t * pObj ) { return ((int)pObj->TravId == p->nTravIds - 1); }
+
+#define Log_ManForEachObj( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjData) && (pObj = Log_ManObj(p,i)); i += Log_ObjSize(pObj) )
+#define Log_ManForEachNode( p, pObj, i ) \
+ for ( i = 0; (i < p->nObjData) && (pObj = Log_ManObj(p,i)); i += Log_ObjSize(pObj) ) if ( Log_ObjIsTerm(pObj) ) {} else
+#define Log_ManForEachObjVec( vVec, p, pObj, i ) \
+ for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Log_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
+#define Log_ObjForEachFanin( pObj, pNext, i ) \
+ for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Log_ObjFanin(pObj,i)); i++ )
+#define Log_ObjForEachFanout( pObj, pNext, i ) \
+ for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Log_ObjFanout(pObj,i)); i++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Collect the fanin IDs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManCollectSuper( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSuper )
+{
+ if ( pObj->fMark0 )
+ {
+ Vec_IntPushUnique( vSuper, Gia_ObjId(p, pObj) );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Log_ManCollectSuper( p, Gia_ObjFanin0(pObj), vSuper );
+ Log_ManCollectSuper( p, Gia_ObjFanin1(pObj), vSuper );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Assigns references while removing the MUX/XOR ones.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManCreateRefsSpecial( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pFan0, * pFan1;
+ Gia_Obj_t * pObjC, * pObjD0, * pObjD1;
+ int i;
+ assert( p->pRefs == NULL );
+ Gia_ManCleanMark0( p );
+ Gia_ManCreateRefs( p );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ assert( pObj->fMark0 == 0 );
+ pFan0 = Gia_ObjFanin0(pObj);
+ pFan1 = Gia_ObjFanin1(pObj);
+ // skip nodes whose fanins are PIs or are already marked
+ if ( Gia_ObjIsCi(pFan0) || pFan0->fMark0 ||
+ Gia_ObjIsCi(pFan1) || pFan1->fMark0 )
+ continue;
+ // skip nodes that are not MUX type
+ if ( !Gia_ObjIsMuxType(pObj) )
+ continue;
+ // the node is MUX type, mark it and its fanins
+ pObj->fMark0 = 1;
+ pFan0->fMark0 = 1;
+ pFan1->fMark0 = 1;
+ // deref the control
+ pObjC = Gia_ObjRecognizeMux( pObj, &pObjD1, &pObjD0 );
+ Gia_ObjRefDec( p, Gia_Regular(pObjC) );
+ if ( Gia_Regular(pObjD0) == Gia_Regular(pObjD1) )
+ Gia_ObjRefDec( p, Gia_Regular(pObjD0) );
+ }
+ Gia_ManForEachAnd( p, pObj, i )
+ assert( Gia_ObjRefs(p, pObj) > 0 );
+ Gia_ManCleanMark0( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Assigns references while removing the MUX/XOR ones.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManTransformRefs( Gia_Man_t * p, int * pnObjs, int * pnFanios )
+{
+ Vec_Int_t * vSuper;
+ Gia_Obj_t * pObj, * pFanin;
+ int i, k, Counter;
+ assert( p->pRefs != NULL );
+
+ // mark nodes to be used in the logic network
+ Gia_ManCleanMark0( p );
+ Gia_ManConst0(p)->fMark0 = 1;
+ // mark the inputs
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->fMark0 = 1;
+ // mark those nodes that have ref count more than 1
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->fMark0 = (Gia_ObjRefs(p, pObj) > 1);
+ // mark the output drivers
+ Gia_ManForEachCoDriver( p, pObj, i )
+ pObj->fMark0 = 1;
+
+ // count the number of nodes
+ Counter = 0;
+ Gia_ManForEachObj( p, pObj, i )
+ Counter += pObj->fMark0;
+ *pnObjs = Counter + Gia_ManCoNum(p);
+
+ // reset the references
+ ABC_FREE( p->pRefs );
+ p->pRefs = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ // reference from internal nodes
+ Counter = 0;
+ vSuper = Vec_IntAlloc( 100 );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ if ( pObj->fMark0 == 0 )
+ continue;
+ Vec_IntClear( vSuper );
+ pObj->fMark0 = 0;
+ Log_ManCollectSuper( p, pObj, vSuper );
+ pObj->fMark0 = 1;
+ Gia_ManForEachObjVec( vSuper, p, pFanin, k )
+ {
+ assert( pFanin->fMark0 );
+ Gia_ObjRefInc( p, pFanin );
+ }
+ Counter += Vec_IntSize( vSuper );
+ }
+ Vec_IntFree( vSuper );
+ // reference from outputs
+ Gia_ManForEachCoDriver( p, pObj, i )
+ {
+ assert( pObj->fMark0 );
+ Gia_ObjRefInc( p, pObj );
+ }
+ *pnFanios = Counter + Gia_ManCoNum(p);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates fanin/fanout pair.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ObjAddFanin( Log_Obj_t * pObj, Log_Obj_t * pFanin )
+{
+ assert( pObj->iFanin < pObj->nFanins );
+ assert( pFanin->iFanout < pFanin->nFanouts );
+ pFanin->Fanios[pFanin->nFanins + pFanin->iFanout++] =
+ pObj->Fanios[pObj->iFanin++] = pObj->hHandle - pFanin->hHandle;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates logic network isomorphic to the given AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Log_Man_t * Log_ManStart( Gia_Man_t * pGia )
+{
+ Log_Man_t * p;
+ Log_Obj_t * pObjLog, * pFanLog;
+ Gia_Obj_t * pObj, * pFanin;
+ Vec_Int_t * vSuper;
+ int nObjs, nFanios;
+ int i, k, hHandle = 0;
+ // prepare the AIG
+// Gia_ManCreateRefs( pGia );
+ Log_ManCreateRefsSpecial( pGia );
+ Log_ManTransformRefs( pGia, &nObjs, &nFanios );
+ Gia_ManFillValue( pGia );
+ // create logic network
+ p = ABC_CALLOC( Log_Man_t, 1 );
+ p->pGia = pGia;
+ p->vCis = Vec_IntAlloc( Gia_ManCiNum(pGia) );
+ p->vCos = Vec_IntAlloc( Gia_ManCoNum(pGia) );
+ p->nObjData = (sizeof(Log_Obj_t) / 4) * nObjs + 2 * nFanios;
+ p->pObjData = ABC_CALLOC( int, p->nObjData );
+ // create constant node
+ Gia_ManConst0(pGia)->Value = hHandle;
+ pObjLog = Log_ManObj( p, hHandle );
+ pObjLog->hHandle = hHandle;
+ pObjLog->nFanins = 0;
+ pObjLog->nFanouts = Gia_ObjRefs( pGia, Gia_ManConst0(pGia) );
+ // count objects
+ hHandle += Log_ObjSize( pObjLog );
+ p->nNodes++;
+ p->nObjs++;
+ // create the PIs
+ Gia_ManForEachCi( pGia, pObj, i )
+ {
+ // create PI object
+ pObj->Value = hHandle;
+ Vec_IntPush( p->vCis, hHandle );
+ pObjLog = Log_ManObj( p, hHandle );
+ pObjLog->hHandle = hHandle;
+ pObjLog->nFanins = 0;
+ pObjLog->nFanouts = Gia_ObjRefs( pGia, pObj );
+ pObjLog->fTerm = 1;
+ // count objects
+ hHandle += Log_ObjSize( pObjLog );
+ p->nObjs++;
+ }
+ // create internal nodes
+ vSuper = Vec_IntAlloc( 100 );
+ Gia_ManForEachAnd( pGia, pObj, i )
+ {
+ if ( pObj->fMark0 == 0 )
+ {
+ assert( Gia_ObjRefs( pGia, pObj ) == 0 );
+ continue;
+ }
+ assert( Gia_ObjRefs( pGia, pObj ) > 0 );
+ // collect fanins
+ Vec_IntClear( vSuper );
+ pObj->fMark0 = 0;
+ Log_ManCollectSuper( pGia, pObj, vSuper );
+ pObj->fMark0 = 1;
+ // create node object
+ pObj->Value = hHandle;
+ pObjLog = Log_ManObj( p, hHandle );
+ pObjLog->hHandle = hHandle;
+ pObjLog->nFanins = Vec_IntSize( vSuper );
+ pObjLog->nFanouts = Gia_ObjRefs( pGia, pObj );
+ // add fanins
+ Gia_ManForEachObjVec( vSuper, pGia, pFanin, k )
+ {
+ pFanLog = Log_ManObj( p, Gia_ObjValue(pFanin) );
+ Log_ObjAddFanin( pObjLog, pFanLog );
+ }
+ // count objects
+ hHandle += Log_ObjSize( pObjLog );
+ p->nNodes++;
+ p->nObjs++;
+ }
+ Vec_IntFree( vSuper );
+ // create the POs
+ Gia_ManForEachCo( pGia, pObj, i )
+ {
+ // create PO object
+ pObj->Value = hHandle;
+ Vec_IntPush( p->vCos, hHandle );
+ pObjLog = Log_ManObj( p, hHandle );
+ pObjLog->hHandle = hHandle;
+ pObjLog->nFanins = 1;
+ pObjLog->nFanouts = 0;
+ pObjLog->fTerm = 1;
+ // add fanins
+ pFanLog = Log_ManObj( p, Gia_ObjValue(Gia_ObjFanin0(pObj)) );
+ Log_ObjAddFanin( pObjLog, pFanLog );
+ // count objects
+ hHandle += Log_ObjSize( pObjLog );
+ p->nObjs++;
+ }
+ Gia_ManCleanMark0( pGia );
+ assert( nObjs == p->nObjs );
+ assert( hHandle == p->nObjData );
+ // make sure the fanin/fanout counters are correct
+ Gia_ManForEachObj( pGia, pObj, i )
+ {
+ if ( !~Gia_ObjValue(pObj) )
+ continue;
+ pObjLog = Log_ManObj( p, Gia_ObjValue(pObj) );
+ assert( pObjLog->nFanins == pObjLog->iFanin );
+ assert( pObjLog->nFanouts == pObjLog->iFanout );
+ pObjLog->iFanin = pObjLog->iFanout = 0;
+ }
+ ABC_FREE( pGia->pRefs );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates logic network isomorphic to the given AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManPrintStats( Log_Man_t * p )
+{
+// if ( p->pName )
+// printf( "%8s : ", p->pName );
+ printf( "i/o =%7d/%7d ", Log_ManCiNum(p), Log_ManCoNum(p) );
+// if ( Log_ManRegNum(p) )
+// printf( "ff =%7d ", Log_ManRegNum(p) );
+ printf( "node =%8d ", Log_ManNodeNum(p) );
+// printf( "lev =%5d ", Log_ManLevelNum(p) );
+// printf( "cut =%5d ", Log_ManCrossCut(p) );
+ printf( "mem =%5.2f Mb", 4.0*p->nObjData/(1<<20) );
+// printf( "obj =%5d ", Log_ManObjNum(p) );
+ printf( "\n" );
+
+// Log_ManSatExperiment( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates logic network isomorphic to the given AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManStop( Log_Man_t * p )
+{
+ Vec_IntFree( p->vCis );
+ Vec_IntFree( p->vCos );
+ ABC_FREE( p->pObjData );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Cleans the value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManCleanTravId( Log_Man_t * p )
+{
+ Log_Obj_t * pObj;
+ int i;
+ Log_ManForEachObj( p, pObj, i )
+ pObj->TravId = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Cleans the value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManCleanValue( Log_Man_t * p )
+{
+ Log_Obj_t * pObj;
+ int i;
+ Log_ManForEachObj( p, pObj, i )
+ pObj->Value = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the distribution of fanins/fanouts in the network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Log_ManPrintFanio( Log_Man_t * p )
+{
+ char Buffer[100];
+ Log_Obj_t * pNode;
+ Vec_Int_t * vFanins, * vFanouts;
+ int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll;
+ int i, k, nSizeMax;
+
+ // determine the largest fanin and fanout
+ nFaninsMax = nFanoutsMax = 0;
+ nFaninsAll = nFanoutsAll = 0;
+ Log_ManForEachNode( p, pNode, i )
+ {
+ if ( i == 0 ) continue; // skip const 0 obj
+ nFanins = Log_ObjFaninNum(pNode);
+ nFanouts = Log_ObjFanoutNum(pNode);
+ nFaninsAll += nFanins;
+ nFanoutsAll += nFanouts;
+ nFaninsMax = ABC_MAX( nFaninsMax, nFanins );
+ nFanoutsMax = ABC_MAX( nFanoutsMax, nFanouts );
+ }
+
+ // allocate storage for fanin/fanout numbers
+ nSizeMax = AIG_MAX( 10 * (Aig_Base10Log(nFaninsMax) + 1), 10 * (Aig_Base10Log(nFanoutsMax) + 1) );
+ vFanins = Vec_IntStart( nSizeMax );
+ vFanouts = Vec_IntStart( nSizeMax );
+
+ // count the number of fanins and fanouts
+ Log_ManForEachNode( p, pNode, i )
+ {
+ if ( i == 0 ) continue; // skip const 0 obj
+ nFanins = Log_ObjFaninNum(pNode);
+ nFanouts = Log_ObjFanoutNum(pNode);
+
+ if ( nFanins < 10 )
+ Vec_IntAddToEntry( vFanins, nFanins, 1 );
+ else if ( nFanins < 100 )
+ Vec_IntAddToEntry( vFanins, 10 + nFanins/10, 1 );
+ else if ( nFanins < 1000 )
+ Vec_IntAddToEntry( vFanins, 20 + nFanins/100, 1 );
+ else if ( nFanins < 10000 )
+ Vec_IntAddToEntry( vFanins, 30 + nFanins/1000, 1 );
+ else if ( nFanins < 100000 )
+ Vec_IntAddToEntry( vFanins, 40 + nFanins/10000, 1 );
+ else if ( nFanins < 1000000 )
+ Vec_IntAddToEntry( vFanins, 50 + nFanins/100000, 1 );
+ else if ( nFanins < 10000000 )
+ Vec_IntAddToEntry( vFanins, 60 + nFanins/1000000, 1 );
+
+ if ( nFanouts < 10 )
+ Vec_IntAddToEntry( vFanouts, nFanouts, 1 );
+ else if ( nFanouts < 100 )
+ Vec_IntAddToEntry( vFanouts, 10 + nFanouts/10, 1 );
+ else if ( nFanouts < 1000 )
+ Vec_IntAddToEntry( vFanouts, 20 + nFanouts/100, 1 );
+ else if ( nFanouts < 10000 )
+ Vec_IntAddToEntry( vFanouts, 30 + nFanouts/1000, 1 );
+ else if ( nFanouts < 100000 )
+ Vec_IntAddToEntry( vFanouts, 40 + nFanouts/10000, 1 );
+ else if ( nFanouts < 1000000 )
+ Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 );
+ else if ( nFanouts < 10000000 )
+ Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 );
+ }
+
+ printf( "The distribution of fanins and fanouts in the network:\n" );
+ printf( " Number Nodes with fanin Nodes with fanout\n" );
+ for ( k = 0; k < nSizeMax; k++ )
+ {
+ if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
+ continue;
+ if ( k < 10 )
+ printf( "%15d : ", k );
+ else
+ {
+ sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
+ printf( "%15s : ", Buffer );
+ }
+ if ( vFanins->pArray[k] == 0 )
+ printf( " " );
+ else
+ printf( "%12d ", vFanins->pArray[k] );
+ printf( " " );
+ if ( vFanouts->pArray[k] == 0 )
+ printf( " " );
+ else
+ printf( "%12d ", vFanouts->pArray[k] );
+ printf( "\n" );
+ }
+ Vec_IntFree( vFanins );
+ Vec_IntFree( vFanouts );
+
+ printf( "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n",
+ nFaninsMax, 1.0*nFaninsAll/Log_ManNodeNum(p),
+ nFanoutsMax, 1.0*nFanoutsAll/Log_ManNodeNum(p) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the distance from the given object]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Log_ManComputeDistance( Log_Man_t * p, Log_Obj_t * pPivot )
+{
+ Vec_Int_t * vThis, * vNext, * vTemp;
+ Log_Obj_t * pThis, * pNext;
+ int i, k, d, nVisited = 0;
+// assert( Log_ObjIsTerm(pPivot) );
+ vThis = Vec_IntAlloc( 1000 );
+ vNext = Vec_IntAlloc( 1000 );
+ Log_ManIncrementTravId( p );
+ Log_ObjSetTravIdCurrent( p, pPivot );
+ Vec_IntPush( vThis, pPivot->hHandle );
+ for ( d = 0; Vec_IntSize(vThis) > 0; d++ )
+ {
+ nVisited += Vec_IntSize(vThis);
+ Vec_IntClear( vNext );
+ Log_ManForEachObjVec( vThis, p, pThis, i )
+ {
+ Log_ObjForEachFanin( pThis, pNext, k )
+ {
+ if ( Log_ObjIsTravIdCurrent(p, pNext) )
+ continue;
+ Log_ObjSetTravIdCurrent(p, pNext);
+ Vec_IntPush( vNext, pNext->hHandle );
+ nVisited += !Log_ObjIsTerm(pNext);
+ }
+ Log_ObjForEachFanout( pThis, pNext, k )
+ {
+ if ( Log_ObjIsTravIdCurrent(p, pNext) )
+ continue;
+ Log_ObjSetTravIdCurrent(p, pNext);
+ Vec_IntPush( vNext, pNext->hHandle );
+ nVisited += !Log_ObjIsTerm(pNext);
+ }
+ }
+ vTemp = vThis; vThis = vNext; vNext = vTemp;
+ }
+ Vec_IntFree( vThis );
+ Vec_IntFree( vNext );
+ // check if there are several strongly connected components
+// if ( nVisited < Log_ManNodeNum(p) )
+// printf( "Visited less nodes (%d) than present (%d).\n", nVisited, Log_ManNodeNum(p) );
+ return d;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Traverses from the given node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTestDistanceInternal( Log_Man_t * p )
+{
+ int nAttempts = 20;
+ int i, iNode, Dist, clk;
+ Log_Obj_t * pPivot, * pNext;
+ Aig_ManRandom( 1 );
+ Log_ManResetTravId( p );
+ // compute distances from several randomly selected PIs
+ clk = clock();
+ printf( "From inputs: " );
+ for ( i = 0; i < nAttempts; i++ )
+ {
+ iNode = Aig_ManRandom( 0 ) % Log_ManCiNum(p);
+ pPivot = Log_ManCi( p, iNode );
+ if ( Log_ObjFanoutNum(pPivot) == 0 )
+ { i--; continue; }
+ pNext = Log_ObjFanout( pPivot, 0 );
+ if ( !Log_ObjIsNode(pNext) )
+ { i--; continue; }
+ Dist = Log_ManComputeDistance( p, pPivot );
+ printf( "%d ", Dist );
+ }
+ ABC_PRT( "Time", clock() - clk );
+ // compute distances from several randomly selected POs
+ clk = clock();
+ printf( "From outputs: " );
+ for ( i = 0; i < nAttempts; i++ )
+ {
+ iNode = Aig_ManRandom( 0 ) % Log_ManCoNum(p);
+ pPivot = Log_ManCo( p, iNode );
+ pNext = Log_ObjFanin( pPivot, 0 );
+ if ( !Log_ObjIsNode(pNext) )
+ { i--; continue; }
+ Dist = Log_ManComputeDistance( p, pPivot );
+ printf( "%d ", Dist );
+ }
+ ABC_PRT( "Time", clock() - clk );
+ // compute distances from several randomly selected nodes
+ clk = clock();
+ printf( "From nodes: " );
+ for ( i = 0; i < nAttempts; i++ )
+ {
+ iNode = Aig_ManRandom( 0 ) % Gia_ManObjNum(p->pGia);
+ if ( !~Gia_ManObj(p->pGia, iNode)->Value )
+ { i--; continue; }
+ pPivot = Log_ManObj( p, Gia_ManObj(p->pGia, iNode)->Value );
+ if ( !Log_ObjIsNode(pPivot) )
+ { i--; continue; }
+ Dist = Log_ManComputeDistance( p, pPivot );
+ printf( "%d ", Dist );
+ }
+ ABC_PRT( "Time", clock() - clk );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns sorted array of node handles with largest fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTestDistance( Gia_Man_t * pGia )
+{
+ Log_Man_t * p;
+ int clk = clock();
+ p = Log_ManStart( pGia );
+// Log_ManPrintFanio( p );
+ Log_ManPrintStats( p );
+ABC_PRT( "Time", clock() - clk );
+ Gia_ManTestDistanceInternal( p );
+ Log_ManStop( p );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c
new file mode 100644
index 00000000..e6e45cb5
--- /dev/null
+++ b/src/aig/gia/giaMan.c
@@ -0,0 +1,203 @@
+/**CFile****************************************************************
+
+ FileName [giaMan.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Package manager.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManStart( int nObjsMax )
+{
+ Gia_Man_t * p;
+ assert( nObjsMax > 0 );
+ p = ABC_CALLOC( Gia_Man_t, 1 );
+ p->nObjsAlloc = nObjsMax;
+ p->pObjs = ABC_CALLOC( Gia_Obj_t, nObjsMax );
+ p->pObjs->iDiff0 = p->pObjs->iDiff1 = GIA_NONE;
+ p->nObjs = 1;
+ p->vCis = Vec_IntAlloc( nObjsMax / 10 );
+ p->vCos = Vec_IntAlloc( nObjsMax / 10 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManStop( Gia_Man_t * p )
+{
+ Vec_IntFree( p->vCis );
+ Vec_IntFree( p->vCos );
+ ABC_FREE( p->pFanData );
+ ABC_FREE( p->pReprs );
+ ABC_FREE( p->pName );
+ ABC_FREE( p->pRefs );
+ ABC_FREE( p->pLevels );
+ ABC_FREE( p->pHTable );
+ ABC_FREE( p->pObjs );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints stats for the AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPrintStats( Gia_Man_t * p )
+{
+ if ( p->pName )
+ printf( "%8s : ", p->pName );
+ printf( "i/o =%7d/%7d ", Gia_ManPiNum(p), Gia_ManPoNum(p) );
+ if ( Gia_ManRegNum(p) )
+ printf( "ff =%7d ", Gia_ManRegNum(p) );
+ printf( "and =%8d ", Gia_ManAndNum(p) );
+ printf( "lev =%5d ", Gia_ManLevelNum(p) );
+// printf( "cut =%5d ", Gia_ManCrossCut(p) );
+ printf( "mem =%5.2f Mb", 12.0*Gia_ManObjNum(p)/(1<<20) );
+// printf( "obj =%5d ", Gia_ManObjNum(p) );
+ printf( "\n" );
+
+// Gia_ManSatExperiment( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints stats for the AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPrintStatsShort( Gia_Man_t * p )
+{
+ printf( "i/o =%7d/%7d ", Gia_ManPiNum(p), Gia_ManPoNum(p) );
+// printf( "ff =%7d ", Gia_ManRegNum(p) );
+ printf( "and =%8d ", Gia_ManAndNum(p) );
+ printf( "lev =%5d ", Gia_ManLevelNum(p) );
+ printf( "mem =%5.2f Mb", 12.0*Gia_ManObjNum(p)/(1<<20) );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints stats for the AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPrintMiterStatus( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pChild;
+ int i, nSat = 0, nUnsat = 0, nUndec = 0, iOut = -1;
+ Gia_ManForEachPo( p, pObj, i )
+ {
+ pChild = Gia_ObjChild0(pObj);
+ // check if the output is constant 0
+ if ( pChild == Gia_ManConst0(p) )
+ nUnsat++;
+ // check if the output is constant 1
+ else if ( pChild == Gia_ManConst1(p) )
+ {
+ nSat++;
+ if ( iOut == -1 )
+ iOut = i;
+ }
+ // check if the output is a primary input
+ else if ( Gia_ObjIsPi(p, Gia_Regular(pChild)) )
+ {
+ nSat++;
+ if ( iOut == -1 )
+ iOut = i;
+ }
+/*
+ // check if the output is 1 for the 0000 pattern
+ else if ( Gia_Regular(pChild)->fPhase != (unsigned)Gia_IsComplement(pChild) )
+ {
+ nSat++;
+ if ( iOut == -1 )
+ iOut = i;
+ }
+*/
+ else
+ nUndec++;
+ }
+ printf( "Outputs = %7d. Unsat = %7d. Sat = %7d. Undec = %7d.\n",
+ Gia_ManPoNum(p), nUnsat, nSat, nUndec );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints stats for the AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs )
+{
+ assert( p->nRegs == 0 );
+ p->nRegs = nRegs;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaProp.c b/src/aig/gia/giaProp.c
new file mode 100644
index 00000000..1d9ed8cf
--- /dev/null
+++ b/src/aig/gia/giaProp.c
@@ -0,0 +1,171 @@
+/**CFile****************************************************************
+
+ FileName [giaProp.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Constraint propagation on the AIG.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaProp.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define GIA_SAT_SHIFT 12
+#define GIA_ROOT_MASK
+#define GIA_PATH00_MASK
+#define GIA_PATH10_MASK
+#define GIA_PATH20_MASK
+#define GIA_PATH30_MASK
+#define GIA_PATH00_MASK
+#define GIA_PATH10_MASK
+#define GIA_PATH20_MASK
+#define GIA_PATH30_MASK
+
+static inline int Gia_SatObjIsRoot( Gia_Obj_t * p ) { return 0; }
+static inline int Gia_SatObjXorRoot( Gia_Obj_t * p ) { return 0; }
+
+
+static inline int Gia_SatObjIsAssigned( Gia_Obj_t * p ) { return 0; }
+static inline int Gia_SatObjIsHeld( Gia_Obj_t * p ) { return 0; }
+static inline int Gia_SatObjValue( Gia_Obj_t * p ) { return 0; }
+
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Checks if the give cut is satisfied.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_SatPathCheckCutSat_rec( Gia_Obj_t * p, int fCompl )
+{
+ if ( Gia_SatObjIsRoot(p) )
+ return Gia_ObjIsAssigned(p) && Gia_SatObjValue(p) == fCompl;
+ if ( Gia_SatObjPath0(p) && !Gia_SatPathCheckCutSat_rec( Gia_ObjFanin0(p), fCompl ^ Gia_ObjFaninC0(p) ) )
+ return 0;
+ if ( Gia_SatObjPath1(p) && !Gia_SatPathCheckCutSat_rec( Gia_ObjFanin1(p), fCompl ^ Gia_ObjFaninC1(p) ) )
+ return 0;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Checks if the give cut is satisfied.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_SatPathCheckCutSat( Gia_Obj_t * p )
+{
+ int RetValue;
+ assert( Gia_SatObjIsRoot(p) );
+ Gia_SatObjXorRoot(p);
+ RetValue = Gia_SatPathCheckCutSat_rec( p );
+ Gia_SatObjXorRoot(p);
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Unbinds literals on the path.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_SatPathUnbind_rec( Gia_Obj_t * p )
+{
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates a feasible path from the node to a terminal.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_SatPathStart_rec( Gia_Obj_t * p, int fDiffs, int fCompl )
+{
+ if ( Gia_SatObjIsRoot(p) )
+ return fDiffs && (!Gia_ObjIsAssigned(p) || Gia_SatObjValue(p) != fCompl);
+ if ( fCompl == 0 )
+ {
+ if ( Gia_SatPathStart_rec( Gia_ObjFanin0(p), fDiffs + !Gia_SatObjPath0(p), fCompl ^ Gia_ObjFaninC0(p) ) &&
+ Gia_SatPathStart_rec( Gia_ObjFanin1(p), fDiffs + !Gia_SatObjPath1(p), fCompl ^ Gia_ObjFaninC1(p) ) )
+ return Gia_ObjSetDraftPath0(p) + Gia_ObjSetDraftPath1(p);
+ }
+ else
+ {
+ if ( Gia_SatPathStart_rec( Gia_ObjFanin0(p), fDiffs + !Gia_SatObjPath0(p), fCompl ^ Gia_ObjFaninC0(p) ) )
+ {
+ Gia_ObjUnsetDraftPath1(p);
+ return Gia_ObjSetDraftPath0(p);
+ }
+ if ( Gia_SatPathStart_rec( Gia_ObjFanin1(p), fDiffs + !Gia_SatObjPath1(p), fCompl ^ Gia_ObjFaninC1(p) ) )
+ {
+ Gia_ObjUnsetDraftPath0(p);
+ return Gia_ObjSetDraftPath1(p);
+ }
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates a feasible path from the node to a terminal.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_SatPathStart( Gia_Obj_t * p )
+{
+ int RetValue;
+ assert( Gia_SatObjIsRoot(p) );
+ Gia_SatObjXorRoot(p);
+ RetValue = Gia_SatPathStart_rec( p, 0, 0 );
+ Gia_SatObjXorRoot(p);
+ return RetValue;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaSat.c b/src/aig/gia/giaSat.c
new file mode 100644
index 00000000..6d127223
--- /dev/null
+++ b/src/aig/gia/giaSat.c
@@ -0,0 +1,421 @@
+/**CFile****************************************************************
+
+ FileName [giaSat.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [New constraint-propagation procedures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define GIA_LIMIT 10
+
+
+typedef struct Gia_ManSat_t_ Gia_ManSat_t;
+struct Gia_ManSat_t_
+{
+ Aig_MmFlex_t * pMem;
+};
+
+typedef struct Gia_ObjSat1_t_ Gia_ObjSat1_t;
+struct Gia_ObjSat1_t_
+{
+ char nFans;
+ char nOffset;
+ char PathsH;
+ char PathsV;
+};
+
+typedef struct Gia_ObjSat2_t_ Gia_ObjSat2_t;
+struct Gia_ObjSat2_t_
+{
+ unsigned fTerm : 1;
+ unsigned iLit : 31;
+};
+
+typedef struct Gia_ObjSat_t_ Gia_ObjSat_t;
+struct Gia_ObjSat_t_
+{
+ union {
+ Gia_ObjSat1_t Obj1;
+ Gia_ObjSat2_t Obj2;
+ };
+};
+
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManSat_t * Gia_ManSatStart()
+{
+ Gia_ManSat_t * p;
+ p = ABC_CALLOC( Gia_ManSat_t, 1 );
+ p->pMem = Aig_MmFlexStart();
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSatStop( Gia_ManSat_t * p )
+{
+ Aig_MmFlexStop( p->pMem, 0 );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate rooted at this ]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSatPartCollectSuper( Gia_Man_t * p, Gia_Obj_t * pObj, int * pLits, int * pnLits )
+{
+ Gia_Obj_t * pFanin;
+ assert( Gia_ObjIsAnd(pObj) );
+ assert( pObj->fMark0 == 0 );
+ pFanin = Gia_ObjFanin0(pObj);
+ if ( pFanin->fMark0 || Gia_ObjFaninC0(pObj) )
+ pLits[(*pnLits)++] = Gia_Var2Lit(Gia_ObjId(p, pFanin), Gia_ObjFaninC0(pObj));
+ else
+ Gia_ManSatPartCollectSuper(p, pFanin, pLits, pnLits);
+ pFanin = Gia_ObjFanin1(pObj);
+ if ( pFanin->fMark0 || Gia_ObjFaninC1(pObj) )
+ pLits[(*pnLits)++] = Gia_Var2Lit(Gia_ObjId(p, pFanin), Gia_ObjFaninC1(pObj));
+ else
+ Gia_ManSatPartCollectSuper(p, pFanin, pLits, pnLits);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of words used.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSatPartCreate_rec( Gia_Man_t * p, Gia_Obj_t * pObj, int * pObjPlace, int * pStore )
+{
+ Gia_Obj_t * pFanin;
+ int i, nWordsUsed, nSuperSize = 0, Super[2*GIA_LIMIT];
+ // make sure this is a valid node
+ assert( Gia_ObjIsAnd(pObj) );
+ assert( pObj->fMark0 == 0 );
+ // collect inputs to the supergate
+ Gia_ManSatPartCollectSuper( p, pObj, Super, &nSuperSize );
+ assert( nSuperSize <= 2*GIA_LIMIT );
+ // create the root entry
+ *pObjPlace = 0;
+ ((Gia_ObjSat1_t *)pObjPlace)->nFans = Gia_Var2Lit( nSuperSize, 0 );
+ ((Gia_ObjSat1_t *)pObjPlace)->nOffset = pStore - pObjPlace;
+ nWordsUsed = nSuperSize;
+ for ( i = 0; i < nSuperSize; i++ )
+ {
+ pFanin = Gia_ManObj( p, Gia_Lit2Var(Super[i]) );
+ if ( pFanin->fMark0 )
+ {
+ ((Gia_ObjSat2_t *)(pStore + i))->fTerm = 1;
+ ((Gia_ObjSat2_t *)(pStore + i))->iLit = Super[i];
+ }
+ else
+ {
+ assert( Gia_LitIsCompl(Super[i]) );
+ nWordsUsed += Gia_ManSatPartCreate_rec( p, pFanin, pStore + i, pStore + nWordsUsed );
+ }
+ }
+ return nWordsUsed;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates part and returns the number of words used.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSatPartCreate( Gia_Man_t * p, Gia_Obj_t * pObj, int * pStore )
+{
+ return 1 + Gia_ManSatPartCreate_rec( p, pObj, pStore, pStore + 1 );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Count the number of internal nodes in the leaf-DAG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSatPartCountClauses( Gia_Man_t * p, Gia_Obj_t * pObj, int * pnOnset, int * pnOffset )
+{
+ Gia_Obj_t * pFanin;
+ int nOnset0, nOnset1, nOffset0, nOffset1;
+ assert( Gia_ObjIsAnd(pObj) );
+ pFanin = Gia_ObjFanin0(pObj);
+ if ( pFanin->fMark0 )
+ nOnset0 = 1, nOffset0 = 1;
+ else
+ {
+ Gia_ManSatPartCountClauses(p, pFanin, &nOnset0, &nOffset0);
+ if ( Gia_ObjFaninC0(pObj) )
+ {
+ int Temp = nOnset0;
+ nOnset0 = nOffset0;
+ nOffset0 = Temp;
+ }
+ }
+ pFanin = Gia_ObjFanin1(pObj);
+ if ( pFanin->fMark0 )
+ nOnset1 = 1, nOffset1 = 1;
+ else
+ {
+ Gia_ManSatPartCountClauses(p, pFanin, &nOnset1, &nOffset1);
+ if ( Gia_ObjFaninC1(pObj) )
+ {
+ int Temp = nOnset1;
+ nOnset1 = nOffset1;
+ nOffset1 = Temp;
+ }
+ }
+ *pnOnset = nOnset0 * nOnset1;
+ *pnOffset = nOffset0 + nOffset1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Count the number of internal nodes in the leaf-DAG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSatPartCount( Gia_Man_t * p, Gia_Obj_t * pObj, int * pnLeaves, int * pnNodes )
+{
+ Gia_Obj_t * pFanin;
+ int Level0 = 0, Level1 = 0;
+ assert( Gia_ObjIsAnd(pObj) );
+ assert( pObj->fMark0 == 0 );
+ (*pnNodes)++;
+ pFanin = Gia_ObjFanin0(pObj);
+ if ( pFanin->fMark0 )
+ (*pnLeaves)++;
+ else
+ Level0 = Gia_ManSatPartCount(p, pFanin, pnLeaves, pnNodes) + Gia_ObjFaninC0(pObj);
+ pFanin = Gia_ObjFanin1(pObj);
+ if ( pFanin->fMark0 )
+ (*pnLeaves)++;
+ else
+ Level1 = Gia_ManSatPartCount(p, pFanin, pnLeaves, pnNodes) + Gia_ObjFaninC1(pObj);
+ return AIG_MAX( Level0, Level1 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Count the number of internal nodes in the leaf-DAG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSatPartCountNodes( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ Gia_Obj_t * pFanin;
+ int nNodes0 = 0, nNodes1 = 0;
+ assert( Gia_ObjIsAnd(pObj) );
+ assert( pObj->fMark0 == 0 );
+ pFanin = Gia_ObjFanin0(pObj);
+ if ( !(pFanin->fMark0) )
+ nNodes0 = Gia_ManSatPartCountNodes(p, pFanin);
+ pFanin = Gia_ObjFanin1(pObj);
+ if ( !(pFanin->fMark0) )
+ nNodes1 = Gia_ManSatPartCountNodes(p, pFanin);
+ return nNodes0 + nNodes1 + 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Count the number of internal nodes in the leaf-DAG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSatPartPrint( Gia_Man_t * p, Gia_Obj_t * pObj, int Step )
+{
+ Gia_Obj_t * pFanin;
+ assert( Gia_ObjIsAnd(pObj) );
+ assert( pObj->fMark0 == 0 );
+ pFanin = Gia_ObjFanin0(pObj);
+ if ( pFanin->fMark0 )
+ printf( "%s%d", Gia_ObjFaninC0(pObj)?"!":"", Gia_ObjId(p,pFanin) );
+ else
+ {
+ if ( Gia_ObjFaninC0(pObj) )
+ printf( "(" );
+ Gia_ManSatPartPrint(p, pFanin, Step + Gia_ObjFaninC0(pObj));
+ if ( Gia_ObjFaninC0(pObj) )
+ printf( ")" );
+ }
+ printf( "%s", (Step & 1)? " + " : "*" );
+ pFanin = Gia_ObjFanin1(pObj);
+ if ( pFanin->fMark0 )
+ printf( "%s%d", Gia_ObjFaninC1(pObj)?"!":"", Gia_ObjId(p,pFanin) );
+ else
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ printf( "(" );
+ Gia_ManSatPartPrint(p, pFanin, Step + Gia_ObjFaninC1(pObj));
+ if ( Gia_ObjFaninC1(pObj) )
+ printf( ")" );
+ }
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSatExperiment( Gia_Man_t * p )
+{
+ int nStored, Storage[1000], * pStart;
+ Gia_ManSat_t * pMan;
+ Gia_Obj_t * pObj;
+ int i, nLevels, nLeaves, nNodes, nCount[2*GIA_LIMIT+2] = {0}, nCountAll = 0;
+ int Num0 = 0, Num1 = 0;
+ int clk = clock(), nWords = 0, nWords2 = 0;
+ pMan = Gia_ManSatStart();
+ // mark the nodes to become roots of leaf-DAGs
+ Gia_ManSetRefs( p );
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ pObj->fMark0 = 0;
+ if ( Gia_ObjIsCo(pObj) )
+ Gia_ObjFanin0(pObj)->fMark0 = 1;
+ else if ( Gia_ObjIsCi(pObj) )
+ pObj->fMark0 = 1;
+ else if ( Gia_ObjIsAnd(pObj) )
+ {
+ if ( pObj->Value > 1 || Gia_ManSatPartCountNodes(p,pObj) >= GIA_LIMIT )
+ pObj->fMark0 = 1;
+ }
+ pObj->Value = 0;
+ }
+ // compute the sizes of leaf-DAGs
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ if ( pObj->fMark0 == 0 )
+ continue;
+ pObj->fMark0 = 0;
+
+ nCountAll++;
+ nStored = Gia_ManSatPartCreate( p, pObj, Storage );
+ nWords2 += nStored;
+ assert( nStored < 500 );
+ pStart = (int *)Aig_MmFlexEntryFetch( pMan->pMem, sizeof(int) * nStored );
+ memcpy( pStart, Storage, sizeof(int) * nStored );
+
+ nLeaves = nNodes = 0;
+ nLevels = 1+Gia_ManSatPartCount( p, pObj, &nLeaves, &nNodes );
+ nWords += nLeaves + nNodes;
+ if ( nNodes <= 2*GIA_LIMIT )
+ nCount[nNodes]++;
+ else
+ nCount[2*GIA_LIMIT+1]++;
+// if ( nNodes > 10 && i % 100 == 0 )
+// if ( nNodes > 5 )
+ if ( 0 )
+ {
+ Gia_ManSatPartCountClauses( p, pObj, &Num0, &Num1 );
+ printf( "%8d : And = %3d. Lev = %2d. Clauses = %3d. (%3d + %3d).\n", i, nNodes, nLevels, Num0+Num1, Num0, Num1 );
+ Gia_ManSatPartPrint( p, pObj, 0 );
+ printf( "\n" );
+ }
+
+ pObj->fMark0 = 1;
+ }
+ printf( "\n" );
+ Gia_ManForEachObj( p, pObj, i )
+ pObj->fMark0 = 0;
+ Gia_ManSatStop( pMan );
+ for ( i = 0; i < 2*GIA_LIMIT+2; i++ )
+ printf( "%2d=%6d %7.2f %% %7.2f %%\n", i, nCount[i], 100.0*nCount[i]/nCountAll, 100.0*i*nCount[i]/Gia_ManAndNum(p) );
+ ABC_PRM( "MemoryEst", 4*nWords );
+ ABC_PRM( "MemoryReal", 4*nWords2 );
+ printf( "%5.2f bpn ", 4.0*nWords2/Gia_ManObjNum(p) );
+ ABC_PRT( "Time", clock() - clk );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaScl.c b/src/aig/gia/giaScl.c
new file mode 100644
index 00000000..3f72b0b9
--- /dev/null
+++ b/src/aig/gia/giaScl.c
@@ -0,0 +1,240 @@
+/**CFile****************************************************************
+
+ FileName [giaScl.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Sequential cleanup.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaScl.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of unmarked nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCombMarkUsed_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( !pObj->fMark0 )
+ return 0;
+ pObj->fMark0 = 0;
+ assert( Gia_ObjIsAnd(pObj) );
+ return Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) ) +
+ Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin1(pObj) ) + 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of unused nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCombMarkUsed( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, nNodes = 0;
+ Gia_ManForEachObj( p, pObj, i )
+ pObj->fMark0 = Gia_ObjIsAnd(pObj);
+ Gia_ManForEachCo( p, pObj, i )
+ nNodes += Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) );
+ return nNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs combinational cleanup.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManCleanup( Gia_Man_t * p )
+{
+ Gia_ManCombMarkUsed( p );
+ return Gia_ManDupMarked( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Marks CIs/COs reachable from POs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSeqMarkUsed_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vRoots )
+{
+ if ( !pObj->fMark0 )
+ return;
+ pObj->fMark0 = 0;
+ if ( Gia_ObjIsCo(pObj) )
+ {
+ Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin0(pObj), vRoots );
+ return;
+ }
+ if ( Gia_ObjIsRo(p, pObj) )
+ {
+ Vec_IntPush( vRoots, Gia_ObjId(p, Gia_ObjRoToRi(p, pObj)) );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin0(pObj), vRoots );
+ Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin1(pObj), vRoots );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs sequential cleanup.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManSeqCleanup( Gia_Man_t * p )
+{
+ Vec_Int_t * vRoots;
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManSetMark0( p );
+ Gia_ManConst0(p)->fMark0 = 0;
+ Gia_ManForEachPi( p, pObj, i )
+ pObj->fMark0 = 0;
+ vRoots = Gia_ManCollectPoIds( p );
+ Gia_ManForEachObjVec( vRoots, p, pObj, i )
+ Gia_ManSeqMarkUsed_rec( p, pObj, vRoots );
+ Vec_IntFree( vRoots );
+ return Gia_ManDupMarked( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find representatives due to identical fanins.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManReduceEquiv( Gia_Man_t * p, int fVerbose )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObjRi, * pObjRo;
+ unsigned * pCi2Lit, * pMaps;
+ int i, iLit, nFanins = 1, Counter0 = 0, Counter = 0;
+ Gia_ManForEachRi( p, pObjRi, i )
+ Gia_ObjFanin0(pObjRi)->Value = 0;
+ Gia_ManForEachRi( p, pObjRi, i )
+ if ( Gia_ObjFanin0(pObjRi)->Value == 0 )
+ Gia_ObjFanin0(pObjRi)->Value = 2*nFanins++;
+ pCi2Lit = ABC_FALLOC( unsigned, Gia_ManCiNum(p) );
+ pMaps = ABC_FALLOC( unsigned, 2 * nFanins );
+ Gia_ManForEachRiRo( p, pObjRi, pObjRo, i )
+ {
+ iLit = Gia_ObjFanin0Copy( pObjRi );
+ if ( Gia_ObjFaninId0p(p, pObjRi) == 0 )
+ pCi2Lit[Gia_ManPiNum(p)+i] = 0, Counter0++;
+ else if ( ~pMaps[iLit] ) // in this case, ID(pObj) > ID(pRepr)
+ pCi2Lit[Gia_ManPiNum(p)+i] = pMaps[iLit], Counter++;
+ else
+ pMaps[iLit] = Gia_Var2Lit( Gia_ObjId(p, pObjRo), 0 );
+ }
+/*
+ Gia_ManForEachCi( p, pObjRo, i )
+ {
+ if ( ~pCi2Lit[i] )
+ {
+ Gia_Obj_t * pObj0 = Gia_ObjRoToRi(p, pObjRo);
+ Gia_Obj_t * pObj1 = Gia_ObjRoToRi(p, Gia_ManObj(p, pCi2Lit[i]));
+ Gia_Obj_t * pFan0 = Gia_ObjChild0( p, Gia_ObjRoToRi(p, pObjRo) );
+ Gia_Obj_t * pFan1 = Gia_ObjChild0( p, Gia_ObjRoToRi(p, Gia_ManObj(p, pCi2Lit[i])) );
+ assert( pFan0 == pFan1 );
+ }
+ }
+*/
+ if ( fVerbose )
+ printf( "ReduceEquiv detected %d constant regs and %d equivalent regs.\n", Counter0, Counter );
+ ABC_FREE( pMaps );
+ pNew = Gia_ManDupDfsCiMap( p, pCi2Lit, NULL );
+ ABC_FREE( pCi2Lit );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs sequential cleanup.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManSeqStructSweep( Gia_Man_t * p, int fConst, int fEquiv, int fVerbose )
+{
+ Gia_Man_t * pTemp;
+ if ( Gia_ManRegNum(p) == 0 )
+ return Gia_ManDup( p );
+ p = Gia_ManSeqCleanup( p );
+ if ( fConst && Gia_ManRegNum(p) )
+ {
+ p = Gia_ManReduceConst( pTemp = p, fVerbose );
+ Gia_ManStop( pTemp );
+ }
+ if ( fEquiv && Gia_ManRegNum(p) )
+ {
+ p = Gia_ManReduceEquiv( pTemp = p, fVerbose );
+ Gia_ManStop( pTemp );
+ }
+ p = Gia_ManSeqCleanup( pTemp = p );
+ Gia_ManStop( pTemp );
+ return p;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaSim.c b/src/aig/gia/giaSim.c
new file mode 100644
index 00000000..7ee0ddc4
--- /dev/null
+++ b/src/aig/gia/giaSim.c
@@ -0,0 +1,437 @@
+/**CFile****************************************************************
+
+ FileName [giaSim.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Fast sequential simulator.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaSim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Gia_ManSim_t_ Gia_ManSim_t;
+struct Gia_ManSim_t_
+{
+ Gia_Man_t * pAig;
+ Gia_ParSim_t * pPars;
+ int nWords;
+ Vec_Int_t * vCis2Ids;
+ // simulation information
+ unsigned * pDataSim; // simulation data
+ unsigned * pDataSimCis; // simulation data for CIs
+ unsigned * pDataSimCos; // simulation data for COs
+};
+
+static inline unsigned * Gia_SimData( Gia_ManSim_t * p, int i ) { return p->pDataSim + i * p->nWords; }
+static inline unsigned * Gia_SimDataCi( Gia_ManSim_t * p, int i ) { return p->pDataSimCis + i * p->nWords; }
+static inline unsigned * Gia_SimDataCo( Gia_ManSim_t * p, int i ) { return p->pDataSimCos + i * p->nWords; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSimSetDefaultParams( Gia_ParSim_t * p )
+{
+ memset( p, 0, sizeof(Gia_ParSim_t) );
+ // user-controlled parameters
+ p->nWords = 8; // the number of machine words
+ p->nIters = 32; // the number of timeframes
+ p->TimeLimit = 60; // time limit in seconds
+ p->fCheckMiter = 0; // check if miter outputs are non-zero
+ p->fVerbose = 1; // enables verbose output
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates fast simulation manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManSim_t * Gia_ManSimCreate( Gia_Man_t * pAig, Gia_ParSim_t * pPars )
+{
+ Gia_ManSim_t * p;
+ int Entry, i;
+ p = ABC_ALLOC( Gia_ManSim_t, 1 );
+ memset( p, 0, sizeof(Gia_ManSim_t) );
+ p->pAig = Gia_ManFront( pAig );
+ p->pPars = pPars;
+ p->nWords = pPars->nWords;
+ p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->pAig->nFront );
+ p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * Gia_ManCiNum(p->pAig) );
+ p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * Gia_ManCoNum(p->pAig) );
+ p->vCis2Ids = Vec_IntAlloc( Gia_ManCiNum(p->pAig) );
+ Vec_IntForEachEntry( pAig->vCis, Entry, i )
+ Vec_IntPush( p->vCis2Ids, Entry );
+ printf( "AIG = %7.2f Mb. Front mem = %7.2f Mb. Other mem = %7.2f Mb.\n",
+ 12.0*Gia_ManObjNum(p->pAig)/(1<<20),
+ 4.0*p->nWords*p->pAig->nFront/(1<<20),
+ 4.0*p->nWords*(Gia_ManCiNum(p->pAig) + Gia_ManCoNum(p->pAig))/(1<<20) );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSimDelete( Gia_ManSim_t * p )
+{
+ Vec_IntFree( p->vCis2Ids );
+ Gia_ManStop( p->pAig );
+ ABC_FREE( p->pDataSim );
+ ABC_FREE( p->pDataSimCis );
+ ABC_FREE( p->pDataSimCos );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimInfoRandom( Gia_ManSim_t * p, unsigned * pInfo )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = Aig_ManRandom( 0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimInfoZero( Gia_ManSim_t * p, unsigned * pInfo )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns index of the first pattern that failed.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManSimInfoIsZero( Gia_ManSim_t * p, unsigned * pInfo )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ if ( pInfo[w] )
+ return 32*(w-1) + Aig_WordFindFirstBit( pInfo[w] );
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimInfoOne( Gia_ManSim_t * p, unsigned * pInfo )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimInfoCopy( Gia_ManSim_t * p, unsigned * pInfo, unsigned * pInfo0 )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimulateCi( Gia_ManSim_t * p, Gia_Obj_t * pObj, int iCi )
+{
+ unsigned * pInfo = Gia_SimData( p, Gia_ObjValue(pObj) );
+ unsigned * pInfo0 = Gia_SimDataCi( p, iCi );
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimulateCo( Gia_ManSim_t * p, int iCo, Gia_Obj_t * pObj )
+{
+ unsigned * pInfo = Gia_SimDataCo( p, iCo );
+ unsigned * pInfo0 = Gia_SimData( p, Gia_ObjDiff0(pObj) );
+ int w;
+ if ( Gia_ObjFaninC0(pObj) )
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~pInfo0[w];
+ else
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimulateNode( Gia_ManSim_t * p, Gia_Obj_t * pObj )
+{
+ unsigned * pInfo = Gia_SimData( p, Gia_ObjValue(pObj) );
+ unsigned * pInfo0 = Gia_SimData( p, Gia_ObjDiff0(pObj) );
+ unsigned * pInfo1 = Gia_SimData( p, Gia_ObjDiff1(pObj) );
+ int w;
+ if ( Gia_ObjFaninC0(pObj) )
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
+ else
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~pInfo0[w] & pInfo1[w];
+ }
+ else
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w] & ~pInfo1[w];
+ else
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w] & pInfo1[w];
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimInfoInit( Gia_ManSim_t * p )
+{
+ int iPioNum, i;
+ Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
+ {
+ if ( iPioNum < Gia_ManPiNum(p->pAig) )
+ Gia_ManSimInfoRandom( p, Gia_SimDataCi(p, i) );
+ else
+ Gia_ManSimInfoZero( p, Gia_SimDataCi(p, i) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimInfoTransfer( Gia_ManSim_t * p )
+{
+ int iPioNum, i;
+ Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
+ {
+ if ( iPioNum < Gia_ManPiNum(p->pAig) )
+ Gia_ManSimInfoRandom( p, Gia_SimDataCi(p, i) );
+ else
+ Gia_ManSimInfoCopy( p, Gia_SimDataCi(p, i), Gia_SimDataCo(p, Gia_ManPoNum(p->pAig)+iPioNum-Gia_ManPiNum(p->pAig)) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimulateRound( Gia_ManSim_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, iCis = 0, iCos = 0;
+ assert( p->pAig->nFront > 0 );
+ assert( Gia_ManConst0(p->pAig)->Value == 0 );
+ Gia_ManSimInfoZero( p, Gia_SimData(p, 0) );
+ Gia_ManForEachObj1( p->pAig, pObj, i )
+ {
+ if ( Gia_ObjIsAndOrConst0(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) < p->pAig->nFront );
+ Gia_ManSimulateNode( p, pObj );
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) == GIA_NONE );
+ Gia_ManSimulateCo( p, iCos++, pObj );
+ }
+ else // if ( Gia_ObjIsCi(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) < p->pAig->nFront );
+ Gia_ManSimulateCi( p, pObj, iCis++ );
+ }
+ }
+ assert( Gia_ManCiNum(p->pAig) == iCis );
+ assert( Gia_ManCoNum(p->pAig) == iCos );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars )
+{
+ Gia_ManSim_t * p;
+ int i, clk = clock();
+ p = Gia_ManSimCreate( pAig, pPars );
+ Aig_ManRandom( 1 );
+ Gia_ManSimInfoInit( p );
+ for ( i = 0; i < pPars->nIters; i++ )
+ {
+ Gia_ManSimulateRound( p );
+/*
+ if ( pPars->fVerbose )
+ {
+ printf( "Frame %4d out of %4d and timeout %3d sec. ", i+1, pPars->nIters, pPars->TimeLimit );
+ printf( "Time = %7.2f sec\r", (1.0*clock()-clkTotal)/CLOCKS_PER_SEC );
+ }
+ if ( pPars->fCheckMiter && Gia_ManCheckPos( p, &iOut, &iPat ) )
+ {
+ assert( pAig->pSeqModel == NULL );
+ pAig->pSeqModel = Gia_ManGenerateCounter( pAig, i, iOut, p->nWords, iPat, p->vCis2Ids );
+ if ( pPars->fVerbose )
+ printf( "Miter is satisfiable after simulation (output %d).\n", iOut );
+ break;
+ }
+ if ( (clock() - clkTotal)/CLOCKS_PER_SEC >= pPars->TimeLimit )
+ {
+ printf( "No bug detected after %d frames with time limit %d seconds.\n", i+1, pPars->TimeLimit );
+ break;
+ }
+*/
+ if ( i < pPars->nIters - 1 )
+ Gia_ManSimInfoTransfer( p );
+ }
+ Gia_ManSimDelete( p );
+ printf( "Simulated %d frames with %d words. ", pPars->nIters, pPars->nWords );
+ ABC_PRT( "Time", clock() - clk );
+ return 0;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaSolver.c b/src/aig/gia/giaSolver.c
new file mode 100644
index 00000000..e1f68c6f
--- /dev/null
+++ b/src/aig/gia/giaSolver.c
@@ -0,0 +1,490 @@
+/**CFile****************************************************************
+
+ FileName [giaSolver.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Circuit-based SAT solver.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaSolver.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Sat_Man_t_ Sat_Man_t;
+struct Sat_Man_t_
+{
+ Gia_Man_t * pGia; // the original AIG manager
+ Vec_Int_t * vModel; // satisfying PI assignment
+ int nConfs; // cur number of conflicts
+ int nConfsMax; // max number of conflicts
+ int iHead; // variable queue
+ int iTail; // variable queue
+ int iJust; // head of justification
+ int nTrail; // variable queue size
+ int pTrail[0]; // variable queue data
+};
+
+static inline int Sat_VarIsAssigned( Gia_Obj_t * pVar ) { return pVar->fMark0; }
+static inline void Sat_VarAssign( Gia_Obj_t * pVar ) { assert(!pVar->fMark0); pVar->fMark0 = 1; }
+static inline void Sat_VarUnassign( Gia_Obj_t * pVar ) { assert(pVar->fMark0); pVar->fMark0 = 0; }
+static inline int Sat_VarValue( Gia_Obj_t * pVar ) { assert(pVar->fMark0); return pVar->fMark1; }
+static inline void Sat_VarSetValue( Gia_Obj_t * pVar, int v ) { assert(pVar->fMark0); pVar->fMark1 = v; }
+
+extern void Cec_ManPatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat );
+extern void Cec_ManPatCleanMark0( Gia_Man_t * p, Gia_Obj_t * pObj );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Sat_Man_t * Sat_ManCreate( Gia_Man_t * pGia )
+{
+ Sat_Man_t * p;
+ p = (Sat_Man_t *)ABC_ALLOC( char, sizeof(Sat_Man_t) + sizeof(int)*Gia_ManObjNum(pGia) );
+ memset( p, 0, sizeof(Sat_Man_t) );
+ p->pGia = pGia;
+ p->nTrail = Gia_ManObjNum(pGia);
+ p->vModel = Vec_IntAlloc( 1000 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Sat_ManDelete( Sat_Man_t * p )
+{
+ Vec_IntFree( p->vModel );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Sat_ManCancelUntil( Sat_Man_t * p, int iBound )
+{
+ Gia_Obj_t * pVar;
+ int i;
+ for ( i = p->iTail-1; i >= iBound; i-- )
+ {
+ pVar = Gia_ManObj( p->pGia, p->pTrail[i] );
+ Sat_VarUnassign( pVar );
+ }
+ p->iTail = p->iTail = iBound;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Sat_ManDeriveModel( Sat_Man_t * p )
+{
+ Gia_Obj_t * pVar;
+ int i;
+ Vec_IntClear( p->vModel );
+ for ( i = 0; i < p->iTail; i++ )
+ {
+ pVar = Gia_ManObj( p->pGia, p->pTrail[i] );
+ if ( Gia_ObjIsCi(pVar) )
+ Vec_IntPush( p->vModel, Gia_ObjCioId(pVar) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Sat_ManEnqueue( Sat_Man_t * p, Gia_Obj_t * pVar, int Value )
+{
+ assert( p->iTail < p->nTrail );
+ Sat_VarAssign( pVar );
+ Sat_VarSetValue( pVar, Value );
+ p->pTrail[p->iTail++] = Gia_ObjId(p->pGia, pVar);
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Sat_ManAssume( Sat_Man_t * p, Gia_Obj_t * pVar, int Value )
+{
+ assert( p->iHead == p->iTail );
+ Sat_ManEnqueue( p, pVar, Value );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagates one assignment.]
+
+ Description [Returns 1 if there is no conflict, 0 otherwise.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Sat_ManPropagateOne( Sat_Man_t * p, int iPos )
+{
+ Gia_Obj_t * pVar, * pFan0, * pFan1;
+ pVar = Gia_ManObj( p->pGia, p->pTrail[iPos] );
+ if ( Gia_ObjIsCi(pVar) )
+ return 1;
+ pFan0 = Gia_ObjFanin0(pVar);
+ pFan1 = Gia_ObjFanin1(pVar);
+ if ( Sat_VarValue(pVar) ) // positive
+ {
+ if ( Sat_VarIsAssigned(pFan0) )
+ {
+ if ( Sat_VarValue(pFan0) == Gia_ObjFaninC0(pVar) ) // negative -> conflict
+ return 0;
+ // check second var
+ if ( Sat_VarIsAssigned(pFan1) )
+ {
+ if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> conflict
+ return 0;
+ // positive + positive -> nothing to do
+ return 1;
+ }
+ }
+ else
+ {
+ // pFan0 unassigned -> enqueue first var
+ Sat_ManEnqueue( p, pFan0, !Gia_ObjFaninC0(pVar) );
+ // check second var
+ if ( Sat_VarIsAssigned(pFan1) )
+ {
+ if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> conflict
+ return 0;
+ // positive + positive -> nothing to do
+ return 1;
+ }
+ }
+ // unassigned -> enqueue second var
+ Sat_ManEnqueue( p, pFan1, !Gia_ObjFaninC1(pVar) );
+ }
+ else // negative
+ {
+ if ( Sat_VarIsAssigned(pFan0) )
+ {
+ if ( Sat_VarValue(pFan0) == Gia_ObjFaninC0(pVar) ) // negative -> nothing to do
+ return 1;
+ if ( Sat_VarIsAssigned(pFan1) )
+ {
+ if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> nothing to do
+ return 1;
+ // positive + positive -> conflict
+ return 0;
+ }
+ // positive + unassigned -> enqueue second var
+ Sat_ManEnqueue( p, pFan1, Gia_ObjFaninC1(pVar) );
+ }
+ else
+ {
+ if ( Sat_VarIsAssigned(pFan1) )
+ {
+ if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> nothing to do
+ return 1;
+ // unassigned + positive -> enqueue first var
+ Sat_ManEnqueue( p, pFan0, Gia_ObjFaninC0(pVar) );
+ }
+ }
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagates assignments.]
+
+ Description [Returns 1 if there is no conflict.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Sat_ManPropagate( Sat_Man_t * p )
+{
+ assert( p->iHead <= p->iTail );
+ for ( ; p->iHead < p->iTail; p->iHead++ )
+ if ( !Sat_ManPropagateOne( p, p->pTrail[p->iHead] ) )
+ return 0;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagates one assignment.]
+
+ Description [Returns 1 if justified, 0 if conflict, -1 if needs justification.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Sat_ManJustifyNextOne( Sat_Man_t * p, int iPos )
+{
+ Gia_Obj_t * pVar, * pFan0, * pFan1;
+ pVar = Gia_ManObj( p->pGia, p->pTrail[iPos] );
+ if ( Gia_ObjIsCi(pVar) )
+ return 1;
+ pFan0 = Gia_ObjFanin0(pVar);
+ pFan1 = Gia_ObjFanin1(pVar);
+ if ( Sat_VarValue(pVar) ) // positive
+ return 1;
+ // nevative
+ if ( Sat_VarIsAssigned(pFan0) )
+ {
+ if ( Sat_VarValue(pFan0) == Gia_ObjFaninC0(pVar) ) // negative -> already justified
+ return 1;
+ // positive
+ if ( Sat_VarIsAssigned(pFan1) )
+ {
+ if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> already justified
+ return 1;
+ // positive -> conflict
+ return 0;
+ }
+ // unasigned -> propagate
+ Sat_ManAssume( p, pFan1, Gia_ObjFaninC1(pVar) );
+ return Sat_ManPropagate(p);
+ }
+ if ( Sat_VarIsAssigned(pFan1) )
+ {
+ if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> already justified
+ return 1;
+ // positive
+ assert( !Sat_VarIsAssigned(pFan0) );
+ // unasigned -> propagate
+ Sat_ManAssume( p, pFan0, Gia_ObjFaninC0(pVar) );
+ return Sat_ManPropagate(p);
+ }
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Justifies assignments.]
+
+ Description [Returns 1 for UNSAT, 0 for SAT, -1 for UNDECIDED.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Sat_ManJustify( Sat_Man_t * p )
+{
+ Gia_Obj_t * pVar, * pFan0, * pFan1;
+ int RetValue, iState, iJustState;
+ if ( p->nConfs && p->nConfs >= p->nConfsMax )
+ return -1;
+ // get the next variable to justify
+ assert( p->iJust <= p->iTail );
+ iJustState = p->iJust;
+ for ( ; p->iJust < p->iTail; p->iJust++ )
+ {
+ RetValue = Sat_ManJustifyNextOne( p, p->pTrail[p->iJust] );
+ if ( RetValue == 0 )
+ return 1;
+ if ( RetValue == -1 )
+ break;
+ }
+ if ( p->iJust == p->iTail ) // could not find
+ return 0;
+ // found variable to justify
+ pVar = Gia_ManObj( p->pGia, p->pTrail[p->iJust] );
+ pFan0 = Gia_ObjFanin0(pVar);
+ pFan1 = Gia_ObjFanin1(pVar);
+ assert( !Sat_VarValue(pVar) && !Sat_VarIsAssigned(pFan0) && !Sat_VarIsAssigned(pFan1) );
+ // remember the state of the stack
+ iState = p->iHead;
+ // try to justify by setting first fanin to 0
+ Sat_ManAssume( p, pFan0, Gia_ObjFaninC0(pVar) );
+ if ( Sat_ManPropagate(p) )
+ {
+ RetValue = Sat_ManJustify(p);
+ if ( RetValue != 1 )
+ return RetValue;
+ }
+ Sat_ManCancelUntil( p, iState );
+ // try to justify by setting second fanin to 0
+ Sat_ManAssume( p, pFan1, Gia_ObjFaninC1(pVar) );
+ if ( Sat_ManPropagate(p) )
+ {
+ RetValue = Sat_ManJustify(p);
+ if ( RetValue != 1 )
+ return RetValue;
+ }
+ Sat_ManCancelUntil( p, iState );
+ p->iJust = iJustState;
+ p->nConfs++;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Runs one call to the SAT solver.]
+
+ Description [Returns 1 for UNSAT, 0 for SAT, -1 for UNDECIDED.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Sat_ManPrepare( Sat_Man_t * p, int * pLits, int nLits, int nConfsMax )
+{
+ Gia_Obj_t * pVar;
+ int i;
+ // double check that vars are unassigned
+ Gia_ManForEachObj( p->pGia, pVar, i )
+ assert( !Sat_VarIsAssigned(pVar) );
+ // prepare
+ p->iHead = p->iTail = p->iJust = 0;
+ p->nConfsMax = nConfsMax;
+ // assign literals
+ for ( i = 0; i < nLits; i++ )
+ {
+ pVar = Gia_ManObj( p->pGia, Gia_Lit2Var(pLits[i]) );
+ if ( Sat_VarIsAssigned(pVar) ) // assigned
+ {
+ if ( Sat_VarValue(pVar) != Gia_LitIsCompl(pLits[i]) ) // compatible assignment
+ continue;
+ }
+ else // unassigned
+ {
+ Sat_ManAssume( p, pVar, !Gia_LitIsCompl(pLits[i]) );
+ if ( Sat_ManPropagate(p) )
+ continue;
+ }
+ // conflict
+ Sat_ManCancelUntil( p, 0 );
+ return 1;
+ }
+ assert( p->iHead == p->iTail );
+ return 0;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Runs one call to the SAT solver.]
+
+ Description [Returns 1 for UNSAT, 0 for SAT, -1 for UNDECIDED.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Sat_ManSolve( Sat_Man_t * p, int * pLits, int nLits, int nConfsMax )
+{
+ int RetValue;
+ // propagate the assignments
+ if ( Sat_ManPrepare( p, pLits, nLits, nConfsMax ) )
+ return 1;
+ // justify the assignments
+ RetValue = Sat_ManJustify( p );
+ if ( RetValue == 0 ) // SAT
+ Sat_ManDeriveModel( p );
+ // return the solver to the initial state
+ Sat_ManCancelUntil( p, 0 );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Testing the SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Sat_ManTest( Gia_Man_t * pGia, Gia_Obj_t * pObj, int nConfsMax )
+{
+ Sat_Man_t * p;
+ int RetValue, iLit;
+ assert( Gia_ObjIsCo(pObj) );
+ p = Sat_ManCreate( pGia );
+ iLit = Gia_LitNot( Gia_ObjFaninLit0p(pGia, pObj) );
+ RetValue = Sat_ManSolve( p, &iLit, 1, nConfsMax );
+ if ( RetValue == 0 )
+ {
+ Cec_ManPatVerifyPattern( pGia, pObj, p->vModel );
+ Cec_ManPatCleanMark0( pGia, pObj );
+ }
+ Sat_ManDelete( p );
+ return RetValue;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaSolver_cnf.c b/src/aig/gia/giaSolver_cnf.c
new file mode 100644
index 00000000..12f6895a
--- /dev/null
+++ b/src/aig/gia/giaSolver_cnf.c
@@ -0,0 +1,103 @@
+/**CFile****************************************************************
+
+ FileName [giaSolver.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Circuit-based SAT solver.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaSolver.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Sat_Cla_t_ Sat_Cla_t;
+struct Sat_Cla_t_
+{
+ unsigned hWatch0; // watched list for 0 literal
+ unsigned hWatch1; // watched list for 1 literal
+ int Activity; // activity of the clause
+ int nLits; // the number of literals
+ int pLits[0]; // the array of literals
+};
+
+typedef struct Sat_Fan_t_ Sat_Fan_t;
+struct Sat_Fan_t_
+{
+ unsigned iFan : 31; // ID of the fanin/fanout
+ unsigned fCompl : 1; // complemented attribute
+};
+
+typedef struct Sat_Obj_t_ Sat_Obj_t;
+struct Sat_Obj_t_
+{
+ unsigned hHandle; // node handle
+ unsigned fAssign : 1; // terminal node (CI/CO)
+ unsigned fValue : 1; // value under 000 pattern
+ unsigned fMark0 : 1; // first user-controlled mark
+ unsigned fMark1 : 1; // second user-controlled mark
+ unsigned nFanouuts : 28; // the number of fanouts
+ unsigned nFanins : 8; // the number of fanins
+ unsigned Level : 24; // logic level
+ unsigned hNext; // next one on this level
+ unsigned hWatch0; // watched list for 0 literal
+ unsigned hWatch1; // watched list for 1 literal
+ unsigned hReason; // reason for this variable
+ unsigned Depth; // decision depth
+ Sat_Fan_t Fanios[0]; // the array of fanins/fanouts
+};
+
+typedef struct Sat_Man_t_ Sat_Man_t;
+struct Sat_Man_t_
+{
+ Gia_Man_t * pGia; // the original AIG manager
+ // circuit
+ Vec_Int_t vCis; // the vector of CIs (PIs + LOs)
+ Vec_Int_t vObjs; // the vector of objects
+ // learned clauses
+ Vec_Int_t vClauses; // the vector of clauses
+ // solver data
+ Vec_Int_t vTrail; // variable queue
+ Vec_Int_t vTrailLim; // pointer into the trail
+ int iHead; // variable queue
+ int iTail; // variable queue
+ int iRootLevel; // first decision
+ // levelized order
+ int iLevelTop; // the largest unassigned level
+ Vec_Int_t vLevels; // the linked lists of levels
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaSwitch.c b/src/aig/gia/giaSwitch.c
new file mode 100644
index 00000000..71aefec3
--- /dev/null
+++ b/src/aig/gia/giaSwitch.c
@@ -0,0 +1,673 @@
+/**CFile****************************************************************
+
+ FileName [giaSwitch.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Computing switching activity.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaSwitch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// switching estimation parameters
+typedef struct Gia_ParSwi_t_ Gia_ParSwi_t;
+struct Gia_ParSwi_t_
+{
+ // user-controlled parameters
+ int nWords; // the number of machine words
+ int nIters; // the number of timeframes
+ int nPref; // the number of first timeframes to skip
+ int nRandPiFactor; // PI trans prob (-1=3/8; 0=1/2; 1=1/4; 2=1/8, etc)
+ int fProbOne; // collect probability of one
+ int fProbTrans; // collect probatility of Swiing
+ int fVerbose; // enables verbose output
+};
+
+typedef struct Gia_ManSwi_t_ Gia_ManSwi_t;
+struct Gia_ManSwi_t_
+{
+ Gia_Man_t * pAig;
+ Gia_ParSwi_t * pPars;
+ int nWords;
+ // simulation information
+ unsigned * pDataSim; // simulation data
+ unsigned * pDataSimCis; // simulation data for CIs
+ unsigned * pDataSimCos; // simulation data for COs
+ int * pData1; // switching data
+};
+
+static inline unsigned * Gia_SwiData( Gia_ManSwi_t * p, int i ) { return p->pDataSim + i * p->nWords; }
+static inline unsigned * Gia_SwiDataCi( Gia_ManSwi_t * p, int i ) { return p->pDataSimCis + i * p->nWords; }
+static inline unsigned * Gia_SwiDataCo( Gia_ManSwi_t * p, int i ) { return p->pDataSimCos + i * p->nWords; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetDefaultParamsSwi( Gia_ParSwi_t * p )
+{
+ memset( p, 0, sizeof(Gia_ParSwi_t) );
+ p->nWords = 1; // the number of machine words of simulatation data
+ p->nIters = 48; // the number of all timeframes to simulate
+ p->nPref = 16; // the number of first timeframes to skip when computing switching
+ p->nRandPiFactor = 2; // primary input transition probability (-1=3/8; 0=1/2; 1=1/4; 2=1/8, etc)
+ p->fProbOne = 0; // compute probability of signal being one (if 0, compute probability of switching)
+ p->fProbTrans = 1; // compute signal transition probability (if 0, compute transition probability using probability of being one)
+ p->fVerbose = 1; // enables verbose output
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates fast simulation manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManSwi_t * Gia_ManSwiCreate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars )
+{
+ Gia_ManSwi_t * p;
+ p = ABC_ALLOC( Gia_ManSwi_t, 1 );
+ memset( p, 0, sizeof(Gia_ManSwi_t) );
+ p->pAig = Gia_ManFront( pAig );
+ p->pPars = pPars;
+ p->nWords = pPars->nWords;
+ p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->pAig->nFront );
+ p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * Gia_ManCiNum(p->pAig) );
+ p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * Gia_ManCoNum(p->pAig) );
+ p->pData1 = ABC_CALLOC( int, Gia_ManObjNum(pAig) );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSwiDelete( Gia_ManSwi_t * p )
+{
+ Gia_ManStop( p->pAig );
+ ABC_FREE( p->pData1 );
+ ABC_FREE( p->pDataSim );
+ ABC_FREE( p->pDataSimCis );
+ ABC_FREE( p->pDataSimCos );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoRandom( Gia_ManSwi_t * p, unsigned * pInfo, int nProbNum )
+{
+ unsigned Mask;
+ int w, i;
+ if ( nProbNum == -1 )
+ { // 3/8 = 1/4 + 1/8
+ Mask = (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 )) |
+ (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 ) & Aig_ManRandom( 0 ));
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] ^= Mask;
+ }
+ else if ( nProbNum > 0 )
+ {
+ Mask = Aig_ManRandom( 0 );
+ for ( i = 0; i < nProbNum; i++ )
+ Mask &= Aig_ManRandom( 0 );
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] ^= Mask;
+ }
+ else if ( nProbNum == 0 )
+ {
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = Aig_ManRandom( 0 );
+ }
+ else
+ assert( 0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoRandomShift( Gia_ManSwi_t * p, unsigned * pInfo, int nProbNum )
+{
+ unsigned Mask;
+ int w, i;
+ if ( nProbNum == -1 )
+ { // 3/8 = 1/4 + 1/8
+ Mask = (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 )) |
+ (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 ) & Aig_ManRandom( 0 ));
+ }
+ else if ( nProbNum >= 0 )
+ {
+ Mask = Aig_ManRandom( 0 );
+ for ( i = 0; i < nProbNum; i++ )
+ Mask &= Aig_ManRandom( 0 );
+ }
+ else
+ assert( 0 );
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = (pInfo[w] << 16) | ((pInfo[w] ^ Mask) & 0xffff);
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoZero( Gia_ManSwi_t * p, unsigned * pInfo )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoOne( Gia_ManSwi_t * p, unsigned * pInfo )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoCopy( Gia_ManSwi_t * p, unsigned * pInfo, unsigned * pInfo0 )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoCopyShift( Gia_ManSwi_t * p, unsigned * pInfo, unsigned * pInfo0 )
+{
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = (pInfo[w] << 16) | (pInfo0[w] & 0xffff);
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimulateCi( Gia_ManSwi_t * p, Gia_Obj_t * pObj, int iCi )
+{
+ unsigned * pInfo = Gia_SwiData( p, Gia_ObjValue(pObj) );
+ unsigned * pInfo0 = Gia_SwiDataCi( p, iCi );
+ int w;
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimulateCo( Gia_ManSwi_t * p, int iCo, Gia_Obj_t * pObj )
+{
+ unsigned * pInfo = Gia_SwiDataCo( p, iCo );
+ unsigned * pInfo0 = Gia_SwiData( p, Gia_ObjDiff0(pObj) );
+ int w;
+ if ( Gia_ObjFaninC0(pObj) )
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~pInfo0[w];
+ else
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimulateNode( Gia_ManSwi_t * p, Gia_Obj_t * pObj )
+{
+ unsigned * pInfo = Gia_SwiData( p, Gia_ObjValue(pObj) );
+ unsigned * pInfo0 = Gia_SwiData( p, Gia_ObjDiff0(pObj) );
+ unsigned * pInfo1 = Gia_SwiData( p, Gia_ObjDiff1(pObj) );
+ int w;
+ if ( Gia_ObjFaninC0(pObj) )
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
+ else
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = ~pInfo0[w] & pInfo1[w];
+ }
+ else
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w] & ~pInfo1[w];
+ else
+ for ( w = p->nWords-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w] & pInfo1[w];
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoInit( Gia_ManSwi_t * p )
+{
+ int i = 0;
+ for ( ; i < Gia_ManPiNum(p->pAig); i++ )
+ Gia_ManSwiSimInfoRandom( p, Gia_SwiDataCi(p, i), 0 );
+ for ( ; i < Gia_ManCiNum(p->pAig); i++ )
+ Gia_ManSwiSimInfoZero( p, Gia_SwiDataCi(p, i) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoTransfer( Gia_ManSwi_t * p, int nProbNum )
+{
+ int i = 0, nShift = Gia_ManPoNum(p->pAig)-Gia_ManPiNum(p->pAig);
+ for ( ; i < Gia_ManPiNum(p->pAig); i++ )
+ Gia_ManSwiSimInfoRandom( p, Gia_SwiDataCi(p, i), nProbNum );
+ for ( ; i < Gia_ManCiNum(p->pAig); i++ )
+ Gia_ManSwiSimInfoCopy( p, Gia_SwiDataCi(p, i), Gia_SwiDataCo(p, nShift+i) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimInfoTransferShift( Gia_ManSwi_t * p, int nProbNum )
+{
+ int i = 0, nShift = Gia_ManPoNum(p->pAig)-Gia_ManPiNum(p->pAig);
+ for ( ; i < Gia_ManPiNum(p->pAig); i++ )
+ Gia_ManSwiSimInfoRandomShift( p, Gia_SwiDataCi(p, i), nProbNum );
+ for ( ; i < Gia_ManCiNum(p->pAig); i++ )
+ Gia_ManSwiSimInfoCopyShift( p, Gia_SwiDataCi(p, i), Gia_SwiDataCo(p, nShift+i) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManSwiSimInfoCountOnes( Gia_ManSwi_t * p, int iPlace )
+{
+ unsigned * pInfo;
+ int w, Counter = 0;
+ pInfo = Gia_SwiData( p, iPlace );
+ for ( w = p->nWords-1; w >= 0; w-- )
+ Counter += Aig_WordCountOnes( pInfo[w] );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManSwiSimInfoCountTrans( Gia_ManSwi_t * p, int iPlace )
+{
+ unsigned * pInfo;
+ int w, Counter = 0;
+ pInfo = Gia_SwiData( p, iPlace );
+ for ( w = p->nWords-1; w >= 0; w-- )
+ Counter += 2*Aig_WordCountOnes( (pInfo[w] ^ (pInfo[w] >> 16)) & 0xffff );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSwiSimulateRound( Gia_ManSwi_t * p, int fCount )
+{
+ Gia_Obj_t * pObj;
+ int i, iCis = 0, iCos = 0;
+ assert( p->pAig->nFront > 0 );
+ assert( Gia_ManConst0(p->pAig)->Value == 0 );
+ Gia_ManSwiSimInfoZero( p, Gia_SwiData(p, 0) );
+ Gia_ManForEachObj1( p->pAig, pObj, i )
+ {
+ if ( Gia_ObjIsAndOrConst0(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) < p->pAig->nFront );
+ Gia_ManSwiSimulateNode( p, pObj );
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) == GIA_NONE );
+ Gia_ManSwiSimulateCo( p, iCos++, pObj );
+ }
+ else // if ( Gia_ObjIsCi(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) < p->pAig->nFront );
+ Gia_ManSwiSimulateCi( p, pObj, iCis++ );
+ }
+ if ( fCount && !Gia_ObjIsCo(pObj) )
+ {
+ if ( p->pPars->fProbTrans )
+ p->pData1[i] += Gia_ManSwiSimInfoCountTrans( p, Gia_ObjValue(pObj) );
+ else
+ p->pData1[i] += Gia_ManSwiSimInfoCountOnes( p, Gia_ObjValue(pObj) );
+ }
+ }
+ assert( Gia_ManCiNum(p->pAig) == iCis );
+ assert( Gia_ManCoNum(p->pAig) == iCos );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes switching activity of one node.]
+
+ Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Gia_ManSwiComputeSwitching( int nOnes, int nSimWords )
+{
+ int nTotal = 32 * nSimWords;
+ return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes switching activity of one node.]
+
+ Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Gia_ManSwiComputeProbOne( int nOnes, int nSimWords )
+{
+ int nTotal = 32 * nSimWords;
+ return (float)nOnes / nTotal;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManSwiSimulate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars )
+{
+ Gia_ManSwi_t * p;
+ Gia_Obj_t * pObj;
+ Vec_Int_t * vSwitching;
+ float * pSwitching;
+ int i, clk, clkTotal = clock();
+ if ( pPars->fProbOne && pPars->fProbTrans )
+ printf( "Conflict of options: Can either compute probability of 1, or probability of switching by observing transitions.\n" );
+ // create manager
+ clk = clock();
+ p = Gia_ManSwiCreate( pAig, pPars );
+ if ( pPars->fVerbose )
+ {
+ printf( "Obj = %8d (%8d). F = %6d. ",
+ pAig->nObjs, Gia_ManCiNum(pAig) + Gia_ManAndNum(pAig), p->pAig->nFront,
+ 4.0*Aig_BitWordNum(2 * p->pAig->nFront)/(1<<20) );
+ printf( "AIG = %7.2f Mb. F-mem = %7.2f Mb. Other = %7.2f Mb. ",
+ 12.0*Gia_ManObjNum(p->pAig)/(1<<20),
+ 4.0*p->nWords*p->pAig->nFront/(1<<20),
+ 4.0*p->nWords*(Gia_ManCiNum(p->pAig) + Gia_ManCoNum(p->pAig))/(1<<20) );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ // perform simulation
+ Aig_ManRandom( 1 );
+ Gia_ManSwiSimInfoInit( p );
+ for ( i = 0; i < pPars->nIters; i++ )
+ {
+ Gia_ManSwiSimulateRound( p, i >= pPars->nPref );
+ if ( i == pPars->nIters - 1 )
+ break;
+ if ( pPars->fProbTrans )
+ Gia_ManSwiSimInfoTransferShift( p, pPars->nRandPiFactor );
+ else
+ Gia_ManSwiSimInfoTransfer( p, pPars->nRandPiFactor );
+ }
+ if ( pPars->fVerbose )
+ {
+ printf( "Simulated %d frames with %d words. ", pPars->nIters, pPars->nWords );
+ ABC_PRT( "Simulation time", clock() - clkTotal );
+ }
+ // derive the result
+ vSwitching = Vec_IntStart( Gia_ManObjNum(pAig) );
+ pSwitching = (float *)vSwitching->pArray;
+ if ( pPars->fProbOne )
+ {
+ Gia_ManForEachObj( pAig, pObj, i )
+ pSwitching[i] = Gia_ManSwiComputeProbOne( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
+ }
+ else if ( pPars->fProbTrans )
+ {
+ Gia_ManForEachObj( pAig, pObj, i )
+ pSwitching[i] = Gia_ManSwiComputeProbOne( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
+ }
+ else
+ {
+ Gia_ManForEachObj( pAig, pObj, i )
+ pSwitching[i] = Gia_ManSwiComputeSwitching( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
+ }
+ Gia_ManSwiDelete( p );
+ return vSwitching;
+
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes probability of switching (or of being 1).]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * pAig, int nFrames, int nPref, int fProbOne )
+{
+ extern char * Abc_FrameReadFlag( char * pFlag );
+ Gia_ParSwi_t Pars, * pPars = &Pars;
+ Vec_Int_t * vSwitching, * vResult;
+ Gia_Man_t * p;
+ Aig_Obj_t * pObj;
+ int i;
+ // set the default parameters
+ Gia_ManSetDefaultParamsSwi( pPars );
+ // override some of the defaults
+ pPars->nWords = 10; // set number machine words to simulate
+ pPars->nIters = nFrames; // set number of total timeframes
+ if ( Abc_FrameReadFlag("seqsimframes") )
+ pPars->nIters = atoi( Abc_FrameReadFlag("seqsimframes") );
+ pPars->nPref = nPref; // set number of first timeframes to skip
+ pPars->fVerbose = 0; // disable verbose output
+ // decide what should be computed
+ if ( fProbOne )
+ {
+ // if the user asked to compute propability of 1, we do not need transition information
+ pPars->fProbOne = 1; // enable computing probabiblity of being one
+ pPars->fProbTrans = 0; // disable computing transition probability
+ }
+ else
+ {
+ // if the user asked for transition propabability, we do not need to compute probability of 1
+ pPars->fProbOne = 0; // disable computing probabiblity of being one
+ pPars->fProbTrans = 1; // enable computing transition probability
+ }
+ // translate AIG into the intermediate form (takes care of choices if present!)
+ p = Gia_ManFromAigSwitch( pAig );
+ // perform the computation of switching activity
+ vSwitching = Gia_ManSwiSimulate( p, pPars );
+ // transfer the computed result to the original AIG
+ vResult = Vec_IntStart( Aig_ManObjNumMax(pAig) );
+ Aig_ManForEachObj( pAig, pObj, i )
+ Vec_IntWriteEntry( vResult, i, Vec_IntEntry(vSwitching, Gia_Lit2Var(pObj->iData)) );
+ // delete intermediate results
+ Vec_IntFree( vSwitching );
+ Gia_ManStop( p );
+ return vResult;
+}
+
+ ////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaTsim.c b/src/aig/gia/giaTsim.c
new file mode 100644
index 00000000..c7aac864
--- /dev/null
+++ b/src/aig/gia/giaTsim.c
@@ -0,0 +1,708 @@
+/**CFile****************************************************************
+
+ FileName [giaTsim.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Ternary simulation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaTsim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline int Gia_ManTerSimInfoGet( unsigned * pInfo, int i )
+{
+ return 3 & (pInfo[i >> 4] >> ((i & 15) << 1));
+}
+static inline void Gia_ManTerSimInfoSet( unsigned * pInfo, int i, int Value )
+{
+ assert( Value >= GIA_ZER && Value <= GIA_UND );
+ Value ^= Gia_ManTerSimInfoGet( pInfo, i );
+ pInfo[i >> 4] ^= (Value << ((i & 15) << 1));
+}
+
+static inline unsigned * Gia_ManTerStateNext( unsigned * pState, int nWords ) { return *((unsigned **)(pState + nWords)); }
+static inline void Gia_ManTerStateSetNext( unsigned * pState, int nWords, unsigned * pNext ) { *((unsigned **)(pState + nWords)) = pNext; }
+
+// ternary simulation manager
+typedef struct Gia_ManTer_t_ Gia_ManTer_t;
+struct Gia_ManTer_t_
+{
+ Gia_Man_t * pAig;
+ int nIters;
+ int nStateWords;
+ Vec_Ptr_t * vStates;
+ Vec_Ptr_t * vFlops;
+ int * pCount0;
+ int * pCountX;
+ // hash table for states
+ int nBins;
+ unsigned ** pBins;
+ // simulation information
+ unsigned * pDataSim; // simulation data
+ unsigned * pDataSimCis; // simulation data for CIs
+ unsigned * pDataSimCos; // simulation data for COs
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates fast simulation manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManTer_t * Gia_ManTerCreate( Gia_Man_t * pAig )
+{
+ Gia_ManTer_t * p;
+ p = ABC_CALLOC( Gia_ManTer_t, 1 );
+ p->pAig = Gia_ManFront( pAig );
+ p->nIters = 300;
+ p->pDataSim = ABC_ALLOC( unsigned, Aig_BitWordNum(2*p->pAig->nFront) );
+ p->pDataSimCis = ABC_ALLOC( unsigned, Aig_BitWordNum(2*Gia_ManCiNum(p->pAig)) );
+ p->pDataSimCos = ABC_ALLOC( unsigned, Aig_BitWordNum(2*Gia_ManCoNum(p->pAig)) );
+ // allocate storage for terminary states
+ p->nStateWords = Aig_BitWordNum( 2*Gia_ManRegNum(pAig) );
+ p->vStates = Vec_PtrAlloc( 1000 );
+ p->pCount0 = ABC_CALLOC( int, Gia_ManRegNum(pAig) );
+ p->pCountX = ABC_CALLOC( int, Gia_ManRegNum(pAig) );
+ p->nBins = Aig_PrimeCudd( 500 );
+ p->pBins = ABC_CALLOC( unsigned *, p->nBins );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTerStatesFree( Vec_Ptr_t * vStates )
+{
+ unsigned * pTemp;
+ int i;
+ Vec_PtrForEachEntry( vStates, pTemp, i )
+ ABC_FREE( pTemp );
+ Vec_PtrFree( vStates );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTerDelete( Gia_ManTer_t * p )
+{
+ if ( p->vStates )
+ Gia_ManTerStatesFree( p->vStates );
+ if ( p->vFlops )
+ Gia_ManTerStatesFree( p->vFlops );
+ Gia_ManStop( p->pAig );
+ ABC_FREE( p->pCount0 );
+ ABC_FREE( p->pCountX );
+ ABC_FREE( p->pBins );
+ ABC_FREE( p->pDataSim );
+ ABC_FREE( p->pDataSimCis );
+ ABC_FREE( p->pDataSimCos );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManTerSimulateCi( Gia_ManTer_t * p, Gia_Obj_t * pObj, int iCi )
+{
+ Gia_ManTerSimInfoSet( p->pDataSim, Gia_ObjValue(pObj), Gia_ManTerSimInfoGet(p->pDataSimCis, iCi) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManTerSimulateCo( Gia_ManTer_t * p, int iCo, Gia_Obj_t * pObj )
+{
+ int Value = Gia_ManTerSimInfoGet( p->pDataSim, Gia_ObjDiff0(pObj) );
+ Gia_ManTerSimInfoSet( p->pDataSimCos, iCo, Gia_XsimNotCond( Value, Gia_ObjFaninC0(pObj) ) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManTerSimulateNode( Gia_ManTer_t * p, Gia_Obj_t * pObj )
+{
+ int Value0 = Gia_ManTerSimInfoGet( p->pDataSim, Gia_ObjDiff0(pObj) );
+ int Value1 = Gia_ManTerSimInfoGet( p->pDataSim, Gia_ObjDiff1(pObj) );
+ Gia_ManTerSimInfoSet( p->pDataSim, Gia_ObjValue(pObj), Gia_XsimAndCond( Value0, Gia_ObjFaninC0(pObj), Value1, Gia_ObjFaninC1(pObj) ) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManTerSimInfoInit( Gia_ManTer_t * p )
+{
+ int i = 0;
+ for ( ; i < Gia_ManPiNum(p->pAig); i++ )
+ Gia_ManTerSimInfoSet( p->pDataSimCis, i, GIA_UND );
+ for ( ; i < Gia_ManCiNum(p->pAig); i++ )
+ Gia_ManTerSimInfoSet( p->pDataSimCis, i, GIA_ZER );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManTerSimInfoTransfer( Gia_ManTer_t * p )
+{
+ int i = 0;
+ for ( ; i < Gia_ManPiNum(p->pAig); i++ )
+ Gia_ManTerSimInfoSet( p->pDataSimCis, i, GIA_UND );
+ for ( ; i < Gia_ManCiNum(p->pAig); i++ )
+ Gia_ManTerSimInfoSet( p->pDataSimCis, i, Gia_ManTerSimInfoGet( p->pDataSimCos, Gia_ManCoNum(p->pAig)-Gia_ManCiNum(p->pAig)+i ) );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Computes hash value of the node using its simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManTerStateHash( unsigned * pState, int nWords, int nTableSize )
+{
+ static int s_FPrimes[128] = {
+ 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
+ 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
+ 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
+ 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
+ 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
+ 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
+ 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
+ 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
+ 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
+ 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
+ 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
+ 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
+ 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
+ };
+ unsigned uHash;
+ int i;
+ uHash = 0;
+ for ( i = 0; i < nWords; i++ )
+ uHash ^= pState[i] * s_FPrimes[i & 0x7F];
+ return uHash % nTableSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts value into the table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned * Gia_ManTerStateLookup( unsigned * pState, int nWords, unsigned ** pBins, int nBins )
+{
+ unsigned * pEntry;
+ int Hash = Gia_ManTerStateHash( pState, nWords, nBins );
+ for ( pEntry = pBins[Hash]; pEntry; pEntry = Gia_ManTerStateNext(pEntry, nWords) )
+ if ( !memcmp( pEntry, pState, sizeof(unsigned) * nWords ) )
+ return pEntry;
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts value into the table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTerStateInsert( unsigned * pState, int nWords, unsigned ** pBins, int nBins )
+{
+ int Hash = Gia_ManTerStateHash( pState, nWords, nBins );
+ assert( !Gia_ManTerStateLookup( pState, nWords, pBins, nBins ) );
+ Gia_ManTerStateSetNext( pState, nWords, pBins[Hash] );
+ pBins[Hash] = pState;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocs new ternary state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned * Gia_ManTerStateAlloc( int nWords )
+{
+ return (unsigned *)ABC_CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates new ternary state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned * Gia_ManTerStateCreate( Gia_ManTer_t * p )
+{
+ int i, Value, nPis = Gia_ManPiNum(p->pAig);
+ unsigned * pRes = Gia_ManTerStateAlloc( p->nStateWords );
+ for ( i = nPis; i < Gia_ManCiNum(p->pAig); i++ )
+ {
+ Value = Gia_ManTerSimInfoGet( p->pDataSimCis, i );
+ Gia_ManTerSimInfoSet( pRes, i-nPis, Value );
+ if ( Value == GIA_ZER )
+ p->pCount0[i-nPis]++;
+ if ( Value == GIA_UND )
+ p->pCountX[i-nPis]++;
+ }
+ Vec_PtrPush( p->vStates, pRes );
+ return pRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs one round of ternary simulation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManTerSimulateRound( Gia_ManTer_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, iCis = 0, iCos = 0;
+ assert( p->pAig->nFront > 0 );
+ assert( Gia_ManConst0(p->pAig)->Value == 0 );
+ Gia_ManTerSimInfoSet( p->pDataSim, 0, GIA_ONE );
+ Gia_ManForEachObj1( p->pAig, pObj, i )
+ {
+ if ( Gia_ObjIsAndOrConst0(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) < p->pAig->nFront );
+ Gia_ManTerSimulateNode( p, pObj );
+ }
+ else if ( Gia_ObjIsCi(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) < p->pAig->nFront );
+ Gia_ManTerSimulateCi( p, pObj, iCis++ );
+ }
+ else // if ( Gia_ObjIsCo(pObj) )
+ {
+ assert( Gia_ObjValue(pObj) == GIA_NONE );
+ Gia_ManTerSimulateCo( p, iCos++, pObj );
+ }
+ }
+ assert( Gia_ManCiNum(p->pAig) == iCis );
+ assert( Gia_ManCoNum(p->pAig) == iCos );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Retires a set of registers to speed up convergence.]
+
+ Description [Retire all non-ternary registers which has max number
+ of ternary values so far.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManTerRetire( Gia_ManTer_t * p, unsigned * pState )
+{
+ int i, iMaxTerValue = 0, Counter = 0;
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ if ( Gia_ManTerSimInfoGet( pState, i ) != GIA_UND && iMaxTerValue < p->pCountX[i] )
+ iMaxTerValue = p->pCountX[i];
+ // retire all registers with this value
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ if ( Gia_ManTerSimInfoGet( pState, i ) != GIA_UND && iMaxTerValue == p->pCountX[i] )
+ {
+ Gia_ManTerSimInfoSet( p->pDataSimCis, Gia_ManPiNum(p->pAig)+i, GIA_UND );
+ Counter++;
+ }
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts value into the table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTerStatePrint( unsigned * pState, int nRegs, int iNum )
+{
+ int i, nZeros = 0, nOnes = 0, nDcs = 0;
+ printf( " %4d : ", iNum );
+ for ( i = 0; i < nRegs; i++ )
+ {
+ if ( Gia_ManTerSimInfoGet(pState, i) == GIA_ZER )
+ printf( "0" ), nZeros++;
+ else if ( Gia_ManTerSimInfoGet(pState, i) == GIA_ONE )
+ printf( "1" ), nOnes++;
+ else if ( Gia_ManTerSimInfoGet(pState, i) == GIA_UND )
+ printf( "x" ), nDcs++;
+ else
+ assert( 0 );
+ }
+ printf( " (0=%4d, 1=%4d, x=%4d)\n", nZeros, nOnes, nDcs );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTerAnalyze2( Vec_Ptr_t * vStates, int nRegs )
+{
+ unsigned * pTemp, * pStates = Vec_PtrPop( vStates );
+ int i, w, nZeros, nConsts, nStateWords;
+ // detect constant zero registers
+ nStateWords = Aig_BitWordNum( 2*nRegs );
+ memset( pStates, 0, sizeof(int) * nStateWords );
+ Vec_PtrForEachEntry( vStates, pTemp, i )
+ for ( w = 0; w < nStateWords; w++ )
+ pStates[w] |= pTemp[w];
+ // count the number of zeros
+ nZeros = 0;
+ for ( i = 0; i < nRegs; i++ )
+ if ( Gia_ManTerSimInfoGet(pStates, i) == GIA_ZER )
+ nZeros++;
+ printf( "Found %d constant registers.\n", nZeros );
+ // detect non-ternary registers
+ memset( pStates, 0, sizeof(int) * nStateWords );
+ Vec_PtrForEachEntry( vStates, pTemp, i )
+ for ( w = 0; w < nStateWords; w++ )
+ pStates[w] |= (~(pTemp[w] ^ (pTemp[w] >> 1)) & 0x55555555);
+ // count the nonternary registers
+ nConsts = 0;
+ for ( i = 0; i < nRegs; i++ )
+ if ( Gia_ManTerSimInfoGet(pStates, i) == 0 )
+ nConsts++;
+ printf( "Found %d non-ternary registers.\n", nConsts );
+ // return the state back
+ Vec_PtrPush( vStates, pStates );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManTerAnalyze( Gia_ManTer_t * p )
+{
+ int i, nZeros = 0, nConsts = 0;
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ if ( p->pCount0[i] == Vec_PtrSize(p->vStates) )
+ nZeros++;
+ else if ( p->pCountX[i] == 0 )
+ nConsts++;
+ printf( "Found %d constant registers.\n", nZeros );
+ printf( "Found %d non-ternary registers.\n", nConsts );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Transposes state vector for non-ternary registers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Gia_ManTerTranspose( Gia_ManTer_t * p )
+{
+ Vec_Ptr_t * vFlops;
+ unsigned * pState, * pFlop;
+ int i, k, nFlopWords;
+ vFlops = Vec_PtrAlloc( 100 );
+ nFlopWords = Aig_BitWordNum( 2*Vec_PtrSize(p->vStates) );
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ {
+ if ( p->pCount0[i] == Vec_PtrSize(p->vStates) )
+ continue;
+ if ( p->pCountX[i] > 0 )
+ continue;
+ pFlop = Gia_ManTerStateAlloc( nFlopWords );
+ Vec_PtrPush( vFlops, pFlop );
+ Vec_PtrForEachEntry( p->vStates, pState, k )
+ Gia_ManTerSimInfoSet( pFlop, k, Gia_ManTerSimInfoGet(pState, i) );
+//Gia_ManTerStatePrint( pFlop, Vec_PtrSize(p->vStates), i );
+ }
+ return vFlops;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transposes state vector for non-ternary registers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManFindEqualFlop( Vec_Ptr_t * vFlops, int iFlop, int nFlopWords )
+{
+ unsigned * pFlop, * pTemp;
+ int i;
+ pFlop = Vec_PtrEntry( vFlops, iFlop );
+ Vec_PtrForEachEntryStop( vFlops, pTemp, i, iFlop )
+ if ( !memcmp( pTemp, pFlop, sizeof(unsigned) * nFlopWords ) )
+ return i;
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates map of registers to replace.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Gia_ManTerCreateMap( Gia_ManTer_t * p )
+{
+ int * pCi2Lit;
+ Gia_Obj_t * pObj;
+ Vec_Int_t * vMapKtoI;
+ int i, iRepr, nFlopWords, Counter0 = 0, CounterE = 0;
+ nFlopWords = Aig_BitWordNum( 2*Vec_PtrSize(p->vStates) );
+ p->vFlops = Gia_ManTerTranspose( p );
+ pCi2Lit = ABC_FALLOC( unsigned, Gia_ManCiNum(p->pAig) );
+ vMapKtoI = Vec_IntAlloc( 100 );
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ if ( p->pCount0[i] == Vec_PtrSize(p->vStates) )
+ pCi2Lit[Gia_ManPiNum(p->pAig)+i] = 0, Counter0++;
+ else if ( p->pCountX[i] == 0 )
+ {
+ iRepr = Gia_ManFindEqualFlop( p->vFlops, Vec_IntSize(vMapKtoI), nFlopWords );
+ Vec_IntPush( vMapKtoI, i );
+ if ( iRepr < 0 )
+ continue;
+ pObj = Gia_ManCi( p->pAig, Gia_ManPiNum(p->pAig)+Vec_IntEntry(vMapKtoI, iRepr) );
+ pCi2Lit[Gia_ManPiNum(p->pAig)+i] = Gia_Var2Lit( Gia_ObjId( p->pAig, pObj ), 0 );
+ CounterE++;
+ }
+ Vec_IntFree( vMapKtoI );
+ printf( "Transformed %d const registers and %d equiv registers.\n", Counter0, CounterE );
+ return pCi2Lit;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManTer_t * Gia_ManTerSimulate( Gia_Man_t * pAig, int fVerbose )
+{
+ Gia_ManTer_t * p;
+ unsigned * pState, * pLoop;
+ int i, Counter, clk, clkTotal = clock();
+ assert( Gia_ManRegNum(pAig) > 0 );
+ // create manager
+ clk = clock();
+ p = Gia_ManTerCreate( pAig );
+ if ( fVerbose )
+ {
+ printf( "Obj = %8d (%8d). F = %6d. ",
+ pAig->nObjs, Gia_ManCiNum(pAig) + Gia_ManAndNum(pAig), p->pAig->nFront,
+ 4.0*Aig_BitWordNum(2 * p->pAig->nFront)/(1<<20) );
+ printf( "AIG = %7.2f Mb. F-mem = %7.2f Mb. Other = %7.2f Mb. ",
+ 12.0*Gia_ManObjNum(p->pAig)/(1<<20),
+ 4.0*Aig_BitWordNum(2 * p->pAig->nFront)/(1<<20),
+ 4.0*Aig_BitWordNum(2 * (Gia_ManCiNum(pAig) + Gia_ManCoNum(pAig)))/(1<<20) );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ // perform simulation
+ Gia_ManTerSimInfoInit( p );
+ // hash the first state
+ pState = Gia_ManTerStateCreate( p );
+ Gia_ManTerStateInsert( pState, p->nStateWords, p->pBins, p->nBins );
+//Gia_ManTerStatePrint( pState, Gia_ManRegNum(pAig), 0 );
+ // perform simuluation till convergence
+ for ( i = 0; ; i++ )
+ {
+ Gia_ManTerSimulateRound( p );
+ Gia_ManTerSimInfoTransfer( p );
+ pState = Gia_ManTerStateCreate( p );
+//Gia_ManTerStatePrint( pState, Gia_ManRegNum(pAig), i+1 );
+ if ( (pLoop = Gia_ManTerStateLookup(pState, p->nStateWords, p->pBins, p->nBins)) )
+ {
+ pAig->nTerStates = Vec_PtrSize( p->vStates );
+ pAig->nTerLoop = Vec_PtrFind( p->vStates, pLoop );
+ break;
+ }
+ Gia_ManTerStateInsert( pState, p->nStateWords, p->pBins, p->nBins );
+ if ( i >= p->nIters && i % 10 == 0 )
+ {
+ Counter = Gia_ManTerRetire( p, pState );
+ if ( fVerbose )
+ printf( "Retired %d registers.\n", Counter );
+ }
+ }
+ if ( fVerbose )
+ {
+ printf( "Saturated after %d iterations. ", i+1 );
+ ABC_PRT( "Total time", clock() - clkTotal );
+ }
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManReduceConst( Gia_Man_t * pAig, int fVerbose )
+{
+ Gia_ManTer_t * p;
+ Gia_Man_t * pNew = NULL;
+ int * pCi2Lit;
+ p = Gia_ManTerSimulate( pAig, fVerbose );
+ Gia_ManTerAnalyze( p );
+ pCi2Lit = Gia_ManTerCreateMap( p );
+ Gia_ManTerDelete( p );
+ pNew = Gia_ManDupDfsCiMap( pAig, pCi2Lit, NULL );
+ ABC_FREE( pCi2Lit );
+ return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c
new file mode 100644
index 00000000..ef433159
--- /dev/null
+++ b/src/aig/gia/giaUtil.c
@@ -0,0 +1,518 @@
+/**CFile****************************************************************
+
+ FileName [giaUtil.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Various utilities.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Sets phases of the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetMark0( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ pObj->fMark0 = 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets phases of the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCleanMark0( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ pObj->fMark0 = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets phases of the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetMark1( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ pObj->fMark1 = 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets phases of the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCleanMark1( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ pObj->fMark1 = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Cleans the value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCleanValue( Gia_Man_t * p )
+{
+ int i;
+ for ( i = 0; i < p->nObjs; i++ )
+ p->pObjs[i].Value = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Cleans the value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManFillValue( Gia_Man_t * p )
+{
+ int i;
+ for ( i = 0; i < p->nObjs; i++ )
+ p->pObjs[i].Value = ~0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets phases of the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetPhase( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->fPhase = (Gia_ObjPhase(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC0(pObj)) &
+ (Gia_ObjPhase(Gia_ObjFanin1(pObj)) ^ Gia_ObjFaninC1(pObj));
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->fPhase = (Gia_ObjPhase(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC0(pObj));
+ else
+ pObj->fPhase = 0;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Assigns levels.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManLevelNum( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ if ( p->pLevels )
+ return p->nLevels;
+ p->nLevels = 0;
+ p->pLevels = ABC_ALLOC( int, p->nObjsAlloc );
+ Gia_ManForEachObj( p, pObj, i )
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ if ( p->pLevels[Gia_ObjFaninId0(pObj, i)] > p->pLevels[Gia_ObjFaninId1(pObj, i)] )
+ p->pLevels[i] = 1 + p->pLevels[Gia_ObjFaninId0(pObj, i)];
+ else
+ p->pLevels[i] = 1 + p->pLevels[Gia_ObjFaninId1(pObj, i)];
+ if ( p->nLevels < p->pLevels[i] )
+ p->nLevels = p->pLevels[i];
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ p->pLevels[i] = p->pLevels[Gia_ObjFaninId0(pObj, i)];
+ else
+ p->pLevels[i] = 0;
+ return p->nLevels;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Assigns levels.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetRefs( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ pObj->Value = 0;
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ Gia_ObjFanin0(pObj)->Value++;
+ Gia_ObjFanin1(pObj)->Value++;
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ Gia_ObjFanin0(pObj)->Value++;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Assigns references.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCreateRefs( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ assert( p->pRefs == NULL );
+ p->pRefs = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ Gia_ObjRefFanin0Inc( p, pObj );
+ Gia_ObjRefFanin1Inc( p, pObj );
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ Gia_ObjRefFanin0Inc( p, pObj );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the maximum frontier size.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCrossCut( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, nCutCur = 0, nCutMax = 0;
+ Gia_ManSetRefs( p );
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( pObj->Value )
+ nCutCur++;
+ if ( nCutMax < nCutCur )
+ nCutMax = nCutCur;
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ if ( --Gia_ObjFanin0(pObj)->Value == 0 )
+ nCutCur--;
+ if ( --Gia_ObjFanin1(pObj)->Value == 0 )
+ nCutCur--;
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ if ( --Gia_ObjFanin0(pObj)->Value == 0 )
+ nCutCur--;
+ }
+ }
+// Gia_ManForEachObj( p, pObj, i )
+// assert( pObj->Value == 0 );
+ return nCutMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Makes sure the manager is normalized.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManIsNormalized( Gia_Man_t * p )
+{
+ int i, nOffset;
+ nOffset = 1;
+ for ( i = 0; i < Gia_ManCiNum(p); i++ )
+ if ( !Gia_ObjIsCi( Gia_ManObj(p, nOffset+i) ) )
+ return 0;
+ nOffset = 1 + Gia_ManCiNum(p) + Gia_ManAndNum(p);
+ for ( i = 0; i < Gia_ManCoNum(p); i++ )
+ if ( !Gia_ObjIsCo( Gia_ManObj(p, nOffset+i) ) )
+ return 0;
+ return 1;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects PO Ids into one array.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManCollectPoIds( Gia_Man_t * p )
+{
+ Vec_Int_t * vStart;
+ int Entry, i;
+ vStart = Vec_IntAlloc( Gia_ManPoNum(p) );
+ Vec_IntForEachEntryStop( p->vCos, Entry, i, Gia_ManPoNum(p) )
+ Vec_IntPush( vStart, Entry );
+ return vStart;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ObjIsMuxType( Gia_Obj_t * pNode )
+{
+ Gia_Obj_t * pNode0, * pNode1;
+ // check that the node is regular
+ assert( !Gia_IsComplement(pNode) );
+ // if the node is not AND, this is not MUX
+ if ( !Gia_ObjIsAnd(pNode) )
+ return 0;
+ // if the children are not complemented, this is not MUX
+ if ( !Gia_ObjFaninC0(pNode) || !Gia_ObjFaninC1(pNode) )
+ return 0;
+ // get children
+ pNode0 = Gia_ObjFanin0(pNode);
+ pNode1 = Gia_ObjFanin1(pNode);
+ // if the children are not ANDs, this is not MUX
+ if ( !Gia_ObjIsAnd(pNode0) || !Gia_ObjIsAnd(pNode1) )
+ return 0;
+ // otherwise the node is MUX iff it has a pair of equal grandchildren
+ return (Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1))) ||
+ (Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1))) ||
+ (Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1))) ||
+ (Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1)));
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Recognizes what nodes are inputs of the EXOR.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ObjRecognizeExor( Gia_Obj_t * pObj, Gia_Obj_t ** ppFan0, Gia_Obj_t ** ppFan1 )
+{
+ Gia_Obj_t * p0, * p1;
+ assert( !Gia_IsComplement(pObj) );
+ if ( !Gia_ObjIsAnd(pObj) )
+ return 0;
+ assert( Gia_ObjIsAnd(pObj) );
+ p0 = Gia_ObjChild0(pObj);
+ p1 = Gia_ObjChild1(pObj);
+ if ( !Gia_IsComplement(p0) || !Gia_IsComplement(p1) )
+ return 0;
+ p0 = Gia_Regular(p0);
+ p1 = Gia_Regular(p1);
+ if ( !Gia_ObjIsAnd(p0) || !Gia_ObjIsAnd(p1) )
+ return 0;
+ if ( Gia_ObjFanin0(p0) != Gia_ObjFanin0(p1) || Gia_ObjFanin1(p0) != Gia_ObjFanin1(p1) )
+ return 0;
+ if ( Gia_ObjFaninC0(p0) == Gia_ObjFaninC0(p1) || Gia_ObjFaninC1(p0) == Gia_ObjFaninC1(p1) )
+ return 0;
+ *ppFan0 = Gia_ObjChild0(p0);
+ *ppFan1 = Gia_ObjChild1(p0);
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Recognizes what nodes are control and data inputs of a MUX.]
+
+ Description [If the node is a MUX, returns the control variable C.
+ Assigns nodes T and E to be the then and else variables of the MUX.
+ Node C is never complemented. Nodes T and E can be complemented.
+ This function also recognizes EXOR/NEXOR gates as MUXes.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Obj_t * Gia_ObjRecognizeMux( Gia_Obj_t * pNode, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE )
+{
+ Gia_Obj_t * pNode0, * pNode1;
+ assert( !Gia_IsComplement(pNode) );
+ assert( Gia_ObjIsMuxType(pNode) );
+ // get children
+ pNode0 = Gia_ObjFanin0(pNode);
+ pNode1 = Gia_ObjFanin1(pNode);
+
+ // find the control variable
+ if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p2) )
+ if ( Gia_ObjFaninC1(pNode0) )
+ { // pNode2->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ return Gia_ObjChild1(pNode1);//pNode2->p2;
+ }
+ else
+ { // pNode1->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ return Gia_ObjChild1(pNode0);//pNode1->p2;
+ }
+ }
+ else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p1) )
+ if ( Gia_ObjFaninC0(pNode0) )
+ { // pNode2->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ return Gia_ObjChild0(pNode1);//pNode2->p1;
+ }
+ else
+ { // pNode1->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ return Gia_ObjChild0(pNode0);//pNode1->p1;
+ }
+ }
+ else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p1) )
+ if ( Gia_ObjFaninC0(pNode0) )
+ { // pNode2->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ return Gia_ObjChild1(pNode1);//pNode2->p2;
+ }
+ else
+ { // pNode1->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1);
+ return Gia_ObjChild0(pNode0);//pNode1->p1;
+ }
+ }
+ else if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1)) )
+ {
+// if ( FrGia_IsComplement(pNode1->p2) )
+ if ( Gia_ObjFaninC1(pNode0) )
+ { // pNode2->p1 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ return Gia_ObjChild0(pNode1);//pNode2->p1;
+ }
+ else
+ { // pNode1->p2 is positive phase of C
+ *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1);
+ *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2);
+ return Gia_ObjChild1(pNode0);//pNode1->p2;
+ }
+ }
+ assert( 0 ); // this is not MUX
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/aig/gia/module.make b/src/aig/gia/module.make
new file mode 100644
index 00000000..67798476
--- /dev/null
+++ b/src/aig/gia/module.make
@@ -0,0 +1,19 @@
+SRC += src/aig/gia/gia.c \
+ src/aig/gia/giaAig.c \
+ src/aig/gia/giaAiger.c \
+ src/aig/gia/giaCof.c \
+ src/aig/gia/giaDfs.c \
+ src/aig/gia/giaDup.c \
+ src/aig/gia/giaFanout.c \
+ src/aig/gia/giaForce.c \
+ src/aig/gia/giaFrames.c \
+ src/aig/gia/giaFront.c \
+ src/aig/gia/giaGlitch.c \
+ src/aig/gia/giaHash.c \
+ src/aig/gia/giaLogic.c \
+ src/aig/gia/giaMan.c \
+ src/aig/gia/giaScl.c \
+ src/aig/gia/giaSim.c \
+ src/aig/gia/giaSwitch.c \
+ src/aig/gia/giaTsim.c \
+ src/aig/gia/giaUtil.c
diff --git a/src/aig/hop/cudd2.h b/src/aig/hop/cudd2.h
index 69711c11..27359b3f 100644
--- a/src/aig/hop/cudd2.h
+++ b/src/aig/hop/cudd2.h
@@ -21,10 +21,6 @@
#ifndef __CUDD2_H__
#define __CUDD2_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
// HA: Added for printing messages
#ifndef MSG
#define MSG(msg) (printf("%s = \n",(msg)));
@@ -38,6 +34,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/hop/hop.h b/src/aig/hop/hop.h
index 6ffc4eac..1e58e825 100644
--- a/src/aig/hop/hop.h
+++ b/src/aig/hop/hop.h
@@ -21,10 +21,6 @@
#ifndef __HOP_H__
#define __HOP_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -41,6 +37,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -102,7 +102,7 @@ struct Hop_Man_t_
// memory management
Vec_Ptr_t * vChunks; // allocated memory pieces
Vec_Ptr_t * vPages; // memory pages used by nodes
- Hop_Obj_t * pListFree; // the list of free nodes
+ Hop_Obj_t * pListFree; // the list of ABC_FREE nodes
// timing statistics
int time1;
int time2;
@@ -115,10 +115,6 @@ struct Hop_Man_t_
#define AIG_MIN(a,b) (((a) < (b))? (a) : (b))
#define AIG_MAX(a,b) (((a) > (b))? (a) : (b))
-#ifndef PRT
-#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
-#endif
-
static inline int Hop_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
static inline int Hop_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline int Hop_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
@@ -127,10 +123,10 @@ static inline void Hop_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^=
static inline int Hop_Base2Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
static inline int Hop_Base10Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
-static inline Hop_Obj_t * Hop_Regular( Hop_Obj_t * p ) { return (Hop_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); }
-static inline Hop_Obj_t * Hop_Not( Hop_Obj_t * p ) { return (Hop_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); }
-static inline Hop_Obj_t * Hop_NotCond( Hop_Obj_t * p, int c ) { return (Hop_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); }
-static inline int Hop_IsComplement( Hop_Obj_t * p ) { return (int)((PORT_PTRUINT_T)(p) & 01); }
+static inline Hop_Obj_t * Hop_Regular( Hop_Obj_t * p ) { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
+static inline Hop_Obj_t * Hop_Not( Hop_Obj_t * p ) { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
+static inline Hop_Obj_t * Hop_NotCond( Hop_Obj_t * p, int c ) { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
+static inline int Hop_IsComplement( Hop_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); }
static inline Hop_Obj_t * Hop_ManConst0( Hop_Man_t * p ) { return Hop_Not(p->pConst1); }
static inline Hop_Obj_t * Hop_ManConst1( Hop_Man_t * p ) { return p->pConst1; }
@@ -169,13 +165,13 @@ static inline int Hop_ObjIsMarkA( Hop_Obj_t * pObj ) { return pObj-
static inline void Hop_ObjSetMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 1; }
static inline void Hop_ObjClearMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 0; }
-static inline void Hop_ObjSetTravId( Hop_Obj_t * pObj, int TravId ) { pObj->pData = (void *)(PORT_PTRINT_T)TravId; }
-static inline void Hop_ObjSetTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(PORT_PTRINT_T)p->nTravIds; }
-static inline void Hop_ObjSetTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(PORT_PTRINT_T)(p->nTravIds - 1); }
-static inline int Hop_ObjIsTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(PORT_PTRINT_T)pObj->pData == p->nTravIds); }
-static inline int Hop_ObjIsTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(PORT_PTRINT_T)pObj->pData == p->nTravIds - 1); }
+static inline void Hop_ObjSetTravId( Hop_Obj_t * pObj, int TravId ) { pObj->pData = (void *)(ABC_PTRINT_T)TravId; }
+static inline void Hop_ObjSetTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(ABC_PTRINT_T)p->nTravIds; }
+static inline void Hop_ObjSetTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(ABC_PTRINT_T)(p->nTravIds - 1); }
+static inline int Hop_ObjIsTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(ABC_PTRINT_T)pObj->pData == p->nTravIds); }
+static inline int Hop_ObjIsTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(ABC_PTRINT_T)pObj->pData == p->nTravIds - 1); }
-static inline int Hop_ObjTravId( Hop_Obj_t * pObj ) { return (int)(PORT_PTRINT_T)pObj->pData; }
+static inline int Hop_ObjTravId( Hop_Obj_t * pObj ) { return (int)(ABC_PTRINT_T)pObj->pData; }
static inline int Hop_ObjPhase( Hop_Obj_t * pObj ) { return pObj->fPhase; }
static inline int Hop_ObjRefs( Hop_Obj_t * pObj ) { return pObj->nRefs; }
static inline void Hop_ObjRef( Hop_Obj_t * pObj ) { pObj->nRefs++; }
diff --git a/src/aig/hop/hopDfs.c b/src/aig/hop/hopDfs.c
index bf196aea..3dd8793c 100644
--- a/src/aig/hop/hopDfs.c
+++ b/src/aig/hop/hopDfs.c
@@ -123,15 +123,15 @@ int Hop_ManCountLevels( Hop_Man_t * p )
vNodes = Hop_ManDfs( p );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
- Level0 = (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData;
- Level1 = (int)(PORT_PTRUINT_T)Hop_ObjFanin1(pObj)->pData;
- pObj->pData = (void *)(PORT_PTRUINT_T)(1 + Hop_ObjIsExor(pObj) + AIG_MAX(Level0, Level1));
+ Level0 = (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData;
+ Level1 = (int)(ABC_PTRUINT_T)Hop_ObjFanin1(pObj)->pData;
+ pObj->pData = (void *)(ABC_PTRUINT_T)(1 + Hop_ObjIsExor(pObj) + AIG_MAX(Level0, Level1));
}
Vec_PtrFree( vNodes );
// get levels of the POs
LevelsMax = 0;
Hop_ManForEachPo( p, pObj, i )
- LevelsMax = AIG_MAX( LevelsMax, (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData );
+ LevelsMax = AIG_MAX( LevelsMax, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData );
return LevelsMax;
}
diff --git a/src/aig/hop/hopMan.c b/src/aig/hop/hopMan.c
index 99f5d316..bf38a780 100644
--- a/src/aig/hop/hopMan.c
+++ b/src/aig/hop/hopMan.c
@@ -43,7 +43,7 @@ Hop_Man_t * Hop_ManStart()
{
Hop_Man_t * p;
// start the manager
- p = ALLOC( Hop_Man_t, 1 );
+ p = ABC_ALLOC( Hop_Man_t, 1 );
memset( p, 0, sizeof(Hop_Man_t) );
// perform initializations
p->nTravIds = 1;
@@ -62,7 +62,7 @@ Hop_Man_t * Hop_ManStart()
// start the table
// p->nTableSize = 107;
p->nTableSize = 10007;
- p->pTable = ALLOC( Hop_Obj_t *, p->nTableSize );
+ p->pTable = ABC_ALLOC( Hop_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
return p;
}
@@ -92,15 +92,15 @@ void Hop_ManStop( Hop_Man_t * p )
Hop_ManForEachNode( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
// print time
- if ( p->time1 ) { PRT( "time1", p->time1 ); }
- if ( p->time2 ) { PRT( "time2", p->time2 ); }
+ if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); }
+ if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); }
// Hop_TableProfile( p );
if ( p->vChunks ) Hop_ManStopMemory( p );
if ( p->vPis ) Vec_PtrFree( p->vPis );
if ( p->vPos ) Vec_PtrFree( p->vPos );
if ( p->vObjs ) Vec_PtrFree( p->vObjs );
- free( p->pTable );
- free( p );
+ ABC_FREE( p->pTable );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/hop/hopMem.c b/src/aig/hop/hopMem.c
index 60f89d53..c6d05865 100644
--- a/src/aig/hop/hopMem.c
+++ b/src/aig/hop/hopMem.c
@@ -65,7 +65,7 @@ void Hop_ManStopMemory( Hop_Man_t * p )
void * pMemory;
int i;
Vec_PtrForEachEntry( p->vChunks, pMemory, i )
- free( pMemory );
+ ABC_FREE( pMemory );
Vec_PtrFree( p->vChunks );
Vec_PtrFree( p->vPages );
p->pListFree = NULL;
@@ -92,10 +92,10 @@ void Hop_ManAddMemory( Hop_Man_t * p )
// assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
// allocate new memory page
nBytes = sizeof(Hop_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
- pMemory = ALLOC( char, nBytes );
+ pMemory = ABC_ALLOC( char, nBytes );
Vec_PtrPush( p->vChunks, pMemory );
// align memory at the 32-byte boundary
- pMemory = pMemory + 64 - (((int)(PORT_PTRUINT_T)pMemory) & 63);
+ pMemory = pMemory + 64 - (((int)(ABC_PTRUINT_T)pMemory) & 63);
// remember the manager in the first entry
Vec_PtrPush( p->vPages, pMemory );
// break the memory down into nodes
diff --git a/src/aig/hop/hopObj.c b/src/aig/hop/hopObj.c
index f173248f..eccf58b8 100644
--- a/src/aig/hop/hopObj.c
+++ b/src/aig/hop/hopObj.c
@@ -193,7 +193,7 @@ void Hop_ObjDelete( Hop_Man_t * p, Hop_Obj_t * pObj )
// remove PIs/POs from the arrays
if ( Hop_ObjIsPi(pObj) )
Vec_PtrRemove( p->vPis, pObj );
- // free the node
+ // ABC_FREE the node
Hop_ManRecycleMemory( p, pObj );
}
diff --git a/src/aig/hop/hopTable.c b/src/aig/hop/hopTable.c
index 76390054..cfc6add0 100644
--- a/src/aig/hop/hopTable.c
+++ b/src/aig/hop/hopTable.c
@@ -172,7 +172,7 @@ clk = clock();
nTableSizeOld = p->nTableSize;
// get the new table
p->nTableSize = Cudd_PrimeAig( 2 * Hop_ManNodeNum(p) );
- p->pTable = ALLOC( Hop_Obj_t *, p->nTableSize );
+ p->pTable = ABC_ALLOC( Hop_Obj_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
// rehash the entries from the old table
Counter = 0;
@@ -190,9 +190,9 @@ clk = clock();
nEntries = Hop_ManNodeNum(p);
assert( Counter == nEntries );
// printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
// replace the table and the parameters
- free( pTableOld );
+ ABC_FREE( pTableOld );
}
/**Function********************************************************************
diff --git a/src/aig/hop/hopUtil.c b/src/aig/hop/hopUtil.c
index d9dbbcaa..d541ab99 100644
--- a/src/aig/hop/hopUtil.c
+++ b/src/aig/hop/hopUtil.c
@@ -516,13 +516,13 @@ void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName )
// collect nodes in the DFS order
vNodes = Hop_ManDfs( p );
// assign IDs to objects
- Hop_ManConst1(p)->pData = (void *)(PORT_PTRUINT_T)Counter++;
+ Hop_ManConst1(p)->pData = (void *)(ABC_PTRUINT_T)Counter++;
Hop_ManForEachPi( p, pObj, i )
- pObj->pData = (void *)(PORT_PTRUINT_T)Counter++;
+ pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
Hop_ManForEachPo( p, pObj, i )
- pObj->pData = (void *)(PORT_PTRUINT_T)Counter++;
+ pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pData = (void *)(PORT_PTRUINT_T)Counter++;
+ pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
nDigits = Hop_Base10Log( Counter );
// write the file
pFile = fopen( pFileName, "w" );
@@ -532,34 +532,34 @@ void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName )
// write PIs
fprintf( pFile, ".inputs" );
Hop_ManForEachPi( p, pObj, i )
- fprintf( pFile, " n%0*d", nDigits, (int)(PORT_PTRUINT_T)pObj->pData );
+ fprintf( pFile, " n%0*d", nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
fprintf( pFile, "\n" );
// write POs
fprintf( pFile, ".outputs" );
Hop_ManForEachPo( p, pObj, i )
- fprintf( pFile, " n%0*d", nDigits, (int)(PORT_PTRUINT_T)pObj->pData );
+ fprintf( pFile, " n%0*d", nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
fprintf( pFile, "\n" );
// write nodes
Vec_PtrForEachEntry( vNodes, pObj, i )
{
fprintf( pFile, ".names n%0*d n%0*d n%0*d\n",
- nDigits, (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData,
- nDigits, (int)(PORT_PTRUINT_T)Hop_ObjFanin1(pObj)->pData,
- nDigits, (int)(PORT_PTRUINT_T)pObj->pData );
+ nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData,
+ nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin1(pObj)->pData,
+ nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
fprintf( pFile, "%d%d 1\n", !Hop_ObjFaninC0(pObj), !Hop_ObjFaninC1(pObj) );
}
// write POs
Hop_ManForEachPo( p, pObj, i )
{
fprintf( pFile, ".names n%0*d n%0*d\n",
- nDigits, (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData,
- nDigits, (int)(PORT_PTRUINT_T)pObj->pData );
+ nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData,
+ nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
fprintf( pFile, "%d 1\n", !Hop_ObjFaninC0(pObj) );
if ( Hop_ObjIsConst1(Hop_ObjFanin0(pObj)) )
pConst1 = Hop_ManConst1(p);
}
if ( pConst1 )
- fprintf( pFile, ".names n%0*d\n 1\n", nDigits, (int)(PORT_PTRUINT_T)pConst1->pData );
+ fprintf( pFile, ".names n%0*d\n 1\n", nDigits, (int)(ABC_PTRUINT_T)pConst1->pData );
fprintf( pFile, ".end\n\n" );
fclose( pFile );
Vec_PtrFree( vNodes );
diff --git a/src/aig/int/int.h b/src/aig/int/int.h
index e0c4e960..c9c5cd1a 100644
--- a/src/aig/int/int.h
+++ b/src/aig/int/int.h
@@ -21,10 +21,6 @@
#ifndef __INT_H__
#define __INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/*
The interpolation algorithm implemented here was introduced in the paper:
K. L. McMillan. Interpolation and SAT-based model checking. CAV’03, pp. 1-13.
@@ -38,6 +34,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/int/intContain.c b/src/aig/int/intContain.c
index dcc80b29..3c16629f 100644
--- a/src/aig/int/intContain.c
+++ b/src/aig/int/intContain.c
@@ -231,7 +231,7 @@ int Inter_ManCheckInductiveContainment( Aig_Man_t * pTrans, Aig_Man_t * pInter,
}
// solve the problem
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
// Inter_ManCheckUniqueness( pTrans, pSat, pCnf, nSteps );
@@ -317,7 +317,7 @@ int Inter_ManCheckUniqueness( Aig_Man_t * p, sat_solver * pSat, Cnf_Dat_t * pCnf
printf( "Uniquness does not hold in %d frames.\n", Counter );
Fra_SmlStop( pSml );
- free( pCounterEx );
+ ABC_FREE( pCounterEx );
return 1;
}
diff --git a/src/aig/int/intCore.c b/src/aig/int/intCore.c
index 8fe15cda..cab0302f 100644
--- a/src/aig/int/intCore.c
+++ b/src/aig/int/intCore.c
@@ -146,7 +146,7 @@ p->timeCnf += clock() - clk;
{
printf( "Step = %2d. Frames = 1 + %d. And = %5d. Lev = %5d. ",
s+1, p->nFrames, Aig_ManNodeNum(p->pFrames), Aig_ManLevelNum(p->pFrames) );
- PRT( "Time", clock() - clk2 );
+ ABC_PRT( "Time", clock() - clk2 );
}
// iterate the interpolation procedure
for ( i = 0; ; i++ )
@@ -176,7 +176,7 @@ p->timeCnf += clock() - clk;
{
printf( " I = %2d. Bmc =%3d. IntAnd =%6d. IntLev =%5d. Conf =%6d. ",
i+1, i + 1 + p->nFrames, Aig_ManNodeNum(p->pInter), Aig_ManLevelNum(p->pInter), p->nConfCur );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
if ( RetValue == 0 ) // found a (spurious?) counter-example
{
diff --git a/src/aig/int/intCtrex.c b/src/aig/int/intCtrex.c
index 4cbe2007..98c01de6 100644
--- a/src/aig/int/intCtrex.c
+++ b/src/aig/int/intCtrex.c
@@ -123,7 +123,7 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose )
return NULL;
}
// solve the miter
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
// if the problem is SAT, get the counterexample
if ( status == l_True )
{
@@ -134,9 +134,9 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose )
for ( i = 0; i < Vec_IntSize(vCiIds); i++ )
if ( pModel[i] )
Aig_InfoSetBit( pCtrex->pData, Saig_ManRegNum(pAig) + i );
- free( pModel );
+ ABC_FREE( pModel );
}
- // free the sat_solver
+ // ABC_FREE the sat_solver
sat_solver_delete( pSat );
Vec_IntFree( vCiIds );
// verify counter-example
@@ -146,7 +146,7 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose )
// report the results
if ( fVerbose )
{
- PRT( "Total ctrex generation time", clock() - clk );
+ ABC_PRT( "Total ctrex generation time", clock() - clk );
}
return pCtrex;
diff --git a/src/aig/int/intDup.c b/src/aig/int/intDup.c
index 3e5aaa7e..4c5b7ab6 100644
--- a/src/aig/int/intDup.c
+++ b/src/aig/int/intDup.c
@@ -46,13 +46,13 @@ Aig_Man_t * Inter_ManStartInitState( int nRegs )
Aig_Obj_t ** ppInputs;
int i;
assert( nRegs > 0 );
- ppInputs = ALLOC( Aig_Obj_t *, nRegs );
+ ppInputs = ABC_ALLOC( Aig_Obj_t *, nRegs );
p = Aig_ManStart( nRegs );
for ( i = 0; i < nRegs; i++ )
ppInputs[i] = Aig_Not( Aig_ObjCreatePi(p) );
pRes = Aig_Multi( p, ppInputs, nRegs, AIG_OBJ_AND );
Aig_ObjCreatePo( p, pRes );
- free( ppInputs );
+ ABC_FREE( ppInputs );
return p;
}
diff --git a/src/aig/int/intInt.h b/src/aig/int/intInt.h
index c84fef2d..2d571f09 100644
--- a/src/aig/int/intInt.h
+++ b/src/aig/int/intInt.h
@@ -21,10 +21,6 @@
#ifndef __INT_INT_H__
#define __INT_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -39,6 +35,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/int/intM114.c b/src/aig/int/intM114.c
index dbf078e2..359d5458 100644
--- a/src/aig/int/intM114.c
+++ b/src/aig/int/intM114.c
@@ -217,19 +217,19 @@ int Inter_ManPerformOneStep( Inter_Man_t * p, int fUseBias, int fUseBackward )
}
// collect global variables
- pGlobalVars = CALLOC( int, sat_solver_nvars(pSat) );
+ pGlobalVars = ABC_CALLOC( int, sat_solver_nvars(pSat) );
Vec_IntForEachEntry( p->vVarsAB, Var, i )
pGlobalVars[Var] = 1;
pSat->pGlobalVars = fUseBias? pGlobalVars : NULL;
// solve the problem
clk = clock();
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->nConfLimit, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
p->nConfCur = pSat->stats.conflicts;
p->timeSat += clock() - clk;
pSat->pGlobalVars = NULL;
- FREE( pGlobalVars );
+ ABC_FREE( pGlobalVars );
if ( status == l_False )
{
pSatCnf = sat_solver_store_release( pSat );
diff --git a/src/aig/int/intMan.c b/src/aig/int/intMan.c
index ec5d06d3..14a79f65 100644
--- a/src/aig/int/intMan.c
+++ b/src/aig/int/intMan.c
@@ -43,7 +43,7 @@ Inter_Man_t * Inter_ManCreate( Aig_Man_t * pAig, Inter_ManParams_t * pPars )
{
Inter_Man_t * p;
// create interpolation manager
- p = ALLOC( Inter_Man_t, 1 );
+ p = ABC_ALLOC( Inter_Man_t, 1 );
memset( p, 0, sizeof(Inter_Man_t) );
p->vVarsAB = Vec_IntAlloc( Aig_ManRegNum(pAig) );
p->nConfLimit = pPars->nBTLimit;
@@ -92,13 +92,13 @@ void Inter_ManStop( Inter_Man_t * p )
{
p->timeOther = p->timeTotal-p->timeRwr-p->timeCnf-p->timeSat-p->timeInt-p->timeEqu;
printf( "Runtime statistics:\n" );
- PRTP( "Rewriting ", p->timeRwr, p->timeTotal );
- PRTP( "CNF mapping", p->timeCnf, p->timeTotal );
- PRTP( "SAT solving", p->timeSat, p->timeTotal );
- PRTP( "Interpol ", p->timeInt, p->timeTotal );
- PRTP( "Containment", p->timeEqu, p->timeTotal );
- PRTP( "Other ", p->timeOther, p->timeTotal );
- PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+ ABC_PRTP( "Rewriting ", p->timeRwr, p->timeTotal );
+ ABC_PRTP( "CNF mapping", p->timeCnf, p->timeTotal );
+ ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal );
+ ABC_PRTP( "Interpol ", p->timeInt, p->timeTotal );
+ ABC_PRTP( "Containment", p->timeEqu, p->timeTotal );
+ ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
+ ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
}
if ( p->pCnfAig )
@@ -116,7 +116,7 @@ void Inter_ManStop( Inter_Man_t * p )
Aig_ManStop( p->pInter );
if ( p->pInterNew )
Aig_ManStop( p->pInterNew );
- free( p );
+ ABC_FREE( p );
}
diff --git a/src/aig/int/intUtil.c b/src/aig/int/intUtil.c
index 722a3611..c0dc9ddb 100644
--- a/src/aig/int/intUtil.c
+++ b/src/aig/int/intUtil.c
@@ -51,9 +51,9 @@ int Inter_ManCheckInitialState( Aig_Man_t * p )
Cnf_DataFree( pCnf );
if ( pSat == NULL )
return 0;
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
sat_solver_delete( pSat );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
return status == l_True;
}
@@ -79,9 +79,9 @@ int Inter_ManCheckAllStates( Aig_Man_t * p )
Cnf_DataFree( pCnf );
if ( pSat == NULL )
return 1;
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
sat_solver_delete( pSat );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
return status == l_False;
}
diff --git a/src/aig/ioa/ioa.h b/src/aig/ioa/ioa.h
index be8594e7..55d95f6e 100644
--- a/src/aig/ioa/ioa.h
+++ b/src/aig/ioa/ioa.h
@@ -21,10 +21,6 @@
#ifndef __IOA_H__
#define __IOA_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -43,6 +39,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ioa/ioaReadAig.c b/src/aig/ioa/ioaReadAig.c
index 342bd9fa..11c866f4 100644
--- a/src/aig/ioa/ioaReadAig.c
+++ b/src/aig/ioa/ioaReadAig.c
@@ -112,7 +112,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
// read the file into the buffer
nFileSize = Ioa_FileSize( pFileName );
pFile = fopen( pFileName, "rb" );
- pContents = ALLOC( char, nFileSize );
+ pContents = ABC_ALLOC( char, nFileSize );
fread( pContents, nFileSize, 1, pFile );
fclose( pFile );
@@ -120,6 +120,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') )
{
fprintf( stdout, "Wrong input file format.\n" );
+ free( pContents );
return NULL;
}
@@ -147,7 +148,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
pName = Ioa_FileNameGeneric( pFileName );
pNew->pName = Aig_UtilStrsav( pName );
// pNew->pSpec = Ioa_UtilStrsav( pFileName );
- free( pName );
+ ABC_FREE( pName );
// prepare the array of nodes
vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds );
@@ -342,7 +343,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
*/
// skipping the comments
- free( pContents );
+ ABC_FREE( pContents );
Vec_PtrFree( vNodes );
// remove the extra nodes
diff --git a/src/aig/ioa/ioaWriteAig.c b/src/aig/ioa/ioaWriteAig.c
index ec37b40e..3d37c0a7 100644
--- a/src/aig/ioa/ioaWriteAig.c
+++ b/src/aig/ioa/ioaWriteAig.c
@@ -329,7 +329,7 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int
// write the nodes into the buffer
Pos = 0;
nBufferSize = 6 * Aig_ManNodeNum(pMan) + 100; // skeptically assuming 3 chars per one AIG edge
- pBuffer = ALLOC( unsigned char, nBufferSize );
+ pBuffer = ABC_ALLOC( unsigned char, nBufferSize );
// pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(pMan) );
Aig_ManForEachNode( pMan, pObj, i )
{
@@ -337,7 +337,13 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int
uLit = Ioa_ObjMakeLit( Ioa_ObjAigerNum(pObj), 0 );
uLit0 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj) );
uLit1 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj) );
- assert( uLit0 < uLit1 );
+ assert( uLit0 != uLit1 );
+ if ( uLit0 > uLit1 )
+ {
+ int Temp = uLit0;
+ uLit0 = uLit1;
+ uLit1 = Temp;
+ }
Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit - uLit1 );
Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 );
if ( Pos > nBufferSize - 10 )
@@ -352,7 +358,7 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int
// write the buffer
fwrite( pBuffer, 1, Pos, pFile );
- free( pBuffer );
+ ABC_FREE( pBuffer );
/*
// write the symbol table
if ( fWriteSymbols )
diff --git a/src/aig/ivy/attr.h b/src/aig/ivy/attr.h
index 16cf0b84..ad342ce9 100644
--- a/src/aig/ivy/attr.h
+++ b/src/aig/ivy/attr.h
@@ -21,10 +21,6 @@
#ifndef __ATTR_H__
#define __ATTR_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -35,6 +31,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ivy/ivy.h b/src/aig/ivy/ivy.h
index 9832e061..2c915e5b 100644
--- a/src/aig/ivy/ivy.h
+++ b/src/aig/ivy/ivy.h
@@ -21,10 +21,6 @@
#ifndef __IVY_H__
#define __IVY_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,6 +33,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -121,7 +121,7 @@ struct Ivy_Man_t_
// memory management
Vec_Ptr_t * vChunks; // allocated memory pieces
Vec_Ptr_t * vPages; // memory pages used by nodes
- Ivy_Obj_t * pListFree; // the list of free nodes
+ Ivy_Obj_t * pListFree; // the list of ABC_FREE nodes
// timing statistics
int time1;
int time2;
@@ -186,10 +186,10 @@ static inline int Ivy_InfoHasBit( unsigned * p, int i ) { return (p[(i
static inline void Ivy_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); }
static inline void Ivy_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); }
-static inline Ivy_Obj_t * Ivy_Regular( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); }
-static inline Ivy_Obj_t * Ivy_Not( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); }
-static inline Ivy_Obj_t * Ivy_NotCond( Ivy_Obj_t * p, int c ) { return (Ivy_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); }
-static inline int Ivy_IsComplement( Ivy_Obj_t * p ) { return (int)((PORT_PTRUINT_T)(p) & 01); }
+static inline Ivy_Obj_t * Ivy_Regular( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
+static inline Ivy_Obj_t * Ivy_Not( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
+static inline Ivy_Obj_t * Ivy_NotCond( Ivy_Obj_t * p, int c ) { return (Ivy_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
+static inline int Ivy_IsComplement( Ivy_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); }
static inline Ivy_Obj_t * Ivy_ManConst0( Ivy_Man_t * p ) { return Ivy_Not(p->pConst1); }
static inline Ivy_Obj_t * Ivy_ManConst1( Ivy_Man_t * p ) { return p->pConst1; }
diff --git a/src/aig/ivy/ivyCut.c b/src/aig/ivy/ivyCut.c
index b0dd6db7..e3651645 100644
--- a/src/aig/ivy/ivyCut.c
+++ b/src/aig/ivy/ivyCut.c
@@ -980,7 +980,7 @@ void Ivy_ManTestCutsAll( Ivy_Man_t * p )
}
printf( "Total cuts = %6d. Trivial = %6d. Nodes = %6d. Satur = %6d. ",
nCutsTotal, Ivy_ManPiNum(p) + Ivy_ManNodeNum(p), nNodeTotal, nNodeOver );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ivy/ivyCutTrav.c b/src/aig/ivy/ivyCutTrav.c
index ea57c9f5..a52bbcf9 100644
--- a/src/aig/ivy/ivyCutTrav.c
+++ b/src/aig/ivy/ivyCutTrav.c
@@ -457,7 +457,7 @@ void Ivy_ManTestCutsTravAll( Ivy_Man_t * p )
}
printf( "Total cuts = %6d. Trivial = %6d. Nodes = %6d. Satur = %6d. ",
nCutsTotal, Ivy_ManPiNum(p) + Ivy_ManNodeNum(p), nNodeTotal, nNodeOver );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
Vec_PtrFree( vNodes );
Vec_PtrFree( vFront );
diff --git a/src/aig/ivy/ivyFastMap.c b/src/aig/ivy/ivyFastMap.c
index 6ee177a4..0c0102c0 100644
--- a/src/aig/ivy/ivyFastMap.c
+++ b/src/aig/ivy/ivyFastMap.c
@@ -105,12 +105,12 @@ void Ivy_FastMapPerform( Ivy_Man_t * pAig, int nLimit, int fRecovery, int fVerbo
Ivy_Obj_t * pObj;
int i, Delay, Area, clk, clkTotal = clock();
// start the memory for supports
- pMan = ALLOC( Ivy_SuppMan_t, 1 );
+ pMan = ABC_ALLOC( Ivy_SuppMan_t, 1 );
memset( pMan, 0, sizeof(Ivy_SuppMan_t) );
pMan->nLimit = nLimit;
pMan->nObjs = Ivy_ManObjIdMax(pAig) + 1;
pMan->nSize = sizeof(Ivy_Supp_t) + nLimit * sizeof(int);
- pMan->pMem = (char *)malloc( pMan->nObjs * pMan->nSize );
+ pMan->pMem = (char *)ABC_ALLOC( char, pMan->nObjs * pMan->nSize );
memset( pMan->pMem, 0, pMan->nObjs * pMan->nSize );
pMan->vLuts = Vec_VecAlloc( 100 );
pAig->pData = pMan;
@@ -191,8 +191,8 @@ void Ivy_FastMapStop( Ivy_Man_t * pAig )
{
Ivy_SuppMan_t * p = pAig->pData;
Vec_VecFree( p->vLuts );
- free( p->pMem );
- free( p );
+ ABC_FREE( p->pMem );
+ ABC_FREE( p );
pAig->pData = NULL;
}
@@ -210,7 +210,7 @@ void Ivy_FastMapStop( Ivy_Man_t * pAig )
void Ivy_FastMapPrint( Ivy_Man_t * pAig, int Delay, int Area, int Time, char * pStr )
{
printf( "%s : Delay = %3d. Area = %6d. ", pStr, Delay, Area );
- PRT( "Time", Time );
+ ABC_PRT( "Time", Time );
}
/**Function*************************************************************
diff --git a/src/aig/ivy/ivyFraig.c b/src/aig/ivy/ivyFraig.c
index 7c5a139c..c0ec3021 100644
--- a/src/aig/ivy/ivyFraig.c
+++ b/src/aig/ivy/ivyFraig.c
@@ -50,9 +50,9 @@ struct Ivy_FraigMan_t_
{
// general info
Ivy_FraigParams_t * pParams; // various parameters
- // temporary backtrack limits because "sint64" cannot be defined in Ivy_FraigParams_t ...
- sint64 nBTLimitGlobal; // global limit on the number of backtracks
- sint64 nInsLimitGlobal;// global limit on the number of clause inspects
+ // temporary backtrack limits because "ABC_INT64_T" cannot be defined in Ivy_FraigParams_t ...
+ ABC_INT64_T nBTLimitGlobal; // global limit on the number of backtracks
+ ABC_INT64_T nInsLimitGlobal;// global limit on the number of clause inspects
// AIG manager
Ivy_Man_t * pManAig; // the starting AIG manager
Ivy_Man_t * pManFraig; // the final AIG manager
@@ -126,11 +126,11 @@ struct Prove_ParamsStruct_t_
// last-gasp mitering
int nMiteringLimitLast; // final mitering limit
// global SAT solver limits
- sint64 nTotalBacktrackLimit; // global limit on the number of backtracks
- sint64 nTotalInspectLimit; // global limit on the number of clause inspects
+ ABC_INT64_T nTotalBacktrackLimit; // global limit on the number of backtracks
+ ABC_INT64_T nTotalInspectLimit; // global limit on the number of clause inspects
// global resources applied
- sint64 nTotalBacktracksMade; // the total number of backtracks made
- sint64 nTotalInspectsMade; // the total number of inspects made
+ ABC_INT64_T nTotalBacktracksMade; // the total number of backtracks made
+ ABC_INT64_T nTotalInspectsMade; // the total number of inspects made
};
static inline Ivy_FraigSim_t * Ivy_ObjSim( Ivy_Obj_t * pObj ) { return (Ivy_FraigSim_t *)pObj->pFanout; }
@@ -141,7 +141,7 @@ static inline Ivy_Obj_t * Ivy_ObjNodeHashNext( Ivy_Obj_t * pObj )
static inline Ivy_Obj_t * Ivy_ObjEquivListNext( Ivy_Obj_t * pObj ) { return pObj->pPrevFan0; }
static inline Ivy_Obj_t * Ivy_ObjEquivListPrev( Ivy_Obj_t * pObj ) { return pObj->pPrevFan1; }
static inline Ivy_Obj_t * Ivy_ObjFraig( Ivy_Obj_t * pObj ) { return pObj->pEquiv; }
-static inline int Ivy_ObjSatNum( Ivy_Obj_t * pObj ) { return (int)(PORT_PTRUINT_T)pObj->pNextFan0; }
+static inline int Ivy_ObjSatNum( Ivy_Obj_t * pObj ) { return (int)(ABC_PTRUINT_T)pObj->pNextFan0; }
static inline Vec_Ptr_t * Ivy_ObjFaninVec( Ivy_Obj_t * pObj ) { return (Vec_Ptr_t *)pObj->pNextFan1; }
static inline void Ivy_ObjSetSim( Ivy_Obj_t * pObj, Ivy_FraigSim_t * pSim ) { pObj->pFanout = (Ivy_Obj_t *)pSim; }
@@ -152,7 +152,7 @@ static inline void Ivy_ObjSetNodeHashNext( Ivy_Obj_t * pObj, Ivy_Obj_t *
static inline void Ivy_ObjSetEquivListNext( Ivy_Obj_t * pObj, Ivy_Obj_t * pNext ) { pObj->pPrevFan0 = pNext; }
static inline void Ivy_ObjSetEquivListPrev( Ivy_Obj_t * pObj, Ivy_Obj_t * pPrev ) { pObj->pPrevFan1 = pPrev; }
static inline void Ivy_ObjSetFraig( Ivy_Obj_t * pObj, Ivy_Obj_t * pNode ) { pObj->pEquiv = pNode; }
-static inline void Ivy_ObjSetSatNum( Ivy_Obj_t * pObj, int Num ) { pObj->pNextFan0 = (Ivy_Obj_t *)(PORT_PTRUINT_T)Num; }
+static inline void Ivy_ObjSetSatNum( Ivy_Obj_t * pObj, int Num ) { pObj->pNextFan0 = (Ivy_Obj_t *)(ABC_PTRUINT_T)Num; }
static inline void Ivy_ObjSetFaninVec( Ivy_Obj_t * pObj, Vec_Ptr_t * vFanins ) { pObj->pNextFan1 = (Ivy_Obj_t *)vFanins; }
static inline unsigned Ivy_ObjRandomSim() { return (rand() << 24) ^ (rand() << 12) ^ rand(); }
@@ -181,7 +181,7 @@ static inline unsigned Ivy_ObjRandomSim() { return (ran
static Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams );
static Ivy_FraigMan_t * Ivy_FraigStartSimple( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams );
-static Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 nBTLimitGlobal, sint64 nInsLimitGlobal, sint64 * pnSatConfs, sint64 * pnSatInspects );
+static Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, ABC_INT64_T nBTLimitGlobal, ABC_INT64_T nInsLimitGlobal, ABC_INT64_T * pnSatConfs, ABC_INT64_T * pnSatInspects );
static void Ivy_FraigPrint( Ivy_FraigMan_t * p );
static void Ivy_FraigStop( Ivy_FraigMan_t * p );
static void Ivy_FraigSimulate( Ivy_FraigMan_t * p );
@@ -199,8 +199,8 @@ static int * Ivy_FraigCreateModel( Ivy_FraigMan_t * p );
static int Ivy_FraigNodesAreEquivBdd( Ivy_Obj_t * pObj1, Ivy_Obj_t * pObj2 );
-static sint64 s_nBTLimitGlobal = 0;
-static sint64 s_nInsLimitGlobal = 0;
+static ABC_INT64_T s_nBTLimitGlobal = 0;
+static ABC_INT64_T s_nInsLimitGlobal = 0;
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -253,7 +253,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
Ivy_FraigParams_t Params, * pIvyParams = &Params;
Ivy_Man_t * pManAig, * pManTemp;
int RetValue, nIter, clk;//, Counter;
- sint64 nSatConfs = 0, nSatInspects = 0;
+ ABC_INT64_T nSatConfs = 0, nSatInspects = 0;
// start the network and parameters
pManAig = *ppManAig;
@@ -334,7 +334,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
{
clk = clock();
pIvyParams->nBTLimitNode = (int)(pParams->nFraigingLimitStart * pow(pParams->nFraigingLimitMulti,nIter));
- pIvyParams->nBTLimitMiter = (int)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)) / Ivy_ManPoNum(pManAig);
+ pIvyParams->nBTLimitMiter = 1 + (int)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)) / Ivy_ManPoNum(pManAig);
pManAig = Ivy_FraigPerform_int( pManTemp = pManAig, pIvyParams, pParams->nTotalBacktrackLimit, pParams->nTotalInspectLimit, &nSatConfs, &nSatInspects ); Ivy_ManStop( pManTemp );
RetValue = Ivy_FraigMiterStatus( pManAig );
Ivy_FraigMiterPrint( pManAig, "Fraiging ", clk, pParams->fVerbose );
@@ -387,7 +387,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
// assign the model if it was proved by rewriting (const 1 miter)
if ( RetValue == 0 && pManAig->pData == NULL )
{
- pManAig->pData = ALLOC( int, Ivy_ManPiNum(pManAig) );
+ pManAig->pData = ABC_ALLOC( int, Ivy_ManPiNum(pManAig) );
memset( pManAig->pData, 0, sizeof(int) * Ivy_ManPiNum(pManAig) );
}
*ppManAig = pManAig;
@@ -405,7 +405,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
SeeAlso []
***********************************************************************/
-Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 nBTLimitGlobal, sint64 nInsLimitGlobal, sint64 * pnSatConfs, sint64 * pnSatInspects )
+Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, ABC_INT64_T nBTLimitGlobal, ABC_INT64_T nInsLimitGlobal, ABC_INT64_T * pnSatConfs, ABC_INT64_T * pnSatInspects )
{
Ivy_FraigMan_t * p;
Ivy_Man_t * pManAigNew;
@@ -504,7 +504,7 @@ clk = clock();
p->timeTotal = clock() - clk;
//printf( "Final nodes = %6d. ", Ivy_ManNodeNum(pManAigNew) );
-//PRT( "Time", p->timeTotal );
+//ABC_PRT( "Time", p->timeTotal );
Ivy_FraigStop( p );
return pManAigNew;
}
@@ -524,7 +524,7 @@ Ivy_FraigMan_t * Ivy_FraigStartSimple( Ivy_Man_t * pManAig, Ivy_FraigParams_t *
{
Ivy_FraigMan_t * p;
// allocat the fraiging manager
- p = ALLOC( Ivy_FraigMan_t, 1 );
+ p = ABC_ALLOC( Ivy_FraigMan_t, 1 );
memset( p, 0, sizeof(Ivy_FraigMan_t) );
p->pParams = pParams;
p->pManAig = pManAig;
@@ -555,16 +555,16 @@ Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParam
// pObj->pEquiv = pObj->pFanout = pObj->pNextFan0 = pObj->pNextFan1 = pObj->pPrevFan0 = pObj->pPrevFan1 = NULL;
assert( !pObj->pEquiv && !pObj->pFanout );
// allocat the fraiging manager
- p = ALLOC( Ivy_FraigMan_t, 1 );
+ p = ABC_ALLOC( Ivy_FraigMan_t, 1 );
memset( p, 0, sizeof(Ivy_FraigMan_t) );
p->pParams = pParams;
p->pManAig = pManAig;
p->pManFraig = Ivy_ManStartFrom( pManAig );
// allocate simulation info
p->nSimWords = pParams->nSimWords;
-// p->pSimWords = ALLOC( unsigned, Ivy_ManObjNum(pManAig) * p->nSimWords );
+// p->pSimWords = ABC_ALLOC( unsigned, Ivy_ManObjNum(pManAig) * p->nSimWords );
EntrySize = sizeof(Ivy_FraigSim_t) + sizeof(unsigned) * p->nSimWords;
- p->pSimWords = (char *)malloc( Ivy_ManObjNum(pManAig) * EntrySize );
+ p->pSimWords = (char *)ABC_ALLOC( char, Ivy_ManObjNum(pManAig) * EntrySize );
memset( p->pSimWords, 0, EntrySize );
k = 0;
Ivy_ManForEachObj( pManAig, pObj, i )
@@ -592,8 +592,8 @@ Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParam
assert( k == Ivy_ManObjNum(pManAig) );
// allocate storage for sim pattern
p->nPatWords = Ivy_BitWordNum( Ivy_ManPiNum(pManAig) );
- p->pPatWords = ALLOC( unsigned, p->nPatWords );
- p->pPatScores = ALLOC( int, 32 * p->nSimWords );
+ p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords );
+ p->pPatScores = ABC_ALLOC( int, 32 * p->nSimWords );
p->vPiVars = Vec_PtrAlloc( 100 );
// set random number generator
srand( 0xABCABC );
@@ -617,10 +617,10 @@ void Ivy_FraigStop( Ivy_FraigMan_t * p )
Ivy_FraigPrint( p );
if ( p->vPiVars ) Vec_PtrFree( p->vPiVars );
if ( p->pSat ) sat_solver_delete( p->pSat );
- FREE( p->pPatScores );
- FREE( p->pPatWords );
- FREE( p->pSimWords );
- free( p );
+ ABC_FREE( p->pPatScores );
+ ABC_FREE( p->pPatWords );
+ ABC_FREE( p->pSimWords );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -646,15 +646,15 @@ void Ivy_FraigPrint( Ivy_FraigMan_t * p )
printf( "Final = %d. Miter = %d. Total = %d. Mux = %d. (Exor = %d.) SatVars = %d.\n",
Ivy_ManNodeNum(p->pManFraig), p->nNodesMiter, Ivy_ManNodeNum(p->pManAig), 0, 0, p->nSatVars );
if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat );
- PRT( "AIG simulation ", p->timeSim );
- PRT( "AIG traversal ", p->timeTrav );
- PRT( "SAT solving ", p->timeSat );
- PRT( " Unsat ", p->timeSatUnsat );
- PRT( " Sat ", p->timeSatSat );
- PRT( " Fail ", p->timeSatFail );
- PRT( "Class refining ", p->timeRef );
- PRT( "TOTAL RUNTIME ", p->timeTotal );
- if ( p->time1 ) { PRT( "time1 ", p->time1 ); }
+ ABC_PRT( "AIG simulation ", p->timeSim );
+ ABC_PRT( "AIG traversal ", p->timeTrav );
+ ABC_PRT( "SAT solving ", p->timeSat );
+ ABC_PRT( " Unsat ", p->timeSatUnsat );
+ ABC_PRT( " Sat ", p->timeSatSat );
+ ABC_PRT( " Fail ", p->timeSatFail );
+ ABC_PRT( "Class refining ", p->timeRef );
+ ABC_PRT( "TOTAL RUNTIME ", p->timeTotal );
+ if ( p->time1 ) { ABC_PRT( "time1 ", p->time1 ); }
}
@@ -1172,7 +1172,7 @@ void Ivy_FraigCreateClasses( Ivy_FraigMan_t * p )
pConst1 = Ivy_ManConst1(p->pManAig);
// allocate the table
nTableSize = Ivy_ManObjNum(p->pManAig) / 2 + 13;
- pTable = ALLOC( Ivy_Obj_t *, nTableSize );
+ pTable = ABC_ALLOC( Ivy_Obj_t *, nTableSize );
memset( pTable, 0, sizeof(Ivy_Obj_t *) * nTableSize );
// collect nodes into the table
Ivy_ManForEachObj( p->pManAig, pObj, i )
@@ -1218,8 +1218,8 @@ void Ivy_FraigCreateClasses( Ivy_FraigMan_t * p )
Ivy_ObjSetClassNodeRepr( pObj, NULL );
Ivy_FraigAddClass( &p->lClasses, pObj );
}
- // free the table
- free( pTable );
+ // ABC_FREE the table
+ ABC_FREE( pTable );
}
/**Function*************************************************************
@@ -1314,7 +1314,7 @@ void Ivy_FraigCheckOutputSimsSavePattern( Ivy_FraigMan_t * p, Ivy_Obj_t * pObj )
// determine the best pattern
BestPat = i * 32 + k;
// fill in the counter-example data
- pModel = ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
+ pModel = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
Ivy_ManForEachPi( p->pManAig, pObj, i )
{
pModel[i] = Ivy_InfoHasBit(Ivy_ObjSim(pObj)->pData, BestPat);
@@ -1513,7 +1513,7 @@ int * Ivy_FraigCreateModel( Ivy_FraigMan_t * p )
int * pModel;
Ivy_Obj_t * pObj;
int i;
- pModel = ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
+ pModel = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
Ivy_ManForEachPi( p->pManFraig, pObj, i )
pModel[i] = ( p->pSat->model.ptr[Ivy_ObjSatNum(pObj)] == l_True );
return pModel;
@@ -1785,7 +1785,7 @@ void Ivy_FraigMiterPrint( Ivy_Man_t * pNtk, char * pString, int clk, int fVerbos
if ( !fVerbose )
return;
printf( "Nodes = %7d. Levels = %4d. ", Ivy_ManNodeNum(pNtk), Ivy_ManLevels(pNtk) );
- PRT( pString, clock() - clk );
+ ABC_PRT( pString, clock() - clk );
}
/**Function*************************************************************
@@ -1871,7 +1871,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p )
{
if ( i && fVerbose )
{
- PRT( "Time", clock() -clk );
+ ABC_PRT( "Time", clock() -clk );
}
pObjNew = Ivy_ObjChild0Equiv(pObj);
// check if the output is constant 1
@@ -1880,7 +1880,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p )
if ( fVerbose )
printf( "Output %2d (out of %2d) is constant 1. ", i, Ivy_ManPoNum(p->pManAig) );
// assing constant 0 model
- p->pManFraig->pData = ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
+ p->pManFraig->pData = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
memset( p->pManFraig->pData, 0, sizeof(int) * Ivy_ManPiNum(p->pManFraig) );
break;
}
@@ -1897,7 +1897,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p )
if ( fVerbose )
printf( "Output %2d (out of %2d) cannot be constant 0. ", i, Ivy_ManPoNum(p->pManAig) );
// assing constant 0 model
- p->pManFraig->pData = ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
+ p->pManFraig->pData = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) );
memset( p->pManFraig->pData, 0, sizeof(int) * Ivy_ManPiNum(p->pManFraig) );
break;
}
@@ -1934,7 +1934,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p )
}
if ( fVerbose )
{
- PRT( "Time", clock() -clk );
+ ABC_PRT( "Time", clock() -clk );
}
}
@@ -2127,7 +2127,7 @@ clk = clock();
pLits[1] = toLitCond( Ivy_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase );
//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0,
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
@@ -2171,7 +2171,7 @@ clk = clock();
pLits[0] = toLitCond( Ivy_ObjSatNum(pOld), 1 );
pLits[1] = toLitCond( Ivy_ObjSatNum(pNew), pOld->fPhase ^ pNew->fPhase );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2,
- (sint64)nBTLimit, (sint64)0,
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
@@ -2203,12 +2203,12 @@ p->timeSatFail += clock() - clk;
// check BDD proof
{
int RetVal;
- PRT( "Sat", clock() - clk2 );
+ ABC_PRT( "Sat", clock() - clk2 );
clk2 = clock();
RetVal = Ivy_FraigNodesAreEquivBdd( pOld, pNew );
// printf( "%d ", RetVal );
assert( RetVal );
- PRT( "Bdd", clock() - clk2 );
+ ABC_PRT( "Bdd", clock() - clk2 );
printf( "\n" );
}
*/
@@ -2259,7 +2259,7 @@ int Ivy_FraigNodeIsConst( Ivy_FraigMan_t * p, Ivy_Obj_t * pNew )
clk = clock();
pLits[0] = toLitCond( Ivy_ObjSatNum(pNew), pNew->fPhase );
RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 1,
- (sint64)p->pParams->nBTLimitMiter, (sint64)0,
+ (ABC_INT64_T)p->pParams->nBTLimitMiter, (ABC_INT64_T)0,
p->nBTLimitGlobal, p->nInsLimitGlobal );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
@@ -2395,7 +2395,7 @@ void Ivy_FraigAddClausesSuper( Ivy_FraigMan_t * p, Ivy_Obj_t * pNode, Vec_Ptr_t
assert( Ivy_ObjIsNode( pNode ) );
// create storage for literals
nLits = Vec_PtrSize(vSuper) + 1;
- pLits = ALLOC( int, nLits );
+ pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
Vec_PtrForEachEntry( vSuper, pFanin, i )
@@ -2411,7 +2411,7 @@ void Ivy_FraigAddClausesSuper( Ivy_FraigMan_t * p, Ivy_Obj_t * pNode, Vec_Ptr_t
pLits[nLits-1] = toLitCond(Ivy_ObjSatNum(pNode), 0);
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
assert( RetValue );
- free( pLits );
+ ABC_FREE( pLits );
}
/**Function*************************************************************
@@ -2663,7 +2663,7 @@ DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_
}
// collect the permutation
NewSize = IVY_MAX(dd->size, Vec_PtrSize(vTemp));
- pFuncs = ALLOC( DdNode *, NewSize );
+ pFuncs = ABC_ALLOC( DdNode *, NewSize );
Vec_PtrForEachEntry( vFront, pObj, i )
{
if ( (int)pObj->Level != Level )
@@ -2693,9 +2693,9 @@ DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_
// deref
for ( i = 0; i < dd->size; i++ )
Cudd_RecursiveDeref( dd, pFuncs[i] );
- free( pFuncs );
+ ABC_FREE( pFuncs );
- free( vFront->pArray );
+ ABC_FREE( vFront->pArray );
*vFront = *vTemp;
vTemp->nCap = vTemp->nSize = 0;
diff --git a/src/aig/ivy/ivyHaig.c b/src/aig/ivy/ivyHaig.c
index 87021600..62624642 100644
--- a/src/aig/ivy/ivyHaig.c
+++ b/src/aig/ivy/ivyHaig.c
@@ -518,7 +518,7 @@ printf( "Using latch %d with fanin %d\n", pObj->Id, Ivy_ObjFanin0(pObj)->Id );
Ivy_ManForEachNodeVec( p, vLatches, pObj, i )
pObj->Init = pObj->Level, pObj->Level = 0;
}
- // free arrays
+ // ABC_FREE arrays
Vec_IntFree( vNodes );
Vec_IntFree( vLatches );
}
diff --git a/src/aig/ivy/ivyMan.c b/src/aig/ivy/ivyMan.c
index 66c279cf..d09f6ffd 100644
--- a/src/aig/ivy/ivyMan.c
+++ b/src/aig/ivy/ivyMan.c
@@ -43,7 +43,7 @@ Ivy_Man_t * Ivy_ManStart()
{
Ivy_Man_t * p;
// start the manager
- p = ALLOC( Ivy_Man_t, 1 );
+ p = ABC_ALLOC( Ivy_Man_t, 1 );
memset( p, 0, sizeof(Ivy_Man_t) );
// perform initializations
p->Ghost.Id = -1;
@@ -63,7 +63,7 @@ Ivy_Man_t * Ivy_ManStart()
p->nCreated = 1;
// start the table
p->nTableSize = 10007;
- p->pTable = ALLOC( int, p->nTableSize );
+ p->pTable = ABC_ALLOC( int, p->nTableSize );
memset( p->pTable, 0, sizeof(int) * p->nTableSize );
return p;
}
@@ -143,7 +143,7 @@ Ivy_Man_t * Ivy_ManDup( Ivy_Man_t * p )
// update the counters of different objects
pNew->nObjs[IVY_PI] -= Ivy_ManLatchNum(p);
pNew->nObjs[IVY_LATCH] += Ivy_ManLatchNum(p);
- // free arrays
+ // ABC_FREE arrays
Vec_IntFree( vNodes );
Vec_IntFree( vLatches );
// make sure structural hashing did not change anything
@@ -234,8 +234,8 @@ Ivy_Man_t * Ivy_ManFrames( Ivy_Man_t * pMan, int nLatches, int nFrames, int fIni
***********************************************************************/
void Ivy_ManStop( Ivy_Man_t * p )
{
- if ( p->time1 ) { PRT( "Update lev ", p->time1 ); }
- if ( p->time2 ) { PRT( "Update levR ", p->time2 ); }
+ if ( p->time1 ) { ABC_PRT( "Update lev ", p->time1 ); }
+ if ( p->time2 ) { ABC_PRT( "Update levR ", p->time2 ); }
// Ivy_TableProfile( p );
// if ( p->vFanouts ) Ivy_ManStopFanout( p );
if ( p->vChunks ) Ivy_ManStopMemory( p );
@@ -244,8 +244,8 @@ void Ivy_ManStop( Ivy_Man_t * p )
if ( p->vPos ) Vec_PtrFree( p->vPos );
if ( p->vBufs ) Vec_PtrFree( p->vBufs );
if ( p->vObjs ) Vec_PtrFree( p->vObjs );
- free( p->pTable );
- free( p );
+ ABC_FREE( p->pTable );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -346,7 +346,7 @@ int Ivy_ManCleanupSeq( Ivy_Man_t * p )
// delete buffer from the array of buffers
if ( p->fFanout && Ivy_ObjIsBuf(pObj) )
Vec_PtrRemove( p->vBufs, pObj );
- // free the node
+ // ABC_FREE the node
Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
Ivy_ManRecycleMemory( p, pObj );
}
diff --git a/src/aig/ivy/ivyMem.c b/src/aig/ivy/ivyMem.c
index fd29e9ae..4ea6d891 100644
--- a/src/aig/ivy/ivyMem.c
+++ b/src/aig/ivy/ivyMem.c
@@ -65,7 +65,7 @@ void Ivy_ManStopMemory( Ivy_Man_t * p )
void * pMemory;
int i;
Vec_PtrForEachEntry( p->vChunks, pMemory, i )
- free( pMemory );
+ ABC_FREE( pMemory );
Vec_PtrFree( p->vChunks );
Vec_PtrFree( p->vPages );
p->pListFree = NULL;
@@ -93,10 +93,10 @@ void Ivy_ManAddMemory( Ivy_Man_t * p )
// assert( (Ivy_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
// allocate new memory page
nBytes = sizeof(Ivy_Obj_t) * (1<<IVY_PAGE_SIZE) + EntrySizeMax;
- pMemory = ALLOC( char, nBytes );
+ pMemory = ABC_ALLOC( char, nBytes );
Vec_PtrPush( p->vChunks, pMemory );
// align memory at the 32-byte boundary
- pMemory = pMemory + EntrySizeMax - (((int)(PORT_PTRUINT_T)pMemory) & (EntrySizeMax-1));
+ pMemory = pMemory + EntrySizeMax - (((int)(ABC_PTRUINT_T)pMemory) & (EntrySizeMax-1));
// remember the manager in the first entry
Vec_PtrPush( p->vPages, pMemory );
// break the memory down into nodes
diff --git a/src/aig/ivy/ivyObj.c b/src/aig/ivy/ivyObj.c
index 59dda19c..d7925fab 100644
--- a/src/aig/ivy/ivyObj.c
+++ b/src/aig/ivy/ivyObj.c
@@ -268,7 +268,7 @@ void Ivy_ObjDelete( Ivy_Man_t * p, Ivy_Obj_t * pObj, int fFreeTop )
// clean and recycle the entry
if ( fFreeTop )
{
- // free the node
+ // ABC_FREE the node
Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
Ivy_ManRecycleMemory( p, pObj );
}
diff --git a/src/aig/ivy/ivyResyn.c b/src/aig/ivy/ivyResyn.c
index f42d7464..35ecb122 100644
--- a/src/aig/ivy/ivyResyn.c
+++ b/src/aig/ivy/ivyResyn.c
@@ -50,21 +50,21 @@ if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pMan, fUpdateLevel );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
// Ivy_ManRewriteAlg( pMan, fUpdateLevel, 0 );
clk = clock();
Ivy_ManRewritePre( pMan, fUpdateLevel, 0, 0 );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel );
Ivy_ManStop( pTemp );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
return pMan;
}
@@ -91,49 +91,49 @@ if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pMan, fUpdateLevel );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
// Ivy_ManRewriteAlg( pMan, fUpdateLevel, 0 );
clk = clock();
Ivy_ManRewritePre( pMan, fUpdateLevel, 0, 0 );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel );
Ivy_ManStop( pTemp );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
// Ivy_ManRewriteAlg( pMan, fUpdateLevel, 1 );
clk = clock();
Ivy_ManRewritePre( pMan, fUpdateLevel, 1, 0 );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel );
Ivy_ManStop( pTemp );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
// Ivy_ManRewriteAlg( pMan, fUpdateLevel, 1 );
clk = clock();
Ivy_ManRewritePre( pMan, fUpdateLevel, 1, 0 );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel );
Ivy_ManStop( pTemp );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
return pMan;
}
@@ -160,7 +160,7 @@ if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
Ivy_ManRewritePre( pMan, 0, 0, 0 );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
@@ -168,21 +168,21 @@ clk = clock();
// pMan = Ivy_ManDup( pTemp = pMan );
Ivy_ManStop( pTemp );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
/*
clk = clock();
Ivy_ManRewritePre( pMan, 0, 0, 0 );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
clk = clock();
pMan = Ivy_ManBalance( pTemp = pMan, 0 );
Ivy_ManStop( pTemp );
if ( fVerbose ) { printf( "\n" ); }
-if ( fVerbose ) { PRT( "Balance", clock() - clk ); }
+if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); }
if ( fVerbose ) Ivy_ManPrintStats( pMan );
*/
return pMan;
diff --git a/src/aig/ivy/ivySeq.c b/src/aig/ivy/ivySeq.c
index f4585fa2..0971a548 100644
--- a/src/aig/ivy/ivySeq.c
+++ b/src/aig/ivy/ivySeq.c
@@ -1127,7 +1127,7 @@ void Ivy_CutComputeAll( Ivy_Man_t * p, int nInputs )
}
printf( "All = %6d. Minus = %6d. Triv = %6d. Node = %6d. Satur = %6d. ",
nCutsTotal, nCutsTotalM, Ivy_ManPiNum(p) + Ivy_ManNodeNum(p), nNodeTotal, nNodeOver );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ivy/ivyTable.c b/src/aig/ivy/ivyTable.c
index 2ac0ae49..fdcc4bfb 100644
--- a/src/aig/ivy/ivyTable.c
+++ b/src/aig/ivy/ivyTable.c
@@ -210,7 +210,7 @@ clk = clock();
nTableSizeOld = p->nTableSize;
// get the new table
p->nTableSize = Cudd_PrimeAig( 5 * Ivy_ManHashObjNum(p) );
- p->pTable = ALLOC( int, p->nTableSize );
+ p->pTable = ABC_ALLOC( int, p->nTableSize );
memset( p->pTable, 0, sizeof(int) * p->nTableSize );
// rehash the entries from the old table
Counter = 0;
@@ -227,9 +227,9 @@ clk = clock();
nEntries = Ivy_ManHashObjNum(p);
// assert( Counter == nEntries );
// printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
// replace the table and the parameters
- free( pTableOld );
+ ABC_FREE( pTableOld );
}
/**Function********************************************************************
diff --git a/src/aig/kit/cloud.c b/src/aig/kit/cloud.c
index f5c91fe7..dc57e2b7 100644
--- a/src/aig/kit/cloud.c
+++ b/src/aig/kit/cloud.c
@@ -77,7 +77,7 @@ CloudManager * Cloud_Init( int nVars, int nBits )
nBits = CLOUD_NODE_BITS;
// start the manager
- dd = CALLOC( CloudManager, 1 );
+ dd = ABC_CALLOC( CloudManager, 1 );
dd->nMemUsed += sizeof(CloudManager);
// variables
@@ -96,10 +96,10 @@ CloudManager * Cloud_Init( int nVars, int nBits )
// unique table
clk1 = clock();
- dd->tUnique = CALLOC( CloudNode, dd->nNodesAlloc );
+ dd->tUnique = ABC_CALLOC( CloudNode, dd->nNodesAlloc );
dd->nMemUsed += sizeof(CloudNode) * dd->nNodesAlloc;
clk2 = clock();
-//PRT( "calloc() time", clk2 - clk1 );
+//ABC_PRT( "calloc() time", clk2 - clk1 );
// set up the constant node (the only node that is not in the hash table)
dd->nSignCur = 1;
@@ -116,7 +116,7 @@ clk2 = clock();
dd->pNodeEnd = dd->tUnique + dd->nNodesAlloc;
// set up the elementary variables
- dd->vars = ALLOC( CloudNode *, dd->nVars );
+ dd->vars = ABC_ALLOC( CloudNode *, dd->nVars );
dd->nMemUsed += sizeof(CloudNode *) * dd->nVars;
for ( i = 0; i < dd->nVars; i++ )
dd->vars[i] = cloudMakeNode( dd, i, dd->one, dd->zero );
@@ -140,12 +140,12 @@ clk2 = clock();
void Cloud_Quit( CloudManager * dd )
{
int i;
- FREE( dd->ppNodes );
- free( dd->tUnique );
- free( dd->vars );
+ ABC_FREE( dd->ppNodes );
+ ABC_FREE( dd->tUnique );
+ ABC_FREE( dd->vars );
for ( i = 0; i < 4; i++ )
- FREE( dd->tCaches[i] );
- free( dd );
+ ABC_FREE( dd->tCaches[i] );
+ ABC_FREE( dd );
}
/**Function********************************************************************
@@ -218,17 +218,17 @@ void cloudCacheAllocate( CloudManager * dd, CloudOper oper )
if ( CacheSize[oper] == 1 )
{
- dd->tCaches[oper] = (CloudCacheEntry2 *)CALLOC( CloudCacheEntry1, nCacheEntries );
+ dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry1, nCacheEntries );
dd->nMemUsed += sizeof(CloudCacheEntry1) * nCacheEntries;
}
else if ( CacheSize[oper] == 2 )
{
- dd->tCaches[oper] = (CloudCacheEntry2 *)CALLOC( CloudCacheEntry2, nCacheEntries );
+ dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry2, nCacheEntries );
dd->nMemUsed += sizeof(CloudCacheEntry2) * nCacheEntries;
}
else if ( CacheSize[oper] == 3 )
{
- dd->tCaches[oper] = (CloudCacheEntry2 *)CALLOC( CloudCacheEntry3, nCacheEntries );
+ dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry3, nCacheEntries );
dd->nMemUsed += sizeof(CloudCacheEntry3) * nCacheEntries;
}
}
@@ -619,7 +619,7 @@ CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n )
CLOUD_ASSERT(n);
// allocate and initialize support array for cloudSupport
- support = CALLOC( int, dd->nVars );
+ support = ABC_CALLOC( int, dd->nVars );
// compute support and clean up markers
cloudSupport( dd, Cloud_Regular(n), support );
@@ -634,7 +634,7 @@ CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n )
if ( res == NULL )
break;
}
- FREE( support );
+ ABC_FREE( support );
return res;
}
@@ -658,7 +658,7 @@ int Cloud_SupportSize( CloudManager * dd, CloudNode * n )
CLOUD_ASSERT(n);
// allocate and initialize support array for cloudSupport
- support = CALLOC( int, dd->nVars );
+ support = ABC_CALLOC( int, dd->nVars );
// compute support and clean up markers
cloudSupport( dd, Cloud_Regular(n), support );
@@ -672,7 +672,7 @@ int Cloud_SupportSize( CloudManager * dd, CloudNode * n )
count++;
}
- FREE( support );
+ ABC_FREE( support );
return count;
}
@@ -769,7 +769,7 @@ int Cloud_DagCollect( CloudManager * dd, CloudNode * n )
{
int res, Counter = 0;
if ( dd->ppNodes == NULL )
- dd->ppNodes = ALLOC( CloudNode *, dd->nNodesLimit );
+ dd->ppNodes = ABC_ALLOC( CloudNode *, dd->nNodesLimit );
res = Cloud_DagCollect_rec( dd, Cloud_Regular( n ), &Counter );
cloudClearMark( dd, Cloud_Regular( n ) );
assert( res == Counter );
diff --git a/src/aig/kit/cloud.h b/src/aig/kit/cloud.h
index ec8e9059..6f6a1eae 100644
--- a/src/aig/kit/cloud.h
+++ b/src/aig/kit/cloud.h
@@ -19,15 +19,15 @@
#ifndef __CLOUD_H__
#define __CLOUD_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
-#include "port_type.h"
+#include "abc_global.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
@@ -176,14 +176,14 @@ struct cloudCacheEntry3 // the three-argument cache
#define DD_P2 4256249
#define DD_P3 741457
#define DD_P4 1618033999
-#define cloudHashCudd2(f,g,s) ((((unsigned)(PORT_PTRUINT_T)(f) * DD_P1 + (unsigned)(PORT_PTRUINT_T)(g)) * DD_P2) >> (s))
-#define cloudHashCudd3(f,g,h,s) (((((unsigned)(PORT_PTRUINT_T)(f) * DD_P1 + (unsigned)(PORT_PTRUINT_T)(g)) * DD_P2 + (unsigned)(PORT_PTRUINT_T)(h)) * DD_P3) >> (s))
+#define cloudHashCudd2(f,g,s) ((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2) >> (s))
+#define cloudHashCudd3(f,g,h,s) (((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2 + (unsigned)(ABC_PTRUINT_T)(h)) * DD_P3) >> (s))
// node complementation (using node)
-#define Cloud_Regular(p) ((CloudNode*)(((PORT_PTRUINT_T)(p)) & ~01)) // get the regular node (w/o bubble)
-#define Cloud_Not(p) ((CloudNode*)(((PORT_PTRUINT_T)(p)) ^ 01)) // complement the node
-#define Cloud_NotCond(p,c) ((CloudNode*)(((PORT_PTRUINT_T)(p)) ^ (c))) // complement the node conditionally
-#define Cloud_IsComplement(p) ((int)(((PORT_PTRUINT_T)(p)) & 01)) // check if complemented
+#define Cloud_Regular(p) ((CloudNode*)(((ABC_PTRUINT_T)(p)) & ~01)) // get the regular node (w/o bubble)
+#define Cloud_Not(p) ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ 01)) // complement the node
+#define Cloud_NotCond(p,c) ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ (c))) // complement the node conditionally
+#define Cloud_IsComplement(p) ((int)(((ABC_PTRUINT_T)(p)) & 01)) // check if complemented
// checking constants (using node)
#define Cloud_IsConstant(p) (((Cloud_Regular(p))->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)
#define cloudIsConstant(p) (((p)->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)
@@ -213,23 +213,6 @@ struct cloudCacheEntry3 // the three-argument cache
//#define CLOUD_ASSERT(p) (assert((p) >= (dd->pNodeStart-1) && (p) < dd->pNodeEnd))
#define CLOUD_ASSERT(p) assert((p) >= dd->tUnique && (p) < dd->tUnique+dd->nNodesAlloc)
-// utility macros
-#ifndef ALLOC
-#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
-#endif
-
-#ifndef CALLOC
-#define CALLOC(type, num) ((type *) calloc((num), sizeof(type)))
-#endif
-
-#ifndef FREE
-#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
-#endif
-
-#ifndef PRT
-#define PRT(a,t) fprintf( stdout, "%s = ", (a)); printf( "%.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC) )
-#endif
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/kit/kit.h b/src/aig/kit/kit.h
index e8dea11a..3b564da5 100644
--- a/src/aig/kit/kit.h
+++ b/src/aig/kit/kit.h
@@ -21,10 +21,6 @@
#ifndef __KIT_H__
#define __KIT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -42,6 +38,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -140,17 +140,6 @@ struct Kit_DsdMan_t_
Vec_Int_t * vNodes; // temporary array for BDD nodes
};
-#ifdef WIN32
-#define ABC_DLLEXPORT __declspec(dllexport)
-#define ABC_DLLIMPORT __declspec(dllimport)
-#else /* defined(WIN32) */
-#define ABC_DLLIMPORT
-#endif /* defined(WIN32) */
-
-#ifndef ABC_DLL
-#define ABC_DLL ABC_DLLIMPORT
-#endif
-
static inline int Kit_DsdVar2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
static inline int Kit_DsdLit2Var( int Lit ) { return Lit >> 1; }
static inline int Kit_DsdLitIsCompl( int Lit ) { return Lit & 1; }
@@ -186,20 +175,6 @@ static inline unsigned Kit_DsdLitSupport( Kit_DsdNtk_t * pNtk, int Lit )
#define KIT_MAX(a,b) (((a) > (b))? (a) : (b))
#define KIT_INFINITY (100000000)
-#ifndef ALLOC
-#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
-#endif
-
-#ifndef FREE
-#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
-#endif
-
-#ifndef REALLOC
-#define REALLOC(type, obj, num) \
- ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
- ((type *) malloc(sizeof(type) * (num))))
-#endif
-
static inline int Kit_CubeHasLit( unsigned uCube, int i ) { return(uCube & (unsigned)(1<<i)) > 0; }
static inline unsigned Kit_CubeSetLit( unsigned uCube, int i ) { return uCube | (unsigned)(1<<i); }
static inline unsigned Kit_CubeXorLit( unsigned uCube, int i ) { return uCube ^ (unsigned)(1<<i); }
diff --git a/src/aig/kit/kitDsd.c b/src/aig/kit/kitDsd.c
index 75358093..c4ed70e4 100644
--- a/src/aig/kit/kitDsd.c
+++ b/src/aig/kit/kitDsd.c
@@ -42,7 +42,7 @@
Kit_DsdMan_t * Kit_DsdManAlloc( int nVars, int nNodes )
{
Kit_DsdMan_t * p;
- p = ALLOC( Kit_DsdMan_t, 1 );
+ p = ABC_ALLOC( Kit_DsdMan_t, 1 );
memset( p, 0, sizeof(Kit_DsdMan_t) );
p->nVars = nVars;
p->nWords = Kit_TruthWordNum( p->nVars );
@@ -72,7 +72,7 @@ void Kit_DsdManFree( Kit_DsdMan_t * p )
Vec_PtrFree( p->vTtBdds );
Vec_PtrFree( p->vTtElems );
Vec_PtrFree( p->vTtNodes );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -90,7 +90,7 @@ Kit_DsdObj_t * Kit_DsdObjAlloc( Kit_DsdNtk_t * pNtk, Kit_Dsd_t Type, int nFans )
{
Kit_DsdObj_t * pObj;
int nSize = sizeof(Kit_DsdObj_t) + sizeof(unsigned) * (Kit_DsdObjOffset(nFans) + (Type == KIT_DSD_PRIME) * Kit_TruthWordNum(nFans));
- pObj = (Kit_DsdObj_t *)ALLOC( char, nSize );
+ pObj = (Kit_DsdObj_t *)ABC_ALLOC( char, nSize );
memset( pObj, 0, nSize );
pObj->Id = pNtk->nVars + pNtk->nNodes;
pObj->Type = Type;
@@ -100,7 +100,7 @@ Kit_DsdObj_t * Kit_DsdObjAlloc( Kit_DsdNtk_t * pNtk, Kit_Dsd_t Type, int nFans )
if ( pNtk->nNodes == pNtk->nNodesAlloc )
{
pNtk->nNodesAlloc *= 2;
- pNtk->pNodes = REALLOC( Kit_DsdObj_t *, pNtk->pNodes, pNtk->nNodesAlloc );
+ pNtk->pNodes = ABC_REALLOC( Kit_DsdObj_t *, pNtk->pNodes, pNtk->nNodesAlloc );
}
assert( pNtk->nNodes < pNtk->nNodesAlloc );
pNtk->pNodes[pNtk->nNodes++] = pObj;
@@ -120,7 +120,7 @@ Kit_DsdObj_t * Kit_DsdObjAlloc( Kit_DsdNtk_t * pNtk, Kit_Dsd_t Type, int nFans )
***********************************************************************/
void Kit_DsdObjFree( Kit_DsdNtk_t * p, Kit_DsdObj_t * pObj )
{
- free( pObj );
+ ABC_FREE( pObj );
}
/**Function*************************************************************
@@ -137,12 +137,12 @@ void Kit_DsdObjFree( Kit_DsdNtk_t * p, Kit_DsdObj_t * pObj )
Kit_DsdNtk_t * Kit_DsdNtkAlloc( int nVars )
{
Kit_DsdNtk_t * pNtk;
- pNtk = ALLOC( Kit_DsdNtk_t, 1 );
+ pNtk = ABC_ALLOC( Kit_DsdNtk_t, 1 );
memset( pNtk, 0, sizeof(Kit_DsdNtk_t) );
- pNtk->pNodes = ALLOC( Kit_DsdObj_t *, nVars+1 );
+ pNtk->pNodes = ABC_ALLOC( Kit_DsdObj_t *, nVars+1 );
pNtk->nVars = nVars;
pNtk->nNodesAlloc = nVars+1;
- pNtk->pMem = ALLOC( unsigned, 6 * Kit_TruthWordNum(nVars) );
+ pNtk->pMem = ABC_ALLOC( unsigned, 6 * Kit_TruthWordNum(nVars) );
return pNtk;
}
@@ -162,11 +162,11 @@ void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk )
Kit_DsdObj_t * pObj;
unsigned i;
Kit_DsdNtkForEachObj( pNtk, pObj, i )
- free( pObj );
- FREE( pNtk->pSupps );
- free( pNtk->pNodes );
- free( pNtk->pMem );
- free( pNtk );
+ ABC_FREE( pObj );
+ ABC_FREE( pNtk->pSupps );
+ ABC_FREE( pNtk->pNodes );
+ ABC_FREE( pNtk->pMem );
+ ABC_FREE( pNtk );
}
/**Function*************************************************************
@@ -1032,7 +1032,7 @@ unsigned Kit_DsdNonDsdSupports( Kit_DsdNtk_t * pNtk )
{
Kit_DsdObj_t * pObj;
unsigned i, uSupport = 0;
-// FREE( pNtk->pSupps );
+// ABC_FREE( pNtk->pSupps );
Kit_DsdGetSupports( pNtk );
Kit_DsdNtkForEachObj( pNtk, pObj, i )
{
@@ -1531,7 +1531,7 @@ unsigned Kit_DsdGetSupports( Kit_DsdNtk_t * p )
Kit_DsdObj_t * pRoot;
unsigned uSupport;
assert( p->pSupps == NULL );
- p->pSupps = ALLOC( unsigned, p->nNodes );
+ p->pSupps = ABC_ALLOC( unsigned, p->nNodes );
// consider simple special cases
pRoot = Kit_DsdNtkRoot(p);
if ( pRoot->Type == KIT_DSD_CONST1 )
@@ -2377,7 +2377,7 @@ int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit
// allocate storage for cofactors
nMemSize = Kit_TruthWordNum(nVars);
- ppCofs[0][0] = ALLOC( unsigned, 80 * nMemSize );
+ ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize );
nSize = 0;
for ( i = 0; i < 5; i++ )
for ( k = 0; k < 16; k++ )
@@ -2422,7 +2422,7 @@ int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit
// compute the sum total of supports
nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+0], nVars );
nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+1], nVars );
- // free the networks
+ // ABC_FREE the networks
Kit_DsdNtkFree( ppNtks[nStep+1][2*i+0] );
Kit_DsdNtkFree( ppNtks[nStep+1][2*i+1] );
}
@@ -2460,12 +2460,12 @@ int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit
}
}
- // free the networks
+ // ABC_FREE the networks
for ( i = 0; i < 5; i++ )
for ( k = 0; k < 16; k++ )
if ( ppNtks[i][k] )
Kit_DsdNtkFree( ppNtks[i][k] );
- free( ppCofs[0][0] );
+ ABC_FREE( ppCofs[0][0] );
assert( nStep <= nLimit );
return nStep;
@@ -2502,7 +2502,7 @@ void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVe
// allocate storage for cofactors
nMemSize = Kit_TruthWordNum(nVars);
- ppCofs[0][0] = ALLOC( unsigned, 80 * nMemSize );
+ ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize );
nSize = 0;
for ( i = 0; i < 5; i++ )
for ( k = 0; k < 16; k++ )
@@ -2713,7 +2713,7 @@ void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVe
}
- free( ppCofs[0][0] );
+ ABC_FREE( ppCofs[0][0] );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/kit/kitFactor.c b/src/aig/kit/kitFactor.c
index f596d9a8..273d4821 100644
--- a/src/aig/kit/kitFactor.c
+++ b/src/aig/kit/kitFactor.c
@@ -123,7 +123,7 @@ Kit_Edge_t Kit_SopFactor_rec( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, int nLits,
if ( Kit_SopCubeNum(cQuo) == 1 )
return Kit_SopFactorLF_rec( pFForm, cSop, cQuo, nLits, vMemory );
- // make the quotient cube free
+ // make the quotient cube ABC_FREE
Kit_SopMakeCubeFree( cQuo );
// divide the cover by the quotient
diff --git a/src/aig/kit/kitGraph.c b/src/aig/kit/kitGraph.c
index 80dcbdc0..565c000b 100644
--- a/src/aig/kit/kitGraph.c
+++ b/src/aig/kit/kitGraph.c
@@ -42,12 +42,12 @@
Kit_Graph_t * Kit_GraphCreate( int nLeaves )
{
Kit_Graph_t * pGraph;
- pGraph = ALLOC( Kit_Graph_t, 1 );
+ pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
memset( pGraph, 0, sizeof(Kit_Graph_t) );
pGraph->nLeaves = nLeaves;
pGraph->nSize = nLeaves;
pGraph->nCap = 2 * nLeaves + 50;
- pGraph->pNodes = ALLOC( Kit_Node_t, pGraph->nCap );
+ pGraph->pNodes = ABC_ALLOC( Kit_Node_t, pGraph->nCap );
memset( pGraph->pNodes, 0, sizeof(Kit_Node_t) * pGraph->nSize );
return pGraph;
}
@@ -66,7 +66,7 @@ Kit_Graph_t * Kit_GraphCreate( int nLeaves )
Kit_Graph_t * Kit_GraphCreateConst0()
{
Kit_Graph_t * pGraph;
- pGraph = ALLOC( Kit_Graph_t, 1 );
+ pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
memset( pGraph, 0, sizeof(Kit_Graph_t) );
pGraph->fConst = 1;
pGraph->eRoot.fCompl = 1;
@@ -87,7 +87,7 @@ Kit_Graph_t * Kit_GraphCreateConst0()
Kit_Graph_t * Kit_GraphCreateConst1()
{
Kit_Graph_t * pGraph;
- pGraph = ALLOC( Kit_Graph_t, 1 );
+ pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
memset( pGraph, 0, sizeof(Kit_Graph_t) );
pGraph->fConst = 1;
return pGraph;
@@ -127,8 +127,8 @@ Kit_Graph_t * Kit_GraphCreateLeaf( int iLeaf, int nLeaves, int fCompl )
***********************************************************************/
void Kit_GraphFree( Kit_Graph_t * pGraph )
{
- FREE( pGraph->pNodes );
- free( pGraph );
+ ABC_FREE( pGraph->pNodes );
+ ABC_FREE( pGraph );
}
/**Function*************************************************************
@@ -147,7 +147,7 @@ Kit_Node_t * Kit_GraphAppendNode( Kit_Graph_t * pGraph )
Kit_Node_t * pNode;
if ( pGraph->nSize == pGraph->nCap )
{
- pGraph->pNodes = REALLOC( Kit_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
+ pGraph->pNodes = ABC_REALLOC( Kit_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
pGraph->nCap = 2 * pGraph->nCap;
}
pNode = pGraph->pNodes + pGraph->nSize++;
diff --git a/src/aig/kit/kitSop.c b/src/aig/kit/kitSop.c
index 8e175dac..0d1b9e2c 100644
--- a/src/aig/kit/kitSop.c
+++ b/src/aig/kit/kitSop.c
@@ -296,7 +296,7 @@ static inline unsigned Kit_SopCommonCube( Kit_Sop_t * cSop )
/**Function*************************************************************
- Synopsis [Makes the cover cube-free.]
+ Synopsis [Makes the cover cube-ABC_FREE.]
Description []
@@ -319,7 +319,7 @@ void Kit_SopMakeCubeFree( Kit_Sop_t * cSop )
/**Function*************************************************************
- Synopsis [Checks if the cover is cube-free.]
+ Synopsis [Checks if the cover is cube-ABC_FREE.]
Description []
@@ -510,7 +510,7 @@ void Kit_SopDivisorZeroKernel_rec( Kit_Sop_t * cSop, int nLits )
iLit = Kit_SopWorstLiteral( cSop, nLits );
if ( iLit == -1 )
return;
- // derive the cube-free quotient
+ // derive the cube-ABC_FREE quotient
Kit_SopDivideByLiteralQuo( cSop, iLit ); // the same cover
Kit_SopMakeCubeFree( cSop ); // the same cover
// call recursively
diff --git a/src/aig/mem/mem.c b/src/aig/mem/mem.c
index 911ceffb..99d918e9 100644
--- a/src/aig/mem/mem.c
+++ b/src/aig/mem/mem.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include "abc_global.h"
#include "mem.h"
////////////////////////////////////////////////////////////////////////
@@ -35,7 +36,7 @@ struct Mem_Fixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of free entries
+ char * pEntriesFree; // the linked list of ABC_FREE entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -52,8 +53,8 @@ struct Mem_Flex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
- char * pCurrent; // the current pointer to free memory
- char * pEnd; // the first entry outside the free memory
+ char * pCurrent; // the current pointer to ABC_FREE memory
+ char * pEnd; // the first entry outside the ABC_FREE memory
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -74,12 +75,6 @@ struct Mem_Step_t_
Mem_Fixed_t ** pMap; // maps the number of bytes into its memory manager
};
-#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
-#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
-#define REALLOC(type, obj, num) \
- ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
- ((type *) malloc(sizeof(type) * (num))))
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,7 +95,7 @@ Mem_Fixed_t * Mem_FixedStart( int nEntrySize )
{
Mem_Fixed_t * p;
- p = ALLOC( Mem_Fixed_t, 1 );
+ p = ABC_ALLOC( Mem_Fixed_t, 1 );
memset( p, 0, sizeof(Mem_Fixed_t) );
p->nEntrySize = nEntrySize;
@@ -117,7 +112,7 @@ Mem_Fixed_t * Mem_FixedStart( int nEntrySize )
p->nChunksAlloc = 64;
p->nChunks = 0;
- p->pChunks = ALLOC( char *, p->nChunksAlloc );
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
p->nMemoryUsed = 0;
p->nMemoryAlloc = 0;
@@ -148,9 +143,9 @@ void Mem_FixedStop( Mem_Fixed_t * p, int fVerbose )
p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc );
}
for ( i = 0; i < p->nChunks; i++ )
- free( p->pChunks[i] );
- free( p->pChunks );
- free( p );
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -169,16 +164,16 @@ char * Mem_FixedEntryFetch( Mem_Fixed_t * p )
char * pTemp;
int i;
- // check if there are still free entries
+ // check if there are still ABC_FREE entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
if ( p->nChunks == p->nChunksAlloc )
{
p->nChunksAlloc *= 2;
- p->pChunks = REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
}
- p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize );
+ p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize );
p->nMemoryAlloc += p->nEntrySize * p->nChunkSize;
// transform these entries into a linked list
pTemp = p->pEntriesFree;
@@ -198,7 +193,7 @@ char * Mem_FixedEntryFetch( Mem_Fixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the free entry list
+ // return the first entry in the ABC_FREE entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -219,7 +214,7 @@ void Mem_FixedEntryRecycle( Mem_Fixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of free entries
+ // add the entry to the linked list of ABC_FREE entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -242,7 +237,7 @@ void Mem_FixedRestart( Mem_Fixed_t * p )
// deallocate all chunks except the first one
for ( i = 1; i < p->nChunks; i++ )
- free( p->pChunks[i] );
+ ABC_FREE( p->pChunks[i] );
p->nChunks = 1;
// transform these entries into a linked list
pTemp = p->pChunks[0];
@@ -253,7 +248,7 @@ void Mem_FixedRestart( Mem_Fixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the free entry list
+ // set the ABC_FREE entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -311,7 +306,7 @@ Mem_Flex_t * Mem_FlexStart()
{
Mem_Flex_t * p;
- p = ALLOC( Mem_Flex_t, 1 );
+ p = ABC_ALLOC( Mem_Flex_t, 1 );
memset( p, 0, sizeof(Mem_Flex_t) );
p->nEntriesUsed = 0;
@@ -321,7 +316,7 @@ Mem_Flex_t * Mem_FlexStart()
p->nChunkSize = (1 << 14);
p->nChunksAlloc = 64;
p->nChunks = 0;
- p->pChunks = ALLOC( char *, p->nChunksAlloc );
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
p->nMemoryUsed = 0;
p->nMemoryAlloc = 0;
@@ -352,9 +347,9 @@ void Mem_FlexStop( Mem_Flex_t * p, int fVerbose )
p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc );
}
for ( i = 0; i < p->nChunks; i++ )
- free( p->pChunks[i] );
- free( p->pChunks );
- free( p );
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -371,13 +366,13 @@ void Mem_FlexStop( Mem_Flex_t * p, int fVerbose )
char * Mem_FlexEntryFetch( Mem_Flex_t * p, int nBytes )
{
char * pTemp;
- // check if there are still free entries
+ // check if there are still ABC_FREE entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries
if ( p->nChunks == p->nChunksAlloc )
{
p->nChunksAlloc *= 2;
- p->pChunks = REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
}
if ( nBytes > p->nChunkSize )
{
@@ -385,7 +380,7 @@ char * Mem_FlexEntryFetch( Mem_Flex_t * p, int nBytes )
// (ideally, this should never happen)
p->nChunkSize = 2 * nBytes;
}
- p->pCurrent = ALLOC( char, p->nChunkSize );
+ p->pCurrent = ABC_ALLOC( char, p->nChunkSize );
p->pEnd = p->pCurrent + p->nChunkSize;
p->nMemoryAlloc += p->nChunkSize;
// add the chunk to the chunk storage
@@ -420,7 +415,7 @@ void Mem_FlexRestart( Mem_Flex_t * p )
return;
// deallocate all chunks except the first one
for ( i = 1; i < p->nChunks; i++ )
- free( p->pChunks[i] );
+ ABC_FREE( p->pChunks[i] );
p->nChunks = 1;
p->nMemoryAlloc = p->nChunkSize;
// transform these entries into a linked list
@@ -463,7 +458,7 @@ int Mem_FlexReadMemUsage( Mem_Flex_t * p )
are employed internally. Calling this procedure with nSteps equal
to 10 results in 10 hierarchically arranged internal memory managers,
which can allocate up to 4096 (1Kb) entries. Requests for larger
- entries are handed over to malloc() and then free()ed.]
+ entries are handed over to malloc() and then ABC_FREE()ed.]
SideEffects []
@@ -474,16 +469,16 @@ Mem_Step_t * Mem_StepStart( int nSteps )
{
Mem_Step_t * p;
int i, k;
- p = ALLOC( Mem_Step_t, 1 );
+ p = ABC_ALLOC( Mem_Step_t, 1 );
memset( p, 0, sizeof(Mem_Step_t) );
p->nMems = nSteps;
// start the fixed memory managers
- p->pMems = ALLOC( Mem_Fixed_t *, p->nMems );
+ p->pMems = ABC_ALLOC( Mem_Fixed_t *, p->nMems );
for ( i = 0; i < p->nMems; i++ )
p->pMems[i] = Mem_FixedStart( (8<<i) );
// set up the mapping of the required memory size into the corresponding manager
p->nMapSize = (4<<p->nMems);
- p->pMap = ALLOC( Mem_Fixed_t *, p->nMapSize+1 );
+ p->pMap = ABC_ALLOC( Mem_Fixed_t *, p->nMapSize+1 );
p->pMap[0] = NULL;
for ( k = 1; k <= 4; k++ )
p->pMap[k] = p->pMems[0];
@@ -514,12 +509,12 @@ void Mem_StepStop( Mem_Step_t * p, int fVerbose )
// if ( p->pLargeChunks )
// {
// for ( i = 0; i < p->nLargeChunks; i++ )
-// free( p->pLargeChunks[i] );
-// free( p->pLargeChunks );
+// ABC_FREE( p->pLargeChunks[i] );
+// ABC_FREE( p->pLargeChunks );
// }
- free( p->pMems );
- free( p->pMap );
- free( p );
+ ABC_FREE( p->pMems );
+ ABC_FREE( p->pMap );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -546,12 +541,12 @@ char * Mem_StepEntryFetch( Mem_Step_t * p, int nBytes )
if ( p->nLargeChunksAlloc == 0 )
p->nLargeChunksAlloc = 5;
p->nLargeChunksAlloc *= 2;
- p->pLargeChunks = REALLOC( char *, p->pLargeChunks, p->nLargeChunksAlloc );
+ p->pLargeChunks = ABC_REALLOC( char *, p->pLargeChunks, p->nLargeChunksAlloc );
}
- p->pLargeChunks[ p->nLargeChunks++ ] = ALLOC( char, nBytes );
+ p->pLargeChunks[ p->nLargeChunks++ ] = ABC_ALLOC( char, nBytes );
return p->pLargeChunks[ p->nLargeChunks - 1 ];
*/
- return ALLOC( char, nBytes );
+ return ABC_ALLOC( char, nBytes );
}
return Mem_FixedEntryFetch( p->pMap[nBytes] );
}
@@ -574,7 +569,7 @@ void Mem_StepEntryRecycle( Mem_Step_t * p, char * pEntry, int nBytes )
return;
if ( nBytes > p->nMapSize )
{
-// free( pEntry );
+// ABC_FREE( pEntry );
return;
}
Mem_FixedEntryRecycle( p->pMap[nBytes], pEntry );
diff --git a/src/aig/mfx/mfx.h b/src/aig/mfx/mfx.h
index aae9e625..09c4f039 100644
--- a/src/aig/mfx/mfx.h
+++ b/src/aig/mfx/mfx.h
@@ -21,10 +21,6 @@
#ifndef __MFX_H__
#define __MFX_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/mfx/mfxCore.c b/src/aig/mfx/mfxCore.c
index f67fb520..c0d3b650 100644
--- a/src/aig/mfx/mfxCore.c
+++ b/src/aig/mfx/mfxCore.c
@@ -355,7 +355,7 @@ int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib )
1.0*p->nNodesGainedLevel/Vec_PtrSize(vNodes),
1.0*p->nTotConfLevel/Vec_PtrSize(vNodes),
100.0*p->nTimeOutsLevel/Vec_PtrSize(vNodes) );
- PRT( "Time", clock() - clk2 );
+ ABC_PRT( "Time", clock() - clk2 );
}
}
@@ -371,7 +371,7 @@ int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib )
if ( pPars->fPower )
printf( "Total switching after = %7.2f.\n", Nwl_ManComputeTotalSwitching(pNtk) );
- // free the manager
+ // ABC_FREE the manager
p->timeTotal = clock() - clk;
Mfx_ManStop( p );
diff --git a/src/aig/mfx/mfxInt.h b/src/aig/mfx/mfxInt.h
index 9095c8ce..4263724c 100644
--- a/src/aig/mfx/mfxInt.h
+++ b/src/aig/mfx/mfxInt.h
@@ -21,10 +21,6 @@
#ifndef __MFX_INT_H__
#define __MFX_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -41,6 +37,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define MFX_FANIN_MAX 12
typedef struct Mfx_Man_t_ Mfx_Man_t;
diff --git a/src/aig/mfx/mfxInter.c b/src/aig/mfx/mfxInter.c
index a42e02fe..3e1e3de2 100644
--- a/src/aig/mfx/mfxInter.c
+++ b/src/aig/mfx/mfxInter.c
@@ -222,7 +222,7 @@ unsigned * Mfx_InterplateTruth( Mfx_Man_t * p, int * pCands, int nCands, int fIn
pSat = Mfx_CreateSolverResub( p, pCands, nCands, fInvert );
// solve the problem
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( status != l_False )
{
p->nTimeOuts++;
@@ -322,7 +322,7 @@ Hop_Obj_t * Mfx_Interplate( Mfx_Man_t * p, int * pCands, int nCands )
pSat = Mfx_CreateSolverResub( p, pCands, nCands, 0 );
// solve the problem
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( status != l_False )
{
p->nTimeOuts++;
diff --git a/src/aig/mfx/mfxMan.c b/src/aig/mfx/mfxMan.c
index b8361a20..2af3d573 100644
--- a/src/aig/mfx/mfxMan.c
+++ b/src/aig/mfx/mfxMan.c
@@ -43,7 +43,7 @@ Mfx_Man_t * Mfx_ManAlloc( Mfx_Par_t * pPars )
{
Mfx_Man_t * p;
// start the manager
- p = ALLOC( Mfx_Man_t, 1 );
+ p = ABC_ALLOC( Mfx_Man_t, 1 );
memset( p, 0, sizeof(Mfx_Man_t) );
p->pPars = pPars;
p->vProjVars = Vec_IntAlloc( 100 );
@@ -135,13 +135,13 @@ void Mfx_ManPrint( Mfx_Man_t * p )
p->nNodesDec, 1.0 * p->nNodesDec / p->nNodesTried, p->nNodesGained, p->nTimeOuts );
}
/*
- PRTP( "Win", p->timeWin , p->timeTotal );
- PRTP( "Div", p->timeDiv , p->timeTotal );
- PRTP( "Aig", p->timeAig , p->timeTotal );
- PRTP( "Cnf", p->timeCnf , p->timeTotal );
- PRTP( "Sat", p->timeSat-p->timeInt , p->timeTotal );
- PRTP( "Int", p->timeInt , p->timeTotal );
- PRTP( "ALL", p->timeTotal , p->timeTotal );
+ ABC_PRTP( "Win", p->timeWin , p->timeTotal );
+ ABC_PRTP( "Div", p->timeDiv , p->timeTotal );
+ ABC_PRTP( "Aig", p->timeAig , p->timeTotal );
+ ABC_PRTP( "Cnf", p->timeCnf , p->timeTotal );
+ ABC_PRTP( "Sat", p->timeSat-p->timeInt , p->timeTotal );
+ ABC_PRTP( "Int", p->timeInt , p->timeTotal );
+ ABC_PRTP( "ALL", p->timeTotal , p->timeTotal );
*/
}
@@ -178,7 +178,7 @@ void Mfx_ManStop( Mfx_Man_t * p )
Vec_IntFree( p->vProjVars );
Vec_IntFree( p->vDivLits );
Vec_PtrFree( p->vDivCexes );
- free( p );
+ ABC_FREE( p );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/mfx/mfxResub.c b/src/aig/mfx/mfxResub.c
index 312ae226..a9ed23a0 100644
--- a/src/aig/mfx/mfxResub.c
+++ b/src/aig/mfx/mfxResub.c
@@ -97,7 +97,7 @@ int Mfx_TryResubOnce( Mfx_Man_t * p, int * pCands, int nCands )
unsigned * pData;
int RetValue, iVar, i;
p->nSatCalls++;
- RetValue = sat_solver_solve( p->pSat, pCands, pCands + nCands, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSat, pCands, pCands + nCands, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
// assert( RetValue == l_False || RetValue == l_True );
if ( RetValue == l_False )
return 1;
diff --git a/src/aig/mfx/mfxSat.c b/src/aig/mfx/mfxSat.c
index 9dd42e8c..ce8d580b 100644
--- a/src/aig/mfx/mfxSat.c
+++ b/src/aig/mfx/mfxSat.c
@@ -46,7 +46,7 @@ int Mfx_SolveSat_iter( Mfx_Man_t * p )
if ( p->nTotConfLim && p->nTotConfLim <= p->pSat->stats.conflicts )
return -1;
nBTLimit = p->nTotConfLim? p->nTotConfLim - p->pSat->stats.conflicts : 0;
- RetValue = sat_solver_solve( p->pSat, NULL, NULL, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSat, NULL, NULL, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
assert( RetValue == l_Undef || RetValue == l_True || RetValue == l_False );
if ( RetValue == l_Undef )
return -1;
diff --git a/src/aig/ntl/ntl.h b/src/aig/ntl/ntl.h
index ac266ca5..0a44d2dc 100644
--- a/src/aig/ntl/ntl.h
+++ b/src/aig/ntl/ntl.h
@@ -21,10 +21,6 @@
#ifndef __NTL_H__
#define __NTL_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,6 +33,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -185,17 +185,6 @@ struct Ntl_Lut_t_
/// INLINED FUNCTIONS ///
////////////////////////////////////////////////////////////////////////
-#ifdef WIN32
-#define ABC_DLLEXPORT __declspec(dllexport)
-#define ABC_DLLIMPORT __declspec(dllimport)
-#else /* defined(WIN32) */
-#define ABC_DLLIMPORT
-#endif /* defined(WIN32) */
-
-#ifndef ABC_DLL
-#define ABC_DLL ABC_DLLIMPORT
-#endif
-
static inline Ntl_Mod_t * Ntl_ManRootModel( Ntl_Man_t * p ) { return (Ntl_Mod_t *)Vec_PtrEntry( p->vModels, 0 ); }
static inline int Ntl_ModelPiNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_PI]; }
diff --git a/src/aig/ntl/ntlFraig.c b/src/aig/ntl/ntlFraig.c
index d2ae4204..405ec83f 100644
--- a/src/aig/ntl/ntlFraig.c
+++ b/src/aig/ntl/ntlFraig.c
@@ -52,7 +52,7 @@ void Ntl_ManUpdateNoMergeReprs( Aig_Man_t * pAig, Aig_Obj_t ** pReprs )
int i;
// allocate room for the new representative
- pReprsNew = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ pReprsNew = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
memset( pReprsNew, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) );
Aig_ManForEachObj( pAig, pObj, i )
{
@@ -105,7 +105,7 @@ void Ntl_ManUpdateNoMergeReprs( Aig_Man_t * pAig, Aig_Obj_t ** pReprs )
else
pReprs[ pObj->Id ] = NULL;
}
- free( pReprsNew );
+ ABC_FREE( pReprsNew );
}
/**Function*************************************************************
@@ -148,7 +148,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_
// (each node in the collapsed manager may have more than one equivalent node
// in the original manager; this procedure finds the first node in the original
// manager that is equivalent to the given node in the collapsed manager)
- pMapBack = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAigCol) );
+ pMapBack = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAigCol) );
memset( pMapBack, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAigCol) );
Aig_ManForEachObj( pAig, pObj, i )
{
@@ -162,7 +162,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_
}
// create the equivalence classes for the original manager
- pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
memset( pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) );
Aig_ManForEachObj( pAig, pObj, i )
{
@@ -186,7 +186,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_
else
pReprs[pCorresp->Id] = pObj;
}
- free( pMapBack );
+ ABC_FREE( pMapBack );
// recall pointers to the nets of pNew
Aig_ManForEachObj( pAig, pObj, i )
diff --git a/src/aig/ntl/ntlMan.c b/src/aig/ntl/ntlMan.c
index 8b26e405..552d5c15 100644
--- a/src/aig/ntl/ntlMan.c
+++ b/src/aig/ntl/ntlMan.c
@@ -43,7 +43,7 @@ Ntl_Man_t * Ntl_ManAlloc()
{
Ntl_Man_t * p;
// start the manager
- p = ALLOC( Ntl_Man_t, 1 );
+ p = ABC_ALLOC( Ntl_Man_t, 1 );
memset( p, 0, sizeof(Ntl_Man_t) );
p->vModels = Vec_PtrAlloc( 1000 );
p->vCis = Vec_PtrAlloc( 1000 );
@@ -56,7 +56,7 @@ Ntl_Man_t * Ntl_ManAlloc()
p->pMemSops = Aig_MmFlexStart();
// allocate model table
p->nModTableSize = Aig_PrimeCudd( 100 );
- p->pModTable = ALLOC( Ntl_Mod_t *, p->nModTableSize );
+ p->pModTable = ABC_ALLOC( Ntl_Mod_t *, p->nModTableSize );
memset( p->pModTable, 0, sizeof(Ntl_Mod_t *) * p->nModTableSize );
return p;
}
@@ -203,8 +203,8 @@ void Ntl_ManFree( Ntl_Man_t * p )
if ( p->pAig ) Aig_ManStop( p->pAig );
if ( p->pManTime ) Tim_ManStop( p->pManTime );
if ( p->pNal ) p->pNalF( p->pNal );
- FREE( p->pModTable );
- free( p );
+ ABC_FREE( p->pModTable );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -266,7 +266,7 @@ void Nwk_ManPrintStatsShort( Ntl_Man_t * p, Aig_Man_t * pAig, Nwk_Man_t * pNtk )
printf( "ff =%5d ", Counter );
if ( pAig != NULL )
{
- Counter = Aig_ManCountChoices( pAig );
+ Counter = Aig_ManChoiceNum( pAig );
if ( Counter )
printf( "cho =%7d ", Counter );
else
@@ -392,7 +392,7 @@ Ntl_Mod_t * Ntl_ModelAlloc( Ntl_Man_t * pMan, char * pName )
{
Ntl_Mod_t * p;
// start the manager
- p = ALLOC( Ntl_Mod_t, 1 );
+ p = ABC_ALLOC( Ntl_Mod_t, 1 );
memset( p, 0, sizeof(Ntl_Mod_t) );
p->attrBox = 1;
p->attrComb = 1;
@@ -407,7 +407,7 @@ Ntl_Mod_t * Ntl_ModelAlloc( Ntl_Man_t * pMan, char * pName )
p->vNets = Vec_PtrAlloc( 100 );
// start the table
p->nTableSize = Aig_PrimeCudd( 100 );
- p->pTable = ALLOC( Ntl_Net_t *, p->nTableSize );
+ p->pTable = ABC_ALLOC( Ntl_Net_t *, p->nTableSize );
memset( p->pTable, 0, sizeof(Ntl_Net_t *) * p->nTableSize );
// add model to the table
if ( !Ntl_ManAddModel( pMan, p ) )
@@ -562,8 +562,8 @@ void Ntl_ModelFree( Ntl_Mod_t * p )
Vec_PtrFree( p->vObjs );
Vec_PtrFree( p->vPis );
Vec_PtrFree( p->vPos );
- free( p->pTable );
- free( p );
+ ABC_FREE( p->pTable );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/ntl/ntlMap.c b/src/aig/ntl/ntlMap.c
index c6e80e75..10e7dd17 100644
--- a/src/aig/ntl/ntlMap.c
+++ b/src/aig/ntl/ntlMap.c
@@ -47,7 +47,7 @@ Vec_Ptr_t * Ntl_MappingAlloc( int nLuts, int nVars )
Ntl_Lut_t ** pArray;
int nEntrySize, i;
nEntrySize = sizeof(Ntl_Lut_t) + sizeof(int) * nVars + sizeof(unsigned) * Aig_TruthWordNum(nVars);
- pArray = (Ntl_Lut_t **)malloc( (sizeof(Ntl_Lut_t *) + nEntrySize) * nLuts );
+ pArray = (Ntl_Lut_t **)ABC_ALLOC( char, (sizeof(Ntl_Lut_t *) + nEntrySize) * nLuts );
pMemory = (char *)(pArray + nLuts);
memset( pMemory, 0, nEntrySize * nLuts );
for ( i = 0; i < nLuts; i++ )
@@ -312,7 +312,7 @@ Vec_Ptr_t * Ntl_MappingIf( Ntl_Man_t * pMan, Aig_Man_t * p )
// perform FPGA mapping
Ntl_ManSetIfParsDefault( pPars );
// set the arrival times
- pPars->pTimesArr = ALLOC( float, Aig_ManPiNum(p) );
+ pPars->pTimesArr = ABC_ALLOC( float, Aig_ManPiNum(p) );
memset( pPars->pTimesArr, 0, sizeof(float) * Aig_ManPiNum(p) );
// translate into the mapper
pIfMan = Ntl_ManToIf( p, pPars );
diff --git a/src/aig/ntl/ntlReadBlif.c b/src/aig/ntl/ntlReadBlif.c
index 3021d556..f94595b8 100644
--- a/src/aig/ntl/ntlReadBlif.c
+++ b/src/aig/ntl/ntlReadBlif.c
@@ -213,7 +213,7 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
static Ioa_ReadMan_t * Ioa_ReadAlloc()
{
Ioa_ReadMan_t * p;
- p = ALLOC( Ioa_ReadMan_t, 1 );
+ p = ABC_ALLOC( Ioa_ReadMan_t, 1 );
memset( p, 0, sizeof(Ioa_ReadMan_t) );
p->vLines = Vec_PtrAlloc( 512 );
p->vModels = Vec_PtrAlloc( 512 );
@@ -241,7 +241,7 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p )
if ( p->pDesign )
Ntl_ManFree( p->pDesign );
if ( p->pBuffer )
- free( p->pBuffer );
+ ABC_FREE( p->pBuffer );
if ( p->vLines )
Vec_PtrFree( p->vLines );
if ( p->vModels )
@@ -253,7 +253,7 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p )
Vec_PtrFree( p->vTokens );
Vec_PtrFree( p->vTokens2 );
Vec_StrFree( p->vFunc );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -270,7 +270,7 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p )
static Ioa_ReadMod_t * Ioa_ReadModAlloc()
{
Ioa_ReadMod_t * p;
- p = ALLOC( Ioa_ReadMod_t, 1 );
+ p = ABC_ALLOC( Ioa_ReadMod_t, 1 );
memset( p, 0, sizeof(Ioa_ReadMod_t) );
p->vInputs = Vec_PtrAlloc( 8 );
p->vOutputs = Vec_PtrAlloc( 8 );
@@ -304,7 +304,7 @@ static void Ioa_ReadModFree( Ioa_ReadMod_t * p )
Vec_PtrFree( p->vDelays );
Vec_PtrFree( p->vTimeInputs );
Vec_PtrFree( p->vTimeOutputs );
- free( p );
+ ABC_FREE( p );
}
@@ -448,7 +448,7 @@ static char * Ioa_ReadLoadFile( char * pFileName )
printf( "Ioa_ReadLoadFile(): The file is empty.\n" );
return NULL;
}
- pContents = ALLOC( char, nFileSize + 10 );
+ pContents = ABC_ALLOC( char, nFileSize + 10 );
rewind( pFile );
fread( pContents, nFileSize, 1, pFile );
fclose( pFile );
@@ -498,9 +498,9 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
}
do {
if (!bufHead)
- buf = bufHead = ALLOC( buflist, 1 );
+ buf = bufHead = ABC_ALLOC( buflist, 1 );
else
- buf = buf->next = ALLOC( buflist, 1 );
+ buf = buf->next = ABC_ALLOC( buflist, 1 );
nFileSize += buf->nBuf = BZ2_bzRead(&bzError,b,buf->buf,1<<20);
buf->next = NULL;
} while (bzError == BZ_OK);
@@ -509,14 +509,14 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
char * p;
int nBytes = 0;
BZ2_bzReadClose(&bzError,b);
- p = pContents = ALLOC( char, nFileSize + 10 );
+ p = pContents = ABC_ALLOC( char, nFileSize + 10 );
buf = bufHead;
do {
memcpy(p+nBytes,buf->buf,buf->nBuf);
nBytes += buf->nBuf;
// } while((buf = buf->next));
pNext = buf->next;
- free( buf );
+ ABC_FREE( buf );
} while((buf = pNext));
} else if (bzError == BZ_DATA_ERROR_MAGIC) {
// not a BZIP2 file
@@ -528,7 +528,7 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
printf( "Ioa_ReadLoadFileBz2(): The file is empty.\n" );
return NULL;
}
- pContents = ALLOC( char, nFileSize + 10 );
+ pContents = ABC_ALLOC( char, nFileSize + 10 );
rewind( pFile );
fread( pContents, nFileSize, 1, pFile );
} else {
@@ -561,12 +561,12 @@ static char * Ioa_ReadLoadFileGz( char * pFileName )
char * pContents;
int amtRead, readBlock, nFileSize = READ_BLOCK_SIZE;
pFile = gzopen( pFileName, "rb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
- pContents = ALLOC( char, nFileSize );
+ pContents = ABC_ALLOC( char, nFileSize );
readBlock = 0;
while ((amtRead = gzread(pFile, pContents + readBlock * READ_BLOCK_SIZE, READ_BLOCK_SIZE)) == READ_BLOCK_SIZE) {
//printf("%d: read %d bytes\n", readBlock, amtRead);
nFileSize += READ_BLOCK_SIZE;
- pContents = REALLOC(char, pContents, nFileSize);
+ pContents = ABC_REALLOC(char, pContents, nFileSize);
++readBlock;
}
//printf("%d: read %d bytes\n", readBlock, amtRead);
diff --git a/src/aig/ntl/ntlTable.c b/src/aig/ntl/ntlTable.c
index 62f65d6c..d227b1b9 100644
--- a/src/aig/ntl/ntlTable.c
+++ b/src/aig/ntl/ntlTable.c
@@ -82,7 +82,7 @@ clk = clock();
// get the new table size
nTableSizeNew = Aig_PrimeCudd( 3 * p->nTableSize );
// allocate a new array
- pTableNew = ALLOC( Ntl_Net_t *, nTableSizeNew );
+ pTableNew = ABC_ALLOC( Ntl_Net_t *, nTableSizeNew );
memset( pTableNew, 0, sizeof(Ntl_Net_t *) * nTableSizeNew );
// rehash entries
Counter = 0;
@@ -97,9 +97,9 @@ clk = clock();
}
assert( Counter == p->nEntries );
// printf( "Increasing the structural table size from %6d to %6d. ", p->nTableSize, nTableSizeNew );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
// replace the table and the parameters
- free( p->pTable );
+ ABC_FREE( p->pTable );
p->pTable = pTableNew;
p->nTableSize = nTableSizeNew;
}
@@ -447,7 +447,7 @@ clk = clock();
// get the new table size
nModTableSizeNew = Aig_PrimeCudd( 3 * p->nModTableSize );
// allocate a new array
- pModTableNew = ALLOC( Ntl_Mod_t *, nModTableSizeNew );
+ pModTableNew = ABC_ALLOC( Ntl_Mod_t *, nModTableSizeNew );
memset( pModTableNew, 0, sizeof(Ntl_Mod_t *) * nModTableSizeNew );
// rehash entries
Counter = 0;
@@ -462,9 +462,9 @@ clk = clock();
}
assert( Counter == p->nModEntries );
// printf( "Increasing the structural table size from %6d to %6d. ", p->nTableSize, nTableSizeNew );
-// PRT( "Time", clock() - clk );
+// ABC_PRT( "Time", clock() - clk );
// replace the table and the parameters
- free( p->pModTable );
+ ABC_FREE( p->pModTable );
p->pModTable = pModTableNew;
p->nModTableSize = nModTableSizeNew;
}
diff --git a/src/aig/ntl/ntlTime.c b/src/aig/ntl/ntlTime.c
index 121fb8ea..f9fadaa8 100644
--- a/src/aig/ntl/ntlTime.c
+++ b/src/aig/ntl/ntlTime.c
@@ -44,7 +44,7 @@ float * Ntl_ManCreateDelayTable( Vec_Int_t * vDelays, int nIns, int nOuts )
float * pDelayTable, Delay;
int iIn, iOut, i, k;
assert( Vec_IntSize(vDelays) % 3 == 0 );
- pDelayTable = ALLOC( float, nIns * nOuts );
+ pDelayTable = ABC_ALLOC( float, nIns * nOuts );
memset( pDelayTable, 0, sizeof(float) * nIns * nOuts );
Vec_IntForEachEntry( vDelays, iIn, i )
{
diff --git a/src/aig/ntl/ntlUtil.c b/src/aig/ntl/ntlUtil.c
index 6e797590..9c3d4e42 100644
--- a/src/aig/ntl/ntlUtil.c
+++ b/src/aig/ntl/ntlUtil.c
@@ -390,7 +390,7 @@ Vec_Vec_t * Ntl_ManTransformRegClasses( Ntl_Man_t * pMan, int nSizeMax, int fVer
return NULL;
}
// count the number of classes
- pClassNums = CALLOC( int, ClassMax + 1 );
+ pClassNums = ABC_CALLOC( int, ClassMax + 1 );
Vec_IntForEachEntry( pMan->vRegClasses, Class, k )
pClassNums[Class]++;
// count the number of classes
@@ -417,7 +417,7 @@ Vec_Vec_t * Ntl_ManTransformRegClasses( Ntl_Man_t * pMan, int nSizeMax, int fVer
Vec_PtrPush( vParts, vPart );
}
printf( "There is only one class with %d registers.\n", Vec_IntSize(pMan->vRegClasses) );
- free( pClassNums );
+ ABC_FREE( pClassNums );
return (Vec_Vec_t *)vParts;
}
// create classes
@@ -433,7 +433,7 @@ Vec_Vec_t * Ntl_ManTransformRegClasses( Ntl_Man_t * pMan, int nSizeMax, int fVer
assert( Vec_IntSize(vPart) == pClassNums[i] );
Vec_PtrPush( vParts, vPart );
}
- free( pClassNums );
+ ABC_FREE( pClassNums );
Vec_VecSort( (Vec_Vec_t *)vParts, 1 );
// report the selected classes
if ( fVerbose )
diff --git a/src/aig/ntl/ntlWriteBlif.c b/src/aig/ntl/ntlWriteBlif.c
index 3df49270..4099d738 100644
--- a/src/aig/ntl/ntlWriteBlif.c
+++ b/src/aig/ntl/ntlWriteBlif.c
@@ -270,7 +270,7 @@ int fprintfBz2(bz2file * b, char * fmt, ...) {
b->nBytesMax = b->nBytes + 1;
else
b->nBytesMax *= 2;
- if ((newBuf = REALLOC( char,b->buf,b->nBytesMax )) == NULL)
+ if ((newBuf = ABC_REALLOC( char,b->buf,b->nBytesMax )) == NULL)
return -1;
else
b->buf = newBuf;
@@ -645,14 +645,14 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
memset(&b,0,sizeof(b));
b.nBytesMax = (1<<12);
- b.buf = ALLOC( char,b.nBytesMax );
+ b.buf = ABC_ALLOC( char,b.nBytesMax );
// start the output stream
b.f = fopen( pFileName, "wb" );
if ( b.f == NULL )
{
fprintf( stdout, "Ioa_WriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
- FREE(b.buf);
+ ABC_FREE(b.buf);
return;
}
if (!strncmp(pFileName+strlen(pFileName)-4,".bz2",4)) {
@@ -661,7 +661,7 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
BZ2_bzWriteClose( &bzError, b.b, 0, NULL, NULL );
fprintf( stdout, "Ioa_WriteBlif(): Cannot start compressed stream.\n" );
fclose( b.f );
- FREE(b.buf);
+ ABC_FREE(b.buf);
return;
}
}
@@ -676,12 +676,12 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
if (bzError == BZ_IO_ERROR) {
fprintf( stdout, "Ioa_WriteBlif(): I/O error closing compressed stream.\n" );
fclose( b.f );
- FREE(b.buf);
+ ABC_FREE(b.buf);
return;
}
}
fclose( b.f );
- FREE(b.buf);
+ ABC_FREE(b.buf);
}
diff --git a/src/aig/nwk/nwk.h b/src/aig/nwk/nwk.h
index 0ea8241b..c8cc91cb 100644
--- a/src/aig/nwk/nwk.h
+++ b/src/aig/nwk/nwk.h
@@ -20,10 +20,6 @@
#ifndef __NWK_H__
#define __NWK_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
@@ -39,6 +35,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -120,19 +120,6 @@ struct Nwk_Obj_t_
/// INLINED FUNCTIONS ///
////////////////////////////////////////////////////////////////////////
-//#pragma warning( disable : 4273 )
-
-#ifdef WIN32
-#define ABC_DLLEXPORT __declspec(dllexport)
-#define ABC_DLLIMPORT __declspec(dllimport)
-#else /* defined(WIN32) */
-#define ABC_DLLIMPORT
-#endif /* defined(WIN32) */
-
-#ifndef ABC_DLL
-#define ABC_DLL ABC_DLLIMPORT
-#endif
-
static inline int Nwk_ManCiNum( Nwk_Man_t * p ) { return p->nObjs[NWK_OBJ_CI]; }
static inline int Nwk_ManCoNum( Nwk_Man_t * p ) { return p->nObjs[NWK_OBJ_CO]; }
static inline int Nwk_ManNodeNum( Nwk_Man_t * p ) { return p->nObjs[NWK_OBJ_NODE]; }
diff --git a/src/aig/nwk/nwkBidec.c b/src/aig/nwk/nwkBidec.c
index 2b60d779..13abf81f 100644
--- a/src/aig/nwk/nwkBidec.c
+++ b/src/aig/nwk/nwkBidec.c
@@ -160,7 +160,7 @@ void Nwk_ManBidecResyn( Nwk_Man_t * pNtk, int fVerbose )
if ( fVerbose )
{
printf( "Total gain in AIG nodes = %d. ", nGainTotal );
- PRT( "Total runtime", clock() - clk );
+ ABC_PRT( "Total runtime", clock() - clk );
}
}
diff --git a/src/aig/nwk/nwkFlow.c b/src/aig/nwk/nwkFlow.c
index b6155056..5efd0233 100644
--- a/src/aig/nwk/nwkFlow.c
+++ b/src/aig/nwk/nwkFlow.c
@@ -501,7 +501,7 @@ Vec_Ptr_t * Nwk_ManRetimeCutForward( Nwk_Man_t * pMan, int nLatches, int fVerbos
if ( fVerbose )
{
printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
return vNodes;
}
@@ -588,7 +588,7 @@ Vec_Ptr_t * Nwk_ManRetimeCutBackward( Nwk_Man_t * pMan, int nLatches, int fVerbo
if ( fVerbose )
{
printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
return vNodes;
}
diff --git a/src/aig/nwk/nwkMan.c b/src/aig/nwk/nwkMan.c
index 6b67d3c1..d6e20672 100644
--- a/src/aig/nwk/nwkMan.c
+++ b/src/aig/nwk/nwkMan.c
@@ -42,7 +42,7 @@
Nwk_Man_t * Nwk_ManAlloc()
{
Nwk_Man_t * p;
- p = ALLOC( Nwk_Man_t, 1 );
+ p = ABC_ALLOC( Nwk_Man_t, 1 );
memset( p, 0, sizeof(Nwk_Man_t) );
p->vCis = Vec_PtrAlloc( 1000 );
p->vCos = Vec_PtrAlloc( 1000 );
@@ -68,8 +68,8 @@ Nwk_Man_t * Nwk_ManAlloc()
void Nwk_ManFree( Nwk_Man_t * p )
{
// printf( "The number of realloced nodes = %d.\n", p->nRealloced );
- if ( p->pName ) free( p->pName );
- if ( p->pSpec ) free( p->pSpec );
+ if ( p->pName ) ABC_FREE( p->pName );
+ if ( p->pSpec ) ABC_FREE( p->pSpec );
if ( p->vCis ) Vec_PtrFree( p->vCis );
if ( p->vCos ) Vec_PtrFree( p->vCos );
if ( p->vObjs ) Vec_PtrFree( p->vObjs );
@@ -77,7 +77,7 @@ void Nwk_ManFree( Nwk_Man_t * p )
if ( p->pManTime ) Tim_ManStop( p->pManTime );
if ( p->pMemObjs ) Aig_MmFlexStop( p->pMemObjs, 0 );
if ( p->pManHop ) Hop_ManStop( p->pManHop );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -127,10 +127,10 @@ int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
int nPis; // the number of primary inputs
int nPos; // the number of primary outputs
} ParsNew, ParsBest = { 0 };
- // free storage for the name
+ // ABC_FREE storage for the name
if ( pNtk == NULL )
{
- FREE( ParsBest.pName );
+ ABC_FREE( ParsBest.pName );
return 0;
}
// get the parameters
@@ -146,7 +146,7 @@ int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
(ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops) ||
(ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes > ParsNew.Nodes) )
{
- FREE( ParsBest.pName );
+ ABC_FREE( ParsBest.pName );
ParsBest.pName = Aig_UtilStrsav( pNtk->pName );
ParsBest.Depth = ParsNew.Depth;
ParsBest.Flops = ParsNew.Flops;
@@ -242,7 +242,7 @@ void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int
Ioa_WriteBlifLogic( pNtk, pNtl, Buffer );
// sprintf( Buffer, "%s_dump_map.blif", pNameGen );
// Nwk_ManDumpBlif( pNtk, Buffer, NULL, NULL );
- if ( pNtk->pSpec ) free( pNameGen );
+ if ( pNtk->pSpec ) ABC_FREE( pNameGen );
}
pNtk->pLutLib = pLutLib;
diff --git a/src/aig/nwk/nwkMap.c b/src/aig/nwk/nwkMap.c
index a70bb9b1..e6865840 100644
--- a/src/aig/nwk/nwkMap.c
+++ b/src/aig/nwk/nwkMap.c
@@ -113,7 +113,7 @@ If_Man_t * Nwk_ManToIf( Aig_Man_t * p, If_Par_t * pPars, Vec_Ptr_t * vAigToIf )
vSwitching = Saig_ManComputeSwitchProbs( p, 48, 16, 0 );
if ( pPars->fVerbose )
{
- PRT( "Computing switching activity", clock() - clk );
+ ABC_PRT( "Computing switching activity", clock() - clk );
}
pSwitching = (float *)vSwitching->pArray;
vSwitching2 = Vec_IntStart( Aig_ManObjNumMax(p) );
@@ -355,7 +355,7 @@ Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars
If_Man_t * pIfMan;
Vec_Ptr_t * vAigToIf;
// set the arrival times
- pPars->pTimesArr = ALLOC( float, Aig_ManPiNum(p) );
+ pPars->pTimesArr = ABC_ALLOC( float, Aig_ManPiNum(p) );
memset( pPars->pTimesArr, 0, sizeof(float) * Aig_ManPiNum(p) );
// translate into the mapper
vAigToIf = Vec_PtrStart( Aig_ManObjNumMax(p) );
diff --git a/src/aig/nwk/nwkMerge.c b/src/aig/nwk/nwkMerge.c
index 3aec4faa..bc7826e1 100644
--- a/src/aig/nwk/nwkMerge.c
+++ b/src/aig/nwk/nwkMerge.c
@@ -43,11 +43,11 @@
Nwk_Grf_t * Nwk_ManGraphAlloc( int nVertsMax )
{
Nwk_Grf_t * p;
- p = ALLOC( Nwk_Grf_t, 1 );
+ p = ABC_ALLOC( Nwk_Grf_t, 1 );
memset( p, 0, sizeof(Nwk_Grf_t) );
p->nVertsMax = nVertsMax;
p->nEdgeHash = Aig_PrimeCudd( 3 * nVertsMax );
- p->pEdgeHash = CALLOC( Nwk_Edg_t *, p->nEdgeHash );
+ p->pEdgeHash = ABC_CALLOC( Nwk_Edg_t *, p->nEdgeHash );
p->pMemEdges = Aig_MmFixedStart( sizeof(Nwk_Edg_t), p->nEdgeHash );
p->vPairs = Vec_IntAlloc( 1000 );
return p;
@@ -69,11 +69,11 @@ void Nwk_ManGraphFree( Nwk_Grf_t * p )
if ( p->vPairs ) Vec_IntFree( p->vPairs );
if ( p->pMemEdges ) Aig_MmFixedStop( p->pMemEdges, 0 );
if ( p->pMemVerts ) Aig_MmFlexStop( p->pMemVerts, 0 );
- FREE( p->pVerts );
- FREE( p->pEdgeHash );
- FREE( p->pMapLut2Id );
- FREE( p->pMapId2Lut );
- free( p );
+ ABC_FREE( p->pVerts );
+ ABC_FREE( p->pEdgeHash );
+ ABC_FREE( p->pMapLut2Id );
+ ABC_FREE( p->pMapId2Lut );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -276,8 +276,8 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p )
Nwk_Vrt_t * pVertex;
int * pnEdges, nBytes, i;
// allocate memory for the present objects
- p->pMapLut2Id = ALLOC( int, p->nObjs+1 );
- p->pMapId2Lut = ALLOC( int, p->nVertsMax+1 );
+ p->pMapLut2Id = ABC_ALLOC( int, p->nObjs+1 );
+ p->pMapId2Lut = ABC_ALLOC( int, p->nVertsMax+1 );
memset( p->pMapLut2Id, 0xff, sizeof(int) * (p->nObjs+1) );
memset( p->pMapId2Lut, 0xff, sizeof(int) * (p->nVertsMax+1) );
// mark present objects
@@ -299,7 +299,7 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p )
}
}
// count the edges and mark present objects
- pnEdges = CALLOC( int, p->nVerts+1 );
+ pnEdges = ABC_CALLOC( int, p->nVerts+1 );
Nwk_GraphForEachEdge( p, pEntry, i )
{
// translate into vertices
@@ -315,7 +315,7 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p )
}
// allocate the real graph
p->pMemVerts = Aig_MmFlexStart();
- p->pVerts = ALLOC( Nwk_Vrt_t *, p->nVerts + 1 );
+ p->pVerts = ABC_ALLOC( Nwk_Vrt_t *, p->nVerts + 1 );
p->pVerts[0] = NULL;
for ( i = 1; i <= p->nVerts; i++ )
{
@@ -341,9 +341,9 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p )
}
// clean up
Aig_MmFixedStop( p->pMemEdges, 0 ); p->pMemEdges = NULL;
- FREE( p->pEdgeHash );
+ ABC_FREE( p->pEdgeHash );
// p->nEdgeHash = 0;
- free( pnEdges );
+ ABC_FREE( pnEdges );
}
/**Function*************************************************************
@@ -362,7 +362,7 @@ void Nwk_ManGraphSortPairs( Nwk_Grf_t * p )
int nSize = Vec_IntSize(p->vPairs);
int * pIdToPair, i;
// allocate storage
- pIdToPair = ALLOC( int, p->nObjs+1 );
+ pIdToPair = ABC_ALLOC( int, p->nObjs+1 );
for ( i = 0; i <= p->nObjs; i++ )
pIdToPair[i] = -1;
// create mapping
@@ -381,7 +381,7 @@ void Nwk_ManGraphSortPairs( Nwk_Grf_t * p )
Vec_IntPush( p->vPairs, pIdToPair[i] );
}
assert( nSize == Vec_IntSize(p->vPairs) );
- free( pIdToPair );
+ ABC_FREE( pIdToPair );
}
@@ -702,12 +702,12 @@ int Nwk_ManLutMergeGraphTest( char * pFileName )
Nwk_Grf_t * p;
int clk = clock();
p = Nwk_ManLutMergeReadGraph( pFileName );
- PRT( "Reading", clock() - clk );
+ ABC_PRT( "Reading", clock() - clk );
clk = clock();
Nwk_ManGraphSolve( p );
printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ",
p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 );
- PRT( "Solving", clock() - clk );
+ ABC_PRT( "Solving", clock() - clk );
nPairs = Vec_IntSize(p->vPairs)/2;
Nwk_ManGraphReportMemoryUsage( p );
Nwk_ManGraphFree( p );
@@ -1009,7 +1009,7 @@ Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars )
if ( pPars->fVerbose )
{
printf( "Mergable LUTs = %6d. Total cands = %6d. ", p->nVertsMax, nCands );
- PRT( "Deriving graph", clock() - clk );
+ ABC_PRT( "Deriving graph", clock() - clk );
}
// solve the graph problem
clk = clock();
@@ -1018,7 +1018,7 @@ Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars )
{
printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ",
p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 );
- PRT( "Solving", clock() - clk );
+ ABC_PRT( "Solving", clock() - clk );
Nwk_ManGraphReportMemoryUsage( p );
}
vResult = p->vPairs; p->vPairs = NULL;
diff --git a/src/aig/nwk/nwkMerge.h b/src/aig/nwk/nwkMerge.h
index 3763e4b2..ab39ec39 100644
--- a/src/aig/nwk/nwkMerge.h
+++ b/src/aig/nwk/nwkMerge.h
@@ -21,10 +21,6 @@
#ifndef __NWK_MERGE_H__
#define __NWK_MERGE_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define NWK_MAX_LIST 16
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/nwk/nwkSpeedup.c b/src/aig/nwk/nwkSpeedup.c
index 469e9b71..54e4d414 100644
--- a/src/aig/nwk/nwkSpeedup.c
+++ b/src/aig/nwk/nwkSpeedup.c
@@ -221,7 +221,7 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
printf( "\n" );
}
// mark the timing critical nodes and edges
- puTCEdges = ALLOC( unsigned, Nwk_ManObjNumMax(pNtk) );
+ puTCEdges = ABC_ALLOC( unsigned, Nwk_ManObjNumMax(pNtk) );
memset( puTCEdges, 0, sizeof(unsigned) * Nwk_ManObjNumMax(pNtk) );
Nwk_ManForEachNode( pNtk, pNode, i )
{
@@ -244,7 +244,7 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
}
// start the resulting network
pAig = Nwk_ManStrash( pNtk );
- pAig->pEquivs = ALLOC( Aig_Obj_t *, 3 * Aig_ManObjNumMax(pAig) );
+ pAig->pEquivs = ABC_ALLOC( Aig_Obj_t *, 3 * Aig_ManObjNumMax(pAig) );
memset( pAig->pEquivs, 0, sizeof(Aig_Obj_t *) * 3 * Aig_ManObjNumMax(pAig) );
// collect nodes to be used for resynthesis
@@ -332,7 +332,7 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
}
Vec_PtrFree( vTimeCries );
Vec_PtrFree( vTimeFanins );
- free( puTCEdges );
+ ABC_FREE( puTCEdges );
if ( fVerbose )
printf( "Nodes: Total = %7d. 0-slack = %7d. Workable = %7d. Ratio = %4.2f\n",
Nwk_ManNodeNum(pNtk), Counter, CounterRes, Counter? 1.0*CounterRes/Counter : 0.0 );
diff --git a/src/aig/nwk/nwkTiming.c b/src/aig/nwk/nwkTiming.c
index fc56b387..80391c66 100644
--- a/src/aig/nwk/nwkTiming.c
+++ b/src/aig/nwk/nwkTiming.c
@@ -468,7 +468,7 @@ void Nwk_ManDelayTracePrint( Nwk_Man_t * pNtk )
}
// decide how many steps
nSteps = pLutLib ? 20 : Nwk_ManLevelMax(pNtk);
- pCounters = ALLOC( int, nSteps + 1 );
+ pCounters = ABC_ALLOC( int, nSteps + 1 );
memset( pCounters, 0, sizeof(int)*(nSteps + 1) );
// perform delay trace
tArrival = Nwk_ManDelayTraceLut( pNtk );
@@ -493,7 +493,7 @@ void Nwk_ManDelayTracePrint( Nwk_Man_t * pNtk )
printf( "%3d %s : %5d (%6.2f %%)\n", pLutLib? 5*(i+1) : i+1,
pLutLib? "%":"lev", Nodes, 100.0*Nodes/Nwk_ManNodeNum(pNtk) );
}
- free( pCounters );
+ ABC_FREE( pCounters );
}
diff --git a/src/aig/nwk2/nwk.h b/src/aig/nwk2/nwk.h
index bef16284..36d483fc 100644
--- a/src/aig/nwk2/nwk.h
+++ b/src/aig/nwk2/nwk.h
@@ -21,10 +21,6 @@
#ifndef __NWK_H__
#define __NWK_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,6 +33,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/nwk2/nwkMerge.h b/src/aig/nwk2/nwkMerge.h
index df426681..f5697f6e 100644
--- a/src/aig/nwk2/nwkMerge.h
+++ b/src/aig/nwk2/nwkMerge.h
@@ -21,10 +21,6 @@
#ifndef __NWK_MERGE_H__
#define __NWK_MERGE_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define NWK_MAX_LIST 16
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/rwt/rwt.h b/src/aig/rwt/rwt.h
index 56f66f34..9efdc421 100644
--- a/src/aig/rwt/rwt.h
+++ b/src/aig/rwt/rwt.h
@@ -21,10 +21,6 @@
#ifndef __RWT_H__
#define __RWT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,6 +33,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -112,10 +112,10 @@ struct Rwt_Node_t_ // 24 bytes
};
// manipulation of complemented attributes
-static inline int Rwt_IsComplement( Rwt_Node_t * p ) { return (int)(((PORT_PTRUINT_T)p) & 01); }
-static inline Rwt_Node_t * Rwt_Regular( Rwt_Node_t * p ) { return (Rwt_Node_t *)((PORT_PTRUINT_T)(p) & ~01); }
-static inline Rwt_Node_t * Rwt_Not( Rwt_Node_t * p ) { return (Rwt_Node_t *)((PORT_PTRUINT_T)(p) ^ 01); }
-static inline Rwt_Node_t * Rwt_NotCond( Rwt_Node_t * p, int c ) { return (Rwt_Node_t *)((PORT_PTRUINT_T)(p) ^ (c)); }
+static inline int Rwt_IsComplement( Rwt_Node_t * p ) { return (int)(((ABC_PTRUINT_T)p) & 01); }
+static inline Rwt_Node_t * Rwt_Regular( Rwt_Node_t * p ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) & ~01); }
+static inline Rwt_Node_t * Rwt_Not( Rwt_Node_t * p ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) ^ 01); }
+static inline Rwt_Node_t * Rwt_NotCond( Rwt_Node_t * p, int c ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
diff --git a/src/aig/rwt/rwtDec.c b/src/aig/rwt/rwtDec.c
index df6209cd..2f183913 100644
--- a/src/aig/rwt/rwtDec.c
+++ b/src/aig/rwt/rwtDec.c
@@ -49,7 +49,7 @@ void Rwt_ManPreprocess( Rwt_Man_t * p )
Rwt_Node_t * pNode;
int i, k;
// put the nodes into the structure
- p->pMapInv = ALLOC( unsigned short, 222 );
+ p->pMapInv = ABC_ALLOC( unsigned short, 222 );
memset( p->pMapInv, 0, sizeof(unsigned short) * 222 );
p->vClasses = Vec_VecStart( 222 );
for ( i = 0; i < p->nFuncs; i++ )
diff --git a/src/aig/rwt/rwtMan.c b/src/aig/rwt/rwtMan.c
index 869043a4..87074e6e 100644
--- a/src/aig/rwt/rwtMan.c
+++ b/src/aig/rwt/rwtMan.c
@@ -64,10 +64,10 @@ void Rwt_ManGlobalStart()
***********************************************************************/
void Rwt_ManGlobalStop()
{
- FREE( s_puCanons );
- FREE( s_pPhases );
- FREE( s_pPerms );
- FREE( s_pMap );
+ ABC_FREE( s_puCanons );
+ ABC_FREE( s_pPhases );
+ ABC_FREE( s_pPerms );
+ ABC_FREE( s_pMap );
}
/**Function*************************************************************
@@ -86,7 +86,7 @@ Rwt_Man_t * Rwt_ManStart( int fPrecompute )
Rwt_Man_t * p;
int clk = clock();
clk = clock();
- p = ALLOC( Rwt_Man_t, 1 );
+ p = ABC_ALLOC( Rwt_Man_t, 1 );
memset( p, 0, sizeof(Rwt_Man_t) );
p->nFuncs = (1<<16);
// copy the global tables
@@ -98,7 +98,7 @@ clk = clock();
// initialize practical NPN classes
p->pPractical = Rwt_ManGetPractical( p );
// create the table
- p->pTable = ALLOC( Rwt_Node_t *, p->nFuncs );
+ p->pTable = ABC_ALLOC( Rwt_Node_t *, p->nFuncs );
memset( p->pTable, 0, sizeof(Rwt_Node_t *) * p->nFuncs );
// create the elementary nodes
p->pMmNode = Mem_FixedStart( sizeof(Rwt_Node_t) );
@@ -159,11 +159,11 @@ void Rwt_ManStop( Rwt_Man_t * p )
Vec_PtrFree( p->vFanins );
Vec_PtrFree( p->vFaninsCur );
Mem_FixedStop( p->pMmNode, 0 );
- FREE( p->pMapInv );
- free( p->pTable );
- free( p->pPractical );
- free( p->pPerms4 );
- free( p );
+ ABC_FREE( p->pMapInv );
+ ABC_FREE( p->pTable );
+ ABC_FREE( p->pPractical );
+ ABC_FREE( p->pPerms4 );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -191,14 +191,14 @@ void Rwt_ManPrintStats( Rwt_Man_t * p )
printf( "Nodes considered = %8d.\n", p->nNodesConsidered );
printf( "Nodes rewritten = %8d.\n", p->nNodesRewritten );
printf( "Calculated gain = %8d.\n", p->nNodesGained );
- PRT( "Start ", p->timeStart );
- PRT( "Cuts ", p->timeCut );
- PRT( "Truth ", p->timeTruth );
- PRT( "Resynthesis ", p->timeRes );
- PRT( " Mffc ", p->timeMffc );
- PRT( " Eval ", p->timeEval );
- PRT( "Update ", p->timeUpdate );
- PRT( "TOTAL ", p->timeTotal );
+ ABC_PRT( "Start ", p->timeStart );
+ ABC_PRT( "Cuts ", p->timeCut );
+ ABC_PRT( "Truth ", p->timeTruth );
+ ABC_PRT( "Resynthesis ", p->timeRes );
+ ABC_PRT( " Mffc ", p->timeMffc );
+ ABC_PRT( " Eval ", p->timeEval );
+ ABC_PRT( "Update ", p->timeUpdate );
+ ABC_PRT( "TOTAL ", p->timeTotal );
/*
printf( "The scores are:\n" );
diff --git a/src/aig/rwt/rwtUtil.c b/src/aig/rwt/rwtUtil.c
index af3e1893..b0b653bd 100644
--- a/src/aig/rwt/rwtUtil.c
+++ b/src/aig/rwt/rwtUtil.c
@@ -247,7 +247,7 @@ void Rwt_ManLoadFromArray( Rwt_Man_t * p, int fVerbose )
if ( fVerbose )
{
printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
- printf( "The number of nodes loaded = %d. ", nEntries ); PRT( "Loading", clock() - clk );
+ printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", clock() - clk );
}
}
@@ -266,7 +266,7 @@ char * Rwt_ManGetPractical( Rwt_Man_t * p )
{
char * pPractical;
int i;
- pPractical = ALLOC( char, p->nFuncs );
+ pPractical = ABC_ALLOC( char, p->nFuncs );
memset( pPractical, 0, sizeof(char) * p->nFuncs );
pPractical[0] = 1;
for ( i = 1; ; i++ )
diff --git a/src/aig/saig/saig.h b/src/aig/saig/saig.h
index 84ff272a..3db3e396 100644
--- a/src/aig/saig/saig.h
+++ b/src/aig/saig/saig.h
@@ -21,10 +21,6 @@
#ifndef __SAIG_H__
#define __SAIG_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -35,6 +31,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -134,7 +134,7 @@ extern int Saig_MvManSimulate( Aig_Man_t * pAig, int fVerbose );
/*=== saigStrSim.c ==========================================================*/
extern Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fVerbose, Aig_Man_t ** ppMiter );
/*=== saigSwitch.c ==========================================================*/
-extern Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne );
+extern Vec_Int_t * Saig_ManComputeSwitchProb2s( Aig_Man_t * p, int nFrames, int nPref, int fProbOne );
/*=== saigSynch.c ==========================================================*/
extern Aig_Man_t * Saig_ManDupInitZero( Aig_Man_t * p );
/*=== saigTrans.c ==========================================================*/
diff --git a/src/aig/saig/saigAbs.c b/src/aig/saig/saigAbs.c
index d2a45b4e..c9e76626 100644
--- a/src/aig/saig/saigAbs.c
+++ b/src/aig/saig/saigAbs.c
@@ -54,7 +54,7 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo
Intp_Man_t * pManProof;
int RetValue, clk = clock();
// solve the problem
- RetValue = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfMax, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue == l_Undef )
{
printf( "Conflict limit is reached.\n" );
@@ -68,7 +68,7 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo
if ( fVerbose )
{
printf( "SAT solver returned UNSAT after %d conflicts. ", pSat->stats.conflicts );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
assert( RetValue == l_False );
pSatCnf = sat_solver_store_release( pSat );
@@ -81,7 +81,7 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo
if ( fVerbose )
{
printf( "SAT core contains %d clauses (out of %d). ", Vec_IntSize(vCore), pSat->stats.clauses );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
return vCore;
}
@@ -458,7 +458,7 @@ Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec
Vec_PtrForEachEntry( vFrames, pCnf, f )
nSatVars += pCnf->nVars;
// mark register variables
- pVars = ALLOC( int, nSatVars );
+ pVars = ABC_ALLOC( int, nSatVars );
for ( i = 0; i < nSatVars; i++ )
pVars[i] = -1;
Vec_PtrForEachEntry( vFrames, pCnf, f )
@@ -485,7 +485,7 @@ Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec
}
}
// mark used registers
- pFlops = CALLOC( int, Aig_ManRegNum(p) );
+ pFlops = ABC_CALLOC( int, Aig_ManRegNum(p) );
Vec_IntForEachEntry( vCore, iClause, i )
{
nSatClauses = 0;
@@ -513,8 +513,8 @@ Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec
for ( i = 0; i < Aig_ManRegNum(p); i++ )
if ( pFlops[i] )
Vec_IntPush( vFlops, i );
- free( pFlops );
- free( pVars );
+ ABC_FREE( pFlops );
+ ABC_FREE( pVars );
return vFlops;
}
@@ -536,7 +536,7 @@ Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t *
int * pVars, * pFlops;
int i, iClause, iReg, * piLit;
// mark register variables
- pVars = ALLOC( int, pCnf->nVars );
+ pVars = ABC_ALLOC( int, pCnf->nVars );
for ( i = 0; i < pCnf->nVars; i++ )
pVars[i] = -1;
Saig_ManForEachLi( pCnf->pMan, pObj, i )
@@ -544,7 +544,7 @@ Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t *
Saig_ManForEachLo( pCnf->pMan, pObj, i )
pVars[ pCnf->pVarNums[pObj->Id] ] = i;
// mark used registers
- pFlops = CALLOC( int, Aig_ManRegNum(pCnf->pMan) );
+ pFlops = ABC_CALLOC( int, Aig_ManRegNum(pCnf->pMan) );
Vec_IntForEachEntry( vCore, iClause, i )
{
// skip auxiliary clauses
@@ -564,8 +564,8 @@ Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t *
for ( i = 0; i < Aig_ManRegNum(pCnf->pMan); i++ )
if ( pFlops[i] )
Vec_IntPush( vFlops, i );
- free( pFlops );
- free( pVars );
+ ABC_FREE( pFlops );
+ ABC_FREE( pVars );
return vFlops;
}
@@ -806,7 +806,7 @@ Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, int nFrames, int nConfMax,
if ( fVerbose )
{
printf( "SAT solver: Vars = %7d. Clauses = %7d. ", pSat->size, pSat->stats.clauses );
- PRT( "Time", clock() - clk2 );
+ ABC_PRT( "Time", clock() - clk2 );
}
// compute UNSAT core
vCore = Saig_AbsSolverUnsatCore( pSat, nConfMax, fVerbose );
@@ -831,7 +831,7 @@ Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, int nFrames, int nConfMax,
if ( fVerbose )
{
printf( "The number of relevant registers is %d (out of %d). ", Vec_IntSize(vFlops), Aig_ManRegNum(p) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
}
/*
diff --git a/src/aig/saig/saigBmc.c b/src/aig/saig/saigBmc.c
index 7cccce96..d56d97a9 100644
--- a/src/aig/saig/saigBmc.c
+++ b/src/aig/saig/saigBmc.c
@@ -27,7 +27,7 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-#define AIG_VISITED ((Aig_Obj_t *)(PORT_PTRUINT_T)1)
+#define AIG_VISITED ((Aig_Obj_t *)(ABC_PTRUINT_T)1)
typedef struct Saig_Bmc_t_ Saig_Bmc_t;
struct Saig_Bmc_t_
@@ -88,7 +88,7 @@ Saig_Bmc_t * Saig_BmcManStart( Aig_Man_t * pAig, int nFramesMax, int nNodesMax,
Aig_Obj_t * pObj;
int i, Lit;
assert( Aig_ManRegNum(pAig) > 0 );
- p = (Saig_Bmc_t *)malloc( sizeof(Saig_Bmc_t) );
+ p = (Saig_Bmc_t *)ABC_ALLOC( char, sizeof(Saig_Bmc_t) );
memset( p, 0, sizeof(Saig_Bmc_t) );
// set parameters
p->nFramesMax = nFramesMax;
@@ -141,7 +141,7 @@ void Saig_BmcManStop( Saig_Bmc_t * p )
sat_solver_delete( p->pSat );
Vec_PtrFree( p->vTargets );
Vec_PtrFree( p->vVisited );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -311,7 +311,7 @@ void Saig_BmcInterval( Saig_Bmc_t * p )
// check if the node is gone
Vec_PtrForEachEntry( p->vVisited, pObj, i )
{
- iFrame = (int)(PORT_PTRINT_T)Vec_PtrEntry( p->vVisited, 1+i++ );
+ iFrame = (int)(ABC_PTRINT_T)Vec_PtrEntry( p->vVisited, 1+i++ );
pRes = Saig_BmcObjFrame( p, pObj, iFrame );
if ( Aig_ObjIsNone( Aig_Regular(pRes) ) )
Saig_BmcObjSetFrame( p, pObj, iFrame, NULL );
@@ -524,7 +524,7 @@ int Saig_BmcSolveTargets( Saig_Bmc_t * p )
return l_Undef;
VarNum = Saig_BmcSatNum( p, Aig_Regular(pObj) );
Lit = toLitCond( VarNum, Aig_IsComplement(pObj) );
- RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (sint64)p->nConfMaxOne, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (ABC_INT64_T)p->nConfMaxOne, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue == l_False ) // unsat
continue;
if ( RetValue == l_Undef ) // undecided
@@ -614,7 +614,7 @@ void Saig_BmcPerform( Aig_Man_t * pAig, int nFramesMax, int nNodesMax, int nConf
{
printf( "%3d : F = %3d. O =%4d. And = %7d. Var = %7d. Conf = %7d. ",
Iter, p->iFrameLast, p->iOutputLast, Aig_ManNodeNum(p->pFrm), p->nSatVars, (int)p->pSat->stats.conflicts );
- PRT( "Time", clock() - clk2 );
+ ABC_PRT( "Time", clock() - clk2 );
}
if ( RetValue != l_False )
break;
@@ -624,7 +624,7 @@ void Saig_BmcPerform( Aig_Man_t * pAig, int nFramesMax, int nNodesMax, int nConf
p->iOutputFail, p->iFrameFail );
else // if ( RetValue == l_False || RetValue == l_Undef )
printf( "No output was asserted in %d frames. ", p->iFramePrev-1 );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
if ( RetValue != l_True )
{
if ( p->iFrameLast >= p->nFramesMax )
diff --git a/src/aig/saig/saigBmc2.c b/src/aig/saig/saigBmc2.c
index 5776cd4a..8ba02528 100644
--- a/src/aig/saig/saigBmc2.c
+++ b/src/aig/saig/saigBmc2.c
@@ -199,7 +199,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim
printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ",
nFrames, Aig_ManPiNum(pFrames), Aig_ManPoNum(pFrames),
Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
fflush( stdout );
}
// rewrite the timeframes
@@ -213,7 +213,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim
{
printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ",
Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
fflush( stdout );
}
}
@@ -230,7 +230,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim
if ( fVerbose )
{
printf( "CNF: Variables = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
fflush( stdout );
}
status = sat_solver_simplify(pSat);
@@ -254,13 +254,13 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim
i % Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
}
clk = clock();
- status = sat_solver_solve( pSat, &Lit, &Lit + 1, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( fVerbose && (i % Saig_ManPoNum(pAig) == Saig_ManPoNum(pAig) - 1) )
{
printf( "Solved %2d outputs of frame %3d. ",
Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
printf( "Conf =%8.0f. Imp =%11.0f. ", (double)pSat->stats.conflicts, (double)pSat->stats.propagations );
- PRT( "T", clock() - clkPart );
+ ABC_PRT( "T", clock() - clkPart );
clkPart = clock();
fflush( stdout );
}
@@ -284,7 +284,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim
int * pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
pModel[Aig_ManPiNum(pFrames)] = pObj->Id;
pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pFrames, pModel );
- free( pModel );
+ ABC_FREE( pModel );
Vec_IntFree( vCiIds );
// if ( piFrame )
diff --git a/src/aig/saig/saigHaig.c b/src/aig/saig/saigHaig.c
index 8a75ae1f..1c7aa025 100644
--- a/src/aig/saig/saigHaig.c
+++ b/src/aig/saig/saigHaig.c
@@ -273,7 +273,7 @@ clk = clock();
return 0;
}
}
-PRT( "Preparation", clock() - clk );
+ABC_PRT( "Preparation", clock() - clk );
// check in the second timeframe
@@ -291,7 +291,7 @@ clk = clock();
Lits[0] = toLitCond( pCnf->pVarNums[pObj1->Id], 0 );
Lits[1] = toLitCond( pCnf->pVarNums[pObj2->Id], 1 );
- RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue1 == l_False )
{
Lits[0] = lit_neg( Lits[0] );
@@ -303,7 +303,7 @@ clk = clock();
Lits[0]++;
Lits[1]--;
- RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue2 == l_False )
{
Lits[0] = lit_neg( Lits[0] );
@@ -323,7 +323,7 @@ clk = clock();
// break;
}
printf( " \r" );
-PRT( "Solving ", clock() - clk );
+ABC_PRT( "Solving ", clock() - clk );
clkVerif = clock() - clk;
if ( Counter )
printf( "Verification failed for %d out of %d assertions.\n", Counter, pFrames->nAsserts/2 );
@@ -479,7 +479,7 @@ clk = clock();
return 0;
}
}
-PRT( "Preparation", clock() - clk );
+ABC_PRT( "Preparation", clock() - clk );
// check in the second timeframe
@@ -496,12 +496,12 @@ clk = clock();
Lits[0] = toLitCond( pCnf->pVarNums[pObj1->Id]+Delta, 0 );
Lits[1] = toLitCond( pCnf->pVarNums[pObj2->Id]+Delta, 0 );
- RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
Lits[0]++;
Lits[1]++;
- RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue1 != l_False || RetValue2 != l_False )
Counter++;
@@ -511,12 +511,12 @@ clk = clock();
Lits[0] = toLitCond( pCnf->pVarNums[pObj1->Id]+Delta, 0 );
Lits[1] = toLitCond( pCnf->pVarNums[pObj2->Id]+Delta, 1 );
- RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
Lits[0]++;
Lits[1]--;
- RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( RetValue1 != l_False || RetValue2 != l_False )
Counter++;
@@ -527,7 +527,7 @@ clk = clock();
// if ( i / 2 > 1000 )
// break;
}
-PRT( "Solving ", clock() - clk );
+ABC_PRT( "Solving ", clock() - clk );
if ( Counter )
printf( "Verification failed for %d out of %d classes.\n", Counter, Vec_IntSize(pHaig->vEquPairs)/2 );
else
@@ -634,7 +634,7 @@ clk = clock();
// remove structural hashing table
Aig_TableClear( pNew->pManHaig );
pNew->pManHaig->vEquPairs = Vec_IntAlloc( 10000 );
-PRT( "HAIG setup time", clock() - clk );
+ABC_PRT( "HAIG setup time", clock() - clk );
clk = clock();
if ( fSeqHaig )
@@ -682,7 +682,7 @@ clk = clock();
Aig_ManStop( pTemp );
}
}
-PRT( "Synthesis time ", clock() - clk );
+ABC_PRT( "Synthesis time ", clock() - clk );
clkSynth = clock() - clk;
// use the haig for verification
diff --git a/src/aig/saig/saigInd.c b/src/aig/saig/saigInd.c
index 69c250f6..1c26e5df 100644
--- a/src/aig/saig/saigInd.c
+++ b/src/aig/saig/saigInd.c
@@ -121,13 +121,13 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
}
// run the SAT solver
nConfPrev = pSat->stats.conflicts;
- status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfMax, 0, 0, 0 );
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, 0, 0, 0 );
if ( fVerbose )
{
printf( "%3d : PI = %5d. PO = %5d. AIG = %5d. Var = %6d. Conf = %6d. ",
f+1, Aig_ManPiNum(pAigPart), Aig_ManPoNum(pAigPart), Aig_ManNodeNum(pAigPart),
nSatVarNum, pSat->stats.conflicts-nConfPrev );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
if ( status == l_Undef )
break;
diff --git a/src/aig/saig/saigIoa.c b/src/aig/saig/saigIoa.c
index 70870fe9..d049489e 100644
--- a/src/aig/saig/saigIoa.c
+++ b/src/aig/saig/saigIoa.c
@@ -348,7 +348,7 @@ Aig_Man_t * Saig_ManReadBlif( char * pFileName )
{
extern double pow( double x, double y );
int Size = (int)pow(10.0, (double)(strlen(pToken) - 1));
- pNum2Id = CALLOC( int, Size );
+ pNum2Id = ABC_CALLOC( int, Size );
}
// other tokens
@@ -383,7 +383,7 @@ Aig_Man_t * Saig_ManReadBlif( char * pFileName )
// add non-node objects to the mapping
Aig_ManForEachPi( p, pNode, i )
pNum2Id[pNode->Id] = pNode->Id;
-// FREE( pNum2Id );
+// ABC_FREE( pNum2Id );
p->pData = pNum2Id;
// check the new manager
Aig_ManSetRegNum( p, nRegs );
diff --git a/src/aig/saig/saigMiter.c b/src/aig/saig/saigMiter.c
index 6c4b3af0..174a3e97 100644
--- a/src/aig/saig/saigMiter.c
+++ b/src/aig/saig/saigMiter.c
@@ -526,13 +526,13 @@ int Saig_ManDemiterSimple( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAi
if ( ppAig0 )
{
*ppAig0 = Aig_ManDupNodesHalf( p, vSet0, 0 );
- FREE( (*ppAig0)->pName );
+ ABC_FREE( (*ppAig0)->pName );
(*ppAig0)->pName = Aig_UtilStrsav( "part0" );
}
if ( ppAig1 )
{
*ppAig1 = Aig_ManDupNodesHalf( p, vSet1, 1 );
- FREE( (*ppAig1)->pName );
+ ABC_FREE( (*ppAig1)->pName );
(*ppAig1)->pName = Aig_UtilStrsav( "part1" );
}
Vec_PtrFree( vSet0 );
@@ -596,13 +596,13 @@ int Saig_ManDemiterSimpleDiff( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t **
if ( ppAig0 )
{
*ppAig0 = Aig_ManDupNodesAll( p, vSet0 );
- FREE( (*ppAig0)->pName );
+ ABC_FREE( (*ppAig0)->pName );
(*ppAig0)->pName = Aig_UtilStrsav( "part0" );
}
if ( ppAig1 )
{
*ppAig1 = Aig_ManDupNodesAll( p, vSet1 );
- FREE( (*ppAig1)->pName );
+ ABC_FREE( (*ppAig1)->pName );
(*ppAig1)->pName = Aig_UtilStrsav( "part1" );
}
Vec_PtrFree( vSet0 );
@@ -768,14 +768,14 @@ int Saig_ManDemiter( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 )
{
assert( 0 );
*ppAig0 = Aig_ManDupNodesHalf( p, vSet0, 0 ); // not ready
- FREE( (*ppAig0)->pName );
+ ABC_FREE( (*ppAig0)->pName );
(*ppAig0)->pName = Aig_UtilStrsav( "part0" );
}
if ( ppAig1 )
{
assert( 0 );
*ppAig1 = Aig_ManDupNodesHalf( p, vSet1, 1 ); // not ready
- FREE( (*ppAig1)->pName );
+ ABC_FREE( (*ppAig1)->pName );
(*ppAig1)->pName = Aig_UtilStrsav( "part1" );
}
Vec_PtrFree( vSet0 );
@@ -891,12 +891,12 @@ int Ssw_SecSpecial( Aig_Man_t * pPart0, Aig_Man_t * pPart1, int nFrames, int fVe
if ( RetValue == 1 )
{
printf( "Networks are equivalent. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
else if ( RetValue == 0 )
{
printf( "Networks are NOT EQUIVALENT. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
if ( pMiterCec->pData == NULL )
printf( "Counter-example is not available.\n" );
else
@@ -919,7 +919,7 @@ PRT( "Time", clock() - clkTotal );
else
{
printf( "Networks are UNDECIDED. " );
-PRT( "Time", clock() - clkTotal );
+ABC_PRT( "Time", clock() - clkTotal );
}
fflush( stdout );
Aig_ManStop( pMiterCec );
diff --git a/src/aig/saig/saigPhase.c b/src/aig/saig/saigPhase.c
index c6d84066..9b09598c 100644
--- a/src/aig/saig/saigPhase.c
+++ b/src/aig/saig/saigPhase.c
@@ -139,14 +139,14 @@ static inline void Saig_TsiSetNext( unsigned * pState, int nWords, unsigne
Saig_Tsim_t * Saig_TsiStart( Aig_Man_t * pAig )
{
Saig_Tsim_t * p;
- p = (Saig_Tsim_t *)malloc( sizeof(Saig_Tsim_t) );
+ p = (Saig_Tsim_t *)ABC_ALLOC( char, sizeof(Saig_Tsim_t) );
memset( p, 0, sizeof(Saig_Tsim_t) );
p->pAig = pAig;
p->nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) );
p->vStates = Vec_PtrAlloc( 1000 );
p->pMem = Aig_MmFixedStart( sizeof(unsigned) * p->nWords + sizeof(unsigned *), 10000 );
p->nBins = Aig_PrimeCudd(TSIM_MAX_ROUNDS/2);
- p->pBins = ALLOC( unsigned *, p->nBins );
+ p->pBins = ABC_ALLOC( unsigned *, p->nBins );
memset( p->pBins, 0, sizeof(unsigned *) * p->nBins );
return p;
}
@@ -168,8 +168,8 @@ void Saig_TsiStop( Saig_Tsim_t * p )
Vec_IntFree( p->vNonXRegs );
Aig_MmFixedStop( p->pMem, 0 );
Vec_PtrFree( p->vStates );
- free( p->pBins );
- free( p );
+ ABC_FREE( p->pBins );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -696,7 +696,7 @@ Aig_Man_t * Saig_ManPerformAbstraction( Saig_Tsim_t * pTsi, int nFrames, int fVe
assert( Vec_IntSize(pTsi->vNonXRegs) > 0 );
// create mapping for the frames nodes
- pObjMap = ALLOC( Aig_Obj_t *, nFrames * Aig_ManObjNumMax(pAig) );
+ pObjMap = ABC_ALLOC( Aig_Obj_t *, nFrames * Aig_ManObjNumMax(pAig) );
memset( pObjMap, 0, sizeof(Aig_Obj_t *) * nFrames * Aig_ManObjNumMax(pAig) );
// start the fraig package
@@ -762,7 +762,7 @@ Aig_Man_t * Saig_ManPerformAbstraction( Saig_Tsim_t * pTsi, int nFrames, int fVe
//Aig_ManPrintStats( pFrames );
// Aig_ManPiCleanup( pFrames );
//Aig_ManPrintStats( pFrames );
- free( pObjMap );
+ ABC_FREE( pObjMap );
return pFrames;
}
diff --git a/src/aig/saig/saigRetFwd.c b/src/aig/saig/saigRetFwd.c
index b6321da6..8178d26e 100644
--- a/src/aig/saig/saigRetFwd.c
+++ b/src/aig/saig/saigRetFwd.c
@@ -51,7 +51,7 @@ Aig_Obj_t ** Aig_ManStaticFanoutStart( Aig_Man_t * p )
int i, nFanouts, nFanoutsAlloc;
// allocate fanouts
nFanoutsAlloc = 2 * Aig_ManObjNumMax(p) - Aig_ManPiNum(p) - Aig_ManPoNum(p);
- ppFanouts = ALLOC( Aig_Obj_t *, nFanoutsAlloc );
+ ppFanouts = ABC_ALLOC( Aig_Obj_t *, nFanoutsAlloc );
// mark up storage
nFanouts = 0;
Aig_ManForEachObj( p, pObj, i )
@@ -122,7 +122,7 @@ void Saig_ManMarkAutonomous( Aig_Man_t * p )
Aig_ManMarkAutonomous_rec( p, Aig_ManConst1(p) );
Saig_ManForEachPi( p, pObj, i )
Aig_ManMarkAutonomous_rec( p, pObj );
- free( ppFanouts );
+ ABC_FREE( ppFanouts );
// disconnect LIs/LOs and label unreachable registers
Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
{
@@ -220,7 +220,7 @@ Aig_Man_t * Saig_ManRetimeForward( Aig_Man_t * p, int nMaxIters, int fVerbose )
{
printf( "%2d : And = %6d. Reg = %5d. Unret = %5d. Move = %6d. ",
i + 1, Aig_ManNodeNum(pTemp), Aig_ManRegNum(pTemp), nRegFixed, nRegMoves );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
if ( pTemp != p )
Aig_ManStop( pTemp );
@@ -229,7 +229,7 @@ Aig_Man_t * Saig_ManRetimeForward( Aig_Man_t * p, int nMaxIters, int fVerbose )
pNew = Aig_ManReduceLaches( pNew, fVerbose );
if ( fVerbose )
{
- PRT( "Register sharing time", clock() - clk );
+ ABC_PRT( "Register sharing time", clock() - clk );
}
return pNew;
}
diff --git a/src/aig/saig/saigRetMin.c b/src/aig/saig/saigRetMin.c
index 1820ae9a..b9204f44 100644
--- a/src/aig/saig/saigRetMin.c
+++ b/src/aig/saig/saigRetMin.c
@@ -61,7 +61,7 @@ Vec_Int_t * Saig_ManRetimeInitState( Aig_Man_t * p )
Cnf_DataFree( pCnf );
return NULL;
}
- RetValue = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
assert( RetValue != l_Undef );
// create counter-example
if ( RetValue == l_True )
@@ -119,7 +119,7 @@ int Saig_ManRetimeUnsatCore( Aig_Man_t * p, int fVerbose )
}
sat_solver_store_mark_roots( pSat );
// solve the problem
- RetValue = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 );
+ RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
assert( RetValue != l_Undef );
assert( RetValue == l_False );
pSatCnf = sat_solver_store_release( pSat );
@@ -132,7 +132,7 @@ int Saig_ManRetimeUnsatCore( Aig_Man_t * p, int fVerbose )
// derive the set of variables on which the core depends
// collect the variable numbers
nVars = 0;
- pVars = ALLOC( int, pCnf->nVars );
+ pVars = ABC_ALLOC( int, pCnf->nVars );
memset( pVars, 0, sizeof(int) * pCnf->nVars );
Vec_IntForEachEntry( vCore, iClause, i )
{
@@ -170,7 +170,7 @@ int Saig_ManRetimeUnsatCore( Aig_Man_t * p, int fVerbose )
}
if ( fVerbose )
printf( "UNSAT core: %d clauses, %d variables, %d POs. ", Vec_IntSize(vCore), nVars, nPos );
- free( pVars );
+ ABC_FREE( pVars );
Vec_IntFree( vCore );
Cnf_DataFree( pCnf );
return iBadPo;
diff --git a/src/aig/saig/saigSimExt.c b/src/aig/saig/saigSimExt.c
index 49c85ff4..ead0ece5 100644
--- a/src/aig/saig/saigSimExt.c
+++ b/src/aig/saig/saigSimExt.c
@@ -309,7 +309,7 @@ clk = clock();
if ( fVerbose )
{
printf( "Total new PIs = %3d. Non-removable PIs = %3d. ", Saig_ManPiNum(p)-iFirstPi, Vec_IntSize(vRes) );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
Vec_PtrFree( vSimInfo );
Aig_ManFanoutStop( p );
diff --git a/src/aig/saig/saigSimFast.c b/src/aig/saig/saigSimFast.c
index 09bb6a06..05f77f8a 100644
--- a/src/aig/saig/saigSimFast.c
+++ b/src/aig/saig/saigSimFast.c
@@ -108,7 +108,7 @@ Faig_Man_t * Faig_ManAlloc( Aig_Man_t * pAig )
int nWords;
// assert( Faig_ManIsCorrect(pAig) );
nWords = 2 * Aig_ManNodeNum(pAig) + Aig_ManPoNum(pAig);
- p = (Faig_Man_t *)ALLOC( char, sizeof(Faig_Man_t) + sizeof(int) * nWords );
+ p = (Faig_Man_t *)ABC_ALLOC( char, sizeof(Faig_Man_t) + sizeof(int) * nWords );
//printf( "Allocating %7.2f Mb.\n", 1.0 * (sizeof(Faig_Man_t) + sizeof(int) * nWords)/(1<<20) );
memset( p, 0, sizeof(Faig_Man_t) );
p->nPis = Aig_ManPiNum(pAig) - Aig_ManRegNum(pAig);
@@ -247,8 +247,8 @@ static inline unsigned Faig_SimulateTransferShift( unsigned uOld, unsigned uNew
***********************************************************************/
int * Faig_ManSimulateFrames( Faig_Man_t * p, int nFrames, int nPref, int fTrans )
{
- int * pNumOnes = CALLOC( unsigned, p->nObjs );
- unsigned * pSimInfo = ALLOC( unsigned, p->nObjs );
+ int * pNumOnes = ABC_CALLOC( unsigned, p->nObjs );
+ unsigned * pSimInfo = ABC_ALLOC( unsigned, p->nObjs );
int f, i;
//printf( "Allocating %7.2f Mb.\n", 1.0 * 4 * p->nObjs/(1<<20) );
//printf( "Allocating %7.2f Mb.\n", 1.0 * 4 * p->nObjs/(1<<20) );
@@ -287,7 +287,7 @@ int * Faig_ManSimulateFrames( Faig_Man_t * p, int nFrames, int nPref, int fTrans
pNumOnes[i] += Aig_WordCountOnes( pSimInfo[i] );
}
}
- free( pSimInfo );
+ ABC_FREE( pSimInfo );
return pNumOnes;
}
@@ -336,7 +336,7 @@ float Faig_ManComputeProbOne( int nOnes, int nSimWords )
SeeAlso []
***********************************************************************/
-Vec_Int_t * Faig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
+Vec_Int_t * Faig_ManComputeSwitchProbs4( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
{
extern char * Abc_FrameReadFlag( char * pFlag );
int fTrans = 1;
@@ -351,7 +351,7 @@ Vec_Int_t * Faig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, i
pSwitching = (float *)vSwitching->pArray;
clk = clock();
pAig = Faig_ManCreate( p );
-//PRT( "\nCreation ", clock() - clk );
+//ABC_PRT( "\nCreation ", clock() - clk );
Aig_ManRandom( 1 );
// get the number of frames to simulate
// if the parameter "seqsimframes" is defined, use it
@@ -368,7 +368,7 @@ clk = clock();
//printf( "Simulating %d frames.\n", nFramesReal );
clk = clock();
pProbs = Faig_ManSimulateFrames( pAig, nFramesReal, nPref, fTrans );
-//PRT( "Simulation", clock() - clk );
+//ABC_PRT( "Simulation", clock() - clk );
clk = clock();
if ( fTrans )
{
@@ -412,10 +412,10 @@ clk = clock();
pSwitching[pObj->Id] = Faig_ManComputeSwitching( pProbs[Counter++], nFramesReal - nPref );
assert( Counter == pAig->nObjs );
}
- free( pProbs );
- free( pAig );
-//PRT( "Switch ", clock() - clk );
-//PRT( "TOTAL ", clock() - clkTotal );
+ ABC_FREE( pProbs );
+ ABC_FREE( pAig );
+//ABC_PRT( "Switch ", clock() - clk );
+//ABC_PRT( "TOTAL ", clock() - clkTotal );
return vSwitching;
}
@@ -430,9 +430,10 @@ clk = clock();
SeeAlso []
***********************************************************************/
-Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
+Vec_Int_t * Saig_ManComputeSwitchProb3s( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
{
- return Faig_ManComputeSwitchProbs( p, nFrames, nPref, fProbOne );
+// return Faig_ManComputeSwitchProbs( p, nFrames, nPref, fProbOne );
+ return NULL;
}
diff --git a/src/aig/saig/saigSimMv.c b/src/aig/saig/saigSimMv.c
index 0e250a74..9bc6416b 100644
--- a/src/aig/saig/saigSimMv.c
+++ b/src/aig/saig/saigSimMv.c
@@ -129,7 +129,7 @@ Saig_MvObj_t * Saig_ManCreateReducedAig( Aig_Man_t * p, Vec_Ptr_t ** pvFlops )
Aig_Obj_t * pObj;
int i;
*pvFlops = Vec_PtrAlloc( Aig_ManRegNum(p) );
- pAig = CALLOC( Saig_MvObj_t, Aig_ManObjNumMax(p)+1 );
+ pAig = ABC_CALLOC( Saig_MvObj_t, Aig_ManObjNumMax(p)+1 );
Aig_ManForEachObj( p, pObj, i )
{
pEntry = pAig + i;
@@ -171,8 +171,8 @@ static inline int Saig_MvCreateObj( Saig_MvMan_t * p, int iFan0, int iFan1 )
Saig_MvAnd_t * pNode;
if ( p->nObjs == p->nObjsAlloc )
{
- p->pAigNew = REALLOC( Saig_MvAnd_t, p->pAigNew, 2*p->nObjsAlloc );
- p->pLevels = REALLOC( unsigned char, p->pLevels, 2*p->nObjsAlloc );
+ p->pAigNew = ABC_REALLOC( Saig_MvAnd_t, p->pAigNew, 2*p->nObjsAlloc );
+ p->pLevels = ABC_REALLOC( unsigned char, p->pLevels, 2*p->nObjsAlloc );
p->nObjsAlloc *= 2;
}
pNode = p->pAigNew + p->nObjs;
@@ -202,7 +202,7 @@ Saig_MvMan_t * Saig_MvManStart( Aig_Man_t * pAig )
Saig_MvMan_t * p;
int i;
assert( Aig_ManRegNum(pAig) > 0 );
- p = (Saig_MvMan_t *)ALLOC( Saig_MvMan_t, 1 );
+ p = (Saig_MvMan_t *)ABC_ALLOC( Saig_MvMan_t, 1 );
memset( p, 0, sizeof(Saig_MvMan_t) );
// set parameters
p->pAig = pAig;
@@ -213,23 +213,23 @@ Saig_MvMan_t * Saig_MvManStart( Aig_Man_t * pAig )
// compacted AIG
p->pAigOld = Saig_ManCreateReducedAig( pAig, &p->vFlops );
p->nTStatesSize = Aig_PrimeCudd( p->nStatesMax );
- p->pTStates = CALLOC( int, p->nTStatesSize );
+ p->pTStates = ABC_CALLOC( int, p->nTStatesSize );
p->pMemStates = Aig_MmFixedStart( sizeof(int) * (p->nFlops+1), p->nStatesMax );
p->vStates = Vec_PtrAlloc( p->nStatesMax );
Vec_PtrPush( p->vStates, NULL );
- p->pRegsUndef = CALLOC( int, p->nFlops );
- p->pRegsValues = ALLOC( int *, p->nFlops );
- p->pRegsValues[0] = ALLOC( int, p->nValuesMax * p->nFlops );
+ p->pRegsUndef = ABC_CALLOC( int, p->nFlops );
+ p->pRegsValues = ABC_ALLOC( int *, p->nFlops );
+ p->pRegsValues[0] = ABC_ALLOC( int, p->nValuesMax * p->nFlops );
for ( i = 1; i < p->nFlops; i++ )
p->pRegsValues[i] = p->pRegsValues[i-1] + p->nValuesMax;
- p->nRegsValues = CALLOC( int, p->nFlops );
+ p->nRegsValues = ABC_CALLOC( int, p->nFlops );
p->vTired = Vec_PtrAlloc( 100 );
// internal AIG
p->nObjsAlloc = 1000000;
- p->pAigNew = ALLOC( Saig_MvAnd_t, p->nObjsAlloc );
+ p->pAigNew = ABC_ALLOC( Saig_MvAnd_t, p->nObjsAlloc );
p->nTNodesSize = Aig_PrimeCudd( p->nObjsAlloc / 3 );
- p->pTNodes = CALLOC( int, p->nTNodesSize );
- p->pLevels = ALLOC( unsigned char, p->nObjsAlloc );
+ p->pTNodes = ABC_CALLOC( int, p->nTNodesSize );
+ p->pLevels = ABC_ALLOC( unsigned char, p->nObjsAlloc );
Saig_MvCreateObj( p, 0, 0 );
return p;
}
@@ -251,16 +251,16 @@ void Saig_MvManStop( Saig_MvMan_t * p )
Vec_PtrFree( p->vStates );
Vec_PtrFree( p->vFlops );
Vec_PtrFree( p->vTired );
- free( p->pRegsValues[0] );
- free( p->pRegsValues );
- free( p->nRegsValues );
- free( p->pRegsUndef );
- free( p->pAigOld );
- free( p->pTStates );
- free( p->pAigNew );
- free( p->pTNodes );
- free( p->pLevels );
- free( p );
+ ABC_FREE( p->pRegsValues[0] );
+ ABC_FREE( p->pRegsValues );
+ ABC_FREE( p->nRegsValues );
+ ABC_FREE( p->pRegsUndef );
+ ABC_FREE( p->pAigOld );
+ ABC_FREE( p->pTStates );
+ ABC_FREE( p->pAigNew );
+ ABC_FREE( p->pTNodes );
+ ABC_FREE( p->pLevels );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -661,7 +661,7 @@ int Saig_MvManSimulate( Aig_Man_t * pAig, int fVerbose )
int f, i, k, iRegMax, iState, clk = clock();
// start the manager
p = Saig_MvManStart( pAig );
-PRT( "Constructing the problem", clock() - clk );
+ABC_PRT( "Constructing the problem", clock() - clk );
clk = clock();
// initiliaze registers
Vec_PtrForEachEntry( p->vFlops, pEntry, i )
@@ -710,7 +710,7 @@ PRT( "Constructing the problem", clock() - clk );
pEntry->Value = Saig_MvUndef();
}
}
-PRT( "Multi-value simulation", clock() - clk );
+ABC_PRT( "Multi-value simulation", clock() - clk );
// implement equivalences
Saig_MvManPostProcess( p, iState-1 );
Saig_MvManStop( p );
diff --git a/src/aig/saig/saigSimSeq.c b/src/aig/saig/saigSimSeq.c
index 26783346..c527b152 100644
--- a/src/aig/saig/saigSimSeq.c
+++ b/src/aig/saig/saigSimSeq.c
@@ -52,7 +52,7 @@ struct Raig_Man_t_
int nWordsAlloc; // the number of allocated entries
int nMems; // the number of used entries
int nMemsMax; // the max number of used entries
- int MemFree; // next free entry
+ int MemFree; // next ABC_FREE entry
};
static inline int Raig_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
@@ -146,7 +146,7 @@ Raig_Man_t * Raig_ManCreate( Aig_Man_t * pAig )
Aig_Obj_t * pObj;
int i, nObjs;
Aig_ManCleanData( pAig );
- p = (Raig_Man_t *)ALLOC( Raig_Man_t, 1 );
+ p = (Raig_Man_t *)ABC_ALLOC( Raig_Man_t, 1 );
memset( p, 0, sizeof(Raig_Man_t) );
p->pAig = pAig;
p->nPis = Saig_ManPiNum(pAig);
@@ -155,10 +155,10 @@ Raig_Man_t * Raig_ManCreate( Aig_Man_t * pAig )
p->nCos = Aig_ManPoNum(pAig);
p->nNodes = Aig_ManNodeNum(pAig);
nObjs = p->nCis + p->nCos + p->nNodes + 2;
- p->pFans0 = ALLOC( int, nObjs );
- p->pFans1 = ALLOC( int, nObjs );
- p->pRefs = ALLOC( int, nObjs );
- p->pSims = CALLOC( unsigned, nObjs );
+ p->pFans0 = ABC_ALLOC( int, nObjs );
+ p->pFans1 = ABC_ALLOC( int, nObjs );
+ p->pRefs = ABC_ALLOC( int, nObjs );
+ p->pSims = ABC_CALLOC( unsigned, nObjs );
p->vCis2Ids = Vec_IntAlloc( Aig_ManPiNum(pAig) );
// add objects (0=unused; 1=const1)
p->nObjs = 2;
@@ -202,12 +202,12 @@ void Raig_ManDelete( Raig_Man_t * p )
Vec_IntFree( p->vCis2Ids );
Vec_IntFree( p->vLos );
Vec_IntFree( p->vLis );
- FREE( p->pFans0 );
- FREE( p->pFans1 );
- FREE( p->pRefs );
- FREE( p->pSims );
- FREE( p->pMems );
- FREE( p );
+ ABC_FREE( p->pFans0 );
+ ABC_FREE( p->pFans1 );
+ ABC_FREE( p->pRefs );
+ ABC_FREE( p->pSims );
+ ABC_FREE( p->pMems );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -236,7 +236,7 @@ unsigned * Raig_ManSimRef( Raig_Man_t * p, int i )
p->nMems = 1;
}
p->nWordsAlloc *= 2;
- p->pMems = REALLOC( unsigned, p->pMems, p->nWordsAlloc );
+ p->pMems = ABC_REALLOC( unsigned, p->pMems, p->nWordsAlloc );
memset( p->pMems, 0xff, sizeof(unsigned) * (p->nWords + 1) );
pPlace = &p->MemFree;
for ( Ent = p->nMems * (p->nWords + 1);
@@ -421,7 +421,7 @@ Ssw_Cex_t * Raig_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int
// fill in the binary data
Aig_ManRandom( 1 );
Counter = p->nRegs;
- pData = ALLOC( unsigned, nWords );
+ pData = ABC_ALLOC( unsigned, nWords );
for ( f = 0; f <= iFrame; f++, Counter += p->nPis )
for ( i = 0; i < Aig_ManPiNum(pAig); i++ )
{
@@ -433,7 +433,7 @@ Ssw_Cex_t * Raig_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int
if ( Aig_InfoHasBit( pData, iPat ) )
Aig_InfoSetBit( p->pData, Counter + iPioId );
}
- free( pData );
+ ABC_FREE( pData );
return p;
}
@@ -500,7 +500,7 @@ int Raig_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, i
p->nMemsMax,
1.0*(p->nObjs * 16)/(1<<20),
1.0*(p->nMemsMax * 4 * (nWords+1))/(1<<20) );
- PRT( "Total time", clock() - clkTotal );
+ ABC_PRT( "Total time", clock() - clkTotal );
}
Raig_ManDelete( p );
return RetValue > 0;
diff --git a/src/aig/saig/saigStrSim.c b/src/aig/saig/saigStrSim.c
index ce4b8e05..9e50c9b6 100644
--- a/src/aig/saig/saigStrSim.c
+++ b/src/aig/saig/saigStrSim.c
@@ -396,9 +396,9 @@ int Saig_StrSimDetectUnique( Aig_Man_t * p0, Aig_Man_t * p1 )
// allocate the hash table hashing simulation info into nodes
nTableSize = Aig_PrimeCudd( Aig_ManObjNum(p0)/2 );
- ppTable = CALLOC( Aig_Obj_t *, nTableSize );
- ppNexts = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
- ppCands = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
+ ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize );
+ ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
+ ppCands = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
// hash nodes of the first AIG
Aig_ManForEachObj( p0, pObj, i )
@@ -453,9 +453,9 @@ int Saig_StrSimDetectUnique( Aig_Man_t * p0, Aig_Man_t * p1 )
// cleanup
Aig_ManCleanMarkA( p0 );
- free( ppTable );
- free( ppNexts );
- free( ppCands );
+ ABC_FREE( ppTable );
+ ABC_FREE( ppNexts );
+ ABC_FREE( ppCands );
return Counter;
}
@@ -926,7 +926,7 @@ Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDis
i, nMatches,
nFlops, 100.0*nFlops/Aig_ManRegNum(pPart0),
nNodes, 100.0*nNodes/Aig_ManNodeNum(pPart0) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
if ( i == 20 )
break;
@@ -959,7 +959,7 @@ Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDis
Aig_ManFanoutStop( pPart1 );
Aig_ManStop( pPart0 );
Aig_ManStop( pPart1 );
- PRT( "Total runtime", clock() - clkTotal );
+ ABC_PRT( "Total runtime", clock() - clkTotal );
return vPairs;
}
diff --git a/src/aig/saig/saigSwitch.c b/src/aig/saig/saigSwitch.c
index 684551be..122483d2 100644
--- a/src/aig/saig/saigSwitch.c
+++ b/src/aig/saig/saigSwitch.c
@@ -63,7 +63,7 @@ Saig_SimObj_t * Saig_ManCreateMan( Aig_Man_t * p )
Saig_SimObj_t * pAig, * pEntry;
Aig_Obj_t * pObj;
int i;
- pAig = CALLOC( Saig_SimObj_t, Aig_ManObjNumMax(p)+1 );
+ pAig = ABC_CALLOC( Saig_SimObj_t, Aig_ManObjNumMax(p)+1 );
// printf( "Allocating %7.2f Mb.\n", 1.0 * sizeof(Saig_SimObj_t) * (Aig_ManObjNumMax(p)+1)/(1<<20) );
Aig_ManForEachObj( p, pObj, i )
{
@@ -258,7 +258,7 @@ float Saig_ManComputeProbOnePlus( int nOnes, int nSimWords, int fCompl )
SeeAlso []
***********************************************************************/
-Vec_Int_t * Saig_ManComputeSwitchProbs_old( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
+Vec_Int_t * Saig_ManComputeSwitchProb4s( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
{
extern char * Abc_FrameReadFlag( char * pFlag );
Saig_SimObj_t * pAig, * pEntry;
@@ -269,7 +269,7 @@ Vec_Int_t * Saig_ManComputeSwitchProbs_old( Aig_Man_t * p, int nFrames, int nPre
pSwitching = (float *)vSwitching->pArray;
clk = clock();
pAig = Saig_ManCreateMan( p );
-//PRT( "\nCreation ", clock() - clk );
+//ABC_PRT( "\nCreation ", clock() - clk );
Aig_ManRandom( 1 );
// get the number of frames to simulate
@@ -287,7 +287,7 @@ clk = clock();
//printf( "Simulating %d frames.\n", nFramesReal );
clk = clock();
Saig_ManSimulateFrames( pAig, nFramesReal, nPref );
-//PRT( "Simulation", clock() - clk );
+//ABC_PRT( "Simulation", clock() - clk );
clk = clock();
for ( pEntry = pAig; pEntry->Type != AIG_OBJ_VOID; pEntry++ )
{
@@ -312,9 +312,9 @@ clk = clock();
pSwitching[pEntry-pAig] = Saig_ManComputeSwitching( pEntry->Number, nFramesReal - nPref );
//printf( "%3d : %7.2f\n", pEntry-pAig, pSwitching[pEntry-pAig] );
}
- free( pAig );
-//PRT( "Switch ", clock() - clk );
-//PRT( "TOTAL ", clock() - clkTotal );
+ ABC_FREE( pAig );
+//ABC_PRT( "Switch ", clock() - clk );
+//ABC_PRT( "TOTAL ", clock() - clkTotal );
// Aig_CManCreate( p );
return vSwitching;
@@ -356,7 +356,7 @@ struct Aig_CMan_t_
Aig_CMan_t * Aig_CManStart( int nIns, int nNodes, int nOuts )
{
Aig_CMan_t * p;
- p = (Aig_CMan_t *)ALLOC( char, sizeof(Aig_CMan_t) + 2*(2*nNodes + nOuts) );
+ p = (Aig_CMan_t *)ABC_ALLOC( char, sizeof(Aig_CMan_t) + 2*(2*nNodes + nOuts) );
memset( p, 0, sizeof(Aig_CMan_t) );
// set parameters
p->nIns = nIns;
@@ -383,7 +383,7 @@ Aig_CMan_t * Aig_CManStart( int nIns, int nNodes, int nOuts )
***********************************************************************/
void Aig_CManStop( Aig_CMan_t * p )
{
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -559,22 +559,6 @@ Aig_CMan_t * Aig_CManCreate( Aig_Man_t * p )
return pCMan;
}
-/**Function*************************************************************
-
- Synopsis [Compute switching probabilities of all nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Saig_ManComputeSwitchProbs2( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
-{
- return NULL;
-}
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/saig/saigSynch.c b/src/aig/saig/saigSynch.c
index c52f2f48..ff46634e 100644
--- a/src/aig/saig/saigSynch.c
+++ b/src/aig/saig/saigSynch.c
@@ -280,7 +280,7 @@ int Saig_SynchCountX( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords, int *
int * pCounters, i, w, b;
int iPatBest, iTernMin;
// count the number of ternary values in each pattern
- pCounters = CALLOC( int, nWords * 16 );
+ pCounters = ABC_CALLOC( int, nWords * 16 );
Saig_ManForEachLi( pAig, pObj, i )
{
pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
@@ -300,7 +300,7 @@ int Saig_SynchCountX( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords, int *
if ( iTernMin == 0 )
break;
}
- free( pCounters );
+ ABC_FREE( pCounters );
*piPat = iPatBest;
return iTernMin;
}
@@ -512,7 +512,7 @@ clk = clock();
printf( "Design 1: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSequence) / Saig_ManPiNum(pAig) );
if ( fVerbose )
{
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
else
printf( "\n" );
@@ -588,7 +588,7 @@ Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords,
printf( "Design 1: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSeq1) / Saig_ManPiNum(pAig1) );
if ( fVerbose )
{
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
else
printf( "\n" );
@@ -602,7 +602,7 @@ Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords,
printf( "Design 2: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSeq2) / Saig_ManPiNum(pAig2) );
if ( fVerbose )
{
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
else
printf( "\n" );
@@ -646,7 +646,7 @@ Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords,
if ( fVerbose )
{
printf( "Miter of the synchronized designs is constructed. " );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
return pMiter;
}
diff --git a/src/aig/saig/saigTrans.c b/src/aig/saig/saigTrans.c
index c1c2d8e9..f50af285 100644
--- a/src/aig/saig/saigTrans.c
+++ b/src/aig/saig/saigTrans.c
@@ -386,7 +386,7 @@ clk = clock();
{
Aig_ManPrintStats( pFrames );
Aig_ManPrintStats( pFraig );
-PRT( "Fraiging", clock() - clk );
+ABC_PRT( "Fraiging", clock() - clk );
}
Aig_ManStop( pFraig );
assert( pFrames->pReprs != NULL );
@@ -397,12 +397,12 @@ PRT( "Fraiging", clock() - clk );
// create reduced initialized timeframes
clk = clock();
pRes2 = Saig_ManFramesInitialMapped( pAig, nFrames, nFramesMax, fInit );
-PRT( "Mapped", clock() - clk );
- // free mapping
+ABC_PRT( "Mapped", clock() - clk );
+ // ABC_FREE mapping
Saig_ManStopMap2( pAig );
clk = clock();
pRes1 = Saig_ManFramesInitialMapped( pAig, nFrames, nFramesMax, fInit );
-PRT( "Normal", clock() - clk );
+ABC_PRT( "Normal", clock() - clk );
// report the results
if ( fVerbose )
{
diff --git a/src/aig/saig/saigWnd.c b/src/aig/saig/saigWnd.c
index 5524e19f..10202f1b 100644
--- a/src/aig/saig/saigWnd.c
+++ b/src/aig/saig/saigWnd.c
@@ -99,7 +99,7 @@ Vec_Ptr_t * Saig_ManWindowOutline( Aig_Man_t * p, Aig_Obj_t * pObj, int nDist )
Vec_Ptr_t * vNodes;
Aig_Obj_t * pObjLi, * pObjLo;
int * pDists, i;
- pDists = CALLOC( int, Aig_ManObjNumMax(p) );
+ pDists = ABC_CALLOC( int, Aig_ManObjNumMax(p) );
vNodes = Vec_PtrAlloc( 1000 );
Aig_ManIncrementTravId( p );
Saig_ManWindowOutline_rec( p, pObj, nDist, vNodes, pDists );
@@ -108,7 +108,7 @@ Vec_Ptr_t * Saig_ManWindowOutline( Aig_Man_t * p, Aig_Obj_t * pObj, int nDist )
Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
assert( Aig_ObjIsTravIdCurrent(p, pObjLi) ==
Aig_ObjIsTravIdCurrent(p, pObjLo) );
- free( pDists );
+ ABC_FREE( pDists );
return vNodes;
}
diff --git a/src/aig/ssw/ssw.h b/src/aig/ssw/ssw.h
index b3222fca..adb98401 100644
--- a/src/aig/ssw/ssw.h
+++ b/src/aig/ssw/ssw.h
@@ -21,10 +21,6 @@
#ifndef __SSW_H__
#define __SSW_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ssw/sswAig.c b/src/aig/ssw/sswAig.c
index 97f0a755..62e93d2d 100644
--- a/src/aig/ssw/sswAig.c
+++ b/src/aig/ssw/sswAig.c
@@ -42,7 +42,7 @@
Ssw_Frm_t * Ssw_FrmStart( Aig_Man_t * pAig )
{
Ssw_Frm_t * p;
- p = ALLOC( Ssw_Frm_t, 1 );
+ p = ABC_ALLOC( Ssw_Frm_t, 1 );
memset( p, 0, sizeof(Ssw_Frm_t) );
p->pAig = pAig;
p->nObjs = Aig_ManObjNumMax( pAig );
@@ -69,7 +69,7 @@ void Ssw_FrmStop( Ssw_Frm_t * p )
if ( p->pFrames )
Aig_ManStop( p->pFrames );
Vec_PtrFree( p->vAig2Frm );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/ssw/sswBmc.c b/src/aig/ssw/sswBmc.c
index 93859c01..86d04424 100644
--- a/src/aig/ssw/sswBmc.c
+++ b/src/aig/ssw/sswBmc.c
@@ -161,7 +161,7 @@ int Ssw_BmcDynamic( Aig_Man_t * pAig, int nFramesMax, int nConfLimit, int fVerbo
printf( "Solving output %2d of frame %3d ... \r",
i % Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
}
- status = sat_solver_solve( pSat->pSat, &Lit, &Lit + 1, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 );
+ status = sat_solver_solve( pSat->pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
if ( status == l_False )
{
/*
@@ -199,7 +199,7 @@ int Ssw_BmcDynamic( Aig_Man_t * pAig, int nFramesMax, int nConfLimit, int fVerbo
printf( "Conf =%8.0f. Var =%8d. AIG=%9d. ",
(double)pSat->pSat->stats.conflicts,
pSat->nSatVars, Aig_ManNodeNum(pFrm->pFrames) );
- PRT( "T", clock() - clkPart );
+ ABC_PRT( "T", clock() - clkPart );
clkPart = clock();
fflush( stdout );
}
diff --git a/src/aig/ssw/sswClass.c b/src/aig/ssw/sswClass.c
index 3528ae27..5d0be217 100644
--- a/src/aig/ssw/sswClass.c
+++ b/src/aig/ssw/sswClass.c
@@ -136,11 +136,11 @@ static inline Aig_Obj_t ** Ssw_ObjRemoveClass( Ssw_Cla_t * p, Aig_Obj_t * pRepr
Ssw_Cla_t * Ssw_ClassesStart( Aig_Man_t * pAig )
{
Ssw_Cla_t * p;
- p = ALLOC( Ssw_Cla_t, 1 );
+ p = ABC_ALLOC( Ssw_Cla_t, 1 );
memset( p, 0, sizeof(Ssw_Cla_t) );
p->pAig = pAig;
- p->pId2Class = CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) );
- p->pClassSizes = CALLOC( int, Aig_ManObjNumMax(pAig) );
+ p->pId2Class = ABC_CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) );
+ p->pClassSizes = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) );
p->vClassOld = Vec_PtrAlloc( 100 );
p->vClassNew = Vec_PtrAlloc( 100 );
p->vRefined = Vec_PtrAlloc( 1000 );
@@ -187,10 +187,10 @@ void Ssw_ClassesStop( Ssw_Cla_t * p )
if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
Vec_PtrFree( p->vRefined );
- FREE( p->pId2Class );
- FREE( p->pClassSizes );
- FREE( p->pMemClasses );
- free( p );
+ ABC_FREE( p->pId2Class );
+ ABC_FREE( p->pClassSizes );
+ ABC_FREE( p->pMemClasses );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -500,8 +500,8 @@ int Ssw_ClassesPrepareRehash( Ssw_Cla_t * p, Vec_Ptr_t * vCands )
// allocate the hash table hashing simulation info into nodes
nTableSize = Aig_PrimeCudd( Vec_PtrSize(vCands)/2 );
- ppTable = CALLOC( Aig_Obj_t *, nTableSize );
- ppNexts = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
+ ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize );
+ ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
// sort through the candidates
nEntries = 0;
@@ -568,8 +568,8 @@ int Ssw_ClassesPrepareRehash( Ssw_Cla_t * p, Vec_Ptr_t * vCands )
}
p->pMemClassesFree += nEntries2;
assert( nEntries == nEntries2 );
- free( ppTable );
- free( ppNexts );
+ ABC_FREE( ppTable );
+ ABC_FREE( ppNexts );
// now it is time to refine the classes
return Ssw_ClassesRefine( p, 1 );
}
@@ -615,7 +615,7 @@ if ( fVerbose )
printf( "Allocated %.2f Mb to store simulation information.\n",
1.0*(sizeof(unsigned) * Aig_ManObjNumMax(pAig) * nFrames * nWords)/(1<<20) );
printf( "Initial simulation of %d frames with %d words. ", nFrames, nWords );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// set comparison procedures
@@ -643,7 +643,7 @@ clk = clock();
}
// allocate room for classes
- p->pMemClasses = ALLOC( Aig_Obj_t *, Vec_PtrSize(vCands) );
+ p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, Vec_PtrSize(vCands) );
p->pMemClassesFree = p->pMemClasses;
// now it is time to refine the classes
@@ -651,7 +651,7 @@ clk = clock();
if ( fVerbose )
{
printf( "Collecting candidate equivalence classes. " );
-PRT( "Time", clock() - clk );
+ABC_PRT( "Time", clock() - clk );
}
clk = clock();
@@ -677,7 +677,7 @@ if ( fVerbose )
{
printf( "Simulation of %d frames with %d words (%2d rounds). ",
nFrames, nWords, i-1 );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
Ssw_ClassesCheck( p );
// Ssw_ClassesPrint( p, 0 );
@@ -723,7 +723,7 @@ Ssw_Cla_t * Ssw_ClassesPrepareSimple( Aig_Man_t * pAig, int fLatchCorr, int nMax
p->nCands1++;
}
// allocate room for classes
- p->pMemClassesFree = p->pMemClasses = ALLOC( Aig_Obj_t *, p->nCands1 );
+ p->pMemClassesFree = p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, p->nCands1 );
// Ssw_ClassesPrint( p, 0 );
return p;
}
@@ -754,7 +754,7 @@ Ssw_Cla_t * Ssw_ClassesPrepareTargets( Aig_Man_t * pAig )
p->nCands1++;
}
// allocate room for classes
- p->pMemClassesFree = p->pMemClasses = ALLOC( Aig_Obj_t *, p->nCands1 );
+ p->pMemClassesFree = p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, p->nCands1 );
// Ssw_ClassesPrint( p, 0 );
return p;
}
@@ -783,7 +783,7 @@ Ssw_Cla_t * Ssw_ClassesPreparePairs( Aig_Man_t * pAig, Vec_Int_t ** pvClasses )
for ( i = 0; i < Aig_ManObjNumMax(pAig); i++ )
nTotalObjs += pvClasses[i] ? Vec_IntSize(pvClasses[i]) : 0;
// allocate memory for classes
- p->pMemClasses = ALLOC( Aig_Obj_t *, nTotalObjs );
+ p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, nTotalObjs );
// create constant-1 class
if ( pvClasses[0] )
Vec_IntForEachEntry( pvClasses[0], Entry, i )
@@ -845,7 +845,7 @@ Ssw_Cla_t * Ssw_ClassesPreparePairsSimple( Aig_Man_t * pMiter, Vec_Int_t * vPair
// start the classes
p = Ssw_ClassesStart( pMiter );
// allocate memory for classes
- p->pMemClasses = ALLOC( Aig_Obj_t *, Vec_IntSize(vPairs) );
+ p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, Vec_IntSize(vPairs) );
// create classes
for ( i = 0; i < Vec_IntSize(vPairs); i += 2 )
{
diff --git a/src/aig/ssw/sswCnf.c b/src/aig/ssw/sswCnf.c
index c5ea9b28..73fa0b02 100644
--- a/src/aig/ssw/sswCnf.c
+++ b/src/aig/ssw/sswCnf.c
@@ -43,7 +43,7 @@ Ssw_Sat_t * Ssw_SatStart( int fPolarFlip )
{
Ssw_Sat_t * p;
int Lit;
- p = ALLOC( Ssw_Sat_t, 1 );
+ p = ABC_ALLOC( Ssw_Sat_t, 1 );
memset( p, 0, sizeof(Ssw_Sat_t) );
p->pAig = NULL;
p->fPolarFlip = fPolarFlip;
@@ -84,7 +84,7 @@ void Ssw_SatStop( Ssw_Sat_t * p )
Vec_IntFree( p->vSatVars );
Vec_PtrFree( p->vFanins );
Vec_PtrFree( p->vUsedPis );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -225,7 +225,7 @@ void Ssw_AddClausesSuper( Ssw_Sat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
assert( Aig_ObjIsNode( pNode ) );
// create storage for literals
nLits = Vec_PtrSize(vSuper) + 1;
- pLits = ALLOC( int, nLits );
+ pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
Vec_PtrForEachEntry( vSuper, pFanin, i )
@@ -256,7 +256,7 @@ void Ssw_AddClausesSuper( Ssw_Sat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
}
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
assert( RetValue );
- free( pLits );
+ ABC_FREE( pLits );
}
/**Function*************************************************************
diff --git a/src/aig/ssw/sswCore.c b/src/aig/ssw/sswCore.c
index 38a36022..485a5146 100644
--- a/src/aig/ssw/sswCore.c
+++ b/src/aig/ssw/sswCore.c
@@ -157,7 +157,7 @@ clk = clock();
nIter, Ssw_ClassesCand1Num(p->ppClasses), Ssw_ClassesClassNum(p->ppClasses),
p->nSatProof-nSatProof, p->nSatCallsSat-nSatCallsSat,
p->nRecycles-nRecycles, p->nSatFailsReal-nSatFailsReal );
- PRT( "T", clock() - clk );
+ ABC_PRT( "T", clock() - clk );
}
}
else
@@ -180,7 +180,7 @@ clk = clock();
printf( "R =%4d. ", p->nRecycles-nRecycles );
}
printf( "F =%5d. ", p->nSatFailsReal-nSatFailsReal );
- PRT( "T", clock() - clk );
+ ABC_PRT( "T", clock() - clk );
}
// if ( p->pPars->fDynamic && p->nSatCallsSat-nSatCallsSat < 100 )
// p->pPars->nBTLimit = 10000;
@@ -299,7 +299,7 @@ Aig_Man_t * Ssw_SignalCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
Ssw_ClassesSetData( p->ppClasses, NULL, NULL, Ssw_SmlObjIsConstBit, Ssw_SmlObjsAreEqualBit );
}
if ( p->pPars->fLocalSim )
- p->pVisited = CALLOC( int, Ssw_SmlNumFrames( p->pSml ) * Aig_ManObjNumMax(p->pAig) );
+ p->pVisited = ABC_CALLOC( int, Ssw_SmlNumFrames( p->pSml ) * Aig_ManObjNumMax(p->pAig) );
// perform refinement of classes
pAigNew = Ssw_SignalCorrespondenceRefine( p );
if ( pPars->fUniqueness )
diff --git a/src/aig/ssw/sswInt.h b/src/aig/ssw/sswInt.h
index 930796fc..269bdad7 100644
--- a/src/aig/ssw/sswInt.h
+++ b/src/aig/ssw/sswInt.h
@@ -21,10 +21,6 @@
#ifndef __SSW_INT_H__
#define __SSW_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,6 +33,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ssw/sswIslands.c b/src/aig/ssw/sswIslands.c
index 64515f3e..8913116c 100644
--- a/src/aig/ssw/sswIslands.c
+++ b/src/aig/ssw/sswIslands.c
@@ -491,7 +491,7 @@ int Ssw_SecWithSimilarityPairs( Aig_Man_t * p0, Aig_Man_t * p1, Vec_Int_t * vPai
else
printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ",
Aig_ManRegNum(pAigRes), Aig_ManRegNum(p0)+Aig_ManRegNum(p1) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
Aig_ManStop( pAigRes );
return RetValue;
}
diff --git a/src/aig/ssw/sswMan.c b/src/aig/ssw/sswMan.c
index 7e6e4473..90cc9028 100644
--- a/src/aig/ssw/sswMan.c
+++ b/src/aig/ssw/sswMan.c
@@ -47,17 +47,17 @@ Ssw_Man_t * Ssw_ManCreate( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
Aig_ManFanoutStart( pAig );
Aig_ManSetPioNumbers( pAig );
// create interpolation manager
- p = ALLOC( Ssw_Man_t, 1 );
+ p = ABC_ALLOC( Ssw_Man_t, 1 );
memset( p, 0, sizeof(Ssw_Man_t) );
p->pPars = pPars;
p->pAig = pAig;
p->nFrames = pPars->nFramesK + 1;
- p->pNodeToFrames = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) * p->nFrames );
+ p->pNodeToFrames = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) * p->nFrames );
p->vCommon = Vec_PtrAlloc( 100 );
p->iOutputLit = -1;
// allocate storage for sim pattern
p->nPatWords = Aig_BitWordNum( Saig_ManPiNum(pAig) * p->nFrames + Saig_ManRegNum(pAig) );
- p->pPatWords = ALLOC( unsigned, p->nPatWords );
+ p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords );
// other
p->vNewLos = Vec_PtrAlloc( 100 );
p->vNewPos = Vec_IntAlloc( 100 );
@@ -117,16 +117,16 @@ void Ssw_ManPrintStats( Ssw_Man_t * p )
p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/(p->nRegsBeg?p->nRegsBeg:1) );
p->timeOther = p->timeTotal-p->timeBmc-p->timeReduce-p->timeMarkCones-p->timeSimSat-p->timeSat;
- PRTP( "BMC ", p->timeBmc, p->timeTotal );
- PRTP( "Spec reduce", p->timeReduce, p->timeTotal );
- PRTP( "Mark cones ", p->timeMarkCones, p->timeTotal );
- PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal );
- PRTP( "SAT solving", p->timeSat, p->timeTotal );
- PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
- PRTP( " sat ", p->timeSatSat, p->timeTotal );
- PRTP( " undecided", p->timeSatUndec, p->timeTotal );
- PRTP( "Other ", p->timeOther, p->timeTotal );
- PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+ ABC_PRTP( "BMC ", p->timeBmc, p->timeTotal );
+ ABC_PRTP( "Spec reduce", p->timeReduce, p->timeTotal );
+ ABC_PRTP( "Mark cones ", p->timeMarkCones, p->timeTotal );
+ ABC_PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal );
+ ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal );
+ ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
+ ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal );
+ ABC_PRTP( " undecided", p->timeSatUndec, p->timeTotal );
+ ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
+ ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
}
/**Function*************************************************************
@@ -173,7 +173,7 @@ void Ssw_ManCleanup( Ssw_Man_t * p )
***********************************************************************/
void Ssw_ManStop( Ssw_Man_t * p )
{
- FREE( p->pVisited );
+ ABC_FREE( p->pVisited );
if ( p->pPars->fVerbose )
Ssw_ManPrintStats( p );
if ( p->ppClasses )
@@ -187,9 +187,9 @@ void Ssw_ManStop( Ssw_Man_t * p )
Vec_PtrFree( p->vNewLos );
Vec_IntFree( p->vNewPos );
Vec_PtrFree( p->vCommon );
- FREE( p->pNodeToFrames );
- FREE( p->pPatWords );
- free( p );
+ ABC_FREE( p->pNodeToFrames );
+ ABC_FREE( p->pPatWords );
+ ABC_FREE( p );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/ssw/sswPairs.c b/src/aig/ssw/sswPairs.c
index 1af357f9..3c079922 100644
--- a/src/aig/ssw/sswPairs.c
+++ b/src/aig/ssw/sswPairs.c
@@ -149,8 +149,8 @@ Vec_Int_t ** Ssw_TransformPairsIntoTempClasses( Vec_Int_t * vPairs, int nObjNumM
int * pReprs; // mapping nodes into their representatives
int Entry, idObj, idRepr, idReprObj, idReprRepr, i;
// allocate data-structures
- pvClasses = CALLOC( Vec_Int_t *, nObjNumMax );
- pReprs = ALLOC( int, nObjNumMax );
+ pvClasses = ABC_CALLOC( Vec_Int_t *, nObjNumMax );
+ pReprs = ABC_ALLOC( int, nObjNumMax );
for ( i = 0; i < nObjNumMax; i++ )
pReprs[i] = -1;
// consider pairs
@@ -231,7 +231,7 @@ Vec_Int_t ** Ssw_TransformPairsIntoTempClasses( Vec_Int_t * vPairs, int nObjNumM
}
}
}
- free( pReprs );
+ ABC_FREE( pReprs );
return pvClasses;
}
@@ -252,7 +252,7 @@ void Ssw_FreeTempClasses( Vec_Int_t ** pvClasses, int nObjNumMax )
for ( i = 0; i < nObjNumMax; i++ )
if ( pvClasses[i] )
Vec_IntFree( pvClasses[i] );
- free( pvClasses );
+ ABC_FREE( pvClasses );
}
/**Function*************************************************************
@@ -356,7 +356,7 @@ Aig_Man_t * Ssw_SignalCorrespondeceTestPairs( Aig_Man_t * pAig )
else
printf( "Verification UNDECIDED. Remaining registers %d (total %d). ",
Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig) + Aig_ManRegNum(pAigNew) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
// cleanup
Aig_ManStop( pAigNew );
return pAigRes;
@@ -390,7 +390,7 @@ int Ssw_SecWithPairs( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Vec_Int_t * vIds1, V
else
printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ",
Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig1) + Aig_ManRegNum(pAig2) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
// cleanup
Aig_ManStop( pAigRes );
return RetValue;
@@ -426,7 +426,7 @@ int Ssw_SecGeneral( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Ssw_Pars_t * pPars )
else
printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ",
Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig1) + Aig_ManRegNum(pAig2) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
// cleanup
Aig_ManStop( pAigRes );
return RetValue;
@@ -459,7 +459,7 @@ int Ssw_SecGeneralMiter( Aig_Man_t * pMiter, Ssw_Pars_t * pPars )
else
printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ",
Aig_ManRegNum(pAigRes), Aig_ManRegNum(pMiter) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
// cleanup
Aig_ManStop( pAigRes );
return RetValue;
diff --git a/src/aig/ssw/sswPart.c b/src/aig/ssw/sswPart.c
index 9d2ec34e..f481b457 100644
--- a/src/aig/ssw/sswPart.c
+++ b/src/aig/ssw/sswPart.c
@@ -106,7 +106,7 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
Aig_ManStop( pNew );
}
Aig_ManStop( pTemp );
- free( pMapBack );
+ ABC_FREE( pMapBack );
}
// remap the AIG
pNew = Aig_ManDupRepr( pAig, 0 );
@@ -118,7 +118,7 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
pPars->fVerbose = fVerbose;
if ( fVerbose )
{
- PRT( "Total time", clock() - clk );
+ ABC_PRT( "Total time", clock() - clk );
}
return pNew;
}
diff --git a/src/aig/ssw/sswSat.c b/src/aig/ssw/sswSat.c
index 2fd0fba3..21c5c1f1 100644
--- a/src/aig/ssw/sswSat.c
+++ b/src/aig/ssw/sswSat.c
@@ -81,7 +81,7 @@ int Ssw_NodesAreEquiv( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
clk = clock();
RetValue1 = sat_solver_solve( p->pMSat->pSat, pLits, pLits + nLits,
- (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
{
@@ -143,7 +143,7 @@ p->timeSatUndec += clock() - clk;
clk = clock();
RetValue1 = sat_solver_solve( p->pMSat->pSat, pLits, pLits + nLits,
- (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 );
+ (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
p->timeSat += clock() - clk;
if ( RetValue1 == l_False )
{
diff --git a/src/aig/ssw/sswSemi.c b/src/aig/ssw/sswSemi.c
index 572ab076..5f426093 100644
--- a/src/aig/ssw/sswSemi.c
+++ b/src/aig/ssw/sswSemi.c
@@ -64,7 +64,7 @@ Ssw_Sem_t * Ssw_SemManStart( Ssw_Man_t * pMan, int nConfMax, int fVerbose )
Aig_Obj_t * pObj;
int i;
// create interpolation manager
- p = ALLOC( Ssw_Sem_t, 1 );
+ p = ABC_ALLOC( Ssw_Sem_t, 1 );
memset( p, 0, sizeof(Ssw_Sem_t) );
p->nConfMaxStart = nConfMax;
p->nConfMax = nConfMax;
@@ -85,9 +85,9 @@ Ssw_Sem_t * Ssw_SemManStart( Ssw_Man_t * pMan, int nConfMax, int fVerbose )
// update arrays of the manager
assert( 0 );
/*
- free( p->pMan->pNodeToFrames );
+ ABC_FREE( p->pMan->pNodeToFrames );
Vec_IntFree( p->pMan->vSatVars );
- p->pMan->pNodeToFrames = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pMan->pAig) * p->nFramesSweep );
+ p->pMan->pNodeToFrames = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pMan->pAig) * p->nFramesSweep );
p->pMan->vSatVars = Vec_IntStart( Aig_ManObjNumMax(p->pMan->pAig) * (p->nFramesSweep+1) );
*/
return p;
@@ -109,7 +109,7 @@ void Ssw_SemManStop( Ssw_Sem_t * p )
Vec_PtrFree( p->vTargets );
Vec_PtrFree( p->vPatterns );
Vec_IntFree( p->vHistory );
- free( p );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -283,7 +283,7 @@ clk = clock();
Iter, Ssw_ClassesCand1Num(p->pMan->ppClasses), Ssw_ClassesClassNum(p->pMan->ppClasses),
Aig_ManNodeNum(p->pMan->pFrames), Frames, (int)p->pMan->pMSat->pSat->stats.conflicts, p->nPatterns,
p->pMan->nSatFailsReal? "f" : " " );
- PRT( "T", clock() - clk );
+ ABC_PRT( "T", clock() - clk );
}
Ssw_ManCleanup( p->pMan );
if ( fCheckTargets && Ssw_SemCheckTargets( p ) )
diff --git a/src/aig/ssw/sswSim.c b/src/aig/ssw/sswSim.c
index a860199e..7a2f4664 100644
--- a/src/aig/ssw/sswSim.c
+++ b/src/aig/ssw/sswSim.c
@@ -437,7 +437,7 @@ int * Ssw_SmlCheckOutputSavePattern( Ssw_Sml_t * p, Aig_Obj_t * pObjPo )
// determine the best pattern
BestPat = i * 32 + k;
// fill in the counter-example data
- pModel = ALLOC( int, Aig_ManPiNum(p->pAig)+1 );
+ pModel = ABC_ALLOC( int, Aig_ManPiNum(p->pAig)+1 );
Aig_ManForEachPi( p->pAig, pObjPi, i )
{
pModel[i] = Aig_InfoHasBit(Ssw_ObjSim(p, pObjPi->Id), BestPat);
@@ -1074,7 +1074,7 @@ p->nSimRounds++;
Ssw_Sml_t * Ssw_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFrame )
{
Ssw_Sml_t * p;
- p = (Ssw_Sml_t *)malloc( sizeof(Ssw_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame );
+ p = (Ssw_Sml_t *)ABC_ALLOC( char, sizeof(Ssw_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame );
memset( p, 0, sizeof(Ssw_Sml_t) + sizeof(unsigned) * (nPref + nFrames) * nWordsFrame );
p->pAig = pAig;
p->nPref = nPref;
@@ -1114,7 +1114,7 @@ void Ssw_SmlClean( Ssw_Sml_t * p )
***********************************************************************/
void Ssw_SmlStop( Ssw_Sml_t * p )
{
- free( p );
+ ABC_FREE( p );
}
@@ -1244,7 +1244,7 @@ Ssw_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
{
Ssw_Cex_t * pCex;
int nWords = Aig_BitWordNum( nRegs + nRealPis * nFrames );
- pCex = (Ssw_Cex_t *)malloc( sizeof(Ssw_Cex_t) + sizeof(unsigned) * nWords );
+ pCex = (Ssw_Cex_t *)ABC_ALLOC( char, sizeof(Ssw_Cex_t) + sizeof(unsigned) * nWords );
memset( pCex, 0, sizeof(Ssw_Cex_t) + sizeof(unsigned) * nWords );
pCex->nRegs = nRegs;
pCex->nPis = nRealPis;
@@ -1265,7 +1265,7 @@ Ssw_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
***********************************************************************/
void Ssw_SmlFreeCounterExample( Ssw_Cex_t * pCex )
{
- free( pCex );
+ ABC_FREE( pCex );
}
/**Function*************************************************************
diff --git a/src/aig/tim/tim.c b/src/aig/tim/tim.c
index 9d5c8f7f..7327606e 100644
--- a/src/aig/tim/tim.c
+++ b/src/aig/tim/tim.c
@@ -118,15 +118,15 @@ Tim_Man_t * Tim_ManStart( int nCis, int nCos )
{
Tim_Man_t * p;
int i;
- p = ALLOC( Tim_Man_t, 1 );
+ p = ABC_ALLOC( Tim_Man_t, 1 );
memset( p, 0, sizeof(Tim_Man_t) );
p->pMemObj = Mem_FlexStart();
p->vBoxes = Vec_PtrAlloc( 100 );
p->nCis = nCis;
p->nCos = nCos;
- p->pCis = ALLOC( Tim_Obj_t, nCis );
+ p->pCis = ABC_ALLOC( Tim_Obj_t, nCis );
memset( p->pCis, 0, sizeof(Tim_Obj_t) * nCis );
- p->pCos = ALLOC( Tim_Obj_t, nCos );
+ p->pCos = ABC_ALLOC( Tim_Obj_t, nCos );
memset( p->pCos, 0, sizeof(Tim_Obj_t) * nCos );
for ( i = 0; i < nCis; i++ )
{
@@ -182,7 +182,7 @@ Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fDiscrete )
pNew->vDelayTables = Vec_PtrAlloc( 100 );
Tim_ManForEachBox( p, pBox, i )
{
- pDelayTableNew = ALLOC( float, pBox->nInputs * pBox->nOutputs );
+ pDelayTableNew = ABC_ALLOC( float, pBox->nInputs * pBox->nOutputs );
Vec_PtrPush( pNew->vDelayTables, pDelayTableNew );
if ( fDiscrete )
{
@@ -228,7 +228,7 @@ Tim_Man_t * Tim_ManDupUnit( Tim_Man_t * p )
pNew->vDelayTables = Vec_PtrAlloc( 100 );
Tim_ManForEachBox( p, pBox, i )
{
- pDelayTableNew = ALLOC( float, pBox->nInputs * pBox->nOutputs );
+ pDelayTableNew = ABC_ALLOC( float, pBox->nInputs * pBox->nOutputs );
Vec_PtrPush( pNew->vDelayTables, pDelayTableNew );
for ( k = 0; k < pBox->nInputs * pBox->nOutputs; k++ )
pDelayTableNew[k] = 1.0;
@@ -283,14 +283,14 @@ void Tim_ManStop( Tim_Man_t * p )
if ( p->vDelayTables )
{
Vec_PtrForEachEntry( p->vDelayTables, pTable, i )
- FREE( pTable );
+ ABC_FREE( pTable );
Vec_PtrFree( p->vDelayTables );
}
Vec_PtrFree( p->vBoxes );
Mem_FlexStop( p->pMemObj, 0 );
- free( p->pCis );
- free( p->pCos );
- free( p );
+ ABC_FREE( p->pCis );
+ ABC_FREE( p->pCos );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/tim/tim.h b/src/aig/tim/tim.h
index 7c6e33f1..bdb8e61e 100644
--- a/src/aig/tim/tim.h
+++ b/src/aig/tim/tim.h
@@ -21,10 +21,6 @@
#ifndef __TIM_H__
#define __TIM_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////