00001
00021 #ifndef __CSW_INT_H__
00022 #define __CSW_INT_H__
00023
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027
00031
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <string.h>
00035 #include <assert.h>
00036 #include <time.h>
00037
00038 #include "aig.h"
00039 #include "dar.h"
00040 #include "kit.h"
00041 #include "csw.h"
00042
00046
00050
00051 typedef struct Csw_Man_t_ Csw_Man_t;
00052 typedef struct Csw_Cut_t_ Csw_Cut_t;
00053
00054
00055 struct Csw_Cut_t_
00056 {
00057 Csw_Cut_t * pNext;
00058 int Cost;
00059
00060 unsigned uSign;
00061 int iNode;
00062 short nCutSize;
00063 char nLeafMax;
00064 char nFanins;
00065 int pFanins[0];
00066 };
00067
00068
00069 struct Csw_Man_t_
00070 {
00071
00072 Aig_Man_t * pManAig;
00073 Aig_Man_t * pManRes;
00074 Aig_Obj_t ** pEquiv;
00075 Csw_Cut_t ** pCuts;
00076 int * pnRefs;
00077
00078 Csw_Cut_t ** pTable;
00079 int nTableSize;
00080
00081 int nCutsMax;
00082 int nLeafMax;
00083 int fVerbose;
00084
00085 int nCutSize;
00086 int nTruthWords;
00087 Aig_MmFixed_t * pMemCuts;
00088 unsigned * puTemp[4];
00089
00090 int nNodesTriv0;
00091 int nNodesTriv1;
00092 int nNodesTriv2;
00093 int nNodesCuts;
00094 int nNodesTried;
00095 int timeCuts;
00096 int timeHash;
00097 int timeOther;
00098 int timeTotal;
00099 };
00100
00101 static inline int Csw_CutLeaveNum( Csw_Cut_t * pCut ) { return pCut->nFanins; }
00102 static inline int * Csw_CutLeaves( Csw_Cut_t * pCut ) { return pCut->pFanins; }
00103 static inline unsigned * Csw_CutTruth( Csw_Cut_t * pCut ) { return (unsigned *)(pCut->pFanins + pCut->nLeafMax); }
00104 static inline Csw_Cut_t * Csw_CutNext( Csw_Cut_t * pCut ) { return (Csw_Cut_t *)(((char *)pCut) + pCut->nCutSize); }
00105
00106 static inline int Csw_ObjRefs( Csw_Man_t * p, Aig_Obj_t * pObj ) { return p->pnRefs[pObj->Id]; }
00107 static inline void Csw_ObjAddRefs( Csw_Man_t * p, Aig_Obj_t * pObj, int nRefs ) { p->pnRefs[pObj->Id] += nRefs; }
00108
00109 static inline Csw_Cut_t * Csw_ObjCuts( Csw_Man_t * p, Aig_Obj_t * pObj ) { return p->pCuts[pObj->Id]; }
00110 static inline void Csw_ObjSetCuts( Csw_Man_t * p, Aig_Obj_t * pObj, Csw_Cut_t * pCuts ) { p->pCuts[pObj->Id] = pCuts; }
00111
00112 static inline Aig_Obj_t * Csw_ObjEquiv( Csw_Man_t * p, Aig_Obj_t * pObj ) { return p->pEquiv[pObj->Id]; }
00113 static inline void Csw_ObjSetEquiv( Csw_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pEquiv ) { p->pEquiv[pObj->Id] = pEquiv; }
00114
00115 static inline Aig_Obj_t * Csw_ObjChild0Equiv( Csw_Man_t * p, Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Csw_ObjEquiv(p, Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj)) : NULL; }
00116 static inline Aig_Obj_t * Csw_ObjChild1Equiv( Csw_Man_t * p, Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond(Csw_ObjEquiv(p, Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj)) : NULL; }
00117
00121
00125
00126
00127 #define Csw_ObjForEachCut( p, pObj, pCut, i ) \
00128 for ( i = 0, pCut = Csw_ObjCuts(p, pObj); i < p->nCutsMax; i++, pCut = Csw_CutNext(pCut) )
00129
00130 #define Csw_CutForEachLeaf( p, pCut, pLeaf, i ) \
00131 for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Aig_ManObj(p, (pCut)->pFanins[i])); i++ )
00132
00136
00137
00138 extern Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv );
00139 extern Aig_Obj_t * Csw_ObjSweep( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv );
00140
00141 extern Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVerbose );
00142 extern void Csw_ManStop( Csw_Man_t * p );
00143
00144 extern int Csw_TableCountCuts( Csw_Man_t * p );
00145 extern void Csw_TableCutInsert( Csw_Man_t * p, Csw_Cut_t * pCut );
00146 extern Aig_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut );
00147
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151
00152 #endif
00153
00157