if.h 43.3 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**CFile****************************************************************

  FileName    [if.h]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [FPGA mapping based on priority cuts.]

  Synopsis    [External declarations.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - November 21, 2006.]

  Revision    [$Id: if.h,v 1.00 2006/11/21 00:00:00 alanmi Exp $]

***********************************************************************/
 
21 22
#ifndef ABC__map__if__if_h
#define ABC__map__if__if_h
Alan Mishchenko committed
23

24

Alan Mishchenko committed
25 26 27
////////////////////////////////////////////////////////////////////////
///                          INCLUDES                                ///
////////////////////////////////////////////////////////////////////////
28
 
Alan Mishchenko committed
29 30 31 32
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
33

34 35 36
#include "misc/vec/vec.h"
#include "misc/mem/mem.h"
#include "misc/tim/tim.h"
Alan Mishchenko committed
37
#include "misc/util/utilNam.h"
38 39
#include "misc/vec/vecMem.h"
#include "misc/util/utilTruth.h"
40
#include "opt/dau/dau.h"
41
#include "misc/vec/vecHash.h"
42
#include "misc/vec/vecWec.h"
43 44 45

ABC_NAMESPACE_HEADER_START

Alan Mishchenko committed
46

Alan Mishchenko committed
47 48 49 50 51 52 53 54 55 56 57
////////////////////////////////////////////////////////////////////////
///                         PARAMETERS                               ///
////////////////////////////////////////////////////////////////////////
 
// the maximum size of LUTs used for mapping (should be the same as FPGA_MAX_LUTSIZE defined in "fpga.h"!!!)
#define IF_MAX_LUTSIZE       32
// the largest possible number of LUT inputs when funtionality of the LUTs are computed
#define IF_MAX_FUNC_LUTSIZE  15
// a very large number
#define IF_INFINITY          100000000  
// the largest possible user cut cost
58
#define IF_COST_MAX          4095 // ((1<<12)-1)
Alan Mishchenko committed
59

60
#define IF_BIG_CHAR ((char)120)
61

Alan Mishchenko committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
// object types
typedef enum { 
    IF_NONE,     // 0: non-existent object
    IF_CONST1,   // 1: constant 1 
    IF_CI,       // 2: combinational input
    IF_CO,       // 3: combinational output
    IF_AND,      // 4: AND node
    IF_VOID      // 5: unused object
} If_Type_t;

////////////////////////////////////////////////////////////////////////
///                         BASIC TYPES                              ///
////////////////////////////////////////////////////////////////////////

typedef struct If_Man_t_     If_Man_t;
typedef struct If_Par_t_     If_Par_t;
typedef struct If_Obj_t_     If_Obj_t;
typedef struct If_Cut_t_     If_Cut_t;
typedef struct If_Set_t_     If_Set_t;
81 82
typedef struct If_LibLut_t_  If_LibLut_t;
typedef struct If_LibBox_t_  If_LibBox_t;
83
typedef struct If_DsdMan_t_  If_DsdMan_t;
84
typedef struct Ifn_Ntk_t_    Ifn_Ntk_t;
Alan Mishchenko committed
85

86 87 88 89
typedef struct Ifif_Par_t_   Ifif_Par_t;
struct Ifif_Par_t_
{
    int                nLutSize;      // the LUT size
90
    If_LibLut_t *      pLutLib;       // the LUT library
91 92 93 94 95 96 97 98
    float              pLutDelays[IF_MAX_LUTSIZE];  // pin-to-pin delays of the max LUT
    float              DelayWire;     // wire delay
    int                nDegree;       // structure degree 
    int                fCascade;      // cascade
    int                fVerbose;      // verbose
    int                fVeryVerbose;  // verbose
};

Alan Mishchenko committed
99 100 101 102 103 104 105 106
// parameters
struct If_Par_t_
{
    // user-controlable parameters
    int                nLutSize;      // the LUT size
    int                nCutsMax;      // the max number of cuts
    int                nFlowIters;    // the number of iterations of area recovery
    int                nAreaIters;    // the number of iterations of area recovery
107
    int                nGateSize;     // the max size of the AND/OR gate to map into
Alan Mishchenko committed
108
    int                nNonDecLimit;  // the max size of non-dec nodes
Alan Mishchenko committed
109
    float              DelayTarget;   // delay target
Alan Mishchenko committed
110
    float              Epsilon;       // value used in comparison floating point numbers
111
    int                nRelaxRatio;   // delay relaxation ratio
112
    int                nStructType;   // type of the structure
113 114
    int                nAndDelay;     // delay of AND-gate in LUT library units
    int                nAndArea;      // area of AND-gate in LUT library units
Alan Mishchenko committed
115 116 117 118 119 120
    int                fPreprocess;   // preprossing
    int                fArea;         // area-oriented mapping
    int                fFancy;        // a fancy feature
    int                fExpRed;       // expand/reduce of the best cuts
    int                fLatchPaths;   // reset timing on latch paths
    int                fEdge;         // uses edge-based cut selection heuristics
Alan Mishchenko committed
121
    int                fPower;        // uses power-aware cut selection heuristics
Alan Mishchenko committed
122
    int                fCutMin;       // performs cut minimization by removing functionally reducdant variables
123 124 125 126
    int                fDelayOpt;     // special delay optimization
    int                fDelayOptLut;  // delay optimization for LUTs
    int                fDsdBalance;   // special delay optimization
    int                fUserRecLib;   // use recorded library
Alan Mishchenko committed
127
    int                fBidec;        // use bi-decomposition
128
    int                fUse34Spec;    // use specialized matching
129
    int                fUseBat;       // use one specialized feature
130
    int                fUseBuffs;     // use buffers to decouple outputs
131 132 133
    int                fEnableCheck07;// enable additional checking
    int                fEnableCheck08;// enable additional checking
    int                fEnableCheck10;// enable additional checking
134 135
    int                fEnableCheck75;// enable additional checking
    int                fEnableCheck75u;// enable additional checking
Alan Mishchenko committed
136
    int                fUseDsd;       // compute DSD of the cut functions
137
    int                fUseDsdTune;   // use matching based on precomputed manager
138
    int                fUseCofVars;   // use cofactoring variables
139
    int                fUseAndVars;   // use bi-decomposition
140
    int                fUseTtPerm;    // compute truth tables of the cut functions
141
    int                fDeriveLuts;   // enables deriving LUT structures
142
    int                fDoAverage;    // optimize average rather than maximum level
Alan Mishchenko committed
143
    int                fVerbose;      // the verbosity flag
144 145
    char *             pLutStruct;    // LUT structure
    float              WireDelay;     // wire delay
Alan Mishchenko committed
146
    // internal parameters
147
    int                fSkipCutFilter;// skip cut filter
Alan Mishchenko committed
148 149 150 151 152 153 154
    int                fAreaOnly;     // area only mode
    int                fTruth;        // truth table computation enabled
    int                fUsePerm;      // use permutation (delay info)
    int                fUseBdds;      // use local BDDs as a cost function
    int                fUseSops;      // use local SOPs as a cost function
    int                fUseCnfs;      // use local CNFs as a cost function
    int                fUseMv;        // use local MV-SOPs as a cost function
155 156 157 158
    int                nLatchesCi;    // the number of latches among the CIs
    int                nLatchesCo;    // the number of latches among the COs
    int                nLatchesCiBox; // the number of white box outputs among the CIs
    int                nLatchesCoBox; // the number of white box inputs among the COs
Alan Mishchenko committed
159
    int                fLiftLeaves;   // shift the leaves for seq mapping
160
    int                fUseCoAttrs;   // use CO attributes
161
    float              DelayTargetNew;// new delay target
162
    float              FinalDelay;    // final delay after mapping
163
    float              FinalArea;     // final area after mapping
164
    If_LibLut_t *      pLutLib;       // the LUT library
Alan Mishchenko committed
165 166
    float *            pTimesArr;     // arrival times
    float *            pTimesReq;     // required times
167
    int (* pFuncCost)  (If_Man_t *, If_Cut_t *);  // procedure to compute the user's cost of a cut
168 169
    int (* pFuncUser)  (If_Man_t *, If_Obj_t *, If_Cut_t *);        //  procedure called for each cut when cut computation is finished
    int (* pFuncCell)  (If_Man_t *, unsigned *, int, int, char *);  //  procedure called for cut functions
Alan Mishchenko committed
170 171 172 173
    void *             pReoMan;       // reordering manager
};

// the LUT library
174
struct If_LibLut_t_
Alan Mishchenko committed
175 176 177 178 179 180 181 182 183 184 185
{
    char *             pName;         // the name of the LUT library
    int                LutMax;        // the maximum LUT size 
    int                fVarPinDelays; // set to 1 if variable pin delays are specified
    float              pLutAreas[IF_MAX_LUTSIZE+1]; // the areas of LUTs
    float              pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1];// the delays of LUTs
};

// manager
struct If_Man_t_
{
186
    char *             pName;
Alan Mishchenko committed
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
    // mapping parameters
    If_Par_t *         pPars;
    // mapping nodes
    If_Obj_t *         pConst1;       // the constant 1 node
    Vec_Ptr_t *        vCis;          // the primary inputs
    Vec_Ptr_t *        vCos;          // the primary outputs
    Vec_Ptr_t *        vObjs;         // all objects
    Vec_Ptr_t *        vObjsRev;      // reverse topological order of objects
    Vec_Ptr_t *        vTemp;         // temporary array
    int                nObjs[IF_VOID];// the number of objects by type
    // various data
    int                nLevelMax;     // the max number of AIG levels
    float              fEpsilon;      // epsilon used for comparison
    float              RequiredGlo;   // global required times
    float              RequiredGlo2;  // global required times
    float              AreaGlo;       // global area
    int                nNets;         // the sum total of fanins of all LUTs in the mapping
Alan Mishchenko committed
204
    float              dPower;        // the sum total of switching activities of all LUTs in the mapping
Alan Mishchenko committed
205 206 207
    int                nCutsUsed;     // the number of cuts currently used
    int                nCutsMerged;   // the total number of cuts merged
    unsigned *         puTemp[4];     // used for the truth table computation
208
    word *             puTempW;       // used for the truth table computation
Alan Mishchenko committed
209 210 211
    int                SortMode;      // one of the three sorting modes
    int                fNextRound;    // set to 1 after the first round
    int                nChoices;      // the number of choice nodes
Alan Mishchenko committed
212
    Vec_Int_t *        vSwitching;    // switching activity of each node
Alan Mishchenko committed
213
    int                pPerm[3][IF_MAX_LUTSIZE]; // permutations
Alan Mishchenko committed
214
    unsigned           uSharedMask;   // mask of shared variables
Alan Mishchenko committed
215
    int                nShared;       // the number of shared variables
216
    int                fReqTimeWarn;  // warning about exceeding required times was printed
217 218
    // SOP balancing
    Vec_Int_t *        vCover;        // used to compute ISOP
219
    Vec_Int_t *        vArray;        // intermediate storage
220 221 222
    Vec_Wrd_t *        vAnds;         // intermediate storage
    Vec_Wrd_t *        vOrGate;       // intermediate storage
    Vec_Wrd_t *        vAndGate;      // intermediate storage
Alan Mishchenko committed
223 224 225 226 227 228 229
    // sequential mapping
    Vec_Ptr_t *        vLatchOrder;   // topological ordering of latches
    Vec_Int_t *        vLags;         // sequentail lags of all nodes
    int                nAttempts;     // the number of attempts in binary search
    int                nMaxIters;     // the maximum number of iterations
    int                Period;        // the current value of the clock period (for seq mapping)
    // memory management
230
    int                nTruth6Words[IF_MAX_FUNC_LUTSIZE+1];  // the size of the truth table if allocated
Alan Mishchenko committed
231 232 233 234 235 236 237 238
    int                nPermWords;    // the size of the permutation array (in words)
    int                nObjBytes;     // the size of the object
    int                nCutBytes;     // the size of the cut
    int                nSetBytes;     // the size of the cut set
    Mem_Fixed_t *      pMemObj;       // memory manager for objects (entrysize = nEntrySize)
    Mem_Fixed_t *      pMemSet;       // memory manager for sets of cuts (entrysize = nCutSize*(nCutsMax+1))
    If_Set_t *         pMemCi;        // memory for CI cutsets
    If_Set_t *         pMemAnd;       // memory for AND cutsets
239
    If_Set_t *         pFreeList;     // the list of free cutsets
Alan Mishchenko committed
240
    int                nSmallSupp;    // the small support
241
    int                nCutsTotal;
242 243 244 245
    int                nCutsUseless[32];
    int                nCutsCount[32];
    int                nCutsCountAll;
    int                nCutsUselessAll;
246
    int                nCuts5, nCuts5a;
247
    If_DsdMan_t *      pIfDsdMan;     // DSD manager
248
    Vec_Mem_t *        vTtMem[IF_MAX_FUNC_LUTSIZE+1];   // truth table memory and hash table
249
    Vec_Wec_t *        vTtIsops[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into DSD
250 251
    Vec_Int_t *        vTtDsds[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into DSD
    Vec_Str_t *        vTtPerms[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into permutations
252
    Vec_Str_t *        vTtVars[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into selected vars
253
    Vec_Int_t *        vTtDecs[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into decomposition pattern
254
    Hash_IntMan_t *    vPairHash;     // hashing pairs of truth tables
255 256
    Vec_Int_t *        vPairRes;      // resulting truth table
    Vec_Str_t *        vPairPerms;    // resulting permutation
257 258 259 260 261
    char               pCanonPerm[IF_MAX_LUTSIZE];
    unsigned           uCanonPhase;
    int                nCacheHits;
    int                nCacheMisses;
    abctime            timeCache[6];
262
    int                nBestCutSmall[2];
263
    int                nCountNonDec[2];
264
    Vec_Int_t *        vCutData;      // cut data storage
Alan Mishchenko committed
265

Alan Mishchenko committed
266 267
    // timing manager
    Tim_Man_t *        pManTim;
268
    Vec_Int_t *        vCoAttrs;      // CO attributes   0=optimize; 1=keep; 2=relax
269
    // hash table for functions
270 271 272 273
    int                nTableSize[2];    // hash table size
    int                nTableEntries[2]; // hash table entries
    void **            pHashTable[2];    // hash table bins
    Mem_Fixed_t *      pMemEntries;      // memory manager for hash table entries
Alan Mishchenko committed
274
    // statistics 
275
//    abctime                timeTruth;
Alan Mishchenko committed
276 277 278 279 280 281 282
};

// priority cut
struct If_Cut_t_
{
    float              Area;          // area (or area-flow) of the cut
    float              Edge;          // the edge flow
Alan Mishchenko committed
283
    float              Power;         // the power flow
Alan Mishchenko committed
284
    float              Delay;         // delay of the cut
285
    int                iCutFunc;      // TT ID of the cut
286
    int                uMaskFunc;     // polarity bitmask
Alan Mishchenko committed
287
    unsigned           uSign;         // cut signature
288
    unsigned           Cost    : 12;  // the user's cost of the cut (related to IF_COST_MAX)
Alan Mishchenko committed
289 290
    unsigned           fCompl  :  1;  // the complemented attribute 
    unsigned           fUser   :  1;  // using the user's area and delay
291 292
    unsigned           fUseless:  1;  // cannot be used in the mapping
    unsigned           fAndCut :  1;  // matched with AND gate
Alan Mishchenko committed
293 294
    unsigned           nLimit  :  8;  // the maximum number of leaves
    unsigned           nLeaves :  8;  // the number of leaves
295
    int                pLeaves[0];
Alan Mishchenko committed
296 297 298 299 300 301 302
};

// set of priority cut
struct If_Set_t_
{
    short              nCutsMax;      // the max number of cuts
    short              nCuts;         // the current number of cuts
303
    If_Set_t *         pNext;         // next cutset in the free list
Alan Mishchenko committed
304 305 306 307 308 309 310 311 312 313 314 315 316
    If_Cut_t **        ppCuts;        // the array of pointers to the cuts
};

// node extension
struct If_Obj_t_
{
    unsigned           Type    :  4;  // object
    unsigned           fCompl0 :  1;  // complemented attribute
    unsigned           fCompl1 :  1;  // complemented attribute
    unsigned           fPhase  :  1;  // phase of the node
    unsigned           fRepr   :  1;  // representative of the equivalence class
    unsigned           fMark   :  1;  // multipurpose mark
    unsigned           fVisit  :  1;  // multipurpose mark
317
    unsigned           fSpec   :  1;  // multipurpose mark
318
    unsigned           fDriver :  1;  // multipurpose mark
319 320
    unsigned           fSkipCut:  1;  // multipurpose mark
    unsigned           Level   : 19;  // logic level of the node
Alan Mishchenko committed
321 322 323 324 325 326 327 328 329 330 331
    int                Id;            // integer ID
    int                IdPio;         // integer ID of PIs/POs
    int                nRefs;         // the number of references
    int                nVisits;       // the number of visits to this node
    int                nVisitsCopy;   // the number of visits to this node
    If_Obj_t *         pFanin0;       // the first fanin 
    If_Obj_t *         pFanin1;       // the second fanin
    If_Obj_t *         pEquiv;        // the choice node
    float              EstRefs;       // estimated reference counter
    float              Required;      // required time of the onde
    float              LValue;        // sequential arrival time of the node
332
    union{
Alan Mishchenko committed
333
    void *             pCopy;         // used for object duplication
334 335 336
    int                iCopy;
    };
    
Alan Mishchenko committed
337 338 339 340
    If_Set_t *         pCutSet;       // the pointer to the cutset
    If_Cut_t           CutBest;       // the best cut selected 
};

Alan Mishchenko committed
341 342 343 344
typedef struct If_Box_t_ If_Box_t;
struct If_Box_t_
{
    char *             pName;
345 346 347 348
    char               fSeq;
    char               fBlack;
    char               fOuter;
    char               fUnused;
Alan Mishchenko committed
349 350 351 352 353 354 355 356 357 358 359
    int                Id;
    int                nPis;
    int                nPos;
    int *              pDelays;
};

struct If_LibBox_t_
{
    Vec_Ptr_t *        vBoxes;
};

Alan Mishchenko committed
360 361 362 363
static inline If_Obj_t * If_Regular( If_Obj_t * p )                          { return (If_Obj_t *)((ABC_PTRUINT_T)(p) & ~01);  }
static inline If_Obj_t * If_Not( If_Obj_t * p )                              { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^  01);  }
static inline If_Obj_t * If_NotCond( If_Obj_t * p, int c )                   { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c));  }
static inline int        If_IsComplement( If_Obj_t * p )                     { return (int )(((ABC_PTRUINT_T)p) & 01);         }
Alan Mishchenko committed
364 365 366 367 368 369 370 371 372

static inline int        If_ManCiNum( If_Man_t * p )                         { return p->nObjs[IF_CI];               }
static inline int        If_ManCoNum( If_Man_t * p )                         { return p->nObjs[IF_CO];               }
static inline int        If_ManAndNum( If_Man_t * p )                        { return p->nObjs[IF_AND];              }
static inline int        If_ManObjNum( If_Man_t * p )                        { return Vec_PtrSize(p->vObjs);         }

static inline If_Obj_t * If_ManConst1( If_Man_t * p )                        { return p->pConst1;                              }
static inline If_Obj_t * If_ManCi( If_Man_t * p, int i )                     { return (If_Obj_t *)Vec_PtrEntry( p->vCis, i );  }
static inline If_Obj_t * If_ManCo( If_Man_t * p, int i )                     { return (If_Obj_t *)Vec_PtrEntry( p->vCos, i );  }
373 374
static inline If_Obj_t * If_ManLi( If_Man_t * p, int i )                     { return (If_Obj_t *)Vec_PtrEntry( p->vCos, If_ManCoNum(p) - p->pPars->nLatchesCo + i );  }
static inline If_Obj_t * If_ManLo( If_Man_t * p, int i )                     { return (If_Obj_t *)Vec_PtrEntry( p->vCis, If_ManCiNum(p) - p->pPars->nLatchesCi + i );  }
Alan Mishchenko committed
375 376 377 378 379
static inline If_Obj_t * If_ManObj( If_Man_t * p, int i )                    { return (If_Obj_t *)Vec_PtrEntry( p->vObjs, i ); }

static inline int        If_ObjIsConst1( If_Obj_t * pObj )                   { return pObj->Type == IF_CONST1;       }
static inline int        If_ObjIsCi( If_Obj_t * pObj )                       { return pObj->Type == IF_CI;           }
static inline int        If_ObjIsCo( If_Obj_t * pObj )                       { return pObj->Type == IF_CO;           }
Alan Mishchenko committed
380 381
static inline int        If_ObjIsTerm( If_Obj_t * pObj )                     { return pObj->Type == IF_CI || pObj->Type == IF_CO; }
static inline int        If_ObjIsLatch( If_Obj_t * pObj )                    { return If_ObjIsCi(pObj) && pObj->pFanin0 != NULL;  }
Alan Mishchenko committed
382 383
static inline int        If_ObjIsAnd( If_Obj_t * pObj )                      { return pObj->Type == IF_AND;          }

384
static inline int        If_ObjId( If_Obj_t * pObj )                         { return pObj->Id;                      }
Alan Mishchenko committed
385 386 387 388 389
static inline If_Obj_t * If_ObjFanin0( If_Obj_t * pObj )                     { return pObj->pFanin0;                 }
static inline If_Obj_t * If_ObjFanin1( If_Obj_t * pObj )                     { return pObj->pFanin1;                 }
static inline int        If_ObjFaninC0( If_Obj_t * pObj )                    { return pObj->fCompl0;                 }
static inline int        If_ObjFaninC1( If_Obj_t * pObj )                    { return pObj->fCompl1;                 }
static inline void *     If_ObjCopy( If_Obj_t * pObj )                       { return pObj->pCopy;                   }
Alan Mishchenko committed
390 391
static inline int        If_ObjLevel( If_Obj_t * pObj )                      { return pObj->Level;                   }
static inline void       If_ObjSetLevel( If_Obj_t * pObj, int Level )        { pObj->Level = Level;                  }
Alan Mishchenko committed
392
static inline void       If_ObjSetCopy( If_Obj_t * pObj, void * pCopy )      { pObj->pCopy = pCopy;                  }
393
static inline void       If_ObjSetChoice( If_Obj_t * pObj, If_Obj_t * pEqu ) { pObj->pEquiv = pEqu;                  }
Alan Mishchenko committed
394

395 396
static inline int        If_CutLeaveNum( If_Cut_t * pCut )                   { return pCut->nLeaves;                             }
static inline int *      If_CutLeaves( If_Cut_t * pCut )                     { return pCut->pLeaves;                             }
397
static inline If_Obj_t * If_CutLeaf( If_Man_t * p, If_Cut_t * pCut, int i )  { assert(i >= 0 && i < (int)pCut->nLeaves); return If_ManObj(p, pCut->pLeaves[i]);                         }
398 399 400
static inline unsigned   If_CutSuppMask( If_Cut_t * pCut )                   { return (~(unsigned)0) >> (32-pCut->nLeaves);      }
static inline int        If_CutTruthWords( int nVarsMax )                    { return nVarsMax <= 5 ? 2 : (1 << (nVarsMax - 5)); }
static inline int        If_CutPermWords( int nVarsMax )                     { return nVarsMax / sizeof(int) + ((nVarsMax % sizeof(int)) > 0); }
401
static inline int        If_CutLeafBit( If_Cut_t * pCut, int i )             { return (pCut->uMaskFunc >> i) & 1;                }
402 403 404
static inline char *     If_CutPerm( If_Cut_t * pCut )                       { return (char *)(pCut->pLeaves + pCut->nLeaves);   }
static inline void       If_CutCopy( If_Man_t * p, If_Cut_t * pDst, If_Cut_t * pSrc ) { memcpy( pDst, pSrc, p->nCutBytes );      }
static inline void       If_CutSetup( If_Man_t * p, If_Cut_t * pCut        ) { memset(pCut, 0, p->nCutBytes); pCut->nLimit = p->pPars->nLutSize; }
405

Alan Mishchenko committed
406 407
static inline If_Cut_t * If_ObjCutBest( If_Obj_t * pObj )                    { return &pObj->CutBest;                }
static inline unsigned   If_ObjCutSign( unsigned ObjId )                     { return (1 << (ObjId % 31));           }
408
static inline unsigned   If_ObjCutSignCompute( If_Cut_t * p )                { unsigned s = 0; int i; for ( i = 0; i < If_CutLeaveNum(p); i++ ) s |= If_ObjCutSign(p->pLeaves[i]); return s; }
Alan Mishchenko committed
409 410 411 412 413 414 415 416 417 418

static inline float      If_ObjArrTime( If_Obj_t * pObj )                    { return If_ObjCutBest(pObj)->Delay;    }
static inline void       If_ObjSetArrTime( If_Obj_t * pObj, float ArrTime )  { If_ObjCutBest(pObj)->Delay = ArrTime; }

static inline float      If_ObjLValue( If_Obj_t * pObj )                     { return pObj->LValue;                  }
static inline void       If_ObjSetLValue( If_Obj_t * pObj, float LValue )    { pObj->LValue = LValue;                }

static inline void *     If_CutData( If_Cut_t * pCut )                       { return *(void **)pCut;                }
static inline void       If_CutSetData( If_Cut_t * pCut, void * pData )      { *(void **)pCut = pData;               }

419 420 421
static inline int        If_CutDataInt( If_Cut_t * pCut )                    { return *(int *)pCut;                  }
static inline void       If_CutSetDataInt( If_Cut_t * pCut, int Data )       { *(int *)pCut = Data;                  }

422 423
static inline int        If_CutTruthLit( If_Cut_t * pCut )                   { assert( pCut->iCutFunc >= 0 ); return pCut->iCutFunc;             }
static inline int        If_CutTruthIsCompl( If_Cut_t * pCut )               { assert( pCut->iCutFunc >= 0 ); return Abc_LitIsCompl(pCut->iCutFunc);                               }
424
static inline word *     If_CutTruthWR( If_Man_t * p, If_Cut_t * pCut )      { return p->vTtMem ? Vec_MemReadEntry(p->vTtMem[pCut->nLeaves], Abc_Lit2Var(pCut->iCutFunc)) : NULL;  }
425
static inline unsigned * If_CutTruthUR( If_Man_t * p, If_Cut_t * pCut)       { return (unsigned *)If_CutTruthWR(p, pCut);                        }
426
static inline word *     If_CutTruthW( If_Man_t * p, If_Cut_t * pCut )       { if ( p->vTtMem == NULL ) return NULL; assert( pCut->iCutFunc >= 0 ); Abc_TtCopy( p->puTempW, If_CutTruthWR(p, pCut), p->nTruth6Words[pCut->nLeaves], If_CutTruthIsCompl(pCut) ); return p->puTempW;  }
427
static inline unsigned * If_CutTruth( If_Man_t * p, If_Cut_t * pCut )        { return (unsigned *)If_CutTruthW(p, pCut);                         }
428

429
static inline int        If_CutDsdLit( If_Man_t * p, If_Cut_t * pCut )       { return Abc_Lit2LitL( Vec_IntArray(p->vTtDsds[pCut->nLeaves]), If_CutTruthLit(pCut) );               }
430 431
static inline int        If_CutDsdIsCompl( If_Man_t * p, If_Cut_t * pCut )   { return Abc_LitIsCompl( If_CutDsdLit(p, pCut) );                                                     }
static inline char *     If_CutDsdPerm( If_Man_t * p, If_Cut_t * pCut )      { return Vec_StrEntryP( p->vTtPerms[pCut->nLeaves], Abc_Lit2Var(pCut->iCutFunc) * Abc_MaxInt(6, pCut->nLeaves) );           }
Alan Mishchenko committed
432

433
static inline float      If_CutLutArea( If_Man_t * p, If_Cut_t * pCut )      { return pCut->fAndCut ? p->pPars->nAndArea : (pCut->fUser? (float)pCut->Cost : (p->pPars->pLutLib? p->pPars->pLutLib->pLutAreas[pCut->nLeaves] : (float)1.0));  }
434
static inline float      If_CutLutDelay( If_LibLut_t * p, int Size, int iPin )  { return p ? (p->fVarPinDelays ? p->pLutDelays[Size][iPin] : p->pLutDelays[Size][0]) : 1.0;                              }
Alan Mishchenko committed
435

Alan Mishchenko committed
436

Alan Mishchenko committed
437 438 439 440 441 442 443 444 445 446 447 448 449 450
////////////////////////////////////////////////////////////////////////
///                      MACRO DEFINITIONS                           ///
////////////////////////////////////////////////////////////////////////

#define IF_MIN(a,b)      (((a) < (b))? (a) : (b))
#define IF_MAX(a,b)      (((a) > (b))? (a) : (b))

// the small and large numbers (min/max float are 1.17e-38/3.40e+38)
#define IF_FLOAT_LARGE   ((float)1.0e+20)
#define IF_FLOAT_SMALL   ((float)1.0e-20)
#define IF_INT_LARGE     (10000000)

// iterator over the primary inputs
#define If_ManForEachCi( p, pObj, i )                                          \
451
    Vec_PtrForEachEntry( If_Obj_t *, p->vCis, pObj, i )
Alan Mishchenko committed
452 453
// iterator over the primary outputs
#define If_ManForEachCo( p, pObj, i )                                          \
454
    Vec_PtrForEachEntry( If_Obj_t *, p->vCos, pObj, i )
Alan Mishchenko committed
455 456
// iterator over the primary inputs
#define If_ManForEachPi( p, pObj, i )                                          \
457
    Vec_PtrForEachEntryStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox )
Alan Mishchenko committed
458 459
// iterator over the primary outputs
#define If_ManForEachPo( p, pObj, i )                                          \
460
    Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCos, pObj, i, p->pPars->nLatchesCoBox, If_ManCoNum(p) - p->pPars->nLatchesCo )
Alan Mishchenko committed
461 462
// iterator over the latches 
#define If_ManForEachLatchInput( p, pObj, i )                                  \
463
    Vec_PtrForEachEntryStart( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatchesCo )
Alan Mishchenko committed
464
#define If_ManForEachLatchOutput( p, pObj, i )                                 \
465
    Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox, If_ManCiNum(p) - p->pPars->nLatchesCiBox )
Alan Mishchenko committed
466 467
// iterator over all objects in topological order
#define If_ManForEachObj( p, pObj, i )                                         \
468
    Vec_PtrForEachEntry( If_Obj_t *, p->vObjs, pObj, i )
Alan Mishchenko committed
469 470
// iterator over all objects in reverse topological order
#define If_ManForEachObjReverse( p, pObj, i )                                  \
471
    Vec_PtrForEachEntry( If_Obj_t *, p->vObjsRev, pObj, i )
Alan Mishchenko committed
472 473 474 475 476 477 478 479 480 481 482
// iterator over logic nodes 
#define If_ManForEachNode( p, pObj, i )                                        \
    If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else
// iterator over cuts of the node
#define If_ObjForEachCut( pObj, pCut, i )                                      \
    for ( i = 0; (i < (pObj)->pCutSet->nCuts) && ((pCut) = (pObj)->pCutSet->ppCuts[i]); i++ )
// iterator over the leaves of the cut
#define If_CutForEachLeaf( p, pCut, pLeaf, i )                                 \
    for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i++ )
#define If_CutForEachLeafReverse( p, pCut, pLeaf, i )                                 \
    for ( i = (int)(pCut)->nLeaves - 1; (i >= 0) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i-- )
Alan Mishchenko committed
483
//#define If_CutForEachLeaf( p, pCut, pLeaf, i )                                 \ \\prevent multiline comment
Alan Mishchenko committed
484 485 486 487 488 489 490 491 492 493
//    for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, p->pPars->fLiftLeaves? (pCut)->pLeaves[i] >> 8 : (pCut)->pLeaves[i])); i++ )
// iterator over the leaves of the sequential cut
#define If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i )                       \
    for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i] >> 8)) && (((Shift) = ((pCut)->pLeaves[i] & 255)) >= 0); i++ )

////////////////////////////////////////////////////////////////////////
///                    FUNCTION DECLARATIONS                         ///
////////////////////////////////////////////////////////////////////////

/*=== ifCore.c ===========================================================*/
494
extern void            If_ManSetDefaultPars( If_Par_t * pPars );
Alan Mishchenko committed
495 496
extern int             If_ManPerformMapping( If_Man_t * p );
extern int             If_ManPerformMappingComb( If_Man_t * p );
497
extern void            If_ManComputeSwitching( If_Man_t * p );
Alan Mishchenko committed
498
/*=== ifCut.c ============================================================*/
499
extern int             If_CutVerifyCuts( If_Set_t * pCutSet, int fOrdered );
500
extern int             If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut, int fSaveCut0 );
Alan Mishchenko committed
501
extern void            If_CutSort( If_Man_t * p, If_Set_t * pCutSet, If_Cut_t * pCut );
Alan Mishchenko committed
502
extern void            If_CutOrder( If_Cut_t * pCut );
503
extern int             If_CutMergeOrdered( If_Man_t * p, If_Cut_t * pCut0, If_Cut_t * pCut1, If_Cut_t * pCut );
Alan Mishchenko committed
504
extern int             If_CutMerge( If_Man_t * p, If_Cut_t * pCut0, If_Cut_t * pCut1, If_Cut_t * pCut );
Alan Mishchenko committed
505 506
extern int             If_CutCheck( If_Cut_t * pCut );
extern void            If_CutPrint( If_Cut_t * pCut );
Alan Mishchenko committed
507 508 509 510 511
extern void            If_CutPrintTiming( If_Man_t * p, If_Cut_t * pCut );
extern void            If_CutLift( If_Cut_t * pCut );
extern void            If_CutCopy( If_Man_t * p, If_Cut_t * pCutDest, If_Cut_t * pCutSrc );
extern float           If_CutAreaFlow( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutEdgeFlow( If_Man_t * p, If_Cut_t * pCut );
Alan Mishchenko committed
512
extern float           If_CutPowerFlow( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
Alan Mishchenko committed
513 514 515 516 517 518 519 520 521
extern float           If_CutAverageRefs( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutAreaDeref( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutAreaRef( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutAreaDerefed( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutAreaRefed( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutEdgeDeref( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutEdgeRef( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutEdgeDerefed( If_Man_t * p, If_Cut_t * pCut );
extern float           If_CutEdgeRefed( If_Man_t * p, If_Cut_t * pCut );
Alan Mishchenko committed
522 523 524 525
extern float           If_CutPowerDeref( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
extern float           If_CutPowerRef( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
extern float           If_CutPowerDerefed( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
extern float           If_CutPowerRefed( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
526
/*=== ifDec.c =============================================================*/
527
extern word            If_CutPerformDerive07( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
528 529 530 531
extern int             If_CutPerformCheck07( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
extern int             If_CutPerformCheck08( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
extern int             If_CutPerformCheck10( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
extern int             If_CutPerformCheck16( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
532 533 534
extern int             If_CutPerformCheck45( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
extern int             If_CutPerformCheck54( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
extern int             If_CutPerformCheck75( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
535
extern float           If_CutDelayLutStruct( If_Man_t * p, If_Cut_t * pCut, char * pStr, float WireDelay );
536 537 538 539
extern int             If_CluCheckExt( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutRoot, 
                           char * pLut0, char * pLut1, word * pFunc0, word * pFunc1 );
extern int             If_CluCheckExt3( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, 
                           char * pLut0, char * pLut1, char * pLut2, word * pFunc0, word * pFunc1, word * pFunc2 );
540
/*=== ifDelay.c =============================================================*/
541
extern int             If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut );
542
extern int             If_CutSopBalanceEvalInt( Vec_Int_t * vCover, int * pTimes, int * pFaninLits, Vec_Int_t * vAig, int * piRes, int nSuppAll, int * pArea );
543
extern int             If_CutSopBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
544
extern int             If_CutSopBalancePinDelaysInt( Vec_Int_t * vCover, int * pTimes, word * pFaninRes, int nSuppAll, word * pRes );
545
extern int             If_CutSopBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
546 547
extern int             If_CutLutBalanceEval( If_Man_t * p, If_Cut_t * pCut );
extern int             If_CutLutBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
548
/*=== ifDsd.c =============================================================*/
549
extern If_DsdMan_t *   If_DsdManAlloc( int nVars, int nLutSize );
550
extern void            If_DsdManAllocIsops( If_DsdMan_t * p, int nLutSize );
551
extern void            If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int Number, int Support, int fOccurs, int fTtDump, int fVerbose );
552
extern void            If_DsdManTune( If_DsdMan_t * p, int LutSize, int fFast, int fAdd, int fSpec, int fVerbose );
553
extern void            Id_DsdManTuneStr( If_DsdMan_t * p, char * pStruct, int nConfls, int nProcs, int fVerbose );
554
extern void            If_DsdManFree( If_DsdMan_t * p, int fVerbose );
555 556
extern void            If_DsdManSave( If_DsdMan_t * p, char * pFileName );
extern If_DsdMan_t *   If_DsdManLoad( char * pFileName );
557
extern void            If_DsdManMerge( If_DsdMan_t * p, If_DsdMan_t * pNew );
558 559
extern void            If_DsdManCleanOccur( If_DsdMan_t * p, int fVerbose );
extern void            If_DsdManCleanMarks( If_DsdMan_t * p, int fVerbose );
560
extern void            If_DsdManInvertMarks( If_DsdMan_t * p, int fVerbose );
Alan Mishchenko committed
561
extern If_DsdMan_t *   If_DsdManFilter( If_DsdMan_t * p, int Limit );
562
extern int             If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm, char * pLutStruct );
563 564
extern char *          If_DsdManFileName( If_DsdMan_t * p );
extern int             If_DsdManVarNum( If_DsdMan_t * p );
565
extern int             If_DsdManObjNum( If_DsdMan_t * p );
566
extern int             If_DsdManLutSize( If_DsdMan_t * p );
567 568
extern int             If_DsdManTtBitNum( If_DsdMan_t * p );
extern int             If_DsdManPermBitNum( If_DsdMan_t * p );
569
extern void            If_DsdManSetLutSize( If_DsdMan_t * p, int nLutSize );
570
extern int             If_DsdManSuppSize( If_DsdMan_t * p, int iDsd );
571
extern int             If_DsdManCheckDec( If_DsdMan_t * p, int iDsd );
572 573
extern int             If_DsdManReadMark( If_DsdMan_t * p, int iDsd );
extern void            If_DsdManSetNewAsUseless( If_DsdMan_t * p );
574
extern word *          If_DsdManGetFuncConfig( If_DsdMan_t * p, int iDsd );
575
extern char *          If_DsdManGetCellStr( If_DsdMan_t * p );
576
extern unsigned        If_DsdManCheckXY( If_DsdMan_t * p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose );
577
extern int             If_CutDsdBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
578
extern int             If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
579
extern void            Id_DsdManTuneThresh( If_DsdMan_t * p, int fUnate, int fThresh, int fThreshHeuristic, int fVerbose );
Alan Mishchenko committed
580
/*=== ifLib.c =============================================================*/
581 582 583 584 585 586 587 588 589
extern If_LibLut_t *   If_LibLutRead( char * FileName );
extern If_LibLut_t *   If_LibLutDup( If_LibLut_t * p );
extern void            If_LibLutFree( If_LibLut_t * pLutLib );
extern void            If_LibLutPrint( If_LibLut_t * pLutLib );
extern int             If_LibLutDelaysAreDiscrete( If_LibLut_t * pLutLib );
extern int             If_LibLutDelaysAreDifferent( If_LibLut_t * pLutLib );
extern If_LibLut_t *   If_LibLutSetSimple( int nLutSize );
extern float           If_LibLutFastestPinDelay( If_LibLut_t * p );
extern float           If_LibLutSlowestPinDelay( If_LibLut_t * p );
Alan Mishchenko committed
590 591 592 593
/*=== ifLibBox.c =============================================================*/
extern If_LibBox_t *   If_LibBoxStart();
extern void            If_LibBoxFree( If_LibBox_t * p );
extern If_Box_t *      If_LibBoxReadBox( If_LibBox_t * p, int Id );
594
extern If_Box_t *      If_LibBoxFindBox( If_LibBox_t * p, char * pName );
Alan Mishchenko committed
595 596
extern void            If_LibBoxAdd( If_LibBox_t * p, If_Box_t * pBox );
extern If_LibBox_t *   If_LibBoxRead( char * pFileName );
597
extern If_LibBox_t *   If_LibBoxRead2( char * pFileName );
Alan Mishchenko committed
598 599
extern void            If_LibBoxPrint( FILE * pFile, If_LibBox_t * p );
extern void            If_LibBoxWrite( char * pFileName, If_LibBox_t * p );
600
extern int             If_LibBoxLoad( char * pFileName );
Alan Mishchenko committed
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
/*=== ifMan.c =============================================================*/
extern If_Man_t *      If_ManStart( If_Par_t * pPars );
extern void            If_ManRestart( If_Man_t * p );
extern void            If_ManStop( If_Man_t * p );
extern If_Obj_t *      If_ManCreateCi( If_Man_t * p );
extern If_Obj_t *      If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver );
extern If_Obj_t *      If_ManCreateAnd( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1 );
extern If_Obj_t *      If_ManCreateXor( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1 );
extern If_Obj_t *      If_ManCreateMux( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1, If_Obj_t * pCtrl );
extern void            If_ManCreateChoice( If_Man_t * p, If_Obj_t * pRepr );
extern void            If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId );
extern void            If_ManSetupCiCutSets( If_Man_t * p );
extern If_Set_t *      If_ManSetupNodeCutSet( If_Man_t * p, If_Obj_t * pObj );
extern void            If_ManDerefNodeCutSet( If_Man_t * p, If_Obj_t * pObj );
extern void            If_ManDerefChoiceCutSet( If_Man_t * p, If_Obj_t * pObj );
extern void            If_ManSetupSetAll( If_Man_t * p, int nCrossCut );
/*=== ifMap.c =============================================================*/
618
extern void            If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess, int fFirst );
Alan Mishchenko committed
619
extern void            If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess );
620
extern int             If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char * pLabel );
Alan Mishchenko committed
621 622
/*=== ifReduce.c ==========================================================*/
extern void            If_ManImproveMapping( If_Man_t * p );
623 624
/*=== ifSat.c ==========================================================*/
extern void *          If_ManSatBuildXY( int nLutSize );
625 626
extern void *          If_ManSatBuildXYZ( int nLutSize );
extern void            If_ManSatUnbuild( void * p );
627
extern int             If_ManSatCheckXY( void * pSat, int nLutSize, word * pTruth, int nVars, unsigned uSet, word * pTBound, word * pTFree, Vec_Int_t * vLits );
628
extern unsigned        If_ManSatCheckXYall( void * pSat, int nLutSize, word * pTruth, int nVars, Vec_Int_t * vLits );
Alan Mishchenko committed
629 630 631
/*=== ifSeq.c =============================================================*/
extern int             If_ManPerformMappingSeq( If_Man_t * p );
/*=== ifTime.c ============================================================*/
632 633
extern float           If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut );
extern void            If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float Required );
634 635
extern float           If_ManDelayMax( If_Man_t * p, int fSeq );
extern void            If_ManComputeRequired( If_Man_t * p );
Alan Mishchenko committed
636
/*=== ifTruth.c ===========================================================*/
637
extern void            If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
638
extern int             If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
639
extern int             If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
640
/*=== ifTune.c ===========================================================*/
641
extern Ifn_Ntk_t *     Ifn_NtkParse( char * pStr );
642 643
extern int             Ifn_NtkTtBits( char * pStr );
extern int             Ifn_NtkMatch( Ifn_Ntk_t * p, word * pTruth, int nVars, int nConfls, int fVerbose, int fVeryVerbose, word * pConfig );
644 645 646 647 648
extern void            Ifn_NtkPrint( Ifn_Ntk_t * p );
extern int             Ifn_NtkLutSizeMax( Ifn_Ntk_t * p );
extern int             Ifn_NtkInputNum( Ifn_Ntk_t * p );
extern void *          If_ManSatBuildFromCell( char * pStr, Vec_Int_t ** pvPiVars, Vec_Int_t ** pvPoVars, Ifn_Ntk_t ** ppNtk );
extern int             If_ManSatFindCofigBits( void * pSat, Vec_Int_t * vPiVars, Vec_Int_t * vPoVars, word * pTruth, int nVars, word Perm, int nInps, Vec_Int_t * vValues );
649 650
extern int             If_ManSatDeriveGiaFromBits( void * pNew, Ifn_Ntk_t * p, word * pTtData, Vec_Int_t * vLeaves, Vec_Int_t * vValues );
extern void *          If_ManDeriveGiaFromCells( void * p );
Alan Mishchenko committed
651 652 653 654 655 656 657 658 659 660 661 662 663
/*=== ifUtil.c ============================================================*/
extern void            If_ManCleanNodeCopy( If_Man_t * p );
extern void            If_ManCleanCutData( If_Man_t * p );
extern void            If_ManCleanMarkV( If_Man_t * p );
extern float           If_ManScanMapping( If_Man_t * p );
extern float           If_ManScanMappingDirect( If_Man_t * p );
extern float           If_ManScanMappingSeq( If_Man_t * p );
extern void            If_ManResetOriginalRefs( If_Man_t * p );
extern int             If_ManCrossCut( If_Man_t * p );

extern Vec_Ptr_t *     If_ManReverseOrder( If_Man_t * p );
extern void            If_ManMarkMapping( If_Man_t * p );
extern Vec_Ptr_t *     If_ManCollectMappingDirect( If_Man_t * p );
Alan Mishchenko committed
664 665
extern Vec_Int_t *     If_ManCollectMappingInt( If_Man_t * p );

Alan Mishchenko committed
666
extern int             If_ManCountSpecialPos( If_Man_t * p );
667
extern void            If_CutTraverse( If_Man_t * p, If_Obj_t * pRoot, If_Cut_t * pCut, Vec_Ptr_t * vNodes );
668
extern void            If_ObjPrint( If_Obj_t * pObj );
Alan Mishchenko committed
669 670


671
ABC_NAMESPACE_HEADER_END
Alan Mishchenko committed
672 673 674 675 676 677 678

#endif

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////