cutInt.h 7.23 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    [cutInt.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: cutInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

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

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

24

Alan Mishchenko committed
25 26 27 28 29
////////////////////////////////////////////////////////////////////////
///                          INCLUDES                                ///
////////////////////////////////////////////////////////////////////////

#include <stdio.h>
30 31
#include "misc/extra/extra.h"
#include "misc/vec/vec.h"
Alan Mishchenko committed
32
#include "cut.h"
Alan Mishchenko committed
33
#include "cutList.h"
Alan Mishchenko committed
34

35 36 37
ABC_NAMESPACE_HEADER_START


Alan Mishchenko committed
38 39 40 41 42 43 44 45 46 47 48
////////////////////////////////////////////////////////////////////////
///                         PARAMETERS                               ///
////////////////////////////////////////////////////////////////////////

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

typedef struct Cut_HashTableStruct_t_ Cut_HashTable_t;

struct Cut_ManStruct_t_
Alan Mishchenko committed
49
{ 
Alan Mishchenko committed
50 51 52
    // user preferences
    Cut_Params_t *     pParams;          // computation parameters
    Vec_Int_t *        vFanCounts;       // the array of fanout counters
Alan Mishchenko committed
53
    Vec_Int_t *        vNodeAttrs;       // node attributes (1 = global; 0 = local)
Alan Mishchenko committed
54
    // storage for cuts
Alan Mishchenko committed
55 56 57
    Vec_Ptr_t *        vCutsNew;         // new cuts by node ID
    Vec_Ptr_t *        vCutsOld;         // old cuts by node ID
    Vec_Ptr_t *        vCutsTemp;        // temp cuts for cutset nodes by cutset node number
Alan Mishchenko committed
58 59 60
    // memory management
    Extra_MmFixed_t *  pMmCuts;
    int                EntrySize;
Alan Mishchenko committed
61
    int                nTruthWords;
Alan Mishchenko committed
62 63 64 65 66 67
    // temporary variables
    Cut_Cut_t *        pReady;
    Vec_Ptr_t *        vTemp;
    int                fCompl0;
    int                fCompl1;
    int                fSimul;
Alan Mishchenko committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    int                nNodeCuts;
    Cut_Cut_t *        pStore0[2];
    Cut_Cut_t *        pStore1[2];
    Cut_Cut_t *        pCompareOld;
    Cut_Cut_t *        pCompareNew;
    unsigned *         puTemp[4];
    // record of the cut computation
    Vec_Int_t *        vNodeCuts;        // the number of cuts for each node
    Vec_Int_t *        vNodeStarts;      // the number of the starting cut of each node
    Vec_Int_t *        vCutPairs;        // the pairs of parent cuts for each cut
    // minimum delay mapping with the given cuts
    Vec_Ptr_t *        vCutsMax;
    Vec_Int_t *        vDelays;
    Vec_Int_t *        vDelays2;
    int                nDelayMin;
Alan Mishchenko committed
83 84 85 86 87 88
    // statistics
    int                nCutsCur;
    int                nCutsAlloc;
    int                nCutsDealloc;
    int                nCutsPeak;
    int                nCutsTriv;
Alan Mishchenko committed
89 90
    int                nCutsFilter;
    int                nCutsLimit;
Alan Mishchenko committed
91
    int                nNodes;
Alan Mishchenko committed
92 93
    int                nNodesDag;
    int                nNodesNoCuts;
Alan Mishchenko committed
94
    // runtime
95 96 97 98 99 100
    abctime            timeMerge;
    abctime            timeUnion;
    abctime            timeTruth;
    abctime            timeFilter;
    abctime            timeHash;
    abctime            timeMap;
Alan Mishchenko committed
101 102
};

Alan Mishchenko committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
// iterator through all the cuts of the list
#define Cut_ListForEachCut( pList, pCut )                 \
    for ( pCut = pList;                                   \
          pCut;                                           \
          pCut = pCut->pNext )
#define Cut_ListForEachCutStop( pList, pCut, pStop )      \
    for ( pCut = pList;                                   \
          pCut != pStop;                                  \
          pCut = pCut->pNext )
#define Cut_ListForEachCutSafe( pList, pCut, pCut2 )      \
    for ( pCut = pList,                                   \
          pCut2 = pCut? pCut->pNext: NULL;                \
          pCut;                                           \
          pCut = pCut2,                                   \
          pCut2 = pCut? pCut->pNext: NULL )

Alan Mishchenko committed
119
////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
120
///                      MACRO DEFINITIONS                           ///
Alan Mishchenko committed
121 122
////////////////////////////////////////////////////////////////////////

Alan Mishchenko committed
123 124 125 126
// computes signature of the node
static inline unsigned Cut_NodeSign( int Node )        { return (1 << (Node % 31));                        }
static inline int      Cut_TruthWords( int nVarsMax )  { return nVarsMax <= 5 ? 1 : (1 << (nVarsMax - 5)); }

Alan Mishchenko committed
127 128 129 130
////////////////////////////////////////////////////////////////////////
///                    FUNCTION DECLARATIONS                         ///
////////////////////////////////////////////////////////////////////////

Alan Mishchenko committed
131 132 133 134 135 136 137 138 139 140
/*=== cutCut.c ==========================================================*/
extern Cut_Cut_t *         Cut_CutAlloc( Cut_Man_t * p );
extern void                Cut_CutRecycle( Cut_Man_t * p, Cut_Cut_t * pCut );
extern int                 Cut_CutCompare( Cut_Cut_t * pCut1, Cut_Cut_t * pCut2 );
extern Cut_Cut_t *         Cut_CutDupList( Cut_Man_t * p, Cut_Cut_t * pList );
extern void                Cut_CutRecycleList( Cut_Man_t * p, Cut_Cut_t * pList );
extern Cut_Cut_t *         Cut_CutMergeLists( Cut_Cut_t * pList1, Cut_Cut_t * pList2 ); 
extern void                Cut_CutNumberList( Cut_Cut_t * pList );
extern Cut_Cut_t *         Cut_CutCreateTriv( Cut_Man_t * p, int Node );
extern void                Cut_CutPrintMerge( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 );
Alan Mishchenko committed
141 142
/*=== cutMerge.c ==========================================================*/
extern Cut_Cut_t *         Cut_CutMergeTwo( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 );
Alan Mishchenko committed
143
/*=== cutNode.c ==========================================================*/
Alan Mishchenko committed
144 145
extern void                Cut_NodeDoComputeCuts( Cut_Man_t * p, Cut_List_t * pSuper, int Node, int fCompl0, int fCompl1, Cut_Cut_t * pList0, Cut_Cut_t * pList1, int fTriv, int TreeCode ); 
extern int                 Cut_CutListVerify( Cut_Cut_t * pList );
Alan Mishchenko committed
146 147 148 149 150 151 152
/*=== cutTable.c ==========================================================*/
extern Cut_HashTable_t *   Cut_TableStart( int Size );
extern void                Cut_TableStop( Cut_HashTable_t * pTable );
extern int                 Cut_TableLookup( Cut_HashTable_t * pTable, Cut_Cut_t * pCut, int fStore );
extern void                Cut_TableClear( Cut_HashTable_t * pTable );
extern int                 Cut_TableReadTime( Cut_HashTable_t * pTable );
/*=== cutTruth.c ==========================================================*/
Alan Mishchenko committed
153 154 155
extern void                Cut_TruthComputeOld( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1, int fCompl0, int fCompl1 );
extern void                Cut_TruthCompute( Cut_Man_t * p, Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1, int fCompl0, int fCompl1 );

156 157 158 159


ABC_NAMESPACE_HEADER_END

Alan Mishchenko committed
160
#endif
Alan Mishchenko committed
161

Alan Mishchenko committed
162 163 164 165
////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////