00001
00021 #ifndef __CNF_H__
00022 #define __CNF_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 "vec.h"
00039 #include "aig.h"
00040 #include "darInt.h"
00041
00045
00049
00050 typedef struct Cnf_Man_t_ Cnf_Man_t;
00051 typedef struct Cnf_Dat_t_ Cnf_Dat_t;
00052 typedef struct Cnf_Cut_t_ Cnf_Cut_t;
00053
00054
00055 struct Cnf_Dat_t_
00056 {
00057 Aig_Man_t * pMan;
00058 int nVars;
00059 int nLiterals;
00060 int nClauses;
00061 int ** pClauses;
00062 int * pVarNums;
00063 };
00064
00065
00066 struct Cnf_Cut_t_
00067 {
00068 char nFanins;
00069 char Cost;
00070 short nWords;
00071 Vec_Int_t * vIsop[2];
00072 int pFanins[0];
00073 };
00074
00075
00076 struct Cnf_Man_t_
00077 {
00078 Aig_Man_t * pManAig;
00079 char * pSopSizes;
00080 char ** pSops;
00081 int aArea;
00082 Aig_MmFlex_t * pMemCuts;
00083 int nMergeLimit;
00084 unsigned * pTruths[4];
00085 Vec_Int_t * vMemory;
00086 int timeCuts;
00087 int timeMap;
00088 int timeSave;
00089 };
00090
00091
00092 static inline Dar_Cut_t * Dar_ObjBestCut( Aig_Obj_t * pObj ) { Dar_Cut_t * pCut; int i; Dar_ObjForEachCut( pObj, pCut, i ) if ( pCut->fBest ) return pCut; return NULL; }
00093
00094 static inline int Cnf_CutSopCost( Cnf_Man_t * p, Dar_Cut_t * pCut ) { return p->pSopSizes[pCut->uTruth] + p->pSopSizes[0xFFFF & ~pCut->uTruth]; }
00095
00096 static inline int Cnf_CutLeaveNum( Cnf_Cut_t * pCut ) { return pCut->nFanins; }
00097 static inline int * Cnf_CutLeaves( Cnf_Cut_t * pCut ) { return pCut->pFanins; }
00098 static inline unsigned * Cnf_CutTruth( Cnf_Cut_t * pCut ) { return (unsigned *)(pCut->pFanins + pCut->nFanins); }
00099
00100 static inline Cnf_Cut_t * Cnf_ObjBestCut( Aig_Obj_t * pObj ) { return pObj->pData; }
00101 static inline void Cnf_ObjSetBestCut( Aig_Obj_t * pObj, Cnf_Cut_t * pCut ) { pObj->pData = pCut; }
00102
00106
00110
00111
00112 #define Cnf_CutForEachLeaf( p, pCut, pLeaf, i ) \
00113 for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Aig_ManObj(p, (pCut)->pFanins[i])); i++ )
00114
00118
00119
00120 extern Cnf_Dat_t * Cnf_Derive( Aig_Man_t * pAig, int nOutputs );
00121 extern Cnf_Man_t * Cnf_ManRead();
00122 extern void Cnf_ClearMemory();
00123
00124 extern Cnf_Cut_t * Cnf_CutCreate( Cnf_Man_t * p, Aig_Obj_t * pObj );
00125 extern void Cnf_CutPrint( Cnf_Cut_t * pCut );
00126 extern void Cnf_CutFree( Cnf_Cut_t * pCut );
00127 extern void Cnf_CutUpdateRefs( Cnf_Man_t * p, Cnf_Cut_t * pCut, Cnf_Cut_t * pCutFan, Cnf_Cut_t * pCutRes );
00128 extern Cnf_Cut_t * Cnf_CutCompose( Cnf_Man_t * p, Cnf_Cut_t * pCut, Cnf_Cut_t * pCutFan, int iFan );
00129
00130 extern void Cnf_ReadMsops( char ** ppSopSizes, char *** ppSops );
00131
00132 extern Cnf_Man_t * Cnf_ManStart();
00133 extern void Cnf_ManStop( Cnf_Man_t * p );
00134 extern Vec_Int_t * Cnf_DataCollectPiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p );
00135 extern void Cnf_DataFree( Cnf_Dat_t * p );
00136 extern void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable );
00137 void * Cnf_DataWriteIntoSolver( Cnf_Dat_t * p );
00138
00139 extern void Cnf_DeriveMapping( Cnf_Man_t * p );
00140 extern int Cnf_ManMapForCnf( Cnf_Man_t * p );
00141
00142 extern void Cnf_ManTransferCuts( Cnf_Man_t * p );
00143 extern void Cnf_ManFreeCuts( Cnf_Man_t * p );
00144 extern void Cnf_ManPostprocess( Cnf_Man_t * p );
00145
00146 extern Vec_Ptr_t * Aig_ManScanMapping( Cnf_Man_t * p, int fCollect );
00147 extern Vec_Ptr_t * Cnf_ManScanMapping( Cnf_Man_t * p, int fCollect, int fPreorder );
00148
00149 extern void Cnf_SopConvertToVector( char * pSop, int nCubes, Vec_Int_t * vCover );
00150 extern Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs );
00151 extern Cnf_Dat_t * Cnf_DeriveSimple( Aig_Man_t * p, int nOutputs );
00152
00153 #ifdef __cplusplus
00154 }
00155 #endif
00156
00157 #endif
00158
00162