1 /**CFile****************************************************************
2 
3   FileName    [if.h]
4 
5   SystemName  [ABC: Logic synthesis and verification system.]
6 
7   PackageName [FPGA mapping based on priority cuts.]
8 
9   Synopsis    [External declarations.]
10 
11   Author      [Alan Mishchenko]
12 
13   Affiliation [UC Berkeley]
14 
15   Date        [Ver. 1.0. Started - November 21, 2006.]
16 
17   Revision    [$Id: if.h,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__map__if__if_h
22 #define ABC__map__if__if_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 ///                          INCLUDES                                ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <assert.h>
33 
34 #include "misc/vec/vec.h"
35 #include "misc/mem/mem.h"
36 #include "misc/tim/tim.h"
37 #include "misc/util/utilNam.h"
38 #include "misc/vec/vecMem.h"
39 #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 ABC_NAMESPACE_HEADER_START
45 
46 
47 ////////////////////////////////////////////////////////////////////////
48 ///                         PARAMETERS                               ///
49 ////////////////////////////////////////////////////////////////////////
50 
51 // the maximum size of LUTs used for mapping (should be the same as FPGA_MAX_LUTSIZE defined in "fpga.h"!!!)
52 #define IF_MAX_LUTSIZE       32
53 // the largest possible number of LUT inputs when funtionality of the LUTs are computed
54 #define IF_MAX_FUNC_LUTSIZE  15
55 // a very large number
56 #define IF_INFINITY          100000000
57 // the largest possible user cut cost
58 #define IF_COST_MAX          4095 // ((1<<12)-1)
59 
60 #define IF_BIG_CHAR ((char)120)
61 
62 // object types
63 typedef enum {
64     IF_NONE,     // 0: non-existent object
65     IF_CONST1,   // 1: constant 1
66     IF_CI,       // 2: combinational input
67     IF_CO,       // 3: combinational output
68     IF_AND,      // 4: AND node
69     IF_VOID      // 5: unused object
70 } If_Type_t;
71 
72 ////////////////////////////////////////////////////////////////////////
73 ///                         BASIC TYPES                              ///
74 ////////////////////////////////////////////////////////////////////////
75 
76 typedef struct If_Man_t_     If_Man_t;
77 typedef struct If_Par_t_     If_Par_t;
78 typedef struct If_Obj_t_     If_Obj_t;
79 typedef struct If_Cut_t_     If_Cut_t;
80 typedef struct If_Set_t_     If_Set_t;
81 typedef struct If_LibLut_t_  If_LibLut_t;
82 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;
85 
86 typedef struct Ifif_Par_t_   Ifif_Par_t;
87 struct Ifif_Par_t_
88 {
89     int                nLutSize;      // the LUT size
90     If_LibLut_t *      pLutLib;       // the LUT library
91     float              pLutDelays[IF_MAX_LUTSIZE];  // pin-to-pin delays of the max LUT
92     float              DelayWire;     // wire delay
93     int                nDegree;       // structure degree
94     int                fCascade;      // cascade
95     int                fVerbose;      // verbose
96     int                fVeryVerbose;  // verbose
97 };
98 
99 // parameters
100 struct If_Par_t_
101 {
102     // user-controlable parameters
103     int                nLutSize;      // the LUT size
104     int                nCutsMax;      // the max number of cuts
105     int                nFlowIters;    // the number of iterations of area recovery
106     int                nAreaIters;    // the number of iterations of area recovery
107     int                nGateSize;     // the max size of the AND/OR gate to map into
108     int                nNonDecLimit;  // the max size of non-dec nodes
109     float              DelayTarget;   // delay target
110     float              Epsilon;       // value used in comparison floating point numbers
111     int                nRelaxRatio;   // delay relaxation ratio
112     int                nStructType;   // type of the structure
113     int                nAndDelay;     // delay of AND-gate in LUT library units
114     int                nAndArea;      // area of AND-gate in LUT library units
115     int                fPreprocess;   // preprossing
116     int                fArea;         // area-oriented mapping
117     int                fFancy;        // a fancy feature
118     int                fExpRed;       // expand/reduce of the best cuts
119     int                fLatchPaths;   // reset timing on latch paths
120     int                fLut6Filter;   // uses filtering of 6-LUT functions
121     int                fEdge;         // uses edge-based cut selection heuristics
122     int                fPower;        // uses power-aware cut selection heuristics
123     int                fCutMin;       // performs cut minimization by removing functionally reducdant variables
124     int                fDelayOpt;     // special delay optimization
125     int                fDelayOptLut;  // delay optimization for LUTs
126     int                fDsdBalance;   // special delay optimization
127     int                fUserRecLib;   // use recorded library
128     int                fUserSesLib;   // use SAT-based synthesis
129     int                fBidec;        // use bi-decomposition
130     int                fUse34Spec;    // use specialized matching
131     int                fUseBat;       // use one specialized feature
132     int                fUseBuffs;     // use buffers to decouple outputs
133     int                fEnableCheck07;// enable additional checking
134     int                fEnableCheck08;// enable additional checking
135     int                fEnableCheck10;// enable additional checking
136     int                fEnableCheck75;// enable additional checking
137     int                fEnableCheck75u;// enable additional checking
138     int                fUseDsd;       // compute DSD of the cut functions
139     int                fUseDsdTune;   // use matching based on precomputed manager
140     int                fUseCofVars;   // use cofactoring variables
141     int                fUseAndVars;   // use bi-decomposition
142     int                fUseTtPerm;    // compute truth tables of the cut functions
143     int                fDeriveLuts;   // enables deriving LUT structures
144     int                fDoAverage;    // optimize average rather than maximum level
145     int                fHashMapping;  // perform AIG hashing after mapping
146     int                fVerbose;      // the verbosity flag
147     int                fVerboseTrace; // the verbosity flag
148     char *             pLutStruct;    // LUT structure
149     float              WireDelay;     // wire delay
150     // internal parameters
151     int                fSkipCutFilter;// skip cut filter
152     int                fAreaOnly;     // area only mode
153     int                fTruth;        // truth table computation enabled
154     int                fUsePerm;      // use permutation (delay info)
155     int                fUseBdds;      // use local BDDs as a cost function
156     int                fUseSops;      // use local SOPs as a cost function
157     int                fUseCnfs;      // use local CNFs as a cost function
158     int                fUseMv;        // use local MV-SOPs as a cost function
159     int                nLatchesCi;    // the number of latches among the CIs
160     int                nLatchesCo;    // the number of latches among the COs
161     int                nLatchesCiBox; // the number of white box outputs among the CIs
162     int                nLatchesCoBox; // the number of white box inputs among the COs
163     int                fLiftLeaves;   // shift the leaves for seq mapping
164     int                fUseCoAttrs;   // use CO attributes
165     float              DelayTargetNew;// new delay target
166     float              FinalDelay;    // final delay after mapping
167     float              FinalArea;     // final area after mapping
168     If_LibLut_t *      pLutLib;       // the LUT library
169     float *            pTimesArr;     // arrival times
170     float *            pTimesReq;     // required times
171     int (* pFuncCost)  (If_Man_t *, If_Cut_t *);  // procedure to compute the user's cost of a cut
172     int (* pFuncUser)  (If_Man_t *, If_Obj_t *, If_Cut_t *);            //  procedure called for each cut when cut computation is finished
173     int (* pFuncCell)  (If_Man_t *, unsigned *, int, int, char *);      //  procedure called for cut functions
174     int (* pFuncCell2) (If_Man_t *, word *, int, Vec_Str_t *, char **); //  procedure called for cut functions
175     int (* pFuncWrite) (If_Man_t *);                                    //  procedure called for cut functions
176     void *             pReoMan;       // reordering manager
177 };
178 
179 // the LUT library
180 struct If_LibLut_t_
181 {
182     char *             pName;         // the name of the LUT library
183     int                LutMax;        // the maximum LUT size
184     int                fVarPinDelays; // set to 1 if variable pin delays are specified
185     float              pLutAreas[IF_MAX_LUTSIZE+1]; // the areas of LUTs
186     float              pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1];// the delays of LUTs
187 };
188 
189 // manager
190 struct If_Man_t_
191 {
192     char *             pName;
193     // mapping parameters
194     If_Par_t *         pPars;
195     // mapping nodes
196     If_Obj_t *         pConst1;       // the constant 1 node
197     Vec_Ptr_t *        vCis;          // the primary inputs
198     Vec_Ptr_t *        vCos;          // the primary outputs
199     Vec_Ptr_t *        vObjs;         // all objects
200     Vec_Ptr_t *        vObjsRev;      // reverse topological order of objects
201     Vec_Ptr_t *        vTemp;         // temporary array
202     int                nObjs[IF_VOID];// the number of objects by type
203     // various data
204     int                nLevelMax;     // the max number of AIG levels
205     float              fEpsilon;      // epsilon used for comparison
206     float              RequiredGlo;   // global required times
207     float              RequiredGlo2;  // global required times
208     float              AreaGlo;       // global area
209     int                nNets;         // the sum total of fanins of all LUTs in the mapping
210     float              dPower;        // the sum total of switching activities of all LUTs in the mapping
211     int                nCutsUsed;     // the number of cuts currently used
212     int                nCutsMerged;   // the total number of cuts merged
213     unsigned *         puTemp[4];     // used for the truth table computation
214     word *             puTempW;       // used for the truth table computation
215     int                SortMode;      // one of the three sorting modes
216     int                fNextRound;    // set to 1 after the first round
217     int                nChoices;      // the number of choice nodes
218     Vec_Int_t *        vSwitching;    // switching activity of each node
219     int                pPerm[3][IF_MAX_LUTSIZE]; // permutations
220     unsigned           uSharedMask;   // mask of shared variables
221     int                nShared;       // the number of shared variables
222     int                fReqTimeWarn;  // warning about exceeding required times was printed
223     // SOP balancing
224     Vec_Int_t *        vCover;        // used to compute ISOP
225     Vec_Int_t *        vArray;        // intermediate storage
226     Vec_Wrd_t *        vAnds;         // intermediate storage
227     Vec_Wrd_t *        vOrGate;       // intermediate storage
228     Vec_Wrd_t *        vAndGate;      // intermediate storage
229     // sequential mapping
230     Vec_Ptr_t *        vLatchOrder;   // topological ordering of latches
231     Vec_Int_t *        vLags;         // sequentail lags of all nodes
232     int                nAttempts;     // the number of attempts in binary search
233     int                nMaxIters;     // the maximum number of iterations
234     int                Period;        // the current value of the clock period (for seq mapping)
235     // memory management
236     int                nTruth6Words[IF_MAX_FUNC_LUTSIZE+1];  // the size of the truth table if allocated
237     int                nPermWords;    // the size of the permutation array (in words)
238     int                nObjBytes;     // the size of the object
239     int                nCutBytes;     // the size of the cut
240     int                nSetBytes;     // the size of the cut set
241     Mem_Fixed_t *      pMemObj;       // memory manager for objects (entrysize = nEntrySize)
242     Mem_Fixed_t *      pMemSet;       // memory manager for sets of cuts (entrysize = nCutSize*(nCutsMax+1))
243     If_Set_t *         pMemCi;        // memory for CI cutsets
244     If_Set_t *         pMemAnd;       // memory for AND cutsets
245     If_Set_t *         pFreeList;     // the list of free cutsets
246     int                nSmallSupp;    // the small support
247     int                nCutsTotal;
248     int                nCutsUseless[32];
249     int                nCutsCount[32];
250     int                nCutsCountAll;
251     int                nCutsUselessAll;
252     int                nCuts5, nCuts5a;
253     If_DsdMan_t *      pIfDsdMan;     // DSD manager
254     Vec_Mem_t *        vTtMem[IF_MAX_FUNC_LUTSIZE+1];   // truth table memory and hash table
255     Vec_Wec_t *        vTtIsops[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into DSD
256     Vec_Int_t *        vTtDsds[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into DSD
257     Vec_Str_t *        vTtPerms[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into permutations
258     Vec_Str_t *        vTtVars[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into selected vars
259     Vec_Int_t *        vTtDecs[IF_MAX_FUNC_LUTSIZE+1];  // mapping of truth table into decomposition pattern
260     Vec_Int_t *        vTtOccurs[IF_MAX_FUNC_LUTSIZE+1];// truth table occurange counters
261     Hash_IntMan_t *    vPairHash;     // hashing pairs of truth tables
262     Vec_Int_t *        vPairRes;      // resulting truth table
263     Vec_Str_t *        vPairPerms;    // resulting permutation
264     Vec_Mem_t *        vTtMem6;
265     char               pCanonPerm[IF_MAX_LUTSIZE];
266     unsigned           uCanonPhase;
267     int                nCacheHits;
268     int                nCacheMisses;
269     abctime            timeCache[6];
270     int                nBestCutSmall[2];
271     int                nCountNonDec[2];
272     Vec_Int_t *        vCutData;      // cut data storage
273     int                pArrTimeProfile[IF_MAX_FUNC_LUTSIZE];
274     Vec_Ptr_t *        vVisited;
275     void *             pUserMan;
276     Vec_Int_t *        vDump;
277     int                pDumpIns[16];
278 
279     // timing manager
280     Tim_Man_t *        pManTim;
281     Vec_Int_t *        vCoAttrs;      // CO attributes   0=optimize; 1=keep; 2=relax
282     // hash table for functions
283     int                nTableSize[2];    // hash table size
284     int                nTableEntries[2]; // hash table entries
285     void **            pHashTable[2];    // hash table bins
286     Mem_Fixed_t *      pMemEntries;      // memory manager for hash table entries
287     // statistics
288 //    abctime                timeTruth;
289 };
290 
291 // priority cut
292 struct If_Cut_t_
293 {
294     float              Area;          // area (or area-flow) of the cut
295     float              Edge;          // the edge flow
296     float              Power;         // the power flow
297     float              Delay;         // delay of the cut
298     int                iCutFunc;      // TT ID of the cut
299     int                uMaskFunc;     // polarity bitmask
300     unsigned           uSign;         // cut signature
301     unsigned           Cost    : 12;  // the user's cost of the cut (related to IF_COST_MAX)
302     unsigned           fCompl  :  1;  // the complemented attribute
303     unsigned           fUser   :  1;  // using the user's area and delay
304     unsigned           fUseless:  1;  // cannot be used in the mapping
305     unsigned           fAndCut :  1;  // matched with AND gate
306     unsigned           nLimit  :  8;  // the maximum number of leaves
307     unsigned           nLeaves :  8;  // the number of leaves
308     int                pLeaves[0];
309 };
310 
311 // set of priority cut
312 struct If_Set_t_
313 {
314     short              nCutsMax;      // the max number of cuts
315     short              nCuts;         // the current number of cuts
316     If_Set_t *         pNext;         // next cutset in the free list
317     If_Cut_t **        ppCuts;        // the array of pointers to the cuts
318 };
319 
320 // node extension
321 struct If_Obj_t_
322 {
323     unsigned           Type    :  4;  // object
324     unsigned           fCompl0 :  1;  // complemented attribute
325     unsigned           fCompl1 :  1;  // complemented attribute
326     unsigned           fPhase  :  1;  // phase of the node
327     unsigned           fRepr   :  1;  // representative of the equivalence class
328     unsigned           fMark   :  1;  // multipurpose mark
329     unsigned           fVisit  :  1;  // multipurpose mark
330     unsigned           fSpec   :  1;  // multipurpose mark
331     unsigned           fDriver :  1;  // multipurpose mark
332     unsigned           fSkipCut:  1;  // multipurpose mark
333     unsigned           Level   : 19;  // logic level of the node
334     int                Id;            // integer ID
335     int                IdPio;         // integer ID of PIs/POs
336     int                nRefs;         // the number of references
337     int                nVisits;       // the number of visits to this node
338     int                nVisitsCopy;   // the number of visits to this node
339     If_Obj_t *         pFanin0;       // the first fanin
340     If_Obj_t *         pFanin1;       // the second fanin
341     If_Obj_t *         pEquiv;        // the choice node
342     float              EstRefs;       // estimated reference counter
343     float              Required;      // required time of the onde
344     float              LValue;        // sequential arrival time of the node
345     union{
346     void *             pCopy;         // used for object duplication
347     int                iCopy;
348     };
349 
350     If_Set_t *         pCutSet;       // the pointer to the cutset
351     If_Cut_t           CutBest;       // the best cut selected
352 };
353 
354 typedef struct If_Box_t_ If_Box_t;
355 struct If_Box_t_
356 {
357     char *             pName;
358     char               fSeq;
359     char               fBlack;
360     char               fOuter;
361     char               fUnused;
362     int                Id;
363     int                nPis;
364     int                nPos;
365     int *              pDelays;
366 };
367 
368 struct If_LibBox_t_
369 {
370     int                nBoxes;
371     Vec_Ptr_t *        vBoxes;
372 };
373 
If_Regular(If_Obj_t * p)374 static inline If_Obj_t * If_Regular( If_Obj_t * p )                          { return (If_Obj_t *)((ABC_PTRUINT_T)(p) & ~01);  }
If_Not(If_Obj_t * p)375 static inline If_Obj_t * If_Not( If_Obj_t * p )                              { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^  01);  }
If_NotCond(If_Obj_t * p,int c)376 static inline If_Obj_t * If_NotCond( If_Obj_t * p, int c )                   { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c));  }
If_IsComplement(If_Obj_t * p)377 static inline int        If_IsComplement( If_Obj_t * p )                     { return (int )(((ABC_PTRUINT_T)p) & 01);         }
378 
If_ManCiNum(If_Man_t * p)379 static inline int        If_ManCiNum( If_Man_t * p )                         { return p->nObjs[IF_CI];               }
If_ManCoNum(If_Man_t * p)380 static inline int        If_ManCoNum( If_Man_t * p )                         { return p->nObjs[IF_CO];               }
If_ManAndNum(If_Man_t * p)381 static inline int        If_ManAndNum( If_Man_t * p )                        { return p->nObjs[IF_AND];              }
If_ManObjNum(If_Man_t * p)382 static inline int        If_ManObjNum( If_Man_t * p )                        { return Vec_PtrSize(p->vObjs);         }
383 
If_ManConst1(If_Man_t * p)384 static inline If_Obj_t * If_ManConst1( If_Man_t * p )                        { return p->pConst1;                              }
If_ManCi(If_Man_t * p,int i)385 static inline If_Obj_t * If_ManCi( If_Man_t * p, int i )                     { return (If_Obj_t *)Vec_PtrEntry( p->vCis, i );  }
If_ManCo(If_Man_t * p,int i)386 static inline If_Obj_t * If_ManCo( If_Man_t * p, int i )                     { return (If_Obj_t *)Vec_PtrEntry( p->vCos, i );  }
If_ManLi(If_Man_t * p,int i)387 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 );  }
If_ManLo(If_Man_t * p,int i)388 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 );  }
If_ManObj(If_Man_t * p,int i)389 static inline If_Obj_t * If_ManObj( If_Man_t * p, int i )                    { return (If_Obj_t *)Vec_PtrEntry( p->vObjs, i ); }
390 
If_ObjIsConst1(If_Obj_t * pObj)391 static inline int        If_ObjIsConst1( If_Obj_t * pObj )                   { return pObj->Type == IF_CONST1;       }
If_ObjIsCi(If_Obj_t * pObj)392 static inline int        If_ObjIsCi( If_Obj_t * pObj )                       { return pObj->Type == IF_CI;           }
If_ObjIsCo(If_Obj_t * pObj)393 static inline int        If_ObjIsCo( If_Obj_t * pObj )                       { return pObj->Type == IF_CO;           }
If_ObjIsTerm(If_Obj_t * pObj)394 static inline int        If_ObjIsTerm( If_Obj_t * pObj )                     { return pObj->Type == IF_CI || pObj->Type == IF_CO; }
If_ObjIsLatch(If_Obj_t * pObj)395 static inline int        If_ObjIsLatch( If_Obj_t * pObj )                    { return If_ObjIsCi(pObj) && pObj->pFanin0 != NULL;  }
If_ObjIsAnd(If_Obj_t * pObj)396 static inline int        If_ObjIsAnd( If_Obj_t * pObj )                      { return pObj->Type == IF_AND;          }
397 
If_ObjId(If_Obj_t * pObj)398 static inline int        If_ObjId( If_Obj_t * pObj )                         { return pObj->Id;                      }
If_ObjFanin0(If_Obj_t * pObj)399 static inline If_Obj_t * If_ObjFanin0( If_Obj_t * pObj )                     { return pObj->pFanin0;                 }
If_ObjFanin1(If_Obj_t * pObj)400 static inline If_Obj_t * If_ObjFanin1( If_Obj_t * pObj )                     { return pObj->pFanin1;                 }
If_ObjFaninC0(If_Obj_t * pObj)401 static inline int        If_ObjFaninC0( If_Obj_t * pObj )                    { return pObj->fCompl0;                 }
If_ObjFaninC1(If_Obj_t * pObj)402 static inline int        If_ObjFaninC1( If_Obj_t * pObj )                    { return pObj->fCompl1;                 }
If_ObjCopy(If_Obj_t * pObj)403 static inline void *     If_ObjCopy( If_Obj_t * pObj )                       { return pObj->pCopy;                   }
If_ObjLevel(If_Obj_t * pObj)404 static inline int        If_ObjLevel( If_Obj_t * pObj )                      { return pObj->Level;                   }
If_ObjSetLevel(If_Obj_t * pObj,int Level)405 static inline void       If_ObjSetLevel( If_Obj_t * pObj, int Level )        { pObj->Level = Level;                  }
If_ObjSetCopy(If_Obj_t * pObj,void * pCopy)406 static inline void       If_ObjSetCopy( If_Obj_t * pObj, void * pCopy )      { pObj->pCopy = pCopy;                  }
If_ObjSetChoice(If_Obj_t * pObj,If_Obj_t * pEqu)407 static inline void       If_ObjSetChoice( If_Obj_t * pObj, If_Obj_t * pEqu ) { pObj->pEquiv = pEqu;                  }
408 
If_CutLeaveNum(If_Cut_t * pCut)409 static inline int        If_CutLeaveNum( If_Cut_t * pCut )                   { return pCut->nLeaves;                             }
If_CutLeaves(If_Cut_t * pCut)410 static inline int *      If_CutLeaves( If_Cut_t * pCut )                     { return pCut->pLeaves;                             }
If_CutLeaf(If_Man_t * p,If_Cut_t * pCut,int i)411 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]);                         }
If_CutSuppMask(If_Cut_t * pCut)412 static inline unsigned   If_CutSuppMask( If_Cut_t * pCut )                   { return (~(unsigned)0) >> (32-pCut->nLeaves);      }
If_CutTruthWords(int nVarsMax)413 static inline int        If_CutTruthWords( int nVarsMax )                    { return nVarsMax <= 5 ? 2 : (1 << (nVarsMax - 5)); }
If_CutPermWords(int nVarsMax)414 static inline int        If_CutPermWords( int nVarsMax )                     { return nVarsMax / sizeof(int) + ((nVarsMax % sizeof(int)) > 0); }
If_CutLeafBit(If_Cut_t * pCut,int i)415 static inline int        If_CutLeafBit( If_Cut_t * pCut, int i )             { return (pCut->uMaskFunc >> i) & 1;                }
If_CutPerm(If_Cut_t * pCut)416 static inline char *     If_CutPerm( If_Cut_t * pCut )                       { return (char *)(pCut->pLeaves + pCut->nLeaves);   }
If_CutCopy(If_Man_t * p,If_Cut_t * pDst,If_Cut_t * pSrc)417 static inline void       If_CutCopy( If_Man_t * p, If_Cut_t * pDst, If_Cut_t * pSrc ) { memcpy( pDst, pSrc, (size_t)p->nCutBytes );      }
If_CutSetup(If_Man_t * p,If_Cut_t * pCut)418 static inline void       If_CutSetup( If_Man_t * p, If_Cut_t * pCut        ) { memset(pCut, 0, (size_t)p->nCutBytes); pCut->nLimit = p->pPars->nLutSize; }
419 
If_ObjCutBest(If_Obj_t * pObj)420 static inline If_Cut_t * If_ObjCutBest( If_Obj_t * pObj )                    { return &pObj->CutBest;                }
If_ObjCutSign(unsigned ObjId)421 static inline unsigned   If_ObjCutSign( unsigned ObjId )                     { return (1 << (ObjId % 31));           }
If_ObjCutSignCompute(If_Cut_t * p)422 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; }
423 
If_ObjArrTime(If_Obj_t * pObj)424 static inline float      If_ObjArrTime( If_Obj_t * pObj )                    { return If_ObjCutBest(pObj)->Delay;    }
If_ObjSetArrTime(If_Obj_t * pObj,float ArrTime)425 static inline void       If_ObjSetArrTime( If_Obj_t * pObj, float ArrTime )  { If_ObjCutBest(pObj)->Delay = ArrTime; }
426 
If_ObjLValue(If_Obj_t * pObj)427 static inline float      If_ObjLValue( If_Obj_t * pObj )                     { return pObj->LValue;                  }
If_ObjSetLValue(If_Obj_t * pObj,float LValue)428 static inline void       If_ObjSetLValue( If_Obj_t * pObj, float LValue )    { pObj->LValue = LValue;                }
429 
If_CutData(If_Cut_t * pCut)430 static inline void *     If_CutData( If_Cut_t * pCut )                       { return *(void **)pCut;                }
If_CutSetData(If_Cut_t * pCut,void * pData)431 static inline void       If_CutSetData( If_Cut_t * pCut, void * pData )      { *(void **)pCut = pData;               }
432 
If_CutDataInt(If_Cut_t * pCut)433 static inline int        If_CutDataInt( If_Cut_t * pCut )                    { return *(int *)pCut;                  }
If_CutSetDataInt(If_Cut_t * pCut,int Data)434 static inline void       If_CutSetDataInt( If_Cut_t * pCut, int Data )       { *(int *)pCut = Data;                  }
435 
If_CutTruthLit(If_Cut_t * pCut)436 static inline int        If_CutTruthLit( If_Cut_t * pCut )                   { assert( pCut->iCutFunc >= 0 ); return pCut->iCutFunc;             }
If_CutTruthIsCompl(If_Cut_t * pCut)437 static inline int        If_CutTruthIsCompl( If_Cut_t * pCut )               { assert( pCut->iCutFunc >= 0 ); return Abc_LitIsCompl(pCut->iCutFunc);                               }
If_CutTruthWR(If_Man_t * p,If_Cut_t * pCut)438 static inline word *     If_CutTruthWR( If_Man_t * p, If_Cut_t * pCut )      { return p->vTtMem[pCut->nLeaves] ? Vec_MemReadEntry(p->vTtMem[pCut->nLeaves], Abc_Lit2Var(pCut->iCutFunc)) : NULL;  }
If_CutTruthUR(If_Man_t * p,If_Cut_t * pCut)439 static inline unsigned * If_CutTruthUR( If_Man_t * p, If_Cut_t * pCut)       { return (unsigned *)If_CutTruthWR(p, pCut);                        }
If_CutTruthW(If_Man_t * p,If_Cut_t * pCut)440 static inline word *     If_CutTruthW( If_Man_t * p, If_Cut_t * pCut )       { assert( pCut->iCutFunc >= 0 ); Abc_TtCopy( p->puTempW, If_CutTruthWR(p, pCut), p->nTruth6Words[pCut->nLeaves], If_CutTruthIsCompl(pCut) ); return p->puTempW;  }
If_CutTruth(If_Man_t * p,If_Cut_t * pCut)441 static inline unsigned * If_CutTruth( If_Man_t * p, If_Cut_t * pCut )        { return (unsigned *)If_CutTruthW(p, pCut);                         }
442 
If_CutDsdLit(If_Man_t * p,If_Cut_t * pCut)443 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) );               }
If_CutDsdIsCompl(If_Man_t * p,If_Cut_t * pCut)444 static inline int        If_CutDsdIsCompl( If_Man_t * p, If_Cut_t * pCut )   { return Abc_LitIsCompl( If_CutDsdLit(p, pCut) );                                                     }
If_CutDsdPerm(If_Man_t * p,If_Cut_t * pCut)445 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) );           }
446 
If_CutLutArea(If_Man_t * p,If_Cut_t * pCut)447 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));  }
If_CutLutDelay(If_LibLut_t * p,int Size,int iPin)448 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;                              }
449 
450 
451 ////////////////////////////////////////////////////////////////////////
452 ///                      MACRO DEFINITIONS                           ///
453 ////////////////////////////////////////////////////////////////////////
454 
455 #define IF_MIN(a,b)      (((a) < (b))? (a) : (b))
456 #define IF_MAX(a,b)      (((a) > (b))? (a) : (b))
457 
458 // the small and large numbers (min/max float are 1.17e-38/3.40e+38)
459 #define IF_FLOAT_LARGE   ((float)1.0e+20)
460 #define IF_FLOAT_SMALL   ((float)1.0e-20)
461 #define IF_INT_LARGE     (10000000)
462 
463 // iterator over the primary inputs
464 #define If_ManForEachCi( p, pObj, i )                                          \
465     Vec_PtrForEachEntry( If_Obj_t *, p->vCis, pObj, i )
466 // iterator over the primary outputs
467 #define If_ManForEachCo( p, pObj, i )                                          \
468     Vec_PtrForEachEntry( If_Obj_t *, p->vCos, pObj, i )
469 // iterator over the primary inputs
470 #define If_ManForEachPi( p, pObj, i )                                          \
471     Vec_PtrForEachEntryStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox )
472 // iterator over the primary outputs
473 #define If_ManForEachPo( p, pObj, i )                                          \
474     Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCos, pObj, i, p->pPars->nLatchesCoBox, If_ManCoNum(p) - p->pPars->nLatchesCo )
475 // iterator over the latches
476 #define If_ManForEachLatchInput( p, pObj, i )                                  \
477     Vec_PtrForEachEntryStart( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatchesCo )
478 #define If_ManForEachLatchOutput( p, pObj, i )                                 \
479     Vec_PtrForEachEntryStartStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatchesCi - p->pPars->nLatchesCiBox, If_ManCiNum(p) - p->pPars->nLatchesCiBox )
480 // iterator over all objects in topological order
481 #define If_ManForEachObj( p, pObj, i )                                         \
482     Vec_PtrForEachEntry( If_Obj_t *, p->vObjs, pObj, i )
483 // iterator over all objects in reverse topological order
484 #define If_ManForEachObjReverse( p, pObj, i )                                  \
485     Vec_PtrForEachEntry( If_Obj_t *, p->vObjsRev, pObj, i )
486 // iterator over logic nodes
487 #define If_ManForEachNode( p, pObj, i )                                        \
488     If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else
489 // iterator over cuts of the node
490 #define If_ObjForEachCut( pObj, pCut, i )                                      \
491     for ( i = 0; (i < (pObj)->pCutSet->nCuts) && ((pCut) = (pObj)->pCutSet->ppCuts[i]); i++ )
492 // iterator over the leaves of the cut
493 #define If_CutForEachLeaf( p, pCut, pLeaf, i )                                 \
494     for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i++ )
495 #define If_CutForEachLeafReverse( p, pCut, pLeaf, i )                                 \
496     for ( i = (int)(pCut)->nLeaves - 1; (i >= 0) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i])); i-- )
497 //#define If_CutForEachLeaf( p, pCut, pLeaf, i )                                 \ \\prevent multiline comment
498 //    for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, p->pPars->fLiftLeaves? (pCut)->pLeaves[i] >> 8 : (pCut)->pLeaves[i])); i++ )
499 // iterator over the leaves of the sequential cut
500 #define If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i )                       \
501     for ( i = 0; (i < (int)(pCut)->nLeaves) && ((pLeaf) = If_ManObj(p, (pCut)->pLeaves[i] >> 8)) && (((Shift) = ((pCut)->pLeaves[i] & 255)) >= 0); i++ )
502 
503 ////////////////////////////////////////////////////////////////////////
504 ///                    FUNCTION DECLARATIONS                         ///
505 ////////////////////////////////////////////////////////////////////////
506 
507 /*=== ifCore.c ===========================================================*/
508 extern void            If_ManSetDefaultPars( If_Par_t * pPars );
509 extern int             If_ManPerformMapping( If_Man_t * p );
510 extern int             If_ManPerformMappingComb( If_Man_t * p );
511 extern void            If_ManComputeSwitching( If_Man_t * p );
512 /*=== ifCut.c ============================================================*/
513 extern int             If_CutVerifyCuts( If_Set_t * pCutSet, int fOrdered );
514 extern int             If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut, int fSaveCut0 );
515 extern void            If_CutSort( If_Man_t * p, If_Set_t * pCutSet, If_Cut_t * pCut );
516 extern void            If_CutOrder( If_Cut_t * pCut );
517 extern int             If_CutMergeOrdered( If_Man_t * p, If_Cut_t * pCut0, If_Cut_t * pCut1, If_Cut_t * pCut );
518 extern int             If_CutMerge( If_Man_t * p, If_Cut_t * pCut0, If_Cut_t * pCut1, If_Cut_t * pCut );
519 extern int             If_CutCheck( If_Cut_t * pCut );
520 extern void            If_CutPrint( If_Cut_t * pCut );
521 extern void            If_CutPrintTiming( If_Man_t * p, If_Cut_t * pCut );
522 extern void            If_CutLift( If_Cut_t * pCut );
523 extern void            If_CutCopy( If_Man_t * p, If_Cut_t * pCutDest, If_Cut_t * pCutSrc );
524 extern float           If_CutAreaFlow( If_Man_t * p, If_Cut_t * pCut );
525 extern float           If_CutEdgeFlow( If_Man_t * p, If_Cut_t * pCut );
526 extern float           If_CutPowerFlow( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
527 extern float           If_CutAverageRefs( If_Man_t * p, If_Cut_t * pCut );
528 extern float           If_CutAreaDeref( If_Man_t * p, If_Cut_t * pCut );
529 extern float           If_CutAreaRef( If_Man_t * p, If_Cut_t * pCut );
530 extern float           If_CutAreaDerefed( If_Man_t * p, If_Cut_t * pCut );
531 extern float           If_CutAreaRefed( If_Man_t * p, If_Cut_t * pCut );
532 extern float           If_CutEdgeDeref( If_Man_t * p, If_Cut_t * pCut );
533 extern float           If_CutEdgeRef( If_Man_t * p, If_Cut_t * pCut );
534 extern float           If_CutEdgeDerefed( If_Man_t * p, If_Cut_t * pCut );
535 extern float           If_CutEdgeRefed( If_Man_t * p, If_Cut_t * pCut );
536 extern float           If_CutPowerDeref( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
537 extern float           If_CutPowerRef( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
538 extern float           If_CutPowerDerefed( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
539 extern float           If_CutPowerRefed( If_Man_t * p, If_Cut_t * pCut, If_Obj_t * pRoot );
540 /*=== ifDec.c =============================================================*/
541 extern word            If_CutPerformDerive07( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
542 extern int             If_CutPerformCheck07( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
543 extern int             If_CutPerformCheck08( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
544 extern int             If_CutPerformCheck10( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
545 extern int             If_CutPerformCheck16( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
546 extern int             If_CutPerformCheck45( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
547 extern int             If_CutPerformCheck54( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
548 extern int             If_CutPerformCheck75( If_Man_t * p, unsigned * pTruth, int nVars, int nLeaves, char * pStr );
549 extern float           If_CutDelayLutStruct( If_Man_t * p, If_Cut_t * pCut, char * pStr, float WireDelay );
550 extern int             If_CluCheckExt( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutRoot,
551                            char * pLut0, char * pLut1, word * pFunc0, word * pFunc1 );
552 extern int             If_CluCheckExt3( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot,
553                            char * pLut0, char * pLut1, char * pLut2, word * pFunc0, word * pFunc1, word * pFunc2 );
554 /*=== ifDelay.c =============================================================*/
555 extern int             If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut );
556 extern int             If_CutSopBalanceEvalInt( Vec_Int_t * vCover, int * pTimes, int * pFaninLits, Vec_Int_t * vAig, int * piRes, int nSuppAll, int * pArea );
557 extern int             If_CutSopBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
558 extern int             If_CutSopBalancePinDelaysInt( Vec_Int_t * vCover, int * pTimes, word * pFaninRes, int nSuppAll, word * pRes );
559 extern int             If_CutSopBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
560 extern int             If_CutLutBalanceEval( If_Man_t * p, If_Cut_t * pCut );
561 extern int             If_CutLutBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
562 /*=== ifDsd.c =============================================================*/
563 extern If_DsdMan_t *   If_DsdManAlloc( int nVars, int nLutSize );
564 extern void            If_DsdManAllocIsops( If_DsdMan_t * p, int nLutSize );
565 extern void            If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int Number, int Support, int fOccurs, int fTtDump, int fVerbose );
566 extern void            If_DsdManTune( If_DsdMan_t * p, int LutSize, int fFast, int fAdd, int fSpec, int fVerbose );
567 extern void            Id_DsdManTuneStr( If_DsdMan_t * p, char * pStruct, int nConfls, int nProcs, int fVerbose );
568 extern void            If_DsdManFree( If_DsdMan_t * p, int fVerbose );
569 extern void            If_DsdManSave( If_DsdMan_t * p, char * pFileName );
570 extern If_DsdMan_t *   If_DsdManLoad( char * pFileName );
571 extern void            If_DsdManMerge( If_DsdMan_t * p, If_DsdMan_t * pNew );
572 extern void            If_DsdManCleanOccur( If_DsdMan_t * p, int fVerbose );
573 extern void            If_DsdManCleanMarks( If_DsdMan_t * p, int fVerbose );
574 extern void            If_DsdManInvertMarks( If_DsdMan_t * p, int fVerbose );
575 extern If_DsdMan_t *   If_DsdManFilter( If_DsdMan_t * p, int Limit );
576 extern int             If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm, char * pLutStruct );
577 extern char *          If_DsdManFileName( If_DsdMan_t * p );
578 extern int             If_DsdManVarNum( If_DsdMan_t * p );
579 extern int             If_DsdManObjNum( If_DsdMan_t * p );
580 extern int             If_DsdManLutSize( If_DsdMan_t * p );
581 extern int             If_DsdManTtBitNum( If_DsdMan_t * p );
582 extern int             If_DsdManPermBitNum( If_DsdMan_t * p );
583 extern void            If_DsdManSetLutSize( If_DsdMan_t * p, int nLutSize );
584 extern int             If_DsdManSuppSize( If_DsdMan_t * p, int iDsd );
585 extern int             If_DsdManCheckDec( If_DsdMan_t * p, int iDsd );
586 extern int             If_DsdManReadMark( If_DsdMan_t * p, int iDsd );
587 extern void            If_DsdManSetNewAsUseless( If_DsdMan_t * p );
588 extern word *          If_DsdManGetFuncConfig( If_DsdMan_t * p, int iDsd );
589 extern char *          If_DsdManGetCellStr( If_DsdMan_t * p );
590 extern unsigned        If_DsdManCheckXY( If_DsdMan_t * p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose );
591 extern int             If_CutDsdBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
592 extern int             If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
593 extern void            Id_DsdManTuneThresh( If_DsdMan_t * p, int fUnate, int fThresh, int fThreshHeuristic, int fVerbose );
594 /*=== ifLib.c =============================================================*/
595 extern If_LibLut_t *   If_LibLutRead( char * FileName );
596 extern If_LibLut_t *   If_LibLutDup( If_LibLut_t * p );
597 extern void            If_LibLutFree( If_LibLut_t * pLutLib );
598 extern void            If_LibLutPrint( If_LibLut_t * pLutLib );
599 extern int             If_LibLutDelaysAreDiscrete( If_LibLut_t * pLutLib );
600 extern int             If_LibLutDelaysAreDifferent( If_LibLut_t * pLutLib );
601 extern If_LibLut_t *   If_LibLutSetSimple( int nLutSize );
602 extern float           If_LibLutFastestPinDelay( If_LibLut_t * p );
603 extern float           If_LibLutSlowestPinDelay( If_LibLut_t * p );
604 /*=== ifLibBox.c =============================================================*/
605 extern If_LibBox_t *   If_LibBoxStart();
606 extern void            If_LibBoxFree( If_LibBox_t * p );
607 extern int             If_LibBoxNum( If_LibBox_t * p );
608 extern If_Box_t *      If_LibBoxReadBox( If_LibBox_t * p, int Id );
609 extern If_Box_t *      If_LibBoxFindBox( If_LibBox_t * p, char * pName );
610 extern void            If_LibBoxAdd( If_LibBox_t * p, If_Box_t * pBox );
611 extern If_LibBox_t *   If_LibBoxRead( char * pFileName );
612 extern If_LibBox_t *   If_LibBoxRead2( char * pFileName );
613 extern void            If_LibBoxPrint( FILE * pFile, If_LibBox_t * p );
614 extern void            If_LibBoxWrite( char * pFileName, If_LibBox_t * p );
615 extern int             If_LibBoxLoad( char * pFileName );
616 extern If_Box_t *      If_BoxStart( char * pName, int Id, int nPis, int nPos, int fSeq, int fBlack, int fOuter );
617 /*=== ifMan.c =============================================================*/
618 extern If_Man_t *      If_ManStart( If_Par_t * pPars );
619 extern void            If_ManRestart( If_Man_t * p );
620 extern void            If_ManStop( If_Man_t * p );
621 extern If_Obj_t *      If_ManCreateCi( If_Man_t * p );
622 extern If_Obj_t *      If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver );
623 extern If_Obj_t *      If_ManCreateAnd( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1 );
624 extern If_Obj_t *      If_ManCreateXor( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1 );
625 extern If_Obj_t *      If_ManCreateMux( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1, If_Obj_t * pCtrl );
626 extern void            If_ManCreateChoice( If_Man_t * p, If_Obj_t * pRepr );
627 extern void            If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId );
628 extern void            If_ManSetupCiCutSets( If_Man_t * p );
629 extern If_Set_t *      If_ManSetupNodeCutSet( If_Man_t * p, If_Obj_t * pObj );
630 extern void            If_ManDerefNodeCutSet( If_Man_t * p, If_Obj_t * pObj );
631 extern void            If_ManDerefChoiceCutSet( If_Man_t * p, If_Obj_t * pObj );
632 extern void            If_ManSetupSetAll( If_Man_t * p, int nCrossCut );
633 /*=== ifMap.c =============================================================*/
634 extern int *           If_CutArrTimeProfile( If_Man_t * p, If_Cut_t * pCut );
635 extern void            If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess, int fFirst );
636 extern void            If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess );
637 extern int             If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPreprocess, int fFirst, char * pLabel );
638 /*=== ifReduce.c ==========================================================*/
639 extern void            If_ManImproveMapping( If_Man_t * p );
640 /*=== ifSat.c ==========================================================*/
641 extern void *          If_ManSatBuildXY( int nLutSize );
642 extern void *          If_ManSatBuildXYZ( int nLutSize );
643 extern void            If_ManSatUnbuild( void * p );
644 extern int             If_ManSatCheckXY( void * pSat, int nLutSize, word * pTruth, int nVars, unsigned uSet, word * pTBound, word * pTFree, Vec_Int_t * vLits );
645 extern unsigned        If_ManSatCheckXYall( void * pSat, int nLutSize, word * pTruth, int nVars, Vec_Int_t * vLits );
646 /*=== ifSeq.c =============================================================*/
647 extern int             If_ManPerformMappingSeq( If_Man_t * p );
648 /*=== ifTime.c ============================================================*/
649 extern float           If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut );
650 extern void            If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float Required );
651 extern float           If_ManDelayMax( If_Man_t * p, int fSeq );
652 extern void            If_ManComputeRequired( If_Man_t * p );
653 /*=== ifTruth.c ===========================================================*/
654 extern void            If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
655 extern int             If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
656 extern int             If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
657 extern Vec_Mem_t *     If_DeriveHashTable6( int nVars, word Truth );
658 extern int             If_CutCheckTruth6( If_Man_t * p, If_Cut_t * pCut );
659 /*=== ifTune.c ===========================================================*/
660 extern Ifn_Ntk_t *     Ifn_NtkParse( char * pStr );
661 extern int             Ifn_NtkTtBits( char * pStr );
662 extern int             Ifn_NtkMatch( Ifn_Ntk_t * p, word * pTruth, int nVars, int nConfls, int fVerbose, int fVeryVerbose, word * pConfig );
663 extern void            Ifn_NtkPrint( Ifn_Ntk_t * p );
664 extern int             Ifn_NtkLutSizeMax( Ifn_Ntk_t * p );
665 extern int             Ifn_NtkInputNum( Ifn_Ntk_t * p );
666 extern void *          If_ManSatBuildFromCell( char * pStr, Vec_Int_t ** pvPiVars, Vec_Int_t ** pvPoVars, Ifn_Ntk_t ** ppNtk );
667 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 );
668 extern int             If_ManSatDeriveGiaFromBits( void * pNew, Ifn_Ntk_t * p, word * pTtData, Vec_Int_t * vLeaves, Vec_Int_t * vValues );
669 extern void *          If_ManDeriveGiaFromCells( void * p );
670 /*=== ifUtil.c ============================================================*/
671 extern void            If_ManCleanNodeCopy( If_Man_t * p );
672 extern void            If_ManCleanCutData( If_Man_t * p );
673 extern void            If_ManCleanMarkV( If_Man_t * p );
674 extern float           If_ManScanMapping( If_Man_t * p );
675 extern float           If_ManScanMappingDirect( If_Man_t * p );
676 extern float           If_ManScanMappingSeq( If_Man_t * p );
677 extern void            If_ManResetOriginalRefs( If_Man_t * p );
678 extern int             If_ManCrossCut( If_Man_t * p );
679 
680 extern Vec_Ptr_t *     If_ManReverseOrder( If_Man_t * p );
681 extern void            If_ManMarkMapping( If_Man_t * p );
682 extern Vec_Ptr_t *     If_ManCollectMappingDirect( If_Man_t * p );
683 extern Vec_Int_t *     If_ManCollectMappingInt( If_Man_t * p );
684 
685 extern int             If_ManCountSpecialPos( If_Man_t * p );
686 extern void            If_CutTraverse( If_Man_t * p, If_Obj_t * pRoot, If_Cut_t * pCut, Vec_Ptr_t * vNodes );
687 extern void            If_ObjPrint( If_Obj_t * pObj );
688 
689 
690 ABC_NAMESPACE_HEADER_END
691 
692 #endif
693 
694 ////////////////////////////////////////////////////////////////////////
695 ///                       END OF FILE                                ///
696 ////////////////////////////////////////////////////////////////////////
697 
698