cut.h 9.08 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    [cut.h]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [K-feasible cut computation package.]

  Synopsis    [External declarations.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 20, 2005.]

  Revision    [$Id: .h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

***********************************************************************/

21 22
#ifndef ABC__opt__cut__cut_h
#define ABC__opt__cut__cut_h
Alan Mishchenko committed
23

24

Alan Mishchenko committed
25 26 27 28 29 30 31 32
////////////////////////////////////////////////////////////////////////
///                          INCLUDES                                ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                         PARAMETERS                               ///
////////////////////////////////////////////////////////////////////////

33 34 35 36


ABC_NAMESPACE_HEADER_START

Alan Mishchenko committed
37

Alan Mishchenko committed
38 39 40 41 42 43
#define CUT_SIZE_MIN    3      // the min K of the K-feasible cut computation
#define CUT_SIZE_MAX   12      // the max K of the K-feasible cut computation

#define CUT_SHIFT       8      // the number of bits for storing latch number in the cut leaves
#define CUT_MASK        0xFF   // the mask to get the stored latch number

Alan Mishchenko committed
44 45 46 47 48
////////////////////////////////////////////////////////////////////////
///                         BASIC TYPES                              ///
////////////////////////////////////////////////////////////////////////

typedef struct Cut_ManStruct_t_         Cut_Man_t;
Alan Mishchenko committed
49
typedef struct Cut_OracleStruct_t_      Cut_Oracle_t;
Alan Mishchenko committed
50 51 52 53 54
typedef struct Cut_CutStruct_t_         Cut_Cut_t;
typedef struct Cut_ParamsStruct_t_      Cut_Params_t;

struct Cut_ParamsStruct_t_
{
Alan Mishchenko committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68
    int                nVarsMax;          // the max cut size ("k" of the k-feasible cuts)
    int                nKeepMax;          // the max number of cuts kept at a node
    int                nIdsMax;           // the max number of IDs of cut objects
    int                nBitShift;         // the number of bits used for the latch counter of an edge
    int                nCutSet;           // the number of nodes in the cut set
    int                fTruth;            // compute truth tables
    int                fFilter;           // filter dominated cuts
    int                fSeq;              // compute sequential cuts
    int                fDrop;             // drop cuts on the fly
    int                fDag;              // compute only DAG cuts
    int                fTree;             // compute only tree cuts
    int                fGlobal;           // compute only global cuts
    int                fLocal;            // compute only local cuts
    int                fRecord;           // record the cut computation flow
Alan Mishchenko committed
69
    int                fRecordAig;        // record the cut functions
Alan Mishchenko committed
70 71
    int                fFancy;            // perform fancy computations
    int                fMap;              // computes delay of FPGA mapping with cuts
Alan Mishchenko committed
72
    int                fAdjust;           // removed useless fanouts of XORs/MUXes
Alan Mishchenko committed
73
    int                fNpnSave;          // enables dumping 6-input truth tables
Alan Mishchenko committed
74
    int                fVerbose;          // the verbosiness flag
Alan Mishchenko committed
75 76 77 78
};

struct Cut_CutStruct_t_
{
Alan Mishchenko committed
79 80
    unsigned           Num0       : 11;   // temporary number
    unsigned           Num1       : 11;   // temporary number
Alan Mishchenko committed
81 82
    unsigned           fSimul     :  1;   // the value of cut's output at 000.. pattern
    unsigned           fCompl     :  1;   // the cut is complemented
Alan Mishchenko committed
83 84 85 86 87
    unsigned           nVarsMax   :  4;   // the max number of vars [4-6]
    unsigned           nLeaves    :  4;   // the number of leaves [4-6]
    unsigned           uSign;             // the signature
    unsigned           uCanon0;           // the canonical form 
    unsigned           uCanon1;           // the canonical form 
Alan Mishchenko committed
88 89 90 91 92 93
    Cut_Cut_t *        pNext;             // the next cut in the list
    int                pLeaves[0];        // the array of leaves
};

static inline int        Cut_CutReadLeaveNum( Cut_Cut_t * p )  {  return p->nLeaves;   }
static inline int *      Cut_CutReadLeaves( Cut_Cut_t * p )    {  return p->pLeaves;   }
Alan Mishchenko committed
94
static inline unsigned * Cut_CutReadTruth( Cut_Cut_t * p )     {  return (unsigned *)(p->pLeaves + p->nVarsMax); }
Alan Mishchenko committed
95
static inline void       Cut_CutWriteTruth( Cut_Cut_t * p, unsigned * puTruth )  { 
Alan Mishchenko committed
96 97 98
    int i;
    for ( i = (p->nVarsMax <= 5) ? 0 : ((1 << (p->nVarsMax - 5)) - 1); i >= 0; i-- )
        p->pLeaves[p->nVarsMax + i] = (int)puTruth[i];
Alan Mishchenko committed
99 100 101
}

////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
102
///                      MACRO DEFINITIONS                           ///
Alan Mishchenko committed
103 104 105 106 107 108
////////////////////////////////////////////////////////////////////////

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

Alan Mishchenko committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122
/*=== cutApi.c ==========================================================*/
extern Cut_Cut_t *      Cut_NodeReadCutsNew( Cut_Man_t * p, int Node );
extern Cut_Cut_t *      Cut_NodeReadCutsOld( Cut_Man_t * p, int Node );
extern Cut_Cut_t *      Cut_NodeReadCutsTemp( Cut_Man_t * p, int Node );
extern void             Cut_NodeWriteCutsNew( Cut_Man_t * p, int Node, Cut_Cut_t * pList );
extern void             Cut_NodeWriteCutsOld( Cut_Man_t * p, int Node, Cut_Cut_t * pList );
extern void             Cut_NodeWriteCutsTemp( Cut_Man_t * p, int Node, Cut_Cut_t * pList );
extern void             Cut_NodeSetTriv( Cut_Man_t * p, int Node );
extern void             Cut_NodeTryDroppingCuts( Cut_Man_t * p, int Node );
extern void             Cut_NodeFreeCuts( Cut_Man_t * p, int Node );
/*=== cutCut.c ==========================================================*/
extern void             Cut_CutPrint( Cut_Cut_t * pCut, int fSeq );
extern void             Cut_CutPrintList( Cut_Cut_t * pList, int fSeq );
extern int              Cut_CutCountList( Cut_Cut_t * pList );
Alan Mishchenko committed
123 124 125 126
/*=== cutMan.c ==========================================================*/
extern Cut_Man_t *      Cut_ManStart( Cut_Params_t * pParams );
extern void             Cut_ManStop( Cut_Man_t * p );
extern void             Cut_ManPrintStats( Cut_Man_t * p );
127
extern void             Cut_ManPrintStatsToFile( Cut_Man_t * p, char * pFileName, abctime TimeTotal );
Alan Mishchenko committed
128
extern void             Cut_ManSetFanoutCounts( Cut_Man_t * p, Vec_Int_t * vFanCounts );
Alan Mishchenko committed
129 130 131 132 133
extern void             Cut_ManSetNodeAttrs( Cut_Man_t * p, Vec_Int_t * vFanCounts );
extern int              Cut_ManReadVarsMax( Cut_Man_t * p );
extern Cut_Params_t *   Cut_ManReadParams( Cut_Man_t * p );
extern Vec_Int_t *      Cut_ManReadNodeAttrs( Cut_Man_t * p );
extern void             Cut_ManIncrementDagNodes( Cut_Man_t * p );
Alan Mishchenko committed
134
/*=== cutNode.c ==========================================================*/
Alan Mishchenko committed
135
extern Cut_Cut_t *      Cut_NodeComputeCuts( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int fTriv, int TreeCode ); 
Alan Mishchenko committed
136
extern Cut_Cut_t *      Cut_NodeUnionCuts( Cut_Man_t * p, Vec_Int_t * vNodes );
Alan Mishchenko committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
extern Cut_Cut_t *      Cut_NodeUnionCutsSeq( Cut_Man_t * p, Vec_Int_t * vNodes, int CutSetNum, int fFirst );
extern int              Cut_ManMappingArea_rec( Cut_Man_t * p, int Node );
/*=== cutSeq.c ==========================================================*/
extern void             Cut_NodeComputeCutsSeq( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int nLat0, int nLat1, int fTriv, int CutSetNum );
extern void             Cut_NodeNewMergeWithOld( Cut_Man_t * p, int Node );
extern int              Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum );
extern void             Cut_NodeOldTransferToNew( Cut_Man_t * p, int Node );
/*=== cutOracle.c ==========================================================*/
extern Cut_Oracle_t *   Cut_OracleStart( Cut_Man_t * pMan );
extern void             Cut_OracleStop( Cut_Oracle_t * p );
extern void             Cut_OracleSetFanoutCounts( Cut_Oracle_t * p, Vec_Int_t * vFanCounts );
extern int              Cut_OracleReadDrop( Cut_Oracle_t * p );
extern void             Cut_OracleNodeSetTriv( Cut_Oracle_t * p, int Node );
extern Cut_Cut_t *      Cut_OracleComputeCuts( Cut_Oracle_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1 );
extern void             Cut_OracleTryDroppingCuts( Cut_Oracle_t * p, int Node );
/*=== cutTruth.c ==========================================================*/
extern void             Cut_TruthNCanonicize( Cut_Cut_t * pCut );
/*=== cutPre22.c ==========================================================*/
extern void             Cut_CellPrecompute();
extern void             Cut_CellLoad();
extern int              Cut_CellIsRunning();
extern void             Cut_CellDumpToFile();
extern int              Cut_CellTruthLookup( unsigned * pTruth, int nVars );

161 162 163 164 165


ABC_NAMESPACE_HEADER_END


Alan Mishchenko committed
166 167

#endif
Alan Mishchenko committed
168

Alan Mishchenko committed
169 170 171 172
////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////